/* Billfold Console — design v4: white cards on a light grey page, one emerald accent,
   tinted pills and icon tiles. Every style lives here: the page's CSP allows no inline styles. */

:root {
  --bg: #F6F7F9;
  --card: #FFFFFF;
  --border: #E7E8EC;
  --hair: #F0F1F3;
  --text: #0A0A0A;
  --muted: #52525B;
  --faint: #71717A;
  --subtle: #A1A1AA;
  --accent: #047857;
  --accent-soft: #ECFDF5;
  --accent-deep: #064E3B;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04);
  --font: Geist, Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Geist Mono', ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--text); }
a:hover { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.boot, .noscript { padding: 48px; text-align: center; color: var(--faint); }

/* ---------- Frame ---------- */
.app { display: flex; flex-wrap: wrap; min-height: 100vh; }
.sidebar {
  flex: 1 1 220px; border-right: 1px solid var(--border); background: var(--bg);
  padding: 20px 12px; display: flex; flex-direction: column; gap: 28px;
}
.main { flex: 999 1 560px; min-width: 0; padding: 32px 40px 56px; }
.container { max-width: 1180px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }
.container.tight { gap: 20px; }

.brand { display: flex; align-items: center; justify-content: space-between; padding: 0 8px; }
.brand-name { display: inline-flex; align-items: center; gap: 9px; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.logo { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.logo.lg { width: 40px; height: 40px; border-radius: 12px; }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-link {
  display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 0 10px; border-radius: 9px;
  color: var(--muted); text-decoration: none; font-size: 14px;
}
.nav-link:hover { background: #EFF0F3; color: var(--text); }
.nav-link.active { background: var(--card); color: var(--text); font-weight: 500; box-shadow: 0 1px 2px rgba(16, 24, 40, .08), 0 0 0 1px var(--border); }
.nav-link.active svg { color: var(--accent); }

.user-card { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 12px; }
.user-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.user-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 12px; color: var(--faint); display: inline-flex; align-items: center; gap: 5px; }
.avatar {
  width: 30px; height: 30px; flex: none; border-radius: 50%; background: #D1FAE5; color: #065F46;
  display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600;
}
.avatar.sm { width: 28px; height: 28px; background: var(--accent-soft); }
.icon-btn {
  display: inline-flex; width: 30px; height: 30px; align-items: center; justify-content: center;
  border: 0; border-radius: 7px; background: transparent; color: var(--faint); cursor: pointer; flex: none;
}
.icon-btn:hover { background: #EFF0F3; color: var(--text); }

@media (max-width: 820px) {
  .sidebar { flex-basis: 100%; border-right: 0; border-bottom: 1px solid var(--border); gap: 14px; padding: 14px 12px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .user-card { margin-top: 0; }
  .main { padding: 24px 16px 48px; }
}

/* ---------- Building blocks ---------- */
.card { border: 1px solid var(--border); border-radius: 14px; background: var(--card); box-shadow: var(--shadow); }
.card-pad { padding: 20px 22px; }
.card-pad-sm { padding: 18px 20px; }
.stack { display: flex; flex-direction: column; }
.gap-2 { gap: 2px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-10 { gap: 10px; } .gap-12 { gap: 12px; } .gap-14 { gap: 14px; } .gap-16 { gap: 16px; } .gap-20 { gap: 20px; }
.row { display: flex; flex-wrap: wrap; gap: 16px; }
.row.top { align-items: flex-start; }
.grow-3 { flex: 3 1 560px; min-width: 0; }
.grow-2 { flex: 2 1 340px; min-width: 0; }
.grow-1 { flex: 1 1 280px; min-width: 0; }
.between { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.between.center { align-items: center; }
.label { font-size: 13px; color: var(--faint); }
.small { font-size: 12px; color: var(--faint); }
.muted { color: var(--muted); }
.hair { border-top: 1px solid var(--hair); }
.page-title { font-size: 26px; font-weight: 600; letter-spacing: -0.025em; }
.section-title { font-size: 15px; font-weight: 600; }
.crumbs a { color: var(--faint); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.pill.xs { padding: 2px 8px; font-size: 11px; }
.pill-green { background: #DCFCE7; color: #166534; }
.pill-emerald { background: var(--accent-soft); color: var(--accent); }
.pill-amber { background: #FEF3C7; color: #92400E; }
.pill-red { background: #FEE2E2; color: #B91C1C; }
.pill-blue { background: #DBEAFE; color: #1E40AF; }
.pill-indigo { background: #EEF2FF; color: #3730A3; }
.pill-violet { background: #F5F3FF; color: #5B21B6; }
.pill-grey { background: #F4F4F5; color: #3F3F46; }
.dot { width: 6px; height: 6px; border-radius: 50%; flex: none; background: currentColor; }
.dot.lg { width: 8px; height: 8px; }
.dot-green { background: #16A34A; } .dot-red { background: #DC2626; } .dot-amber { background: #F59E0B; }
.dot-blue { background: #3B82F6; } .dot-grey { background: var(--subtle); } .dot-violet { background: #7C3AED; }
.dot-orange { background: #D97706; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 0 14px;
  border-radius: 9px; border: 1px solid var(--border); background: var(--card); color: var(--text);
  font-size: 13px; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: #FAFAFB; color: var(--text); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #FFFFFF; }
.btn-primary:hover { background: #065F46; color: #FFFFFF; }
.btn-freeze { background: #EFF6FF; border-color: #BFDBFE; color: #1D4ED8; }
.btn-freeze:hover { background: #DBEAFE; color: #1D4ED8; }
.btn-blue { background: #1D4ED8; border-color: #1D4ED8; color: #FFFFFF; }
.btn-blue:hover { background: #1E40AF; color: #FFFFFF; }
.btn-ghost-danger { border: 0; background: transparent; color: #B91C1C; min-height: 32px; padding: 0 10px; }
.btn-ghost-danger:hover { background: #FEF2F2; color: #B91C1C; }
.btn-block { width: 100%; min-height: 44px; font-size: 14px; border-radius: 10px; }

.field {
  min-height: 38px; padding: 0 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--card);
  font-size: 13px; outline: none;
}
.field:focus, .search:focus-within, textarea.field:focus { border-color: #A7F3D0; box-shadow: 0 0 0 3px rgba(16, 185, 129, .18); }
textarea.field { width: 100%; padding: 10px 12px; min-height: 84px; resize: vertical; font-size: 14px; }
.select { min-height: 32px; padding: 0 8px; border: 1px solid var(--border); border-radius: 7px; background: var(--card); font-size: 13px; }
.select:disabled { background: #FAFAFA; color: var(--faint); border-color: var(--hair); }
.search {
  display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 10px; border: 1px solid var(--border);
  border-radius: 9px; background: var(--card); box-shadow: var(--shadow);
}
.search input { border: 0; outline: 0; background: transparent; font-size: 13px; min-width: 0; flex: 1; }
.search .kbd { font-family: var(--mono); font-size: 11px; color: var(--faint); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; }
.search-wide { flex: 0 1 460px; }
.search-overview input { width: 220px; flex: none; }

.tile { width: 30px; height: 30px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.tile.sm { width: 28px; height: 28px; border-radius: 8px; }
.tile.lg { width: 44px; height: 44px; border-radius: 12px; }
.t-emerald { background: var(--accent-soft); color: var(--accent); }
.t-blue { background: #EFF6FF; color: #1D4ED8; }
.t-indigo { background: #EEF2FF; color: #4338CA; }
.t-orange { background: #FFF7ED; color: #C2410C; }
.t-violet { background: #F5F3FF; color: #6D28D9; }
.t-grey { background: #F4F4F5; color: var(--muted); }
.t-amber { background: #FFFBEB; color: #B45309; }

.banner { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 10px; font-size: 14px; line-height: 1.5; }
.banner svg { flex: none; margin-top: 2px; }
.banner-amber { background: #FFFBEB; border: 1px solid #FDE68A; color: #78350F; }
.banner-blue { background: #EFF6FF; color: #1E3A8A; }
.banner-red { background: #FEF2F2; border: 1px solid #FECACA; color: #991B1B; }

.empty { padding: 40px 24px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty p { color: var(--muted); max-width: 420px; line-height: 1.5; }
.skeleton { color: var(--faint); padding: 24px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { font-weight: 500; text-align: left; font-size: 13px; color: var(--faint); padding: 8px 12px; }
td { padding: 12px; vertical-align: middle; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
tbody tr { border-top: 1px solid var(--hair); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
/* Signed amounts never break between the sign and the figure. */
td.num { white-space: nowrap; }
.min-500 { min-width: 500px; } .min-620 { min-width: 620px; } .min-680 { min-width: 680px; } .min-720 { min-width: 720px; }
.cell-title { display: flex; flex-direction: column; gap: 2px; }
.cell-code { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.cell-flex { display: flex; align-items: center; gap: 10px; }
.pos { color: var(--accent); } .neg { color: var(--text); } .zero { color: var(--subtle); } .held { color: var(--faint); }

/* ---------- Overview ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.kpi { padding: 18px 18px 16px; display: flex; flex-direction: column; gap: 12px; }
.kpi-value { font-family: var(--mono); font-size: 25px; font-weight: 500; letter-spacing: -0.03em; }
.kpi-foot { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--faint); flex-wrap: wrap; }
.bar-track { display: block; height: 6px; border-radius: 3px; background: #F1F2F4; min-width: 80px; }
.bar-fill { display: block; height: 6px; border-radius: 3px; }
.mix { display: flex; height: 10px; border-radius: 5px; overflow: hidden; gap: 2px; background: #F1F2F4; }
.mix span { display: block; height: 10px; }
.mix .rest { flex: 1; }
.legend { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.promo-panels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.promo-panel { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border-radius: 10px; background: #F5F3FF; }
.promo-panel span:first-child { font-size: 12px; color: #5B21B6; }
.list { list-style: none; margin: 0; padding: 0; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--hair); }
.strip { display: flex; gap: 2px; align-items: center; height: 18px; }
.strip span { width: 4px; height: 18px; border-radius: 2px; background: #E4E4E7; }
.s-ok { background: #6EE7B7 !important; } .s-warn { background: #F59E0B !important; } .s-fail { background: #DC2626 !important; }
.job-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; padding: 14px 0; border-top: 1px solid var(--hair); }
.job-name { flex: 1 1 200px; display: flex; flex-direction: column; gap: 3px; }
.legend-tick { width: 4px; height: 10px; border-radius: 2px; }
.sections { display: flex; flex-direction: column; gap: 24px; }
.row-inline { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.share-cell { width: 30%; }
.life-count { min-width: 52px; text-align: right; }
.legend-row { gap: 16px; flex-wrap: wrap; }

/* ---------- Wallet ---------- */
.identity-id { font-family: var(--mono); font-size: 19px; font-weight: 500; letter-spacing: -0.02em; word-break: break-all; }
.balances { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.balance { padding: 14px 16px; border-radius: 12px; display: flex; flex-direction: column; gap: 6px; }
.balance-value { font-family: var(--mono); font-size: 21px; font-weight: 500; letter-spacing: -0.02em; }
.balance-label { font-size: 12px; display: inline-flex; align-items: center; gap: 6px; }
.b-total { background: var(--accent-deep); color: #FFFFFF; } .b-total .balance-label, .b-total .small { color: #A7F3D0; }
.b-cash { background: var(--accent-soft); } .b-cash .balance-label, .b-cash .small { color: #065F46; }
.b-promo { background: #F5F3FF; } .b-promo .balance-label, .b-promo .small { color: #5B21B6; }
.b-held { background: #FFFBEB; } .b-held .balance-label, .b-held .small { color: #92400E; }
.b-topup { background: #F4F4F5; } .b-topup .balance-label, .b-topup .small { color: var(--muted); }
.segmented { display: flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: 9px; background: #F1F2F4; }
.segmented button { min-height: 30px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent; color: var(--faint); font-size: 13px; font-weight: 500; cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(16, 24, 40, .1); }
.hold-chip { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 10px; background: #FFFBEB; font-size: 14px; }
.lot-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; font-size: 14px; border-top: 1px solid var(--hair); }
.violet { color: #6D28D9; }
.timeline { list-style: none; margin: 0 0 0 4px; padding: 0; border-left: 2px solid var(--hair); }
.timeline li { position: relative; padding: 0 0 16px 16px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline .tdot { position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 0 3px #FFFFFF; }
.load-more { display: flex; justify-content: center; }
.sections.tight { gap: 20px; }
.identity { gap: 14px; min-width: 0; }
.min-0 { min-width: 0; }
.cell-flex.wrap { flex-wrap: wrap; gap: 8px; }
.dot-total { background: #34D399; } .dot-cash { background: #10B981; } .dot-promo { background: #8B5CF6; } .dot-held { background: #F59E0B; }
.strong { font-weight: 500; }
.empty-line { padding: 16px 0; }
.amber-text { color: #B45309; }
.spaced { margin-bottom: 6px; }
.self-start { align-self: flex-start; }
.small-14 { font-size: 13px; }
.small-13 { font-size: 13px; }
.dialog-problem:empty { display: none; }
.dialog-title { font-size: 17px; }

/* ---------- Dialog ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .38); display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 10; }
.dialog { width: 100%; max-width: 460px; background: var(--card); border-radius: 16px; box-shadow: 0 24px 48px -12px rgba(15, 23, 42, .25); padding: 24px; display: flex; flex-direction: column; gap: 18px; }
.dialog-head { display: flex; gap: 14px; align-items: flex-start; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.counter { font-size: 12px; color: var(--faint); text-align: right; }

/* ---------- Access ---------- */
.matrix th { text-align: center; padding: 14px 8px; }
.matrix th:first-child { text-align: left; padding: 14px 20px; width: 40%; }
.matrix td { text-align: center; padding: 12px 8px; }
.matrix tbody th { font-weight: 400; font-size: 14px; color: var(--text); text-align: left; padding: 12px 20px; }
.matrix-head { display: inline-flex; flex-direction: column; align-items: center; gap: 3px; }
.add-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.add-form .field { flex: 1 1 260px; }
.token-dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.token-dl dt { color: var(--faint); }
.token-dl dd { margin: 0; }
.add-form .select { min-height: 38px; border-radius: 9px; }
.block { display: block; }
.check { display: inline-flex; width: 20px; height: 20px; border-radius: 50%; background: #DCFCE7; color: var(--accent); align-items: center; justify-content: center; }
.nocheck { display: inline-flex; color: #D4D4D8; }
.change-row { display: flex; flex-direction: column; gap: 2px; padding: 10px 0; border-top: 1px solid var(--hair); }

/* ---------- Sign-in ---------- */
.login {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 20px;
  background: var(--bg) radial-gradient(#DFE2E7 1px, transparent 1px); background-size: 22px 22px;
}
.login-card {
  width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 24px; padding: 32px; background: var(--card);
  border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 12px 32px -12px rgba(16, 24, 40, .14);
}
.login-title { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.login-form { display: flex; flex-direction: column; gap: 14px; padding-top: 20px; border-top: 1px solid var(--hair); }
.login-form label { font-size: 13px; font-weight: 500; }
.login-form .field { width: 100%; min-height: 40px; font-size: 14px; }
.login-foot { margin-top: 20px; font-size: 12px; color: var(--faint); text-align: center; }
.btn-google { gap: 10px; box-shadow: 0 1px 2px rgba(4, 120, 87, .3); }
.btn-pair { display: flex; gap: 8px; }
.btn-pair .btn { flex: 1; min-height: 40px; }
