/* Console app — sidebar + content, dense but breathing. */

.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100dvh; }

/* ── Sidebar ──────────────────────────────────────────────────────────── */
.side {
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  padding: 14px 12px;
  z-index: 40;
}
.side .brand { padding: 4px 8px 16px; }
.side-nav { display: grid; gap: 2px; }
.side-group { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-4); padding: 16px 10px 6px; font-family: var(--mono); }
.side-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r-xs);
  color: var(--ink-3); font-size: 13.5px; font-weight: 480;
  transition: color .15s, background .15s;
}
.side-link svg { width: 16px; height: 16px; flex: none; opacity: .8; }
.side-link:hover { color: var(--ink); background: var(--hover); }
.side-link[aria-current='page'] { color: var(--ink); background: rgba(255, 138, 61, 0.09); box-shadow: inset 2px 0 0 var(--ember); }
.side-link[aria-current='page'] svg { color: var(--ember); opacity: 1; }
.side-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }

/* ── Main ─────────────────────────────────────────────────────────────── */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  min-height: 60px; padding: 10px clamp(16px, 3vw, 32px);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 17px; letter-spacing: -0.02em; font-weight: 560; }
.topbar .crumb { color: var(--ink-4); font-size: 13px; }
.topbar .spacer { flex: 1; }
.balance-pill {
  display: inline-flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 10px 0 8px; border-radius: var(--r-pill);
  border: 1px solid var(--line-strong); font-size: 12.5px; color: var(--ink-2);
  font-family: var(--mono);
}
.balance-pill b { color: var(--ink); font-weight: 500; }
.balance-pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--mint); }
.content { padding: clamp(16px, 3vw, 32px); display: grid; gap: clamp(14px, 2vw, 22px); align-content: start; width: 100%; max-width: 1320px; }

/* KPI cards */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { padding: 16px 18px; display: grid; gap: 6px; }
.kpi .k-label { font-size: 12px; color: var(--ink-3); display: flex; justify-content: space-between; }
.kpi .k-value { font-size: clamp(1.3rem, 2vw, 1.65rem); font-weight: 560; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.kpi .k-sub { font-size: 12px; color: var(--ink-4); }

/* Panels */
.pane { padding: 0; overflow: hidden; }
.pane-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.pane-head h2 { font-size: 14.5px; font-weight: 560; letter-spacing: -0.01em; }
.pane-head .spacer { flex: 1; }
.pane-body { padding: 18px; }
.pane-body.flush { padding: 0; }

/* Quote rows inside panes must stay flex (pane-body sets display:grid which
   would otherwise cascade onto .line through the shared .line rule). */
.pane-body .quote .line { display: flex; align-items: baseline; justify-content: space-between; gap: 18px; }

.two-col { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 14px; align-items: start; }
@media (max-width: 1080px) { .two-col { grid-template-columns: 1fr; } }

/* Chart */
.chart { position: relative; height: 220px; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 4; }
.chart .area { fill: url(#emberfill); }
.chart .line { fill: none; stroke: var(--ember); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .tick-label { fill: var(--ink-4); font-size: 10.5px; font-family: var(--mono); }
.chart .hit { fill: transparent; }
.chart-tip {
  position: absolute; pointer-events: none; padding: 8px 10px; border-radius: 8px;
  background: var(--raise-2); border: 1px solid var(--line-strong); font-size: 12px;
  transform: translate(-50%, -120%); white-space: nowrap; opacity: 0; transition: opacity .12s;
  box-shadow: 0 12px 30px -14px #000;
}
.chart-tip b { color: var(--ember); font-family: var(--mono); }

/* Key list */
.key-row { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.key-row:last-child { border-bottom: 0; }
.key-row .k-meta { min-width: 0; flex: 1; }
.key-row .k-name { font-size: 14px; font-weight: 520; }
.key-row .k-prefix { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.key-row .k-cap { font-size: 12px; color: var(--ink-4); }

/* Auth pages */
.auth-wrap { min-height: 100dvh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art {
  position: relative; overflow: hidden; border-right: 1px solid var(--line);
  background: radial-gradient(80% 60% at 70% 20%, var(--ember-glow), transparent 70%), var(--bg);
  display: flex; flex-direction: column; justify-content: flex-end; padding: 40px;
}
.auth-art .display { font-size: clamp(2.2rem, 4vw, 3.4rem); max-width: 12ch; }
.auth-art .quote { margin-top: 22px; color: var(--ink-2); max-width: 42ch; font-size: 14.5px; }
.auth-art .quote cite { display: block; margin-top: 10px; color: var(--ink-4); font-style: normal; font-size: 12.5px; }
.auth-form { display: flex; flex-direction: column; justify-content: center; padding: clamp(24px, 6vw, 64px); }
/* Single column below 900px. Declared *after* the desktop rules above: with
   equal specificity the later rule wins, so putting this block earlier would
   leave the decorative panel visible and push the form below the fold. */
.auth-brand { display: none; }
.auth-form { position: relative; }
/* The toggle lives in the top-right corner of the form panel, not inline with
   the card — otherwise it floats mid-panel on desktop where the brand is hidden. */
.auth-top { position: absolute; top: 22px; right: 26px; display: flex; align-items: center; gap: 12px; }
.auth-theme { display: inline-flex; }
@media (max-width: 900px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .auth-form { padding: 20px 20px 40px; min-height: 100dvh; justify-content: flex-start; gap: 20px; }
  .auth-brand { display: inline-flex; }
  /* On mobile the brand is back in the flow, so the toggle joins it in a row. */
  .auth-top { position: static; width: 100%; justify-content: space-between; }
  /* Sit the card just below the brand rather than centring it in the whole
     viewport, which left a large dead band on tall phones. */
  .auth-card { gap: 16px; margin-block: 8vh auto; }
}
.auth-card { width: 100%; max-width: 400px; margin-inline: auto; display: grid; gap: 16px; }
.auth-card h1 { font-size: 1.6rem; letter-spacing: -0.03em; }
.auth-card .switch { font-size: 13.5px; color: var(--ink-3); }
.auth-card .switch a { color: var(--ember); }
.form-error { padding: 10px 12px; border-radius: var(--r-sm); background: rgba(240, 112, 127, 0.08); border: 1px solid rgba(240, 112, 127, 0.3); color: var(--rose); font-size: 13px; }
.pw-meter { height: 3px; border-radius: 2px; background: var(--raise-2); overflow: hidden; }
.pw-meter i { display: block; height: 100%; width: 0; background: var(--rose); transition: width .25s, background .25s; }

/* Playground */
.play { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
@media (max-width: 1000px) { .play { grid-template-columns: 1fr; } }
.play-col { display: grid; gap: 12px; align-content: start; }
.play-col[hidden] { display: none !important; }
.messages { display: grid; gap: 10px; max-height: 52vh; overflow-y: auto; padding-right: 4px; }
.msg { padding: 12px 14px; border-radius: var(--r-md); font-size: 14px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.msg.user { background: var(--hover); border: 1px solid var(--line); }
.msg.assistant { background: rgba(255, 138, 61, 0.06); border: 1px solid rgba(255, 138, 61, 0.18); }
.msg .role { font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-4); margin-bottom: 6px; display: block; }
.composer { display: grid; gap: 8px; }
.composer textarea { min-height: 84px; }
.stat-inline { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-3); font-family: var(--mono); }
.stat-inline b { color: var(--ink-2); font-weight: 500; }

/* Tables in app */
.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 18px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--ink-3); }
.empty { padding: 40px 18px; text-align: center; color: var(--ink-3); font-size: 14px; display: grid; gap: 8px; justify-items: center; }
.empty svg { opacity: .5; }

/* Reveal-once secret */
.secret-box { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: var(--r-sm); border: 1px dashed rgba(255, 138, 61, 0.45); background: rgba(255, 138, 61, 0.05); font-family: var(--mono); font-size: 13px; word-break: break-all; }
.warn-strip { padding: 10px 14px; border-radius: var(--r-sm); background: rgba(255, 138, 61, 0.07); border: 1px solid rgba(255, 138, 61, 0.25); color: var(--ember-on-tint); font-size: 13px; }

/* ── Responsive: drawer sidebar ───────────────────────────────────────── */
.menu-btn { display: none; }
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .side {
    position: fixed; inset: 0 auto 0 0; width: min(280px, 84vw);
    transform: translateX(-102%); transition: transform .28s var(--ease);
    box-shadow: 30px 0 80px -40px #000;
  }
  .app[data-side-open='true'] .side { transform: none; }
  .app[data-side-open='true']::after {
    content: ''; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 35;
  }
  .menu-btn { display: inline-flex; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .kpis { grid-template-columns: 1fr; }
  .content { padding: 12px; }
  .topbar { padding: 8px 12px; }
  .balance-pill span.hide-xs { display: none; }
}

/* Admin-specific */
.admin-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 4px; overflow-x: auto; }
.admin-tabs a { padding: 10px 14px; font-size: 13.5px; color: var(--ink-3); border-bottom: 2px solid transparent; white-space: nowrap; }
.admin-tabs a[aria-current='page'] { color: var(--ink); border-bottom-color: var(--ember); }
.section-title { font-size: 15px; font-weight: 560; margin-bottom: 10px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }

/* Empty chart state: quiet, centred, never mistaken for data. */
.chart-empty { fill: var(--ink-3); font-size: 13px; letter-spacing: 0.01em; }

/* ── Auth: Google sign-in ─────────────────────────────────────────────── */
.auth-sep { display: flex; align-items: center; gap: 12px; margin: 4px 0; color: var(--ink-4); font-size: 12px; }
.auth-sep::before, .auth-sep::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.auth-google {
  width: 100%; justify-content: center; gap: 10px;
  background: var(--raise); border-color: var(--line-strong); color: var(--ink);
}
.auth-google:hover { background: var(--hover); border-color: var(--ink-4); }

/* ── QRIS ─────────────────────────────────────────────────────────────── */
.qris-stage { display: grid; gap: 12px; justify-items: center; }
.qris-box {
  display: grid; gap: 14px; justify-items: center;
  padding: 16px; border-radius: var(--r-md);
  /* A QR must stay on a white field with a dark code in both themes: inverting
     it breaks the scanner, so this surface is intentionally theme-independent. */
  background: #ffffff; border: 1px solid var(--line-strong);
}
.qris-box canvas { display: block; border-radius: 6px; }
.qris-meta { text-align: center; color: #3d352a; }
.qris-meta .muted { color: #6b6357; }
.qris-amount { font-size: 18px; font-weight: 600; color: #1b1712; }
.qris-status { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-3); }
.qris-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ember); box-shadow: 0 0 8px var(--ember); animation: qris-pulse 1.8s ease-in-out infinite; }
.qris-status.ok { color: var(--mint); }
.qris-status.ok .qris-dot { background: var(--mint); box-shadow: 0 0 8px var(--mint); animation: none; }
.qris-status.bad { color: var(--rose); }
.qris-status.bad .qris-dot { background: var(--rose); box-shadow: 0 0 8px var(--rose); animation: none; }
@keyframes qris-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .qris-dot { animation: none; } }
