/* Dark design shared with the desktop app (src/loan_app/ui/theme.py): same tokens, flat surfaces. */
:root {
  --bg: #14161b; --surface: #1b1e25; --surface-2: #232731; --surface-3: #2e3340;
  --border: #2a2f3a; --border-strong: #3a4150;
  --text: #d7dbe3; --strong: #f2f4f8; --muted: #8a93a3;
  --accent: #6574e6; --accent-soft: #93a1ff;
  --success: #5fc48d; --warning: #e0b350; --danger: #ef7b7b;
  --principal: #7d8cf0; --interest: #e39b4a;
  --radius: 10px; --radius-sm: 6px;
  --nav-h: 60px; --side-w: 220px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif; font-size: 15px;
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; }
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.hidden { display: none !important; }

/* layout: bottom navigation on phones, side navigation on wide screens */
.app { min-height: 100%; }
.main { padding: 0 16px calc(var(--nav-h) + var(--safe-b) + 24px); max-width: 960px; margin: 0 auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 0 10px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo { width: 28px; height: 28px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, var(--accent), #7b5be1); }
.brand-logo.big { width: 48px; height: 48px; border-radius: 12px; margin: 0 auto 14px; }
.brand-title { color: var(--strong); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-profile { color: var(--muted); font-size: 12.5px; padding: 2px 10px; border-radius: 999px;
  border: 1px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 50%; }
.brand-profile:empty { display: none; }
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: space-around;
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--surface); border-top: 1px solid var(--border); }
.nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  background: none; border: 0; color: var(--muted); font-size: 11.5px; cursor: pointer; padding: 6px 0; }
.nav-item svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }
.nav-item.active { color: var(--accent-soft); font-weight: 600; }
.nav-item:disabled { opacity: .45; }
@media (min-width: 900px) {
  .nav { top: 0; right: auto; width: var(--side-w); height: auto; flex-direction: column; justify-content: flex-start;
    gap: 2px; padding: 72px 10px 10px; border-top: 0; border-right: 1px solid var(--border); }
  .nav-item { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 9px 12px;
    border-radius: var(--radius-sm); font-size: 14px; }
  .nav-item.active { background: var(--surface-2); color: var(--strong); }
  .main { margin-left: var(--side-w); padding: 0 32px 40px; max-width: calc(960px + var(--side-w)); }
}

.view { display: flex; flex-direction: column; gap: 16px; }
.page-title { color: var(--strong); font-size: 22px; font-weight: 650; letter-spacing: -.015em; margin: 4px 0 0; }
.section-title { color: var(--strong); font-size: 15px; font-weight: 600; margin: 0 0 8px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card p { margin: 0 0 10px; line-height: 1.45; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.kpi-label { color: var(--muted); font-size: 12px; font-weight: 500; }
.kpi-value { color: var(--strong); font-size: 19px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi-sub { color: var(--muted); font-size: 11.5px; margin-top: 3px; line-height: 1.35; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: var(--surface-2); color: var(--accent-soft); border: 1px solid var(--border); }
.pill.ok { color: var(--success); }

/* forms */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { color: var(--muted); font-size: 12.5px; }
.field input, .field select { height: 46px; padding: 0 12px; border-radius: var(--radius-sm);
  background: var(--bg); border: 1px solid var(--border-strong); color: var(--strong); outline: none; width: 100%; }
.field input.amount { text-align: right; font-variant-numeric: tabular-nums; }
.field input:focus, .field select:focus { border-color: var(--accent); }
.field input:disabled { color: var(--muted); }
.field .hint { color: var(--muted); font-size: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; align-items: center; }
.btn { height: 44px; padding: 0 18px; border-radius: var(--radius-sm); border: 0; cursor: pointer; font-weight: 600;
  background: transparent; color: var(--accent-soft); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary.wide { width: 100%; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.btn:focus-visible, .nav-item:focus-visible, .icon-btn:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 2px; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; color: #757575;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none; }
.icon-btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.icon-btn.on { color: var(--warning); }
.icon-btn.on svg { fill: currentColor; }
.notice { border-left: 3px solid var(--accent); padding: 8px 12px; background: var(--surface-2); border-radius: 4px;
  font-size: 13.5px; line-height: 1.45; }
.notice.warn { border-left-color: var(--warning); }

/* lists */
.list { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--border); }
.row:first-child { border-top: 0; }
.row-main { flex: 1; min-width: 0; }
.row-title { color: var(--strong); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.row-sub { color: var(--muted); font-size: 12.5px; }
.details { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 4px 0 10px; font-size: 13.5px; }
.details .v { text-align: right; color: var(--strong); font-variant-numeric: tabular-nums; }

/* chart */
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .s0 { stroke: var(--principal); stroke-width: 2.4; fill: none; }
.chart .s1 { stroke: var(--muted); stroke-width: 1.6; fill: none; stroke-dasharray: 5 4; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.legend .l0 { background: var(--principal); }
.legend .l1 { background: var(--muted); }

/* loading, toast, dialog */
.loading { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 16px; }
.loading-card { width: 100%; max-width: 360px; text-align: center; }
.loading-title { color: var(--strong); font-weight: 600; margin-bottom: 14px; }
.progress { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-bottom: 10px; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .25s; }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(var(--nav-h) + var(--safe-b) + 12px); z-index: 60;
  margin: 0 auto; max-width: 480px; background: var(--surface-3); color: var(--strong); border-radius: var(--radius-sm);
  padding: 12px 14px; font-size: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.45); opacity: 0; pointer-events: none;
  transform: translateY(8px); transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: none; }
.toast.error { border-left: 3px solid var(--danger); }
.dialog { width: calc(100% - 32px); max-width: 420px; background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 18px; }
.dialog::backdrop { background: rgba(0,0,0,.6); }
.dialog h2 { color: var(--strong); font-size: 17px; margin: 0 0 10px; }
.dialog p { margin: 0 0 12px; line-height: 1.45; }
.error-text { color: var(--danger); font-size: 13px; min-height: 1em; margin: 0 0 8px; }
.update-bar { position: fixed; left: 16px; right: 16px; top: calc(env(safe-area-inset-top, 0px) + 8px); z-index: 40;
  margin: 0 auto; max-width: 520px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 8px 8px 8px 14px; }
