/* CardLab web app — brand design system, phone-first layout. */
:root {
  --bg-deep: #041114; --bg-raised: #092123; --bg-panel: #0c2b2c; --surface: #0c2b2c;
  --emerald: #095e4a; --mint: #8ef5cd; --gold: #ecba63;
  --text: #f5fcf8; --muted: #9ebbb1; --crit: #e8836b;
  --border: rgba(142, 245, 205, 0.12);
  --radius: 18px; --radius-sm: 12px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
body { font-family: var(--font); background: #02090b; color: var(--text); min-height: 100vh; display: grid; place-items: center; }
input, select, button { font-family: inherit; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Phone frame on desktop; full-bleed on mobile */
.device {
  width: 100%; max-width: 430px; min-height: 100vh; position: relative;
  background: linear-gradient(180deg, var(--bg-deep), var(--bg-raised));
  display: flex; flex-direction: column; overflow: hidden;
}
@media (min-width: 480px) {
  body { padding: 24px; }
  .device { min-height: 880px; height: 880px; border-radius: 38px; border: 1px solid var(--border); box-shadow: 0 40px 100px rgba(0, 0, 0, 0.6); }
}

/* Topbar / tabbar */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; position: sticky; top: 0; background: rgba(4, 17, 20, 0.7); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); z-index: 5; }
.topbar .brand { font-weight: 800; letter-spacing: -0.02em; }
.icon-btn { background: none; border: none; color: var(--mint); font-size: 1.15rem; cursor: pointer; width: 36px; height: 36px; border-radius: 50%; }
.icon-btn:active { background: rgba(142, 245, 205, 0.1); }
.screen { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; padding-bottom: 90px; }
.tabbar { position: absolute; bottom: 0; left: 0; right: 0; display: flex; background: rgba(4, 17, 20, 0.85); backdrop-filter: blur(14px); border-top: 1px solid var(--border); padding: 8px 6px calc(8px + env(safe-area-inset-bottom)); }
.tab { flex: 1; text-align: center; color: var(--muted); text-decoration: none; font-size: 0.66rem; font-weight: 600; display: grid; gap: 3px; padding: 4px; }
.tab .ti { font-size: 1.1rem; }
.tab.active { color: var(--mint); }

h1 { font-size: 1.6rem; letter-spacing: -0.02em; }
.screen-title { margin: 4px 2px; }
.muted { color: var(--muted); }
.small { font-size: 0.8rem; }
.grad { background: linear-gradient(110deg, var(--mint), var(--gold) 85%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.fineprint { font-size: 0.72rem; color: var(--muted); margin-top: 8px; }
.row { display: flex; align-items: center; gap: 14px; }
.row.between { justify-content: space-between; }
.row.end { align-items: flex-end; }
.row.gap { gap: 28px; justify-content: center; }
.r { text-align: right; }
.center { text-align: center; align-items: center; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.panel.best { border-color: var(--mint); }
.panel.gold { background: rgba(236, 186, 99, 0.08); border-color: rgba(236, 186, 99, 0.3); }
.metric { font-size: 1.7rem; font-weight: 800; font-variant-numeric: tabular-nums; }

/* Buttons */
.btn { border: none; border-radius: 999px; padding: 13px 22px; font-weight: 700; font-size: 0.95rem; cursor: pointer; }
.btn-primary { background: var(--mint); color: var(--bg-deep); }
.btn-ghost { background: rgba(255, 255, 255, 0.05); color: var(--text); border: 1px solid var(--border); }
.btn.full { width: 100%; margin-top: 6px; }
.btn.danger { color: var(--crit); }
.qb { flex: 1; background: var(--surface); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm); padding: 14px 6px; font-weight: 600; font-size: 0.82rem; cursor: pointer; }
.qb:active { background: rgba(142, 245, 205, 0.08); }
.quick { display: flex; gap: 10px; }
.mini { background: rgba(255,255,255,0.06); border: 1px solid var(--border); color: var(--text); border-radius: 999px; padding: 5px 14px; font-size: 0.8rem; cursor: pointer; }

/* Tiles */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--bg-panel); border-radius: var(--radius-sm); padding: 13px; }
.tval { font-size: 1.05rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tmini { text-align: center; }
.calm-text { color: var(--mint); } .warn-text { color: var(--gold); } .crit-text { color: var(--crit); }

/* Sim card */
.simcard { border-radius: 20px; padding: 18px; min-height: 196px; display: flex; flex-direction: column; justify-content: space-between; box-shadow: 0 22px 44px rgba(0, 0, 0, 0.45); border: 1px solid rgba(255, 255, 255, 0.12); color: #fff; }
.sc-sub { font-size: 0.72rem; color: rgba(255, 255, 255, 0.7); }
.sc-state { font-size: 0.68rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.sc-state.calm { background: rgba(142, 245, 205, 0.9); color: #04211a; }
.sc-state.caution { background: var(--gold); color: #2a1e02; }
.sc-state.critical { background: var(--crit); color: #2a0d06; }
.sc-chip { width: 40px; height: 28px; border-radius: 6px; background: linear-gradient(180deg, var(--gold), #c79a48); }
.sc-lbl { font-size: 0.58rem; letter-spacing: 0.08em; color: rgba(255, 255, 255, 0.65); }
.sc-val { font-weight: 700; font-variant-numeric: tabular-nums; }
.sc-num { font-family: ui-monospace, monospace; letter-spacing: 2px; color: rgba(255, 255, 255, 0.55); font-size: 0.82rem; }

/* Badges */
.badge { font-size: 0.7rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.badge.ok { background: rgba(142, 245, 205, 0.15); color: var(--mint); }
.badge.warn { background: rgba(236, 186, 99, 0.15); color: var(--gold); }
.badge.gold { background: rgba(236, 186, 99, 0.18); color: var(--gold); }

/* Ring */
.ring { width: 110px; flex: none; }
.ring.big { width: 150px; margin: 0 auto; }
.ringsvg { width: 100%; }
.ring-pct { fill: var(--text); font-size: 1.5rem; font-weight: 800; font-family: var(--font); }
.ring-band { font-size: 0.7rem; font-weight: 700; font-family: var(--font); }

/* AI promo + dot */
.ai-promo { flex-direction: row; align-items: center; cursor: pointer; }
.ai-dot { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(from 0deg, var(--mint), var(--gold), #4fd2b0, var(--mint)); }
.ai-dot.big { width: 60px; height: 60px; font-size: 1.5rem; margin: 0 auto 8px; }
.chev { margin-left: auto; color: var(--muted); }

/* Activity / timeline */
.act { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--border); }
.act:first-of-type { border-top: none; }
.act > :last-child { font-variant-numeric: tabular-nums; }
.tl { display: flex; flex-direction: column; }
.tl-row { display: flex; gap: 12px; }
.tl-rail { display: flex; flex-direction: column; align-items: center; }
.tl-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--mint); margin-top: 4px; }
.tl-dot.statement { background: var(--gold); } .tl-dot.due { background: var(--crit); } .tl-dot.payment { background: var(--mint); }
.tl-dot.purchase, .tl-dot.fee, .tl-dot.cashAdvance { background: var(--muted); }
.tl-line { flex: 1; width: 2px; background: var(--border); margin: 4px 0; }
.tl-body { flex: 1; padding-bottom: 16px; }

/* Segmented */
.seg { display: flex; gap: 6px; background: var(--bg-panel); padding: 4px; border-radius: 999px; }
.seg-b { flex: 1; background: none; border: none; color: var(--muted); padding: 8px; border-radius: 999px; font-weight: 600; cursor: pointer; }
.seg-b.on { background: var(--mint); color: var(--bg-deep); }

/* Chart */
.chart { width: 100%; height: 150px; }
.legend { display: flex; gap: 16px; }
.lg { display: flex; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--muted); }
.lg i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

/* Lessons */
.lgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; text-decoration: none; color: var(--text); display: flex; flex-direction: column; gap: 6px; min-height: 150px; }
.lico { font-size: 1.5rem; } .lico.big { font-size: 2rem; }
.lhead { display: flex; align-items: center; gap: 12px; }
.back { color: var(--mint); text-decoration: none; font-size: 0.9rem; }

/* Onboarding */
.onb { min-height: 100vh; display: grid; place-items: center; padding: 18px; }
.onb-card { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.onb h1 { font-size: 2rem; line-height: 1.05; letter-spacing: -0.02em; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips.wrap { margin: 4px 0; }
.chip { font-size: 0.72rem; font-weight: 600; color: var(--mint); background: rgba(142, 245, 205, 0.08); border: 1px solid var(--border); padding: 6px 12px; border-radius: 999px; }
.field { display: flex; flex-direction: column; gap: 6px; }
label { font-size: 0.78rem; color: var(--muted); }
input, select { background: var(--bg-panel); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm); padding: 12px; font-size: 1rem; width: 100%; }
input:focus, select:focus { outline: none; border-color: var(--mint); }

/* Modal / sheet */
.overlay { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); display: flex; align-items: flex-end; z-index: 20; }
.sheet { background: var(--bg-raised); width: 100%; border-radius: 22px 22px 0 0; padding: 18px; display: flex; flex-direction: column; gap: 10px; max-height: 90%; overflow-y: auto; border-top: 1px solid var(--border); animation: up 0.25s ease; }
.sheet.tall { height: 86%; }
@keyframes up { from { transform: translateY(30px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.sheet-h { display: flex; justify-content: space-between; align-items: center; }
.sheet-h button { background: none; border: none; color: var(--muted); font-size: 1.1rem; cursor: pointer; }
.rowbtn { background: var(--surface); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm); padding: 13px; text-align: left; cursor: pointer; }

/* Chat */
.chat { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 0; }
.chat-intro { text-align: center; padding: 30px 10px; }
.bubble { padding: 11px 14px; border-radius: 16px; max-width: 85%; font-size: 0.92rem; line-height: 1.45; }
.bubble.user { background: var(--mint); color: var(--bg-deep); align-self: flex-end; }
.bubble.ai { background: var(--surface); align-self: flex-start; border: 1px solid var(--border); }
.chip-b { background: var(--surface); border: 1px solid var(--mint); color: var(--text); border-radius: 999px; padding: 7px 12px; font-size: 0.78rem; cursor: pointer; }
.chatbar { display: flex; gap: 8px; align-items: center; }
.chatbar input { flex: 1; }
.chatbar button { background: var(--mint); color: var(--bg-deep); border: none; width: 42px; height: 42px; border-radius: 50%; font-size: 1.1rem; cursor: pointer; flex: none; }
