:root {
  --bg: #0b1120;
  --surface: #131c31;
  --surface-2: #1c2844;
  --border: rgba(148, 163, 184, 0.18);
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #10b981;
  --accent-soft: rgba(16, 185, 129, 0.14);
  --accent-ink: #042f2e;
  --blue: #38bdf8;
  --amber: #f59e0b;
  --rose: #f43f5e;
  --purple: #a855f7;
}
[data-theme="light"] {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: rgba(15, 23, 42, 0.12);
  --text: #0f172a;
  --muted: #64748b;
  --accent: #059669;
  --accent-soft: rgba(5, 150, 105, 0.12);
  --accent-ink: #ffffff;
  --blue: #0284c7;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  height: 100%; overflow: hidden;
}
.app-shell {
  display: flex; flex-direction: column;
  height: 100dvh; max-width: 980px; margin: 0 auto;
  background: var(--bg);
}
.app-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: var(--surface);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.brand-title { font-size: 16px; font-weight: 800; letter-spacing: -0.02em; display: flex; align-items: center; gap: 7px; }
.brand-sub { font-size: 11px; color: var(--muted); font-weight: 500; }
.app-scroll {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 12px; display: flex; flex-direction: column; gap: 10px;
}
.hud, .item-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 12px 14px; flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
.grid-3 {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px;
}
@media (max-width: 640px) {
  .grid-3 { grid-template-columns: 1fr; }
}
.bucket-card {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px;
}
.bucket-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.bucket-val { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.bucket-sub { font-size: 11.5px; color: var(--muted); }
.sec-label {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted); padding: 4px 2px 0; flex-shrink: 0;
}
.bar-track {
  width: 100%; height: 8px; background: var(--surface-2);
  border-radius: 999px; overflow: hidden; margin-top: 5px;
}
.bar-fill { height: 100%; border-radius: 999px; transition: width 0.25s ease; }
.pill-btn, .ghost-btn, .primary-btn {
  border-radius: 10px; font-size: 12.5px; font-weight: 600;
  min-height: 34px; padding: 0 11px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
}
.primary-btn {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700;
}
.pill-btn.active {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
}
.search-row {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}
.search-input, .select-input, .num-input {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  min-height: 36px; padding: 0 10px; font-size: 13px;
}
.search-input { flex: 1; min-width: 160px; }
.txn-row {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
  padding: 10px 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; cursor: pointer; flex-shrink: 0;
}
.txn-row:hover { border-color: var(--accent); }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 6px; font-size: 11px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
}
.badge.ot { background: rgba(245, 158, 11, 0.16); color: #fbbf24; border-color: rgba(245, 158, 11, 0.35); }
.badge.rec { background: rgba(16, 185, 129, 0.14); color: #34d399; border-color: rgba(16, 185, 129, 0.35); }
.badge.split { background: rgba(56, 189, 248, 0.15); color: #38bdf8; border-color: rgba(56, 189, 248, 0.35); }
.nav-tabs {
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); flex-shrink: 0;
}
.nav-tab {
  background: transparent; border: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 2px; font-size: 11px; font-weight: 600; cursor: pointer; border-radius: 10px;
}
.nav-tab.active { color: var(--accent); background: var(--accent-soft); }
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(2, 6, 23, 0.72);
  display: none; align-items: flex-end; justify-content: center; z-index: 1000;
}
.drawer-backdrop.open { display: flex; }
.drawer-sheet {
  background: var(--surface); width: 100%; max-width: 640px;
  max-height: 88dvh; border-radius: 18px 18px 0 0;
  border: 1px solid var(--border); padding: 16px;
  overflow-y: auto; display: flex; flex-direction: column; gap: 12px;
}
.field-row { display: flex; flex-direction: column; gap: 4px; }
.field-row label { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.toast-box {
  position: fixed; bottom: 74px; left: 50%; transform: translateX(-50%);
  background: #10b981; color: #042f2e; font-weight: 700; font-size: 13px;
  padding: 8px 16px; border-radius: 999px; z-index: 2000; display: none;
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
}
.toast-box.show { display: block; }
