/* Kantor AI — dashboard. Token warna di :root, mode gelap di bawah. */
:root {
  --bg: #f4efe4; --surface: #fffdf8; --surface-2: #faf6ee; --ink: #22302a; --ink-2: #4c574f; --muted: #7a8077;
  --line: #e4dccd; --line-strong: #d3c8b5;
  --primary: #2f5d48; --primary-ink: #fdfbf5; --primary-soft: #e3ece4;
  --accent: #b4553a; --accent-soft: #f6e4dc;
  --ok: #2f8f5b; --ok-soft: #e0f0e6; --warn: #b7791f; --warn-soft: #f8ecd4; --bad: #c0412f; --bad-soft: #f8e1dc;
  --idle: #9a9c92; --idle-soft: #ecebe4;
  --shadow: 0 1px 2px rgba(34,48,42,.06), 0 4px 16px rgba(34,48,42,.05);
  --radius: 12px; --radius-sm: 8px;
  --font: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif; --mono: 'IBM Plex Mono', ui-monospace, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151a17; --surface: #1d2420; --surface-2: #222a25; --ink: #ece6d8; --ink-2: #c9c3b5; --muted: #949a90;
    --line: #2f3833; --line-strong: #3c4741; --primary: #7fb89a; --primary-ink: #10251a; --primary-soft: #23352b;
    --accent: #e08a6c; --accent-soft: #3a2620; --ok: #6cc38f; --ok-soft: #1f3528; --warn: #e2b05a; --warn-soft: #3a3020;
    --bad: #ef7e6b; --bad-soft: #3d2420; --idle: #8a8d84; --idle-soft: #2a302c; --shadow: 0 1px 2px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #151a17; --surface: #1d2420; --surface-2: #222a25; --ink: #ece6d8; --ink-2: #c9c3b5; --muted: #949a90;
  --line: #2f3833; --line-strong: #3c4741; --primary: #7fb89a; --primary-ink: #10251a; --primary-soft: #23352b;
  --accent: #e08a6c; --accent-soft: #3a2620; --ok: #6cc38f; --ok-soft: #1f3528; --warn: #e2b05a; --warn-soft: #3a3020;
  --bad: #ef7e6b; --bad-soft: #3d2420; --idle: #8a8d84; --idle-soft: #2a302c; --shadow: 0 1px 2px rgba(0,0,0,.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); }
button, input, select, textarea { font: inherit; color: inherit; }
code, .mono { font-family: var(--mono); font-size: .86em; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.05rem; font-weight: 650; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; padding: 20px 14px;
  border-right: 1px solid var(--line); background: var(--surface-2); }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--primary); color: var(--primary-ink);
  display: grid; place-items: center; font-weight: 800; letter-spacing: -.04em; }
.brand-name { font-weight: 750; font-size: 1.02rem; }
.env-badge { display: inline-block; font: 600 10px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase;
  padding: 3px 6px; border-radius: 4px; background: var(--warn-soft); color: var(--warn); margin-top: 3px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); color: var(--ink-2);
  text-decoration: none; font-weight: 520; }
.nav a:hover { background: var(--primary-soft); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-weight: 650; }
.nav svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav .count { margin-left: auto; min-width: 20px; padding: 1px 6px; border-radius: 10px; background: var(--accent); color: #fff;
  font: 600 11px/18px var(--mono); text-align: center; }
.nav .count:empty, .nav .count[data-n="0"] { display: none; }
.sidebar-foot { margin-top: auto; padding: 10px; font-size: 12.5px; color: var(--muted); display: grid; gap: 6px; }
.live { display: inline-flex; align-items: center; gap: 6px; }
.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--idle); }
.live.on::before { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }

.main { min-width: 0; padding: 28px clamp(16px, 3vw, 40px) 64px; }
.view { display: none; max-width: 1240px; }
.view.active { display: block; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.view-head p { margin: 4px 0 0; color: var(--muted); }

/* ---------- komponen ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-head a { font-size: 13px; text-decoration: none; }
.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--ink); }
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary); filter: brightness(1.08); }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.input, .select, .textarea { width: 100%; min-height: 38px; padding: 8px 11px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); }
.textarea { min-height: 90px; resize: vertical; }
.field { display: grid; gap: 6px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font: 600 11.5px/18px var(--font);
  background: var(--idle-soft); color: var(--ink-2); white-space: nowrap; }
.chip.mono { font-family: var(--mono); font-weight: 500; }
.st { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.st::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--idle); }
.st-working::before, .st-in_progress::before, .st-revision::before { background: var(--ok); }
.st-review::before, .st-ready::before { background: var(--warn); }
.st-blocked::before, .st-failed::before { background: var(--bad); }
.st-approved::before, .st-merged::before { background: var(--primary); }
.empty { padding: 28px 18px; text-align: center; color: var(--muted); font-size: 14px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; padding: 10px 16px; border-radius: var(--radius-sm);
  background: var(--ink); color: var(--bg); box-shadow: var(--shadow); font-weight: 600; max-width: calc(100vw - 32px); }
.toast[hidden] { display: none; }

/* ---------- ringkasan ---------- */
.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { padding: 16px 18px; }
.stat b { display: block; font: 700 1.9rem/1.1 var(--font); letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: 13px; }
.stat.attn { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); background: linear-gradient(0deg, var(--accent-soft), var(--surface) 70%); }
.roles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.role { padding: 16px; display: grid; gap: 10px; align-content: start; }
.role-top { display: flex; align-items: center; gap: 12px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font: 700 13px/1 var(--mono);
  background: var(--primary-soft); color: var(--primary); flex: none; position: relative; }
.avatar[data-state="working"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ok); }
.avatar[data-state="review"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--warn); }
.avatar[data-state="blocked"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--bad); }
.role h3 { font-size: 15px; }
.role .sub { font-size: 12.5px; color: var(--muted); }
.role .now { font-size: 13.5px; color: var(--ink-2); min-height: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.split { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; }
.sec-title { display: flex; align-items: baseline; gap: 10px; margin: 26px 0 12px; }
.sec-title .muted { font-size: 13px; }

/* ---------- event ---------- */
.events { list-style: none; margin: 0; padding: 0; }
.events li { display: grid; grid-template-columns: 74px 1fr; gap: 10px; padding: 10px 18px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.events li:last-child { border-bottom: 0; }
.events time { color: var(--muted); font: 12px/20px var(--mono); }
.ev-type { font: 600 11.5px/18px var(--mono); color: var(--ink-2); }
.ev-type.t-task { color: var(--primary); } .ev-type.t-approval { color: var(--accent); } .ev-type.t-agent { color: var(--muted); }
.ev-sum { color: var(--ink); overflow-wrap: anywhere; }
.ev-meta { color: var(--muted); font-size: 12px; }
.events li.fresh { animation: fresh 1.6s ease-out; }
@keyframes fresh { from { background: var(--accent-soft); } to { background: transparent; } }

/* ---------- persetujuan ---------- */
.approval { padding: 16px 18px; display: grid; gap: 10px; border-bottom: 1px solid var(--line); }
.approval:last-child { border-bottom: 0; }
.approval-top { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.approval h3 { font-size: 15.5px; }
.approval .summary { white-space: pre-wrap; color: var(--ink-2); font-size: 14px; margin: 0; }
.approval-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.approval-actions .input { flex: 1 1 220px; }
.kind { font: 600 11px/18px var(--mono); text-transform: uppercase; letter-spacing: .05em; padding: 1px 7px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); }
.tabs { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--idle-soft); }
.tabs button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 13.5px; color: var(--ink-2); }
.tabs button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- papan task ---------- */
.board { display: grid; grid-template-columns: repeat(5, minmax(188px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); min-height: 180px; display: flex; flex-direction: column; }
.col-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 8px; font-weight: 650; font-size: 13.5px; }
.col-head .n { font: 600 12px/1 var(--mono); color: var(--muted); }
.col-body { display: grid; gap: 8px; padding: 4px 10px 12px; align-content: start; }
.tcard { text-align: left; width: 100%; display: grid; gap: 8px; padding: 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; box-shadow: var(--shadow); }
.tcard:hover { border-color: var(--line-strong); }
.tcard h3 { font-size: 14px; font-weight: 600; }
.tcard .row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.progress { height: 4px; border-radius: 4px; background: var(--idle-soft); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--primary); }
.rev-hot { background: var(--bad-soft); color: var(--bad); }

/* drawer detail task */
.drawer { position: fixed; inset: 0; z-index: 40; display: grid; grid-template-columns: 1fr min(640px, 100%); }
.drawer[hidden] { display: none; }
.drawer-scrim { background: rgba(20,26,22,.35); }
.drawer-panel { background: var(--surface); border-left: 1px solid var(--line); overflow-y: auto; padding: 22px 24px 40px; display: grid; gap: 18px; align-content: start; }
.drawer-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.md { font-size: 14px; line-height: 1.6; }
.md h1, .md h2, .md h3 { margin: 18px 0 8px; font-size: 15px; }
.md ul { padding-left: 20px; margin: 6px 0; }
.md li.done { color: var(--muted); }
.md p { margin: 6px 0; }
.md code { background: var(--idle-soft); padding: 1px 5px; border-radius: 4px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 13.5px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- tabel ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
td.num, th.num { text-align: right; font-family: var(--mono); }
.notice { padding: 12px 16px; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--ink); font-size: 13.5px; }

/* ---------- perintah ---------- */
.cmd { padding: 14px 18px; border-bottom: 1px solid var(--line); display: grid; gap: 4px; }
.cmd:last-child { border-bottom: 0; }

/* ---------- kantor (visual) ---------- */
.office-frame { width: 100%; height: min(72vh, 760px); border: 0; border-radius: var(--radius); background: var(--surface-2); display: block; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: min(400px, 100%); padding: 28px; display: grid; gap: 16px; }
.login .brand { padding: 0; }
.error { color: var(--bad); font-size: 13.5px; min-height: 20px; margin: 0; }

/* ---------- responsif ---------- */
@media (max-width: 1080px) { .roles { grid-template-columns: repeat(2, minmax(0, 1fr)); } .split { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 30; top: auto; bottom: 0; left: 0; right: 0; height: auto; flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--line); background: var(--surface); }
  .brand, .sidebar-foot, .nav a.desk-only { display: none; }
  .nav { flex-direction: row; justify-content: space-around; width: 100%; }
  .nav a { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: 11px; position: relative; flex: 1; text-align: center; }
  .nav a[aria-current="page"] { box-shadow: none; background: var(--primary-soft); }
  .nav .count { position: absolute; top: 2px; right: calc(50% - 22px); margin: 0; }
  .main { padding: 18px 16px 96px; }
  .mobile-top { display: flex !important; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .board { grid-template-columns: repeat(5, minmax(240px, 82vw)); scroll-snap-type: x mandatory; }
  .col { scroll-snap-align: start; }
  .drawer { grid-template-columns: 1fr; }
  .drawer-scrim { display: none; }
  .drawer-panel { padding: 18px 16px 40px; border-left: 0; }
}
@media (max-width: 560px) { .roles { grid-template-columns: 1fr; } .kv { grid-template-columns: 1fr; } .kv dt { margin-top: 6px; } }
.mobile-top { display: none; align-items: center; justify-content: space-between; margin-bottom: 14px; }
@media (prefers-reduced-motion: reduce) { .events li.fresh { animation: none; } }
