/* Amarillo — design tokens: tema scuro (Linear) e tema chiaro (Stripe)
   Fonti: Inter (dark) / Source Sans 3 (light) da Google Fonts */

:root {
  --radius-card: 8px;
  --radius-btn: 6px;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---- Tema scuro — Linear ---- */
:root[data-theme="dark"] {
  --bg: #08090a;
  --bg-panel: #0f1011;
  --bg-card: rgba(255, 255, 255, 0.02);
  --bg-card-hover: rgba(255, 255, 255, 0.045);
  --bg-elevated: #191a1b;
  --bg-input: rgba(255, 255, 255, 0.02);
  --text: #f7f8f8;
  --text-secondary: #d0d6e0;
  --text-muted: #8a8f98;
  --text-faint: #62666d;
  --accent: #7170ff;
  --accent-bg: #5e6ad2;
  --border: rgba(255, 255, 255, 0.08);
  --border-subtle: rgba(255, 255, 255, 0.05);
  --green: #10b981;
  --green-text: #34d399;
  --blue: #38bdf8;
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.12);
  --shadow-card: 0 0 0 1px rgba(0,0,0,0.2);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --weight-ui: 500;
  --font-feature: 'cv01', 'ss03';
}

/* ---- Tema chiaro — Stripe ---- */
:root[data-theme="light"] {
  --bg: #ffffff;
  --bg-panel: #f7f8fa;
  --bg-card: #ffffff;
  --bg-card-hover: #f7f8fa;
  --bg-elevated: #ffffff;
  --bg-input: #ffffff;
  --text: #061b31;
  --text-secondary: #273951;
  --text-muted: #64748d;
  --text-faint: #94a3b8;
  --accent: #533afd;
  --accent-bg: #533afd;
  --border: #e5edf5;
  --border-subtle: #f0f4f8;
  --green: #15be53;
  --green-text: #108c3d;
  --blue: #2e6ff2;
  --red: #d92d20;
  --red-soft: rgba(217, 45, 32, 0.08);
  --shadow-card: rgba(50, 50, 93, 0.25) 0px 30px 45px -30px, rgba(0, 0, 0, 0.1) 0px 18px 36px -18px;
  --font: 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --weight-ui: 400;
  --font-feature: 'ss01';
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; }
body {
  margin: 0;
  font-family: var(--font);
  font-feature-settings: var(--font-feature);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
.wrap { max-width: 1100px; margin: 0 auto; padding: 28px 20px 64px; }

/* ---- header ---- */
header { display: flex; align-items: baseline; gap: 12px; margin-bottom: 24px; }
.logo {
  width: 24px; height: 24px; display: inline-block; transform: translateY(4px);
}
h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.4px; margin: 0; }
.subtitle { color: var(--text-muted); font-size: 14px; }
.spacer { flex: 1; }
.theme-toggle {
  font-family: var(--font); font-size: 13px; font-weight: var(--weight-ui);
  color: var(--text-secondary); background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-btn);
  padding: 6px 12px; cursor: pointer;
}
.theme-toggle:hover { background: var(--bg-card-hover); }

/* ---- tabs di navigazione ---- */
.tabs {
  display: flex; gap: 4px; border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.tab {
  font-size: 14px; font-weight: var(--weight-ui);
  color: var(--text-muted); text-decoration: none;
  padding: 8px 14px 9px; border-radius: 6px 6px 0 0;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text-secondary); background: var(--bg-card-hover); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* ---- form / input ---- */
.form-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
input, select {
  font-family: var(--font); font-size: 14px;
  color: var(--text); background: var(--bg-input);
  border: 1px solid var(--border); border-radius: var(--radius-btn);
  padding: 7px 10px; min-width: 0;
}
input::placeholder { color: var(--text-faint); }
input:focus, select:focus { outline: none; border-color: var(--accent); }
.btn-primary {
  font-family: var(--font); font-size: 13px; font-weight: var(--weight-ui);
  color: #fff; background: var(--accent-bg);
  border: none; border-radius: var(--radius-btn); padding: 8px 14px; cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-small {
  font-family: var(--font); font-size: 12px; font-weight: var(--weight-ui);
  color: var(--text-secondary); background: transparent;
  border: 1px solid var(--border); border-radius: var(--radius-btn);
  padding: 4px 10px; cursor: pointer;
}
.btn-small:hover { border-color: var(--accent); color: var(--text); }
.balance-form { display: flex; gap: 6px; margin-top: 10px; }
.balance-form input { flex: 1; min-width: 70px; padding: 5px 8px; font-size: 13px; }
.account .faint { margin-top: 2px; }

/* ---- user / login ---- */
.user-chip { font-size: 13px; color: var(--text-muted); font-weight: var(--weight-ui); }

.login-card { max-width: 420px; margin: 32px auto 0; }
.login-form { display: flex; flex-direction: column; gap: 10px; }
.login-form input { width: 100%; }
.login-form .btn-primary { align-self: stretch; padding: 9px 14px; }
.login-error { color: var(--red); font-size: 13px; margin-top: 10px; }

/* ---- KPI cards ---- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.kpi {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-card); padding: 14px 16px;
}
.kpi .label { font-size: 12px; color: var(--text-muted); font-weight: var(--weight-ui); }
.kpi .value { font-size: 22px; font-weight: 600; letter-spacing: -0.5px; margin-top: 4px;
  font-variant-numeric: tabular-nums; }
.kpi .hint { font-size: 11px; color: var(--text-faint); margin-top: 2px; }
.kpi.neg .value { color: var(--red); }

/* ---- section cards ---- */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-card); margin-bottom: 20px; overflow: hidden;
}
.card-head {
  display: flex; align-items: baseline; gap: 10px;
  padding: 14px 18px 10px;
}
.card-head h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.2px; margin: 0; }
.card-head .meta { font-size: 12px; color: var(--text-muted); }
.card-body { padding: 0 18px 16px; }

/* ---- tables ---- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-size: 12px; font-weight: var(--weight-ui);
  color: var(--text-muted); padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
td { padding: 7px 10px; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg-card-hover); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
th.num { text-align: right; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); font-size: 12px; }

/* colori tipo (convenzione proprietario): introito verde, giroconto azzurro */
.t-income, .t-income .num { color: var(--green-text); }
.t-transfer, .t-transfer .num { color: var(--blue); }
tr.neg-balance td.saldo { color: var(--red); }
.badge {
  display: inline-block; font-size: 11px; font-weight: var(--weight-ui);
  padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border);
  color: var(--text-secondary); white-space: nowrap;
}
.badge.paid { color: var(--green-text); border-color: var(--green); }
.badge.due { color: var(--text-muted); }
.badge.est { color: var(--accent); border-color: var(--accent); }

/* ---- chart ---- */
.chart-box { position: relative; }
.chart-legend { display: flex; gap: 18px; font-size: 12px; color: var(--text-muted); padding: 8px 0 0; }
.chart-legend .swatch { display: inline-block; width: 18px; height: 2px; vertical-align: middle; margin-right: 6px; }
svg .axis { stroke: var(--text-faint); stroke-width: 1; font-size: 10px; fill: var(--text-muted); }
svg .zero { stroke: var(--text-faint); stroke-dasharray: 4 3; }

/* ---- filters ---- */
.filters { display: flex; gap: 8px; padding: 0 18px 12px; flex-wrap: wrap; }
.chip {
  font-family: var(--font); font-size: 13px; font-weight: var(--weight-ui);
  color: var(--text-secondary); background: transparent;
  border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 12px; cursor: pointer;
}
.chip.active { color: var(--text); background: var(--bg-card-hover); border-color: var(--accent); }

/* ---- accounts ---- */
.accounts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.account { border: 1px solid var(--border-subtle); border-radius: 6px; padding: 12px 14px; }
.account .name { font-size: 13px; font-weight: var(--weight-ui); color: var(--text-secondary); }
.account .balance { font-size: 18px; font-weight: 600; letter-spacing: -0.3px; margin-top: 2px;
  font-variant-numeric: tabular-nums; }
.account .iban { font-size: 11px; color: var(--text-faint); font-family: var(--font-mono);
  margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 800px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .card-body, .table-scroll { overflow-x: auto; }
}
