:root {
  --bg: #f4f2ef;
  --card: #ffffff;
  --ink: #1d1f22;
  --ink-2: #555a61;
  --ink-3: #848990;
  --line: #e4e0da;
  --side: #23181b;
  --side-ink: #cfc6c8;
  --brand: #9e1238;
  --brand-dark: #7d0d2b;
  --brand-bg: #fbe9ee;
  --ok: #1f7a4d;
  --ok-bg: #e6f3ec;
  --warn: #9a5b00;
  --warn-bg: #fdf1dc;
  --red: #c62828;
  --red-bg: #fdecea;
  --radius: 10px;
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { display: flex; background: var(--bg); overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 224px; flex-shrink: 0; background: var(--side); color: var(--side-ink);
  display: flex; flex-direction: column; padding: 20px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 22px; }
.brand-mark { width: 38px; height: 38px; flex-shrink: 0; }
.brand-name { color: #fff; font-weight: 600; }
.brand-sub { font-size: 12px; color: #9a8f92; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px;
  background: none; border: 0; border-radius: 8px; color: var(--side-ink); cursor: pointer; text-align: left;
}
.nav-item:hover { background: #33262a; color: #fff; }
.nav-item.active { background: #45313a; color: #fff; }
.nav-icon { width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; font-size: 14px; font-weight: 700; }
.nav-icon.cal { background: var(--brand); color: #fff; }
.nav-icon.in { background: #24533b; color: #9fe0bc; }
.nav-icon.ord { background: #5a4518; color: #f5cf7a; }
.nav-badge { margin-left: auto; background: #e8a317; color: #2b1d00; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 10px; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.clock { padding: 12px 10px; border-top: 1px solid #3d2e33; margin-bottom: 4px; }
.clock-time { color: #fff; font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.clock-date { font-size: 12px; color: #9a8f92; }
.btn-ghost { background: none; border: 1px solid #4a3a3f; color: var(--side-ink); border-radius: 8px; padding: 8px 10px; cursor: pointer; text-align: left; }
.btn-ghost:hover { border-color: #6b5a60; color: #fff; }
.btn-ghost:disabled { opacity: .5; cursor: wait; }
.sync { font-size: 11px; color: #8d8285; padding: 4px 2px 0; }

/* ---------- Main ---------- */
.main { flex: 1; overflow-y: auto; padding: 26px 30px 40px; }
.page { display: none; }
.page.active { display: block; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0 0 4px; font-size: 24px; letter-spacing: -.01em; }
.page-head p { margin: 0; color: var(--ink-2); max-width: 600px; }
.stats { display: flex; gap: 10px; flex-wrap: wrap; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 16px; min-width: 120px; }
.stat span { display: block; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat label { font-size: 12px; color: var(--ink-3); }
.stat.warn span { color: var(--warn); }
.stat.ok span { color: var(--ok); }
.banner { background: var(--red-bg); border: 1px solid #f3b9b4; color: #7f1d1d; padding: 12px 14px; border-radius: var(--radius); margin-bottom: 18px; white-space: pre-line; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }

/* ---------- Kalender ---------- */
.cal-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-title { font-size: 22px; font-weight: 600; letter-spacing: .02em; }
.cal-nav { display: flex; gap: 6px; align-items: center; }
.icon-btn { width: 34px; height: 34px; border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer; font-size: 20px; line-height: 1; }
.btn-small { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 12px; cursor: pointer; }
.icon-btn:hover, .btn-small:hover { border-color: var(--ink-3); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); margin-bottom: 14px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

.calendar { display: flex; flex-direction: column; gap: 18px; }
.week { display: grid; gap: 8px 10px; grid-template-columns: 52px repeat(var(--days), minmax(0, 1fr)); }
.slot-labels { display: flex; flex-direction: column; gap: 4px; padding-top: 34px; }
.slot-label {
  height: 40px; display: flex; align-items: center; justify-content: center;
}
.slot-label span {
  font-size: 10px; font-weight: 700; letter-spacing: .04em; border: 1.5px solid #6c6f75; border-radius: 4px;
  padding: 1px 0; width: 46px; text-align: center; background: #fff; color: #3a3d42;
}
.slot-label.rev span { border-color: #b0570a; color: #b0570a; }
.slot-label.kitar span { border-color: #2f5fa8; color: #2f5fa8; }

.day { display: flex; flex-direction: column; gap: 4px; position: relative; min-width: 0; }
.day-pill {
  height: 30px; border-radius: 7px; background: var(--brand); color: #fff; font-weight: 600; letter-spacing: .04em;
  display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 13px; text-transform: uppercase;
}
button.day-pill { border: 0; cursor: pointer; width: 100%; font-family: inherit; }
button.day-pill:hover { filter: brightness(1.12); }
.more-n { background: #e8a317; color: #2b1d00; border-radius: 9px; padding: 0 6px; font-size: 11px; font-weight: 700; }
.day-pill small { font-weight: 500; opacity: .8; font-size: 12px; }
.day.today .day-pill { background: var(--brand-dark); box-shadow: 0 0 0 3px #e8a317; }
.day.out .day-pill { background: #c9b9be; }
.day-slots { position: relative; display: flex; flex-direction: column; gap: 4px; }
.day-num {
  position: absolute; inset: 0; display: grid; place-items: center; font-size: 64px; font-weight: 300;
  color: #ddd8d3; pointer-events: none; z-index: 0; font-variant-numeric: tabular-nums;
}
.day.out .day-num { color: #ebe7e3; }
.slot {
  position: relative; z-index: 1; height: 40px; border: 1.5px solid #c5c2bd; border-radius: 6px;
  background: #ffffffb0; cursor: pointer; text-align: left; padding: 3px 7px; overflow: hidden;
  display: flex; flex-direction: column; justify-content: center; gap: 1px;
}
.slot.free:hover { border-color: var(--brand); background: #fff; }
.slot.free:hover::after { content: '+'; position: absolute; right: 8px; top: 50%; transform: translateY(-50%); color: var(--brand); font-weight: 700; }
.day.out .slot.free { opacity: .45; }
.slot.filled { background: var(--tb); border-color: var(--tc); border-left-width: 4px; }
.slot.filled:hover { filter: brightness(.97); }
.slot .s-main { font-size: 11px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--tt); }
.slot .s-sub { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--tt); opacity: .8; }
.slot.done .s-main::before { content: '\2713  '; }
.slot.done { opacity: .62; }

/* ---------- Form ---------- */
.split { display: grid; grid-template-columns: 370px 1fr; gap: 18px; align-items: start; }
.form { padding: 18px; display: flex; flex-direction: column; gap: 12px; position: sticky; top: 0; }
.form-head { display: flex; justify-content: space-between; align-items: center; }
.form h2, .report h2 { margin: 0; font-size: 15px; }
.form.editing { border-color: var(--brand); box-shadow: 0 0 0 3px #9e123822; }
.btn-link { background: none; border: 0; color: var(--brand); cursor: pointer; padding: 0; text-decoration: underline; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.field input, .field select, .field textarea, .filters input, .filters select, .search-big {
  border: 1px solid #d6d1ca; border-radius: 8px; padding: 9px 11px; background: #fff; min-width: 0; width: 100%;
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .filters input:focus, .filters select:focus, .search-big:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px #9e123826;
}
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.hint { font-size: 12px; color: var(--ink-3); }
.hint:empty { display: none; }
.hint.warn { color: var(--red); }
.order-pill { font-size: 12px; padding: 8px 12px; border-radius: 8px; background: #f6f3ee; color: var(--ink-2); line-height: 1.5; }
.order-pill b { color: var(--ink); }
.btn-primary { margin-top: 4px; border: 0; border-radius: 8px; padding: 11px; font-weight: 600; cursor: pointer; background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled { opacity: .6; cursor: wait; }

/* ---------- Daftar jadwal ---------- */
.report { padding: 18px; min-height: 400px; }
.report-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filters input[type=search] { width: 200px; }
.filters input[type=date], .filters select { width: auto; }
.report-sum { font-size: 12px; color: var(--ink-3); margin: 10px 0 6px; }
.jday { margin-top: 14px; }
.jday-head {
  display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; color: var(--ink-2);
  text-transform: uppercase; letter-spacing: .04em; padding-bottom: 6px; border-bottom: 1px solid var(--line);
}
.jday-head > span:last-child { display: flex; align-items: center; gap: 8px; }
.tele-btn {
  border: 1px solid #b9d4ee; background: #eaf3fc; color: #1d5f9e; border-radius: 6px; padding: 2px 8px;
  font-size: 11px; font-weight: 700; text-transform: none; letter-spacing: 0; cursor: pointer;
}
.tele-btn:hover { background: #d6e8f9; }
.tele-preview {
  white-space: pre-wrap; font: 13px/1.5 inherit; font-family: inherit; background: #f6f4f1; border: 1px solid var(--line);
  border-radius: 8px; padding: 12px 14px; max-height: 50vh; overflow: auto;
}
.jentry {
  display: grid; grid-template-columns: 58px 1fr auto; gap: 12px; align-items: center;
  padding: 10px 6px; border-bottom: 1px solid #f0ece6; cursor: pointer; border-radius: 6px;
}
.jentry:hover { background: #faf8f5; }
.slot-tag { font-size: 11px; font-weight: 700; text-align: center; padding: 3px 0; border-radius: 5px; border: 1.5px solid #6c6f75; color: #3a3d42; }
.slot-tag.rev { border-color: #b0570a; color: #b0570a; }
.slot-tag.kitar { border-color: #2f5fa8; color: #2f5fa8; }
.jentry-name { font-weight: 600; }
.jentry-meta { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.team-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.badge.TERJADWAL { background: var(--brand-bg); color: var(--brand); }
.badge.SELESAI, .badge.TERKIRIM, .badge.AKTIF-ok { background: var(--ok-bg); color: var(--ok); }
.badge.BERANGKAT { background: #dde8f8; color: #1d3e72; }
.badge.BATAL, .badge.GAGAL { background: var(--red-bg); color: var(--red); }
.badge.AKTIF { background: var(--warn-bg); color: var(--warn); }
.badge.muted { background: #f1eee9; color: var(--ink-2); }
.more { display: block; margin: 14px auto 0; background: none; border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; cursor: pointer; }
.empty { text-align: center; color: var(--ink-3); padding: 40px 0; }

/* ---------- Daftar order ---------- */
.order-tools { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.search-big { font-size: 15px; padding: 11px 14px; }
.tool-row { display: flex; gap: 18px; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid #d6d1ca; background: #fff; border-radius: 16px; padding: 5px 12px; cursor: pointer; font-size: 13px; }
.chip:hover { border-color: var(--ink-3); }
.chip.active { background: var(--side); border-color: var(--side); color: #fff; }
.chip .n { color: var(--ink-3); margin-left: 4px; }
.chip.active .n { color: #c7b8bc; }
.order-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.order-col { overflow: hidden; }
.col-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; font-weight: 600; border-bottom: 1px solid var(--line); }
.col-head.belum { background: var(--warn-bg); color: var(--warn); }
.col-head.terkirim { background: var(--ok-bg); color: var(--ok); }
.col-head b { font-size: 18px; font-variant-numeric: tabular-nums; }
.order-list { max-height: calc(100vh - 330px); overflow-y: auto; }
.ocard { display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid #f0ece6; padding: 11px 16px; cursor: pointer; }
.ocard:hover { background: #faf8f5; }
.ocard-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.ocard-id { font-weight: 700; color: var(--brand); white-space: nowrap; }
.ocard-date { font-size: 12px; color: var(--ink-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ocard-title { font-weight: 600; margin: 2px 0 5px; }
.ocard-meta { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--ink-3); }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: #1a1114a0; display: grid; place-items: center; z-index: 20; padding: 24px; }
.modal-box { position: relative; background: var(--card); border-radius: 14px; width: min(760px, 100%); max-height: 100%; overflow: auto; }
.modal-close { position: absolute; top: 10px; right: 12px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: #f1eee9; font-size: 20px; cursor: pointer; z-index: 1; }
.modal-close:hover { background: #e5e0d8; }
.modal-body { padding: 24px 26px; }
.m-kicker { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); }
.modal-body h2 { margin: 4px 40px 8px 0; font-size: 20px; }
.modal-body h3 { font-size: 13px; margin: 20px 0 6px; }
.m-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 18px; margin: 12px 0; }
.kv div { border-top: 1px solid var(--line); padding-top: 6px; min-width: 0; }
.kv dt { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .03em; }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.m-list { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.m-list li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid #f0ece6; }
.m-list li span:first-child { color: var(--ink-2); }
.day-list li { padding: 0; }
.day-item { width: 100%; text-align: left; background: none; border: 0; padding: 8px 4px; cursor: pointer; border-radius: 6px; }
.day-item:hover { background: #faf8f5; }
.day-item small { color: var(--ink-3); }
.modal-body .order-pill { margin-top: 10px; }
.m-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line); }
.btn { border: 1px solid #d6d1ca; background: #fff; border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 600; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--red); border-color: #f3b9b4; }
.btn:disabled { opacity: .6; cursor: wait; }

/* ---------- Tab jenis jadwal ---------- */
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: #f1eee9; padding: 4px; border-radius: 9px; }
.tab { border: 0; background: none; border-radius: 6px; padding: 7px 4px; cursor: pointer; font-weight: 700; font-size: 13px; color: var(--ink-2); }
.tab:hover { color: var(--ink); }
.tab small { display: block; font-size: 11px; font-weight: 400; color: var(--ink-3); margin-top: 1px; }
.form.mode-SPK .tab[data-mode=SPK] { background: #fff; color: var(--brand); box-shadow: 0 1px 2px #0001; }
.form.mode-REV .tab[data-mode=REV] { background: #fff; color: #b0570a; box-shadow: 0 1px 2px #0001; }
.form.mode-KITAR .tab[data-mode=KITAR] { background: #fff; color: #2f5fa8; box-shadow: 0 1px 2px #0001; }
.form.mode-SPK { border-top: 4px solid var(--brand); }
.form.mode-REV { border-top: 4px solid #b0570a; }
.form.mode-KITAR { border-top: 4px solid #2f5fa8; }
.form.mode-REV .btn-primary { background: #b0570a; }
.form.mode-KITAR .btn-primary { background: #2f5fa8; }
.form.mode-REV .btn-primary:hover, .form.mode-KITAR .btn-primary:hover { filter: brightness(.9); }
.form:not(.mode-SPK) .row2 { grid-template-columns: 1fr; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--side); color: #fff; padding: 11px 18px; border-radius: 8px; z-index: 30; box-shadow: 0 6px 24px #0003; }
.toast.err { background: var(--red); }

@media (max-width: 1180px) {
  .split, .order-cols { grid-template-columns: 1fr; }
  .form { position: static; }
  .day-num { font-size: 44px; }
}
