:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --ink: #16233a;
  --ink-soft: #5b6b85;
  --line: #e4e9f2;
  --primary: #1f6feb;
  --primary-dark: #1552b8;
  --primary-soft: #e8f0fe;
  --teal: #0ea5a5;
  --green: #14a06a;
  --amber: #d98a0b;
  --red: #d64545;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(20,35,58,.06), 0 8px 24px rgba(20,35,58,.06);
  --shadow-lg: 0 12px 40px rgba(20,35,58,.14);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--ink); line-height: 1.5; -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }

/* Topbar */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 28px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 40px; height: 40px; border-radius: 11px; background: linear-gradient(135deg, var(--primary), var(--teal)); color: #fff; display: grid; place-items: center; font-weight: 800; letter-spacing: .5px; }
.logo-img { height: 34px; width: auto; display: block; }
.brand-name { font-weight: 700; font-size: 16px; }
.brand-sub { font-size: 12px; color: var(--ink-soft); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.lang-toggle { display: flex; background: var(--bg); border-radius: 9px; padding: 3px; }
.lang-toggle button { border: 0; background: transparent; padding: 5px 12px; border-radius: 7px; font-weight: 600; font-size: 13px; color: var(--ink-soft); cursor: pointer; }
.lang-toggle button.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }

/* Buttons */
.btn { border: 1px solid transparent; border-radius: 10px; padding: 10px 18px; font-family: inherit; font-weight: 600; font-size: 14px; cursor: pointer; transition: .15s; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { background: var(--bg); }
.btn.big { padding: 15px 34px; font-size: 16px; border-radius: 12px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

/* Welcome */
.welcome { min-height: calc(100vh - 69px); display: grid; place-items: center; padding: 40px 20px; }
.welcome-inner { max-width: 900px; text-align: center; }
.welcome h1 { font-size: 44px; font-weight: 800; letter-spacing: -1px; background: linear-gradient(135deg, var(--primary), var(--teal)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { font-size: 20px; color: var(--ink-soft); margin: 12px 0 6px; }
.welcome-note { color: var(--ink-soft); font-size: 14px; margin-bottom: 30px; }
.template-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 24px 0 30px; }
.template-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 18px; cursor: pointer; transition: .18s; text-align: left; }
.template-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--primary); }
.template-card .ico { font-size: 30px; }
.template-card .tname { font-weight: 700; margin-top: 10px; }
.template-card .tdesc { font-size: 13px; color: var(--ink-soft); margin-top: 3px; }

/* Wizard */
.wizard { max-width: 1200px; margin: 0 auto; padding: 24px; }
.stepper { display: flex; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px; margin-bottom: 20px; overflow-x: auto; }
.step-tab { flex: 1; display: flex; align-items: center; gap: 9px; padding: 11px 14px; border-radius: 9px; cursor: pointer; white-space: nowrap; color: var(--ink-soft); font-weight: 600; font-size: 14px; }
.step-tab .num { width: 24px; height: 24px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; font-size: 13px; }
.step-tab.active { background: var(--primary-soft); color: var(--primary); }
.step-tab.active .num { background: var(--primary); color: #fff; }
.step-tab.done .num { background: var(--green); color: #fff; }

.wizard-body { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.step-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); min-height: 420px; }
.step-panel h2 { font-size: 22px; margin-bottom: 4px; }
.step-panel .sub { color: var(--ink-soft); margin-bottom: 22px; font-size: 14px; }

/* Live panel */
.live-panel { position: sticky; top: 90px; display: flex; flex-direction: column; gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi .label { font-size: 12px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .4px; font-weight: 600; }
.kpi .value { font-size: 24px; font-weight: 800; margin-top: 4px; }
.kpi .value.pos { color: var(--green); }
.kpi .value.neg { color: var(--red); }
.kpi .sub { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.gauge { height: 8px; background: var(--bg); border-radius: 5px; overflow: hidden; margin-top: 10px; }
.gauge > span { display: block; height: 100%; border-radius: 5px; transition: .4s; }

/* Forms */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.field input, .field select { width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; font-family: inherit; font-size: 15px; color: var(--ink); background: var(--surface); transition: .15s; }
.field input:focus, .field select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.inline-fetch { display: flex; gap: 8px; align-items: flex-end; }
.inline-fetch .field { flex: 1; margin-bottom: 0; }

/* Category / line rows */
.cat-row { display: grid; grid-template-columns: 1fr 160px; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cat-row .cname { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.cat-row .cname .ico { font-size: 18px; }
.amount-input { position: relative; }
.section-label { font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--primary); margin: 18px 0 6px; }
.mode-toggle { display: inline-flex; background: var(--bg); border-radius: 9px; padding: 3px; margin-bottom: 16px; }
.mode-toggle button { border: 0; background: transparent; padding: 7px 16px; border-radius: 7px; font-weight: 600; font-size: 13px; color: var(--ink-soft); cursor: pointer; }
.mode-toggle button.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }

.line-item { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 12px; background: #fbfcfe; }
.line-item .row { display: grid; gap: 10px; }
.line-item .del { justify-self: end; background: none; border: 0; color: var(--red); cursor: pointer; font-size: 13px; font-weight: 600; }
.add-btn { background: var(--primary-soft); color: var(--primary); border: 1px dashed var(--primary); border-radius: 10px; padding: 12px; width: 100%; font-weight: 600; cursor: pointer; }

/* Alerts */
.alert { border-radius: 10px; padding: 12px 14px; font-size: 13px; margin-top: 12px; display: flex; gap: 10px; }
.alert.warn { background: #fff7e8; color: var(--amber); border: 1px solid #f5d998; }
.alert.ok { background: #e9f8f0; color: var(--green); border: 1px solid #a8e0c4; }
.alert.info { background: var(--primary-soft); color: var(--primary-dark); border: 1px solid #bcd6fb; }

/* Results */
.results-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stmt { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 18px; box-shadow: var(--shadow); }
.stmt h3 { font-size: 17px; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
table.fin { width: 100%; border-collapse: collapse; font-size: 14px; }
table.fin th, table.fin td { padding: 8px 10px; text-align: right; }
table.fin th:first-child, table.fin td:first-child { text-align: left; }
table.fin thead th { border-bottom: 2px solid var(--line); color: var(--ink-soft); font-size: 12px; text-transform: uppercase; }
table.fin tbody tr:hover { background: var(--bg); }
table.fin tr.subtotal td { font-weight: 700; border-top: 1px solid var(--line); }
table.fin tr.grand td { font-weight: 800; border-top: 2px solid var(--ink); font-size: 15px; }
table.fin tr.neg td { color: var(--red); }
.bank-score { display: flex; align-items: center; gap: 20px; }
.score-ring { width: 96px; height: 96px; flex: none; }
.bars { display: flex; align-items: flex-end; gap: 8px; height: 120px; padding-top: 10px; }
.bars .bar { flex: 1; background: linear-gradient(180deg, var(--primary), var(--teal)); border-radius: 6px 6px 0 0; position: relative; min-height: 2px; }
.bars .bar span { position: absolute; top: -18px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--ink-soft); font-weight: 600; }
.bars .bar small { position: absolute; bottom: -20px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--ink-soft); }

/* Toast + modal */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px); background: var(--ink); color: #fff; padding: 12px 22px; border-radius: 10px; font-weight: 600; font-size: 14px; opacity: 0; transition: .3s; z-index: 60; }
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.modal { position: fixed; inset: 0; background: rgba(20,35,58,.5); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal-card { background: var(--surface); border-radius: var(--radius); padding: 24px; max-width: 520px; width: 100%; max-height: 80vh; overflow: auto; box-shadow: var(--shadow-lg); }
.plan-item { display: flex; justify-content: space-between; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; cursor: pointer; }
.plan-item:hover { border-color: var(--primary); background: var(--bg); }

@media (max-width: 920px) {
  .wizard-body { grid-template-columns: 1fr; }
  .live-panel { position: static; flex-direction: row; flex-wrap: wrap; }
  .live-panel .kpi { flex: 1; min-width: 140px; }
  .template-grid, .results-grid { grid-template-columns: 1fr 1fr; }
  .grid3 { grid-template-columns: 1fr; }
}
