/* Portfolio — ink-neutral theme, dark (default) + light.
   Direction: calm, exact, private. Night securities desk / statement ledger.
   One accent (cobalt) used rarely: chart line, active nav icon, focus, privacy-on.
   All money/units/meta figures use the mono face with tabular numbers.
   Light mode = same roles inverted: white cards on a grey page, recessed controls
   slightly darker than the page. Every surface color lives in a variable so the
   charts (which read them via getComputedStyle) follow the toggle too. */

@font-face {
  font-family: "Geist";
  src: url("/vendor/fonts/geist-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("/vendor/fonts/geist-mono-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  /* ink ramp — surfaces read grey, not navy */
  --bg: #0b0d14;
  --panel: #11141c;
  --raised: #1a1e28;
  --deep: #07080d;
  --border: rgba(238, 240, 245, 0.08);
  --border-strong: rgba(238, 240, 245, 0.16);
  --border-input: rgba(238, 240, 245, 0.12);
  /* three text roles */
  --text: #eef0f5;
  --text-2: #a3a9b8;
  --text-3: #8a91a3;
  /* one accent + semantic colors, toned to sit inside the ramp */
  --accent: #7aa2f7;
  --accent-dim: rgba(122, 162, 247, 0.16);
  --pos: #4cc38a;
  --neg: #e5484d;
  --warn: #d9a441;
  --warn-dim: rgba(217, 164, 65, 0.12);
  /* theme-dependent component colors */
  --btn-hover: #222735;
  --primary-fg: #0b0d14;
  --primary-hover: #ffffff;
  --inset-hi: rgba(255, 255, 255, 0.06);
  --row-hover: rgba(238, 240, 245, 0.02);
  --chart-fill: rgba(122, 162, 247, 0.10);
  --chart-grid: rgba(238, 240, 245, 0.06);
  /* type */
  --font-ui: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  /* radius: card 16, control 10, small 6 — nested inner = outer - padding */
  --r-card: 16px;
  --r-ctl: 10px;
  --r-sm: 6px;
  /* motion: one curve, named properties only */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

:root[data-theme="light"] {
  color-scheme: light;
  /* paper ramp — same roles, inverted: cards white, page grey, recess darker */
  --bg: #f4f5f7;
  --panel: #ffffff;
  --raised: #eceef1;
  --deep: #e8eaee;
  --border: rgba(17, 20, 28, 0.10);
  --border-strong: rgba(17, 20, 28, 0.18);
  --border-input: rgba(17, 20, 28, 0.14);
  --text: #171a21;
  --text-2: #4c5261;
  --text-3: #5f6677;
  /* accent + semantics darkened to keep contrast on white */
  --accent: #3563d9;
  --accent-dim: rgba(53, 99, 217, 0.12);
  --pos: #177a4c;
  --neg: #cc3339;
  --warn: #96660f;
  --warn-dim: rgba(150, 102, 15, 0.12);
  --btn-hover: #dfe2e8;
  --primary-fg: #ffffff;
  --primary-hover: #2b303b;
  --inset-hi: rgba(255, 255, 255, 0.65);
  --row-hover: rgba(17, 20, 28, 0.03);
  --chart-fill: rgba(53, 99, 217, 0.10);
  --chart-grid: rgba(17, 20, 28, 0.07);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}
::selection { background: var(--accent-dim); }
a { color: var(--accent); }
a:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.hidden { display: none !important; }
.muted { color: var(--text-2); font-size: 13px; }
.error { color: var(--neg); font-size: 13px; margin-top: 8px; }
.note { font-size: 12px; color: var(--text-3); margin-top: 4px; }

/* ---------- shell: sidebar on desktop, topbar on mobile ---------- */
.shell { display: block; }
.side {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 12px 16px;
  background: var(--deep);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 16px; font-weight: 600; letter-spacing: 0; color: var(--text);
}
.brand svg { color: var(--accent); flex: none; }
.nav { display: flex; gap: 4px; overflow-x: auto; -webkit-overflow-scrolling: touch; order: 3; width: 100%; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  display: inline-flex; align-items: center; gap: 10px;
  height: 32px; padding: 0 10px; border-radius: 8px;
  color: var(--text-2); text-decoration: none; white-space: nowrap; font-size: 14px;
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}
.nav a svg { display: none; }
.nav a:hover { color: var(--text); background: var(--panel); }
.nav a.active { color: var(--text); background: var(--raised); box-shadow: inset 0 1px 0 var(--inset-hi); }
.side-foot { display: flex; align-items: center; gap: 8px; margin-left: auto; }

main { max-width: 1200px; margin: 0 auto; padding: 16px; }

@media (min-width: 960px) {
  body.signed-in .shell {
    display: grid; grid-template-columns: 248px minmax(0, 1fr);
    min-height: 100vh;
  }
  body.signed-in .side {
    flex-direction: column; align-items: stretch; flex-wrap: nowrap;
    gap: 24px; padding: 20px 16px;
    height: 100vh; position: sticky; top: 0;
    border-bottom: none; border-right: 1px solid var(--border);
  }
  body.signed-in .brand { padding: 0 8px; }
  body.signed-in .nav { flex-direction: column; gap: 2px; overflow: visible; order: 0; width: auto; }
  body.signed-in .nav a { height: 36px; padding: 0 10px; }
  body.signed-in .nav a svg { display: block; width: 18px; height: 18px; flex: none; color: var(--text-3); transition: color 0.15s var(--ease); }
  body.signed-in .nav a.active svg { color: var(--accent); }
  body.signed-in .side-foot { margin-top: auto; margin-left: 0; }
  body.signed-in main { padding: 24px 32px; }
}

/* ---------- cards ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 20px;
  margin-bottom: 16px;
}
main .card:last-child { margin-bottom: 0; }
.card-title { font-size: 15px; font-weight: 500; color: var(--text); margin-bottom: 12px; }
.card-title:has(+ .note) { margin-bottom: 4px; }
.card-title + .note { margin: 0 0 12px; }

/* ---------- forms ---------- */
label { display: block; font-size: 12px; color: var(--text-2); }
label input, label select { margin-top: 6px; }
input, select {
  width: 100%; max-width: 100%; min-width: 0; height: 40px; padding: 0 12px;
  border-radius: var(--r-ctl); border: 1px solid var(--border-input);
  background: var(--deep); color: var(--text);
  font-family: var(--font-ui); font-size: 14px;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
input::placeholder { color: var(--text-3); }
input:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 16px) 17px, calc(100% - 11px) 17px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
input[type="date"] { font-family: var(--font-mono); font-size: 13px; }
/* iOS Safari draws date inputs as native buttons and, AFTER the cascade,
   forces a min-width floor + box-sizing: content-box + min-height, so
   width:100% with padding spills past the form column (WebKit bug 301648)
   and the value sits centered. appearance:none opts out of that adjustment;
   the native picker wheel still opens on tap because it follows the input
   type, not the paint (same fix Bootstrap ships). Geometry only — the field
   styles above still apply. */
input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  /* grid 1fr + center, bukan block/flex: block membuat nilai date mepet ke
     atas di iOS (WebKit bug 139848). Grid juga merentangkan container internal
     Chromium (-internal-datetime-container, tidak bisa diseleksi author CSS)
     supaya edit box flex:1 mendorong ikon kalender ke tepi kanan. */
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  text-align: left;
}
/* iOS centers the value in its UA stylesheet; an empty field collapses
   unless one line of height is reserved (WebKit bugs 198959 / 139848) */
input[type="date"]::-webkit-date-and-time-value {
  margin: 0;
  text-align: left;
  min-height: 1.2em;
  min-height: 1lh;
}
/* desktop engines pad the edit box a pixel or two; keep heights equal */
input[type="date"]::-webkit-datetime-edit { flex: 1; padding: 0; }
input[type="date"]::-webkit-datetime-edit-fields-wrapper { padding: 0; }
input[type="date"]::-webkit-calendar-picker-indicator { padding-block: 0; margin-block: 0; cursor: pointer; }
input[inputmode="decimal"], input[inputmode="numeric"] { font-family: var(--font-mono); font-size: 13px; }
.tx-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tx-form-grid > * { min-width: 0; }
.tx-form-grid .form-actions { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.form-actions .error { margin-top: 0; align-self: center; }
.note + .tx-form-grid { margin-top: 12px; }
#passkeyList { margin-top: 12px; }
.fx-form { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 16px; }
.note b, .note strong { font-weight: 500; color: var(--text-2); }
.inline-form { display: inline-flex; gap: 6px; align-items: center; }
.inline-form input { height: 32px; text-align: right; }
.w-units { width: 130px; }
.w-cost { width: 140px; }
details { margin-top: 12px; }
details summary { cursor: pointer; font-size: 13px; color: var(--text-2); }
details summary:hover { color: var(--text); }
details[open] summary { margin-bottom: 12px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 16px;
  border: 1px solid var(--border); border-radius: var(--r-ctl);
  background: var(--raised); color: var(--text);
  font-family: var(--font-ui); font-size: 14px; font-weight: 500;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease), transform 0.12s var(--ease);
}
.btn:hover { background: var(--btn-hover); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn-primary { background: var(--text); border-color: transparent; color: var(--primary-fg); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--raised); color: var(--text); }
.btn-danger { background: transparent; color: var(--neg); }
.btn-danger:hover { background: rgba(229, 72, 77, 0.08); border-color: rgba(229, 72, 77, 0.4); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.btn-icon { width: 32px; height: 32px; padding: 0; color: var(--text-3); }
.btn-icon:hover { color: var(--text); }
.btn-icon.privacy-on { color: var(--accent); }
.btn-link { width: 100%; height: 32px; font-size: 13px; margin-top: 8px; }

/* ---------- login ---------- */
.login-wrap { display: flex; justify-content: center; align-items: center; min-height: calc(100vh - 60px); }
.login-card { width: 100%; max-width: 360px; padding: 24px; }
.login-card h1 { font-size: 20px; font-weight: 500; margin-bottom: 4px; }
.login-card .muted { margin-bottom: 4px; }
.login-card label { margin-top: 12px; }
.login-card button[type="submit"] { margin-top: 16px; width: 100%; }
.login-subtitle { font-size: 15px; font-weight: 500; margin-bottom: 4px; }

/* ---------- dashboard ---------- */
.total-line { display: flex; flex-direction: column; gap: 8px; }
.total-label { display: flex; align-items: center; gap: 6px; }
.badge { font-size: 12px; font-weight: 400; color: var(--text-2); }
.total-value {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 32px; font-weight: 500; line-height: 1.1; letter-spacing: -0.02em;
  color: var(--text);
}
.as-of {
  margin-top: 8px;
  font-family: var(--font-mono); font-size: 12px; color: var(--text-3);
}
.fx-pair { white-space: nowrap; }
.fresh-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; vertical-align: middle; background: var(--pos); }
.fresh-dot.stale { background: var(--warn); }
.stale-tag {
  font-family: var(--font-ui); font-size: 11px; color: var(--warn);
  background: var(--warn-dim); padding: 2px 6px; border-radius: var(--r-sm);
}
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 16px 0 12px; }
.toolbar-pie { margin: 0 0 12px; }
.toolbar-range { margin: 0 0 4px; }
.summary-left .toolbar { margin-bottom: 0; }
.seg {
  display: inline-flex; gap: 2px; padding: 2px;
  background: var(--deep); border: 1px solid var(--border); border-radius: var(--r-ctl);
}
.seg button {
  height: 28px; padding: 0 12px; border: none; border-radius: 8px;
  background: transparent; color: var(--text-2);
  font-family: var(--font-ui); font-size: 13px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--raised); color: var(--text); box-shadow: inset 0 1px 0 var(--inset-hi); }

.summary-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.summary-right { border-top: 1px solid var(--border); padding-top: 16px; }
@media (min-width: 960px) {
  .summary-grid { grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: center; }
  .summary-right { border-top: none; padding-top: 0; border-left: 1px solid var(--border); padding-left: 24px; }
}

.chart-wrap { position: relative; height: 300px; margin-top: 12px; }

/* ---------- asset chart carousel (C8a): native scroll-snap swipe ---------- */
.carousel { position: relative; border-radius: var(--r-ctl); }
.carousel:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.slides {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.slides::-webkit-scrollbar { display: none; }
.slide { flex: 0 0 100%; min-width: 0; scroll-snap-align: start; }
.slide-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 4px 16px; flex-wrap: wrap; margin-top: 8px;
}
.slide-title { font-size: 14px; font-weight: 500; color: var(--text); }
.slide-title .muted { font-size: 12px; font-weight: 400; }
.slide-change { font-size: 12px; }
.slide .chart-wrap { margin-top: 8px; }
.chart-empty { display: flex; align-items: center; justify-content: center; }
.car-controls { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 12px; }
.dots { display: flex; gap: 6px; }
.dots button {
  width: 8px; height: 8px; padding: 0; border: none; border-radius: 50%;
  background: var(--border-strong); cursor: pointer;
  transition: background-color 0.15s var(--ease);
}
.dots button:hover { background: var(--text-3); }
.dots button.active { background: var(--accent); }
.car-arrow {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border: 1px solid var(--border); border-radius: 8px;
  background: transparent; color: var(--text-2); cursor: pointer;
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}
.car-arrow:hover { background: var(--btn-hover); color: var(--text); }
@media (hover: none) { .car-arrow { display: none; } } /* touch devices swipe; arrows are for pointer users */

.pie-grid { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.pie-holder { position: relative; width: 170px; height: 170px; flex: none; }
.legend {
  font-size: 13px; display: grid; grid-template-columns: 1fr auto auto;
  column-gap: 12px; row-gap: 8px; align-items: baseline; min-width: 230px;
}
.legend p { grid-column: 1 / -1; }
.legend .lg-val, .legend .lg-pct {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  text-align: right; white-space: nowrap;
}
.legend .lg-val { font-size: 12px; }
.legend .lg-pct { min-width: 52px; color: var(--text-3); font-size: 12px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; }

/* ---------- tables ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; color: var(--text-3); font-weight: 400; font-size: 12px;
  padding: 8px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 10px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; color: var(--text-2); }
td:first-child { color: var(--text); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.num { font-family: var(--font-mono); font-size: 12px; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background-color 0.15s var(--ease); }
tbody tr:hover { background: var(--row-hover); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.na { color: var(--text-3); }
.bal-input { width: 120px; height: 32px; text-align: right; }

/* ---------- status & alerts ---------- */
.src-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
  font-size: 14px; flex-wrap: wrap;
}
.src-row:last-child { border-bottom: none; }
.src-row .muted { font-family: var(--font-mono); font-size: 12px; }
.ok-tag { color: var(--pos); }
.err-tag { color: var(--neg); }
.warn-tag { color: var(--warn); }
.section-head { font-size: 12px; font-weight: 400; color: var(--text-3); margin: 20px 0 8px; }
.alert-item { border-bottom: 1px solid var(--border); padding: 8px 0; font-size: 14px; }
.alert-item:last-child { border-bottom: none; }
.alert-text { white-space: pre-wrap; font-size: 13px; color: var(--text-2); margin: 4px 0 0; }
.severity-warning { color: var(--warn); }
.severity-critical { color: var(--neg); }

/* ---------- responsive 390px ---------- */
@media (max-width: 480px) {
  .card { padding: 16px; }
  .total-value { font-size: 28px; }
  .tx-form-grid { grid-template-columns: 1fr; }
  td, th { padding: 8px 4px; }
  td.num { font-size: 11px; }
  .pie-holder { width: 150px; height: 150px; margin: 0 auto; }
  .chart-wrap { height: 240px; }
  .inline-form { flex-wrap: wrap; }
  .w-units { width: 110px; }
}
