/* ============================================================
   Smallbytes – Update untuk Pak Yanto
   Mobile-first, dependency-free. Jalan via file:// & Cloudflare Pages.
   ============================================================ */

:root {
  --navy: #003d79;
  --navy-2: #00559f;
  --blue: #2563eb;
  --gold: #f5a524;

  --bg: #eef2f8;
  --surface: #ffffff;
  --surface-2: #f1f5fa;
  --border: #e3e9f2;
  --border-strong: #d3dcea;

  --text: #0f1c2e;
  --text-2: #4a5a70;
  --text-3: #8592a6;

  --late: #d92d20;   --late-bg: #fdeceb;   --late-ring: #f7c9c5;
  --risk: #b54708;   --risk-bg: #fef3e2;   --risk-ring: #f5d9a8;
  --ok:   #067647;   --ok-bg:   #e6f6ee;   --ok-ring:   #b3e3c9;
  --done: #026aa2;   --done-bg: #e4f2fb;   --done-ring: #b3ddf2;
  --hold: #566173;   --hold-bg: #eef1f6;   --hold-ring: #d5dce7;

  --shadow-sm: 0 1px 2px rgba(11, 32, 66, .06);
  --shadow: 0 8px 24px -12px rgba(11, 32, 66, .28), 0 2px 6px -3px rgba(11, 32, 66, .10);
  --shadow-lg: 0 -18px 50px -18px rgba(11, 32, 66, .38);
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 9px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  --tap: 44px;
  --maxw: 720px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1420;
    --surface: #131e2c;
    --surface-2: #1a2836;
    --border: #24344a;
    --border-strong: #31445d;
    --text: #eaf0f8;
    --text-2: #a9b8cc;
    --text-3: #7d8da0;
    --late-bg: #3a1a18; --late-ring: #6d2b26; --late: #ff8b80;
    --risk-bg: #3a2a12; --risk-ring: #6d4c1c; --risk: #f7b955;
    --ok-bg: #10301f;   --ok-ring: #1e5a3a;   --ok: #62d99b;
    --done-bg: #0e2c3f; --done-ring: #1b516f; --done: #6ec7f2;
    --hold-bg: #1c2735; --hold-ring: #33455c; --hold: #a3b1c4;
    --shadow: 0 8px 24px -12px rgba(0,0,0,.6), 0 2px 6px -3px rgba(0,0,0,.4);
    --shadow-lg: 0 -18px 50px -18px rgba(0,0,0,.7);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
  overflow-x: hidden;
}

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 14px; }

/* ---------------- Header ---------------- */
.appbar {
  position: sticky; top: 0; z-index: 40;
  background: linear-gradient(160deg, var(--navy), var(--navy-2));
  color: #fff;
  padding: calc(14px + env(safe-area-inset-top)) 0 12px;
  box-shadow: 0 2px 14px -6px rgba(0, 34, 68, .55);
}
.appbar h1 { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: -.2px; }
.appbar .sub { margin-top: 2px; font-size: 12px; color: #c6dcf3; }
.appbar .datechip {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 9px;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.22);
  padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
}

/* ---------------- Tabs ---------------- */
.tabs {
  position: sticky; top: 0; z-index: 35;
  background: var(--surface); border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.tabs .wrap { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs .wrap::-webkit-scrollbar { display: none; }
.tabs .wrap { scroll-snap-type: x proximity; }
.tab {
  flex: 0 0 auto; white-space: nowrap; scroll-snap-align: center;
  min-height: var(--tap); padding: 0 11px;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  background: none; border: 0; border-bottom: 3px solid transparent;
  font: inherit; font-size: 12.5px; font-weight: 700; color: var(--text-2);
  cursor: pointer;
}
@media (min-width: 720px) { .tab { font-size: 13.5px; padding: 0 14px; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
select.linkbtn { -webkit-appearance: none; appearance: none; padding-right: 22px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 13px) 13px, calc(100% - 8px) 13px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.score { font-size: 10.5px; font-weight: 800; padding: 2px 7px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.score b { font-size: 12px; color: var(--text); }
.tab .cnt {
  font-size: 10.5px; font-weight: 800; background: var(--surface-2); color: var(--text-2);
  border-radius: 999px; padding: 1px 6px;
}
.tab[aria-selected="true"] { color: var(--navy); border-bottom-color: var(--navy); }
.tab[aria-selected="true"] .cnt { background: var(--navy); color: #fff; }
@media (prefers-color-scheme: dark) {
  .tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--gold); }
  .tab[aria-selected="true"] .cnt { background: var(--gold); color: #2a1c00; }
}

main { padding-top: 14px; }
.view[hidden] { display: none; }

/* ---------------- Cards & sections ---------------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 14px; margin-bottom: 12px;
}
.sec-title {
  margin: 18px 2px 9px; font-size: 12px; font-weight: 800;
  letter-spacing: .08em; text-transform: uppercase; color: var(--text-3);
}
.sec-title:first-child { margin-top: 4px; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 560px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px; box-shadow: var(--shadow-sm); text-align: left;
  font: inherit; color: inherit; cursor: pointer; min-height: var(--tap);
}
.kpi .n { font-size: 26px; font-weight: 800; line-height: 1.1; letter-spacing: -.5px; }
.kpi .l { font-size: 11.5px; color: var(--text-2); font-weight: 600; margin-top: 3px; }
.kpi.late .n { color: var(--late); } .kpi.risk .n { color: var(--risk); }
.kpi.done .n { color: var(--done); } .kpi.hold .n { color: var(--hold); }
.kpi:active { transform: scale(.98); }

/* Charts */
.chartbox { margin-top: 4px; }
.chartbox h3 { margin: 0 0 8px; font-size: 13.5px; font-weight: 800; }
#chart-prioritas { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.donut { position: relative; display: grid; place-items: center; }
.chartbox .legend { display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: center; font-size: 12.5px; color: var(--text-2); }
.chartbox .legend .li { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.chartbox .legend .sw { display: inline-block; width: 9px; height: 9px; border-radius: 3px; }
.chartbox .legend .nm { font-weight: 600; }
.chartbox .legend .vl { font-weight: 800; color: var(--text); }
.chartbox .legend .pc { color: var(--text-3); font-size: 11px; }
.donut .center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.donut .center b { display: block; font-size: 24px; font-weight: 800; line-height: 1.05; }
.donut .center span { font-size: 10.5px; color: var(--text-3); }

/* Deadline timeline */
.tl { list-style: none; margin: 0; padding: 0; }
.tl li { display: flex; gap: 11px; padding: 9px 0; border-bottom: 1px dashed var(--border); }
.tl li:last-child { border-bottom: 0; }
.tl .when { flex: 0 0 68px; text-align: right; }
.tl .when b { display: block; font-size: 13px; font-weight: 800; }
.tl .when span { font-size: 10.5px; color: var(--text-3); }
.tl .dot { flex: 0 0 9px; height: 9px; width: 9px; border-radius: 50%; margin-top: 6px; background: var(--hold); }
.tl li.late .dot { background: var(--late); } .tl li.risk .dot { background: var(--risk); }
.tl .what { font-size: 13.5px; color: var(--text-2); }

/* ---------------- Toolbar ---------------- */
.toolbar { position: sticky; top: 47px; z-index: 30; background: var(--bg); padding: 8px 0 6px; }
.search { position: relative; }
.search input {
  width: 100%; min-height: var(--tap); padding: 10px 40px 10px 38px;
  font: inherit; font-size: 15px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 999px; box-shadow: var(--shadow-sm);
}
.search input:focus { outline: 2px solid var(--navy); outline-offset: 1px; }
.search .ico { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: 15px; }
.search .clr {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--surface-2);
  color: var(--text-2); font: inherit; font-size: 16px; cursor: pointer;
}
.chips { display: flex; gap: 7px; overflow-x: auto; padding: 9px 0 3px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; min-height: 34px; padding: 0 13px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border-strong);
  font: inherit; font-size: 12.5px; font-weight: 700; color: var(--text-2); cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.chip.u[aria-pressed="true"] { background: var(--late); border-color: var(--late); }
.chip.t[aria-pressed="true"] { background: var(--risk); border-color: var(--risk); }
.chip.n[aria-pressed="true"] { background: var(--done); border-color: var(--done); }
.meta-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 2px 8px; }
.meta-row .count { font-size: 12px; color: var(--text-3); font-weight: 600; }
.linkbtns { display: flex; gap: 6px; }
.linkbtn {
  min-height: 32px; padding: 0 10px; border-radius: var(--radius-xs);
  background: var(--surface); border: 1px solid var(--border-strong);
  font: inherit; font-size: 12px; font-weight: 700; color: var(--text-2); cursor: pointer;
}

/* ---------------- Item cards ---------------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--hold);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); padding: 12px 13px;
}
.item:active { transform: scale(.995); }
.item.p-urgent { border-left-color: var(--late); }
.item.p-tinggi { border-left-color: var(--risk); }
.item.p-normal { border-left-color: var(--done); }
.item .top { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 5px; }
.no {
  font-size: 11px; font-weight: 800; color: var(--text-3);
  background: var(--surface-2); border-radius: 6px; padding: 1px 6px;
}
.badge {
  font-size: 10.5px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap;
}
.b-late { background: var(--late-bg); color: var(--late); border-color: var(--late-ring); }
.b-risk { background: var(--risk-bg); color: var(--risk); border-color: var(--risk-ring); }
.b-done { background: var(--done-bg); color: var(--done); border-color: var(--done-ring); }
.b-ok   { background: var(--ok-bg);   color: var(--ok);   border-color: var(--ok-ring); }
.b-hold { background: var(--hold-bg); color: var(--hold); border-color: var(--hold-ring); }
.item h2 { margin: 0 0 4px; font-size: 15px; font-weight: 800; letter-spacing: -.15px; }
.item .kat { font-size: 11.5px; color: var(--text-3); font-weight: 600; }
.item .sub { margin-top: 7px; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; color: var(--text-2); }
.item .sub span { display: inline-flex; align-items: center; gap: 5px; }
.item .sub b { font-weight: 700; color: var(--text); }
.empty { text-align: center; padding: 34px 16px; color: var(--text-3); font-size: 14px; }

/* Weekend checklist */
.wk { display: flex; gap: 11px; align-items: flex-start; }
.wk .box {
  flex: 0 0 24px; height: 24px; margin-top: 1px; border-radius: 7px;
  border: 2px solid var(--border-strong); background: var(--surface);
  display: grid; place-items: center; font-size: 14px; color: #fff; font-weight: 800;
}
.item.checked { opacity: .62; }
.item.checked .box { background: var(--ok); border-color: var(--ok); }
.item.checked h2 { text-decoration: line-through; }
.progressbar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 9px; }
.progressbar i { display: block; height: 100%; background: var(--ok); border-radius: 999px; transition: width .5s ease; }

/* ODP */
.grp { margin-bottom: 14px; }
.grp h3 {
  margin: 0 0 7px; font-size: 12.5px; font-weight: 800; color: var(--navy);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
@media (prefers-color-scheme: dark) { .grp h3 { color: var(--text); } }
.names { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.names li {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-xs); padding: 9px 11px; font-size: 13.5px;
}
.names .idx { font-size: 11px; font-weight: 800; color: var(--text-3); min-width: 20px; }
.names .nm { flex: 1; font-weight: 600; }
.names .un { font-size: 10.5px; font-weight: 800; color: var(--text-2); background: var(--surface-2); border-radius: 6px; padding: 2px 7px; }
.statline { display: grid; gap: 10px; grid-template-columns: repeat(2, 1fr); margin-bottom: 10px; }
.statline.three { grid-template-columns: repeat(3, 1fr); }
@media (min-width: 560px) { .statline { grid-template-columns: repeat(4, 1fr); } .statline.three { grid-template-columns: repeat(3, 1fr); } }
.statline .s {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px; text-align: center;
}
.statline .s b { display: block; font-size: 22px; font-weight: 800; }
.statline .s span { font-size: 11px; color: var(--text-2); }

/* Notes */
.notes { list-style: none; margin: 0; padding: 0; }
.notes li { position: relative; padding: 7px 0 7px 18px; font-size: 13px; color: var(--text-2); border-bottom: 1px dashed var(--border); }
.notes li:last-child { border-bottom: 0; }
.notes li::before { content: "•"; position: absolute; left: 4px; color: var(--gold); font-weight: 800; }

/* ---------------- Bottom sheet ---------------- */
.scrim {
  position: fixed; inset: 0; z-index: 60; background: rgba(8, 18, 33, .5);
  opacity: 0; pointer-events: none; transition: opacity .22s ease;
  backdrop-filter: blur(2px);
}
.scrim.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61;
  max-height: 88vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--surface); color: var(--text);
  border-radius: 22px 22px 0 0; box-shadow: var(--shadow-lg);
  transform: translateY(102%); transition: transform .28s cubic-bezier(.2,.8,.2,1);
  padding: 0 16px calc(20px + env(safe-area-inset-bottom));
}
.sheet.open { transform: translateY(0); }
@media (min-width: 720px) {
  .sheet { left: 50%; transform: translate(-50%, 102%); width: 640px; border-radius: 20px; bottom: 16px; }
  .sheet.open { transform: translate(-50%, 0); }
}
.sheet .grab { width: 42px; height: 5px; border-radius: 999px; background: var(--border-strong); margin: 9px auto 4px; }
.sheet .hd { position: sticky; top: 0; background: var(--surface); padding: 4px 0 10px; border-bottom: 1px solid var(--border); }
.sheet h2 { margin: 6px 0 6px; font-size: 17px; font-weight: 800; letter-spacing: -.2px; }
.sheet .close {
  position: absolute; right: 0; top: 10px; width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2);
  font: inherit; font-size: 17px; cursor: pointer;
}
.kv { display: flex; flex-direction: column; gap: 2px; padding: 11px 0; border-bottom: 1px dashed var(--border); }
.kv:last-of-type { border-bottom: 0; }
.kv .k { font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.kv .v { font-size: 14px; color: var(--text); }
.kv.hi .v { font-weight: 700; }
.sheet .actions { display: flex; gap: 8px; padding-top: 14px; }
.sheet .actions button {
  flex: 1; min-height: var(--tap); border-radius: var(--radius-sm); cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 700;
  background: var(--navy); color: #fff; border: 0;
}
.sheet .actions .ghost { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border-strong); }

.toast {
  position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: #0f1c2e; color: #fff; font-size: 13px; font-weight: 600;
  padding: 10px 16px; border-radius: 999px; z-index: 80;
  opacity: 0; pointer-events: none; transition: all .25s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

footer { text-align: center; font-size: 11.5px; color: var(--text-3); padding: 20px 8px 6px; }

@media print {
  .appbar, .tabs, .toolbar, .scrim, .sheet, .linkbtns, footer { display: none !important; }
  .view[hidden] { display: block !important; }
  body { background: #fff; }
  .item, .card, .names li { break-inside: avoid; box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
