/* Valas Tracker — by drummergimbal */
:root {
  --emerald: #0F9D74;
  --emerald-2: #0B7F5E;
  --emerald-3: #14B886;
  --gold: #E0B04B;
  --gold-2: #B9852A;
  --gold-soft: #FBF1D6;
  --navy: #13294B;
  --up: #16A34A;
  --down: #DC2626;
  --flat: #64748B;

  --bg: #F7F9FC;
  --surface: #FFFFFF;
  --surface-2: #F1F5F9;
  --line: #E4E9F0;
  --text: #13294B;
  --muted: #5B6B82;
  --faint: #93A1B5;
  --up-bg: #E7F7EE;
  --down-bg: #FDECEC;
  --flat-bg: #EEF2F6;
  --shadow: 0 1px 2px rgba(19, 41, 75, .05), 0 8px 24px -12px rgba(19, 41, 75, .18);
  --shadow-lg: 0 20px 48px -20px rgba(11, 127, 94, .55);
  --radius: 20px;
  --c-USD: #0F9D74;
  --c-SGD: #2E5FAA;
  --c-MYR: #E0B04B;
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B1426;
    --surface: #111D33;
    --surface-2: #17253F;
    --line: #22324F;
    --text: #E8EEF7;
    --muted: #A2B0C6;
    --faint: #6E7F99;
    --up: #34D27B;
    --down: #F26B6B;
    --flat: #94A3B8;
    --up-bg: rgba(52, 210, 123, .12);
    --down-bg: rgba(242, 107, 107, .12);
    --flat-bg: rgba(148, 163, 184, .12);
    --gold-soft: rgba(224, 176, 75, .14);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 28px -16px rgba(0, 0, 0, .6);
    --c-SGD: #6E9BE8;
  }
}
:root[data-theme="dark"] {
  --bg: #0B1426; --surface: #111D33; --surface-2: #17253F; --line: #22324F;
  --text: #E8EEF7; --muted: #A2B0C6; --faint: #6E7F99;
  --up: #34D27B; --down: #F26B6B; --flat: #94A3B8;
  --up-bg: rgba(52, 210, 123, .12); --down-bg: rgba(242, 107, 107, .12); --flat-bg: rgba(148, 163, 184, .12);
  --gold-soft: rgba(224, 176, 75, .14); --c-SGD: #6E9BE8;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}
button { font: inherit; color: inherit; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
.money, .num, .board-rate, .trend-rate { font-variant-numeric: tabular-nums; }

.wrap {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  padding-top: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 10px; }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--text); min-width: 0; }
.brand img { flex: none; filter: drop-shadow(0 2px 4px rgba(185, 133, 42, .35)); }
.brand-text { font-weight: 600; font-size: 17px; letter-spacing: -.02em; white-space: nowrap; }
.brand-text b { font-weight: 800; color: var(--emerald); margin-left: 3px; }
.top-actions { display: flex; align-items: center; gap: 6px; }

.conn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 12px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
  background: var(--flat-bg); color: var(--muted);
}
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.conn[data-state="live"] { background: var(--up-bg); color: var(--up); }
.conn[data-state="live"] .dot { animation: pulse 2s infinite; }
.conn[data-state="cache"] { background: var(--gold-soft); color: var(--gold-2); }
.conn[data-state="offline"] { background: var(--down-bg); color: var(--down); }
.conn[data-state="loading"] .dot { animation: blink 1s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--up) 55%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@keyframes blink { 50% { opacity: .3; } }

.icon-btn {
  width: 36px; height: 36px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); display: grid; place-items: center; cursor: pointer; flex: none;
  transition: transform .15s, background .15s;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ico-eye-off { display: none; }
body.private .ico-eye { display: none; }
body.private .ico-eye-off { display: block; }

/* ---------- Pull to refresh ---------- */
.ptr {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 66px); z-index: 30;
  transform: translate(-50%, -80px); opacity: 0;
  display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px;
  background: var(--surface); box-shadow: var(--shadow); font-size: 13px; font-weight: 600; color: var(--emerald);
  pointer-events: none; transition: opacity .2s;
}
.ptr.ready .ptr-icon { transform: rotate(180deg); }
.ptr-icon { display: inline-block; transition: transform .2s; font-size: 16px; }

/* ---------- Main ---------- */
main { padding-top: 18px; padding-bottom: 28px; display: grid; gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h3 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -.01em; }

/* ---------- Hero (banknote) ---------- */
.hero {
  position: relative; overflow: hidden; border-radius: 24px; color: #fff;
  background: linear-gradient(135deg, var(--emerald-3) 0%, var(--emerald) 45%, #0A6A50 100%);
  box-shadow: var(--shadow-lg);
  padding: 22px 20px 18px;
  isolation: isolate;
}
.hero::before { /* bingkai emas ganda ala uang kertas */
  content: ""; position: absolute; inset: 8px; border-radius: 18px;
  border: 1px solid rgba(243, 210, 122, .55);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .06), inset 0 0 0 4px rgba(243, 210, 122, .25);
  pointer-events: none; z-index: 1;
}
.hero-bg { position: absolute; inset: 0; background: url(assets/guilloche.svg) center / cover no-repeat; z-index: -1; opacity: .9; }
.hero-bg::after {
  content: "Rp"; position: absolute; right: -10px; bottom: -48px;
  font-size: 170px; font-weight: 800; letter-spacing: -.06em; line-height: 1;
  color: rgba(255, 255, 255, .07);
}
.hero-serial {
  position: absolute; top: 16px; right: 22px; z-index: 2;
  font-size: 10px; font-weight: 700; letter-spacing: .22em; color: rgba(251, 231, 166, .85);
}
.hero-content { position: relative; z-index: 2; }
.hero-label { font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: rgba(255, 255, 255, .82); }
.hero-value {
  margin: 6px 0 12px; font-size: clamp(30px, 8.6vw, 50px); font-weight: 800; letter-spacing: -.035em; line-height: 1.05;
  text-shadow: 0 2px 12px rgba(0, 0, 0, .12);
}
.hero-value .dec { font-size: .5em; font-weight: 700; opacity: .75; letter-spacing: -.01em; }
.hero-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 999px;
  font-size: 13px; font-weight: 700; background: rgba(255, 255, 255, .16); color: #fff;
  border: 1px solid rgba(255, 255, 255, .22); backdrop-filter: blur(4px);
}
.chip small { white-space: nowrap; font-weight: 600; opacity: .8; font-size: 11.5px; }
.chip-gold { background: rgba(251, 231, 166, .2); border-color: rgba(251, 231, 166, .45); color: #FFF4D2; }
.hero-meta { margin-top: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 12px; color: rgba(255, 255, 255, .85); }
.hero-meta .sep { opacity: .6; }
.badge-stale { background: #FFF4D2; color: #8A5A00; font-weight: 700; padding: 2px 8px; border-radius: 999px; font-size: 11px; }

/* ---------- Board ---------- */
.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.board-tile {
  background: var(--navy); color: #fff; border-radius: 16px; padding: 12px 12px 11px;
  position: relative; overflow: hidden; min-width: 0;
  background-image: linear-gradient(160deg, rgba(255, 255, 255, .06), transparent 60%);
}
:root[data-theme="dark"] .board-tile { background-color: #0F2347; }
.board-code { display: flex; align-items: center; justify-content: space-between; font-size: 11px; font-weight: 800; letter-spacing: .12em; color: #F3D27A; }
.board-code .sym { color: rgba(255, 255, 255, .5); letter-spacing: 0; font-weight: 700; }
.board-rate { font-size: clamp(14px, 4.4vw, 22px); font-weight: 800; letter-spacing: -.02em; margin: 4px 0 2px; white-space: nowrap; }
.board-chg { font-size: 12px; font-weight: 700; white-space: nowrap; }
.board-chg.up { color: #4ADE80; } .board-chg.down { color: #FB7185; } .board-chg.flat { color: #CBD5E1; }
.board-tile.flash { animation: flash 1s ease; }
@keyframes flash { 0% { box-shadow: inset 0 0 0 2px #F3D27A; } 100% { box-shadow: inset 0 0 0 0 transparent; } }

/* ---------- Currency cards ---------- */
.cards { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .cards { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .cards { grid-template-columns: repeat(3, 1fr); } }
.cur-card { position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 12px; }
.cur-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent, var(--emerald)); }
.cur-top { display: flex; align-items: center; gap: 12px; }
.cur-badge {
  width: 44px; height: 44px; border-radius: 14px; flex: none; display: grid; place-items: center;
  font-weight: 800; font-size: 15px; color: #fff; background: var(--accent);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .25);
}
.cur-name { min-width: 0; }
.cur-name b { display: block; font-size: 16px; letter-spacing: -.01em; }
.cur-name span { font-size: 12.5px; color: var(--muted); }
.status {
  margin-left: auto; display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 800; letter-spacing: .02em; white-space: nowrap;
}
.status.up { background: var(--up-bg); color: var(--up); }
.status.down { background: var(--down-bg); color: var(--down); }
.status.flat { background: var(--flat-bg); color: var(--flat); }
.cur-rate { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.cur-rate .big { font-size: 26px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.cur-rate .unit { font-size: 12px; color: var(--muted); font-weight: 600; }
.chg { font-size: 13.5px; font-weight: 700; }
.chg.up { color: var(--up); } .chg.down { color: var(--down); } .chg.flat { color: var(--flat); }
.closed-note { font-size: 12px; color: var(--muted); margin-top: -6px; }
.spark { height: 46px; width: 100%; display: block; }
.cur-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.stat span { display: block; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.stat b { font-size: 14.5px; font-weight: 700; letter-spacing: -.01em; }
.stat b.up { color: var(--up); } .stat b.down { color: var(--down); }
.share-row { grid-column: 1 / -1; display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); font-weight: 600; margin-bottom: -6px; }
.share-row b { color: var(--text); font-size: 12.5px; }
.share-bar { grid-column: 1 / -1; height: 6px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.share-bar i { display: block; height: 100%; background: var(--accent); border-radius: 6px; transition: width .8s cubic-bezier(.2, .8, .2, 1); }

/* ---------- Charts ---------- */
.charts { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 1000px) { .charts { grid-template-columns: 2fr 1fr; } }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border-radius: 12px; }
.seg button {
  border: 0; background: transparent; padding: 6px 12px; border-radius: 9px; font-size: 13px; font-weight: 700;
  color: var(--muted); cursor: pointer; transition: background .15s, color .15s;
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(19, 41, 75, .14); }
.seg-sm button { padding: 5px 10px; font-size: 12px; }
.trend-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.trend-rate { font-size: 24px; font-weight: 800; letter-spacing: -.03em; }
.trend-sub { font-size: 12.5px; font-weight: 700; }
.trend-chart { position: relative; height: 230px; margin: 0 -4px; touch-action: pan-y; }
@media (min-width: 1000px) { .trend-chart { height: 280px; } }
.trend-chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.axis text { font-size: 10.5px; fill: var(--faint); font-family: var(--font); }
.grid line { stroke: var(--line); stroke-dasharray: 3 4; }
.tip {
  position: absolute; top: 0; pointer-events: none; background: var(--navy); color: #fff;
  padding: 7px 10px; border-radius: 10px; font-size: 12px; font-weight: 600; white-space: nowrap;
  transform: translate(-50%, -110%); box-shadow: var(--shadow); opacity: 0; transition: opacity .12s;
}
.tip b { display: block; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.legend-line { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.lg { display: inline-block; width: 16px; height: 3px; border-radius: 2px; margin-left: 6px; }
.lg-rate { background: var(--line-c, var(--emerald)); margin-left: 0; }
.lg-base { background: repeating-linear-gradient(90deg, var(--gold-2) 0 4px, transparent 4px 7px); }

.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: center; }
.donut { width: 170px; height: 170px; position: relative; flex: none; }
.donut svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.donut-center span { font-size: 11px; color: var(--muted); font-weight: 600; }
.donut-center b { font-size: 15px; font-weight: 800; letter-spacing: -.02em; }
.donut-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; min-width: 170px; flex: 1; }
.donut-legend li { display: grid; grid-template-columns: 12px 1fr auto; align-items: center; gap: 10px; font-size: 13.5px; }
.donut-legend i { width: 12px; height: 12px; border-radius: 4px; }
.donut-legend small { display: block; color: var(--muted); font-size: 11.5px; }
.donut-legend b { font-variant-numeric: tabular-nums; }

/* ---------- Setup ---------- */
.setup { text-align: center; padding: 34px 22px; }
.setup h2 { margin: 12px 0 6px; }
.setup p { color: var(--muted); max-width: 460px; margin: 0 auto; }

/* ---------- Skeleton ---------- */
.skel { display: inline-block; height: .9em; border-radius: 8px; background: linear-gradient(90deg, rgba(255,255,255,.18), rgba(255,255,255,.32), rgba(255,255,255,.18)); background-size: 200% 100%; animation: shimmer 1.3s infinite; vertical-align: middle; }
.w30 { width: 90px; } .w40 { width: 130px; } .w60 { width: 62%; }
.skel-card { min-height: 250px; background: linear-gradient(90deg, var(--surface), var(--surface-2), var(--surface)); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Privacy ---------- */
body.private .money { filter: blur(9px); user-select: none; transition: filter .2s; }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--line); padding: 18px 0 calc(22px + env(safe-area-inset-bottom)); color: var(--muted); font-size: 12.5px; }
.footer-inner { display: grid; gap: 4px; text-align: center; justify-items: center; }
.credit { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-size: 13.5px; }
.credit b { color: var(--emerald); }
.ver { font-weight: 600; }
.note { color: var(--faint); font-size: 11.5px; }

/* ---------- Install / sheet / toast ---------- */
.install-btn {
  position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 25;
  display: inline-flex; align-items: center; gap: 8px; border: 0; cursor: pointer;
  background: var(--navy); color: #fff; padding: 11px 16px; border-radius: 999px; font-weight: 700; font-size: 14px;
  box-shadow: 0 10px 24px -10px rgba(19, 41, 75, .7);
}
.install-btn svg { width: 18px; height: 18px; fill: none; stroke: #F3D27A; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.sheet { position: fixed; inset: 0; z-index: 40; background: rgba(11, 20, 38, .5); display: grid; align-items: end; justify-items: center; padding: 16px; }
.sheet-card { background: var(--surface); border-radius: 22px; padding: 20px; width: 100%; max-width: 420px; margin-bottom: env(safe-area-inset-bottom); }
.sheet-card h3 { margin: 0 0 8px; }
.sheet-card ol { margin: 0 0 16px; padding-left: 20px; display: grid; gap: 6px; }
.share-ico { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--surface-2); color: #2E7CF6; }
.btn { width: 100%; border: 0; border-radius: 14px; padding: 12px; font-weight: 700; background: var(--emerald); color: #fff; cursor: pointer; }
.toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 45;
  background: var(--navy); color: #fff; border-radius: 14px; padding: 10px 12px 10px 16px;
  display: flex; align-items: center; gap: 12px; font-size: 13.5px; font-weight: 600;
  box-shadow: 0 14px 30px -12px rgba(0, 0, 0, .5); max-width: calc(100% - 32px);
}
.toast button { border: 0; background: var(--gold); color: var(--navy); font-weight: 800; padding: 7px 12px; border-radius: 10px; cursor: pointer; white-space: nowrap; }

@media (max-width: 480px) { .hero-serial { display: none; } .hero { padding-top: 20px; } }
@media (max-width: 380px) {
  .brand-text { font-size: 15px; }
  .conn { padding: 0 9px; font-size: 11.5px; }
  .board-tile { padding: 10px 9px; }
  .icon-btn { width: 34px; height: 34px; }
}
@media (max-width: 359px) { .conn-label { display: none; } .conn { width: 32px; padding: 0; justify-content: center; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
