:root {
  --z-navy: #0b1f4a;
  --z-navy-2: #14306b;
  --z-blue: #1e5eff;
  --z-blue-dark: #1449cc;
  --z-blue-soft: #eaf0ff;
  --z-bg: #f3f5fa;
  --z-border: #e2e7f1;
  --z-text: #18223a;
  --z-muted: #67728a;
  --z-green: #15803d;
  --z-red: #dc2626;
  --bs-body-color: var(--z-text);
  --bs-link-color: var(--z-blue);
  --bs-link-hover-color: var(--z-blue-dark);
}

body {
  background: var(--z-bg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---- Navbar ---- */
.app-nav { background: var(--z-navy); }
.app-nav .navbar-brand { font-weight: 700; letter-spacing: .2px; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; margin-right: 10px;
  border-radius: 9px; background: var(--z-blue);
  font-weight: 800; font-size: 1rem; color: #fff;
}
.app-nav .nav-link { color: rgba(255,255,255,.72); border-radius: 8px; padding: .45rem .8rem !important; }
.app-nav .nav-link:hover { color: #fff; }
.app-nav .nav-link.active { color: #fff; background: rgba(255,255,255,.1); }
.nav-icon {
  display: inline-grid; place-items: center; width: 34px; height: 34px;
  border-radius: 8px; color: rgba(255,255,255,.75); text-decoration: none; font-size: 1.1rem;
}
.nav-icon:hover, .nav-icon.active { color: #fff; background: rgba(255,255,255,.1); }

/* ---- Buttons ---- */
.btn-primary {
  --bs-btn-bg: var(--z-blue); --bs-btn-border-color: var(--z-blue);
  --bs-btn-hover-bg: var(--z-blue-dark); --bs-btn-hover-border-color: var(--z-blue-dark);
  --bs-btn-active-bg: #103da8; --bs-btn-active-border-color: #103da8;
  --bs-btn-disabled-bg: var(--z-blue); --bs-btn-disabled-border-color: var(--z-blue);
}
.btn-outline-primary {
  --bs-btn-color: var(--z-blue); --bs-btn-border-color: var(--z-blue);
  --bs-btn-hover-bg: var(--z-blue); --bs-btn-hover-border-color: var(--z-blue);
  --bs-btn-active-bg: var(--z-blue-dark);
}
.form-control:focus, .form-select:focus, .form-check-input:focus {
  border-color: #8aa9ff; box-shadow: 0 0 0 .2rem rgba(30,94,255,.15);
}
.form-check-input:checked { background-color: var(--z-blue); border-color: var(--z-blue); }

/* ---- Layout ---- */
.page-head {
  display: flex; flex-wrap: wrap; gap: .75rem;
  align-items: center; justify-content: space-between; margin-bottom: 1.25rem;
}
.page-head h1 { font-size: 1.45rem; font-weight: 700; margin: 0; }
.page-head .sub { color: var(--z-muted); font-size: .9rem; }

.card { border: 1px solid var(--z-border); border-radius: 14px; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: #fff; border-bottom: 1px solid var(--z-border); font-weight: 600; padding: .9rem 1.1rem; border-radius: 14px 14px 0 0 !important; }
.card-body { padding: 1.1rem; }

/* ---- Stat cards ---- */
.stat-card { height: 100%; }
.stat-card .label { font-size: .76rem; color: var(--z-muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat-card .value { font-size: 1.55rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.25; margin-top: .25rem; }
.stat-card .hint { font-size: .8rem; color: var(--z-muted); margin-top: .2rem; }
.stat-card.highlight { background: var(--z-navy); border-color: var(--z-navy); color: #fff; }
.stat-card.highlight .label, .stat-card.highlight .hint { color: rgba(255,255,255,.7); }
.stat-card.highlight .value.text-profit { color: #4ade80 !important; }
.stat-card.highlight .value.text-loss { color: #fca5a5 !important; }
.stat-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--z-blue-soft); color: var(--z-blue); font-size: 1.1rem; }
.highlight .stat-icon { background: rgba(255,255,255,.12); color: #fff; }

.text-profit { color: var(--z-green) !important; }
.text-loss { color: var(--z-red) !important; }
.chg-up { color: var(--z-green); font-weight: 600; }
.chg-down { color: var(--z-red); font-weight: 600; }
.highlight .chg-up { color: #4ade80; }
.highlight .chg-down { color: #fca5a5; }

/* ---- Tables ---- */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > thead th {
  font-size: .74rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--z-muted); font-weight: 600; background: #f8f9fc; border-bottom-width: 1px; white-space: nowrap;
}
.table td, .table th { padding: .65rem .8rem; vertical-align: middle; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tfoot td, .table tfoot th { font-weight: 700; background: #f8f9fc; }
.table-hover > tbody > tr:hover > * { background: #f6f8ff; }
.row-link { cursor: pointer; }
.cell-main { font-weight: 600; }
.cell-sub { font-size: .8rem; color: var(--z-muted); }
.badge-soft { background: var(--z-blue-soft); color: var(--z-blue); font-weight: 600; }
.actions { white-space: nowrap; text-align: right; }
.actions .btn { padding: .2rem .5rem; }

/* ---- Filter bar ---- */
.filter-bar .form-control, .filter-bar .form-select { min-width: 140px; }

/* ---- Forms ---- */
.form-label { font-weight: 600; font-size: .86rem; margin-bottom: .3rem; }
.form-text { font-size: .78rem; }
.calc-box { position: sticky; top: 1rem; }
.calc-box dl { display: grid; grid-template-columns: 1fr auto; gap: .55rem 1rem; margin: 0; }
.calc-box dt { font-weight: 500; color: var(--z-muted); }
.calc-box dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.calc-box .big dt, .calc-box .big dd { font-size: 1.1rem; color: var(--z-text); font-weight: 700; padding-top: .55rem; border-top: 1px dashed var(--z-border); }

.chart-wrap { position: relative; height: 300px; }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--z-muted); }
.empty-state i { font-size: 2rem; display: block; margin-bottom: .5rem; color: #b4bfd6; }

/* ---- Login / install ---- */
body.bare {
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 10% -10%, #1e5eff33, transparent), var(--z-navy);
}
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; flex-direction: column; }
.auth-wrap .alert { width: 100%; max-width: 420px; }
.auth-card { width: 100%; max-width: 420px; border: 0; border-radius: 18px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.auth-card .card-body { padding: 2rem; }
.auth-brand { display: flex; align-items: center; gap: .7rem; margin-bottom: 1.25rem; }
.auth-brand .brand-mark { margin: 0; width: 40px; height: 40px; font-size: 1.2rem; }

.future-row td { color: #a3acbf; }

@media (max-width: 575.98px) {
  .stat-card .value { font-size: 1.25rem; }
  .stat-card .label { font-size: .7rem; }
  .stat-icon { display: none; }
  .card-body { padding: .9rem; }
  .table td, .table th { padding: .55rem .45rem; font-size: .86rem; }
  .table > thead th { font-size: .68rem; }
  .page-head h1 { font-size: 1.25rem; }
}

@media print {
  .app-nav, .no-print, footer { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
