/* Pusat Analitik — tokens first; light/dark are selected values, not a flip. */
:root {
  color-scheme: light;
  --bg: #f4f4f1; --surface: #fcfcfb; --surface-2: #f0efec; --line: #e2e1db; --grid: #e9e8e3; --axis: #bdbcb4;
  --text: #0b0b0b; --text-2: #52514e; --text-3: #6b6a65;
  --accent: #256abf; --on-accent: #ffffff; --accent-soft: #e4eefb;
  --good: #006300; --bad: #c22f2f; --warn: #8a5a00; --good-bg: #e3f3e3; --bad-bg: #fbe7e7; --warn-bg: #fdf1d6;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100; --series-5: #e87ba4; --series-6: #008300; --series-7: #6250d6; --series-8: #e34948;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --line: #33332f; --grid: #2b2b28; --axis: #55554f;
    --text: #f0efec; --text-2: #c3c2b7; --text-3: #9a998f;
    --accent: #3987e5; --on-accent: #0b0b0b; --accent-soft: #1d2b3f;
    --good: #5fd35f; --bad: #e66767; --warn: #f0b94a; --good-bg: #1b2f1b; --bad-bg: #3a1f1f; --warn-bg: #3a2f14;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --line: #33332f; --grid: #2b2b28; --axis: #55554f;
  --text: #f0efec; --text-2: #c3c2b7; --text-3: #9a998f;
  --accent: #3987e5; --on-accent: #0b0b0b; --accent-soft: #1d2b3f;
  --good: #5fd35f; --bad: #e66767; --warn: #f0b94a; --good-bg: #1b2f1b; --bad-bg: #3a1f1f; --warn-bg: #3a2f14;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h2 { font-size: 17px; } h3 { font-size: 15px; }
p { margin: 0; }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); } .small { font-size: 13px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.boot { padding: 40px 16px; text-align: center; color: var(--text-3); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ----- layout ----- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
header.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.top-row { display: flex; align-items: center; gap: 12px; min-height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 16px; margin-right: auto; white-space: nowrap; }
.brand svg { flex: none; }
.sync-info { font-size: 13px; color: var(--text-3); text-align: right; line-height: 1.3; }
.sync-info b { color: var(--text-2); font-weight: 600; }
nav.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs a { padding: 10px 14px; text-decoration: none; color: var(--text-2); font-weight: 560; white-space: nowrap; border-bottom: 2px solid transparent; }
nav.tabs a:hover { color: var(--text); }
nav.tabs a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }
main { padding: 16px 0 64px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; padding: 12px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; cursor: pointer; font-size: 13.5px; color: var(--text-2); }
.chip:hover { border-color: var(--axis); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.filters .sep { flex: 1 1 8px; }
.field { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--text-2); }
.range-label { font-size: 13px; color: var(--text-3); }

/* ----- controls ----- */
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], select {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-height: 36px; max-width: 100%; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 7px 14px; min-height: 36px; cursor: pointer; font-weight: 560; text-decoration: none; color: var(--text); white-space: nowrap; }
.btn:hover { border-color: var(--axis); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); }
.btn.sm { min-height: 30px; padding: 3px 10px; font-size: 13.5px; }
.btn[disabled] { opacity: .55; cursor: default; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13.5px; color: var(--text-2); }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

/* ----- cards, tiles ----- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card > header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card > header p { font-size: 13px; color: var(--text-3); }
.grid { display: grid; gap: 14px; margin-top: 14px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 168px), 1fr)); }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.tile .k { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.tile .v { font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tile .s { font-size: 12.5px; color: var(--text-3); margin-top: 2px; min-height: 18px; display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: center; }
.delta { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta.up.good, .delta.down.good { color: var(--good); } .delta.up.bad, .delta.down.bad { color: var(--bad); }
.delta.neutral, .delta.flat, .delta.new { color: var(--text-3); }
.tile.loss .v { color: var(--bad); }

.banner { display: flex; gap: 10px; align-items: flex-start; border-radius: 10px; padding: 10px 14px; margin-top: 12px; font-size: 14px; background: var(--warn-bg); color: var(--text); border: 1px solid transparent; }
.banner b { color: var(--warn); } .banner a { font-weight: 600; }
.banner.info { background: var(--accent-soft); } .banner.bad { background: var(--bad-bg); }
.empty { text-align: center; padding: 36px 16px; color: var(--text-2); }
.empty h2 { margin-bottom: 6px; color: var(--text); } .empty p { margin: 0 auto 14px; max-width: 46ch; }

/* ----- charts ----- */
.chart .plot { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; touch-action: pan-y; }
.chart .gl { stroke: var(--grid); stroke-width: 1; } .chart .zero { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--text-3); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.chart .ln { fill: none; stroke: var(--c); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .pt { fill: var(--c); stroke: var(--surface); stroke-width: 2; }
.chart .dl { fill: var(--text-2); font-size: 12px; font-weight: 600; }
.chart .cross { stroke: var(--axis); stroke-width: 1; stroke-dasharray: 3 3; }
.c1 { --c: var(--series-1); } .c2 { --c: var(--series-2); } .c3 { --c: var(--series-3); } .c4 { --c: var(--series-4); }
.c5 { --c: var(--series-5); } .c6 { --c: var(--series-6); } .c7 { --c: var(--series-7); } .c8 { --c: var(--series-8); }
.tip { position: absolute; top: 4px; pointer-events: none; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; box-shadow: 0 4px 18px rgba(0,0,0,.14); font-size: 13px; z-index: 5; min-width: 130px; }
.tip .t { color: var(--text-3); margin-bottom: 4px; font-size: 12px; }
.tip .r { display: flex; align-items: center; gap: 8px; white-space: nowrap; } .tip .r .n { margin-right: auto; color: var(--text-2); } .tip .r b { font-variant-numeric: tabular-nums; }
.sw { width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0 0 6px; font-size: 13px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-tools { display: flex; justify-content: flex-end; margin-top: 4px; }
.linkish { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 2px 0; font-size: 13px; font-weight: 560; }
.tablewrap { overflow: auto; max-height: 340px; border: 1px solid var(--line); border-radius: 8px; margin-top: 8px; }

/* bar rows */
.bars { display: grid; gap: 12px; }
.bar-row { cursor: default; }
.bar-row .top { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.bar-row .name { font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.bar-row .name small { color: var(--text-3); font-weight: 400; margin-left: 6px; }
.bar-row .val { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.bar-row .track { height: 10px; background: var(--surface-2); border-radius: 0 5px 5px 0; margin: 5px 0 4px; }
.bar-row .fill { height: 100%; background: var(--c); border-radius: 0 5px 5px 0; min-width: 2px; }
.bar-row .sub { font-size: 12.5px; color: var(--text-3); display: flex; flex-wrap: wrap; gap: 2px 14px; }
.bar-row:hover .track { background: color-mix(in srgb, var(--surface-2) 70%, var(--c) 30%); }

/* ----- tables ----- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12.5px; font-weight: 600; color: var(--text-3); background: var(--surface); position: sticky; top: 0; white-space: nowrap; }
td.r, th.r { text-align: right; } td.r { font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--surface-2); }
tr.testrow td { color: var(--text-3); }
.scroll { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.pill.paid { background: var(--good-bg); color: var(--good); } .pill.pending { background: var(--warn-bg); color: var(--warn); }
.pill.cancelled { background: var(--bad-bg); color: var(--bad); } .pill.test { background: var(--surface-2); color: var(--text-2); }
.costin { width: 92px; text-align: right; } .costin.unset { border-color: var(--warn); }
.saved { color: var(--good); font-size: 12.5px; margin-left: 6px; }

/* ----- forms / panels ----- */
.form { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); align-items: end; }
.form label { display: grid; gap: 4px; font-size: 13px; color: var(--text-2); font-weight: 560; }
.form label input, .form label select { width: 100%; font-weight: 400; color: var(--text); }
.form .full { grid-column: 1 / -1; } .actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.msg { font-size: 13.5px; min-height: 20px; } .msg.err { color: var(--bad); } .msg.ok { color: var(--good); }
.src { display: grid; gap: 8px; }
.src + .src { margin-top: 12px; }
.src .head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; justify-content: space-between; }
.src .title { font-weight: 650; font-size: 16px; } .src code { font-size: 12.5px; color: var(--text-2); word-break: break-all; }
details.how { margin-top: 12px; font-size: 13.5px; color: var(--text-2); } details.how summary { cursor: pointer; font-weight: 560; color: var(--accent); }
details.how ul { margin: 8px 0 0; padding-left: 18px; } details.how li { margin: 3px 0; }

/* ----- auth ----- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px 16px; }
.auth .card { width: min(100%, 400px); padding: 24px; }
.auth h1 { font-size: 21px; margin: 10px 0 4px; } .auth .form { grid-template-columns: 1fr; }

@media (max-width: 640px) {
  .tile .v { font-size: 22px; } .top-row { flex-wrap: wrap; padding: 8px 0; gap: 8px; } .sync-info { order: 10; flex: 1 1 100%; text-align: left; }
  th, td { padding: 8px 10px; } .card { padding: 14px; }
}
@media (prefers-reduced-motion: no-preference) { .fill { transition: width .25s ease; } }
[hidden] { display: none !important; }
main.wrap { padding: 16px 16px 64px; }
.stack { display: grid; gap: 14px; } .stack > .grid { margin-top: 0; }
td.r { white-space: nowrap; }
