:root {
  --bg: #F4F6FA; --surface: #FFFFFF; --surface-2: #F8FAFC; --border: #E2E8F0; --border-strong: #CBD5E1;
  --text: #0F172A; --muted: #64748B; --faint: #94A3B8;
  --brand: #1F3864; --brand-2: #2B4C86; --brand-soft: #E8EEF8; --on-brand: #FFFFFF;
  --ok: #15803D; --ok-soft: #E3F4E8; --warn: #B45309; --warn-soft: #FEF3E2; --bad: #B91C1C; --bad-soft: #FDE8E8;
  --info: #1D4ED8; --info-soft: #E5EDFB; --off: #475569; --off-soft: #EEF1F5;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .04);
  --radius: 10px; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B1120; --surface: #111A2E; --surface-2: #0F1728; --border: #1F2A40; --border-strong: #2C3A55;
    --text: #E2E8F0; --muted: #94A3B8; --faint: #64748B;
    --brand: #6E9BE8; --brand-2: #8DB1EE; --brand-soft: #18264A; --on-brand: #0B1120;
    --ok: #4ADE80; --ok-soft: #10301E; --warn: #FBBF24; --warn-soft: #3A2A0B; --bad: #F87171; --bad-soft: #3A1414;
    --info: #93B4F5; --info-soft: #182A4D; --off: #A3B0C2; --off-soft: #1C2538;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0B1120; --surface: #111A2E; --surface-2: #0F1728; --border: #1F2A40; --border-strong: #2C3A55;
  --text: #E2E8F0; --muted: #94A3B8; --faint: #64748B;
  --brand: #6E9BE8; --brand-2: #8DB1EE; --brand-soft: #18264A; --on-brand: #0B1120;
  --ok: #4ADE80; --ok-soft: #10301E; --warn: #FBBF24; --warn-soft: #3A2A0B; --bad: #F87171; --bad-soft: #3A1414;
  --info: #93B4F5; --info-soft: #182A4D; --off: #A3B0C2; --off-soft: #1C2538;
  --shadow: none; color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; }
h3 { font-size: 13px; margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.boot { padding: 40px; color: var(--muted); text-align: center; }

/* Layout */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--border); padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 16px; }
.brand img { width: 30px; height: 30px; }
.brand b { display: block; font-size: 14px; }
.brand span { font-size: 11.5px; color: var(--muted); }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--brand-soft); color: var(--brand); }
.nav .sep { font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; padding: 14px 10px 4px; }
.nav svg { width: 17px; height: 17px; flex: none; }
.side .me { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted); }
.side .me b { color: var(--text); }
.main { padding: 24px 28px 48px; min-width: 0; max-width: 1280px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.top .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.mobilebar { display: none; }

/* Komponen */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2 { padding: 16px 18px 0; }
.grid { display: grid; gap: 16px; }
.grid.k4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.k2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpi { padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: 12.5px; }
.kpi .value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .note { color: var(--muted); font-size: 12px; margin-top: 2px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.stack > * + * { margin-top: 12px; }
.empty { color: var(--muted); padding: 24px; text-align: center; }
.pre { white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin: 0; }
.log { max-height: 560px; overflow: auto; font-size: 11.5px; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--off-soft); color: var(--off); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: currentColor; }

/* Tabel */
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.c, th.c { text-align: center; }
.person b { display: block; }
.person span { font-size: 12px; color: var(--muted); }
.matrix td.cell { text-align: center; font-variant-numeric: tabular-nums; min-width: 44px; padding: 6px; }
.matrix th.c { min-width: 44px; }
.cell .v { display: inline-block; min-width: 34px; padding: 3px 6px; border-radius: 6px; font-weight: 600; font-size: 12.5px; }
.cell .v.sent { background: var(--ok-soft); color: var(--ok); }
.cell .v.miss { background: var(--bad-soft); color: var(--bad); }
.cell .v.abs { background: var(--info-soft); color: var(--info); font-size: 10.5px; }
.cell .v.na { color: var(--faint); }
.cell a.v:hover { text-decoration: none; filter: brightness(.96); }
.bar { height: 6px; border-radius: 3px; background: var(--off-soft); overflow: hidden; min-width: 60px; }
.bar i { display: block; height: 100%; background: var(--ok); border-radius: 3px; }

/* Laporan harian */
.staffcard { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 14px 16px; }
.staffcard header { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; margin-bottom: 8px; }
.proj { font-weight: 600; font-size: 12.5px; color: var(--brand); margin: 10px 0 4px; text-transform: uppercase; letter-spacing: .02em; }
.task { display: flex; gap: 8px; justify-content: space-between; padding: 3px 0; }
.task span:first-child { min-width: 0; overflow-wrap: anywhere; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.msg { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.msg + .msg { margin-top: 10px; }
.msg .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }

/* Form */
label.f { display: block; }
label.f > span { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 4px; }
label.f > small { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }
input, select, textarea { font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; padding: 7px 10px; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--brand); }
textarea { resize: vertical; min-height: 90px; font-family: var(--mono); font-size: 13px; }
.inline { width: auto; }
.check { display: flex; gap: 8px; align-items: center; padding: 3px 0; }
.form { display: grid; gap: 14px; }
.form.k2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form .full { grid-column: 1 / -1; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin: 0; }
legend { font-size: 12.5px; font-weight: 600; padding: 0 4px; }
.err { color: var(--bad); font-size: 13px; white-space: pre-wrap; }

.btn { font: inherit; font-weight: 600; font-size: 13px; border-radius: 8px; padding: 7px 14px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.btn.icon { padding: 5px 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.seg button { font: inherit; font-size: 13px; font-weight: 600; border: 0; background: var(--surface); color: var(--muted); padding: 6px 12px; cursor: pointer; }
.seg button.on { background: var(--brand-soft); color: var(--brand); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs a { padding: 8px 12px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--brand); border-color: var(--brand); text-decoration: none; }

/* Login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .card { width: 100%; max-width: 380px; padding: 28px; }
.auth .brand { padding: 0 0 20px; }

/* Modal & toast */
dialog { border: 1px solid var(--border); border-radius: 12px; padding: 0; background: var(--surface); color: var(--text); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
dialog::backdrop { background: rgba(15, 23, 42, .45); }
dialog form { padding: 20px; }
dialog .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
dialog .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: calc(100vw - 32px); }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 8px; font-size: 13px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); max-width: 420px; white-space: pre-wrap; }
.toast.bad { background: var(--bad); color: #fff; }
.secret { font-family: var(--mono); font-size: 16px; letter-spacing: .08em; background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: 8px; padding: 10px 12px; word-break: break-all; text-align: center; user-select: all; }

/* Responsif */
@media (max-width: 1000px) {
  .grid.k4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 30% 0 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
  .side.open { transform: none; }
  .mobilebar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; }
  .mobilebar b { font-size: 14px; }
  .main { padding: 16px 16px 40px; }
  .grid.k2, .form.k2, .form.k3 { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr; }
  .kpi .value { font-size: 22px; }
  th, td { padding: 8px 9px; }
}

/* Penyesuaian */
.btn svg, .me svg { width: 16px; height: 16px; flex: none; }
.grid { margin-bottom: 16px; }
.grid > .card { margin-bottom: 0; }
.task .badge, .staffcard header .badge { flex: none; align-self: flex-start; }
.matrix td.person { min-width: 120px; }
@media (max-width: 760px) {
  .matrix .person span { display: none; }
  .matrix td.person b { font-size: 12.5px; }
}

/* Pilihan tema */
.theme { display: flex; margin-top: 10px; }
.theme button { flex: 1; padding: 4px 6px; font-size: 12px; }
.auth .theme { width: max-content; margin: 16px auto 0; }
.auth .theme button { flex: none; }
.brand img { object-fit: contain; }
.mobilebar .mlogo { width: 24px; height: 24px; object-fit: contain; }
