/* ============================================================
   Delforth ERP — modern desktop-app UI
   All class names preserved; visual layer refreshed.
   ============================================================ */
:root {
  --bg: #eef1f6;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --surface-3: #f7f8fb;
  --ink: #172033;
  --muted: #6b7488;
  --line: #e4e8f0;
  --line-soft: #eef1f6;
  --accent: #2f5fe0;
  --accent-2: #1e40af;
  --accent-ink: #ffffff;
  --accent-soft: #eaf0ff;
  --good: #16915b;
  --bad: #d13b30;
  --warn: #c07a12;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(23,32,51,.05);
  --shadow: 0 1px 3px rgba(23,32,51,.06), 0 10px 28px rgba(23,32,51,.06);
  --shadow-lg: 0 12px 40px rgba(23,32,51,.16);
  --sidebar-w: 244px;
  --v-payment: #d13b30;
  --v-receipt: #16915b;
  --v-contra: #0d8290;
  --v-journal: #6d4fc2;
  --v-sales: #2f5fe0;
  --v-purchase: #c07a12;
}

[data-theme="dark"] {
  --bg: #0d1119;
  --surface: #151b26;
  --surface-2: #1c2431;
  --surface-3: #11161f;
  --ink: #e6eaf2;
  --muted: #8a93a7;
  --line: #26303f;
  --line-soft: #1c2431;
  --accent: #6ea0ff;
  --accent-2: #4d7fe6;
  --accent-ink: #0d1119;
  --accent-soft: #1a2740;
  --good: #4cc38a;
  --bad: #ff7a70;
  --warn: #f0a94b;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px rgba(0,0,0,.4);
  --shadow-lg: 0 16px 48px rgba(0,0,0,.55);
  --v-payment: #ff7a70;
  --v-receipt: #4cc38a;
  --v-contra: #52c5d6;
  --v-journal: #b39dff;
  --v-sales: #6ea0ff;
  --v-purchase: #f0a94b;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
kbd {
  font-family: inherit; font-size: 11px; border: 1px solid var(--line);
  border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; background: var(--surface-2); color: var(--muted);
}
a { color: inherit; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--muted) 35%, transparent); border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--muted) 55%, transparent); background-clip: content-box; }

.shell { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w); flex: 0 0 auto; background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 16px 16px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 18px;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 40%, transparent);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text strong { font-size: 15.5px; letter-spacing: .2px; font-weight: 700; }
.brand-text span { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav { padding: 6px 10px 14px; display: flex; flex-direction: column; gap: 1px; overflow-y: auto; flex: 1; }
.nav-label { font-size: 10px; text-transform: uppercase; letter-spacing: .13em; color: var(--muted); padding: 14px 10px 5px; font-weight: 600; }
.nav a {
  position: relative;
  display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 10px;
  text-decoration: none; color: var(--ink); font-size: 13.5px; font-weight: 500;
  transition: background .12s ease, color .12s ease;
}
.nav a .ic { width: 20px; text-align: center; color: var(--muted); font-size: 15px; transition: color .12s ease; }
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--accent-soft); color: var(--accent-2); font-weight: 600; }
[data-theme="dark"] .nav a.active { color: var(--accent); }
.nav a.active .ic { color: var(--accent-2); }
[data-theme="dark"] .nav a.active .ic { color: var(--accent); }
.nav a.active::before {
  content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--accent);
}

.sidebar-foot { margin-top: auto; padding: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.hint { font-size: 11.5px; color: var(--muted); }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 13px 24px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.crumb { font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
#branchSel { max-width: 190px; margin-left: auto; }
.searchbox {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
  border-radius: 10px; padding: 8px 12px; font-size: 13px; cursor: pointer; min-width: 230px; justify-content: space-between;
  transition: border-color .12s ease, background .12s ease;
}
.searchbox:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.view { padding: 24px; max-width: 1200px; width: 100%; margin: 0 auto; }

/* ---------- Cards, grids ---------- */
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 18px;
  transition: box-shadow .15s ease, border-color .15s ease;
}
.kpi { position: relative; overflow: hidden; }
.kpi:hover { box-shadow: var(--shadow); }
.kpi .kpi-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi .kpi-value { font-size: 24px; font-weight: 750; margin-top: 5px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi .kpi-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.kpi-value.good { color: var(--good); }
.kpi-value.bad { color: var(--bad); }

.two-col { grid-template-columns: 1fr 1fr; }

h2.section { font-size: 16px; margin: 22px 0 10px; }
.card h3 { margin: 0 0 12px; font-size: 14.5px; font-weight: 700; letter-spacing: -.01em; }

hr { border: none; border-top: 1px solid var(--line); margin: 14px 0; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line-soft); }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; background: var(--surface); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.bad { color: var(--bad); }
tr.total td { font-weight: 750; border-top: 2px solid color-mix(in srgb, var(--ink) 30%, transparent); border-bottom: none; }
tbody tr { transition: background .1s ease; }
tbody tr:hover { background: var(--surface-3); }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--accent-soft); }
.empty { color: var(--muted); padding: 22px; text-align: center; }

/* voucher / status chip */
.chip {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700;
  letter-spacing: .02em; color: #fff; background: var(--muted); line-height: 1.4;
}
.chip.Payment { background: var(--v-payment); }
.chip.Receipt { background: var(--v-receipt); }
.chip.Contra { background: var(--v-contra); }
.chip.Journal { background: var(--v-journal); }
.chip.Sales { background: var(--v-sales); }
.chip.Purchase { background: var(--v-purchase); }
[data-theme="dark"] .chip { color: #0f141d; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 11px; outline: none; width: 100%;
  transition: border-color .12s ease, box-shadow .12s ease;
}
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--accent) 20%, transparent); }
input.num { text-align: right; font-variant-numeric: tabular-nums; }
select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%236b7488' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }

.btn {
  font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); border-radius: var(--radius-sm); padding: 9px 15px; cursor: pointer;
  transition: background .12s ease, border-color .12s ease, transform .05s ease, box-shadow .12s ease;
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, var(--line)); }
.btn.danger:hover { background: color-mix(in srgb, var(--bad) 12%, var(--surface)); border-color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 11px; font-size: 12.5px; border-radius: 8px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

/* voucher type picker */
.vtype-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.vtype-picker button {
  font: inherit; font-weight: 600; padding: 8px 16px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer;
  transition: all .12s ease;
}
.vtype-picker button:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); color: var(--ink); }
.vtype-picker button.sel { color: #fff; border-color: transparent; box-shadow: 0 2px 8px color-mix(in srgb, var(--ink) 12%, transparent); }
[data-theme="dark"] .vtype-picker button.sel { color: #0f141d; }
.vtype-picker button.sel.Payment { background: var(--v-payment); }
.vtype-picker button.sel.Receipt { background: var(--v-receipt); }
.vtype-picker button.sel.Contra { background: var(--v-contra); }
.vtype-picker button.sel.Journal { background: var(--v-journal); }
.vtype-picker button.sel.Sales { background: var(--v-sales); }
.vtype-picker button.sel.Purchase { background: var(--v-purchase); }
.vtype-picker button[disabled] { opacity: .5; cursor: not-allowed; }

.balance-bar {
  font-variant-numeric: tabular-nums; font-size: 13.5px; color: var(--muted);
  background: var(--surface-3); border: 1px solid var(--line-soft); border-radius: 999px; padding: 7px 15px;
}
.balance-bar .ok { color: var(--good); font-weight: 700; }
.balance-bar .off { color: var(--bad); font-weight: 700; }

/* ---------- Command palette ---------- */
.palette-backdrop {
  position: fixed; inset: 0; background: rgba(10, 15, 25, .48); backdrop-filter: blur(3px); display: flex;
  justify-content: center; align-items: flex-start; padding-top: 12vh; z-index: 90;
}
.palette { width: min(580px, 92vw); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; }
.palette input { border: none; border-bottom: 1px solid var(--line); border-radius: 0; padding: 15px 18px; font-size: 15px; }
.palette input:focus { box-shadow: none; }
.palette-results, .palette-list { max-height: 48vh; overflow-y: auto; padding: 6px; }
.palette-results .pr-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); padding: 10px 12px 2px; }
.palette-results a, .palette-list a { display: flex; gap: 10px; align-items: center; padding: 10px 12px; text-decoration: none; font-size: 13.5px; color: var(--ink); border-radius: 9px; }
.palette-results a:hover, .palette-results a.hover, .palette-list a:hover, .palette-list a.active { background: var(--accent-soft); color: var(--accent-2); }
[data-theme="dark"] .palette-results a:hover, [data-theme="dark"] .palette-list a:hover { color: var(--accent); }
.palette-results .muted { color: var(--muted); font-size: 12px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 11px 20px; border-radius: 999px;
  font-size: 13.5px; font-weight: 500; z-index: 95; box-shadow: var(--shadow-lg);
  animation: toast-in .2s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
.toast.err, .toast.error { background: var(--bad); color: #fff; }
.hidden { display: none !important; }

/* ---------- Mobile ---------- */
.only-mobile { display: none; }
#menuBtn { font-size: 18px; padding: 6px 11px; }
.scrim { display: none; }

@media (max-width: 860px) {
  :root { --sidebar-w: 260px; }
  .sidebar {
    position: fixed; z-index: 80; left: calc(-1 * var(--sidebar-w) - 10px); top: 0;
    transition: left .22s cubic-bezier(.4,0,.2,1); box-shadow: var(--shadow-lg);
  }
  .sidebar.open { left: 0; }
  .scrim.show { display: block; position: fixed; inset: 0; background: rgba(10,15,25,.4); z-index: 70; }
  .only-mobile { display: inline-flex; }
  .searchbox { min-width: 0; padding: 8px 11px; }
  .searchbox span { display: none; }
  .crumb { font-size: 15px; }
  #branchSel { max-width: 140px; }
  .view { padding: 16px; }
  .card { padding: 15px; }
}

@media (max-width: 620px) {
  .two-col { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .topbar { padding: 11px 16px; gap: 10px; }
  .kpi .kpi-value { font-size: 21px; }
  .card > table, .view > table { display: block; overflow-x: auto; white-space: nowrap; }
  .btn { padding: 8px 13px; }
}

@media (min-width: 861px) {
  .two-col { grid-template-columns: 1fr 1fr; }
}

@media print {
  .sidebar, .topbar, .no-print, .scrim { display: none !important; }
  .view { max-width: none; padding: 0; }
  .card { box-shadow: none; border: none; padding: 0; }
  body { background: #fff; }
}

/* ============================================================
   Top navigation bar (replaces sidebar layout)
   ============================================================ */
.appbar {
  background: #1e2b45;
  color: #e8ecf5;
  position: sticky; top: 0; z-index: 40;
  box-shadow: 0 2px 10px rgba(0,0,0,.14);
}
[data-theme="dark"] .appbar { background: #10151f; border-bottom: 1px solid var(--line); }
.appbar-inner {
  display: flex; align-items: center; gap: 6px;
  max-width: 1500px; margin: 0 auto; padding: 0 18px; height: 56px;
}
.app-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #fff; margin-right: 8px; }
.app-brand .brand-mark {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, #4f7dff, #2f5fe0); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 16px;
}
.app-brand-name { font-weight: 700; font-size: 15.5px; white-space: nowrap; max-width: 190px; overflow: hidden; text-overflow: ellipsis; }

.topnav { display: flex; align-items: center; gap: 2px; flex: 1 1 auto; min-width: 0; overflow: visible; }
.topnav-item { position: relative; flex: 0 0 auto; }
.topnav-link {
  font: inherit; font-size: 13.5px; font-weight: 500;
  color: #b9c3d9; background: transparent; border: none; cursor: pointer;
  padding: 8px 12px; border-radius: 8px; text-decoration: none;
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  transition: background .12s ease, color .12s ease;
}
.topnav-link:hover { color: #fff; background: rgba(255,255,255,.08); }
.topnav-link.active { color: #fff; background: rgba(79,125,255,.32); font-weight: 600; }
.topnav-link .caret { font-size: 9px; opacity: .8; }

.dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; min-width: 210px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-lg); padding: 6px; z-index: 60;
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: opacity .14s ease, transform .14s ease, visibility .14s;
}
.topnav-item:hover .dropdown, .topnav-item.open .dropdown { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown a {
  display: block; padding: 9px 12px; border-radius: 8px; text-decoration: none;
  color: var(--ink); font-size: 13.5px; font-weight: 500; white-space: nowrap;
}
.dropdown a:hover { background: var(--accent-soft); color: var(--accent-2); }
.dropdown a.active { background: var(--accent-soft); color: var(--accent-2); font-weight: 600; }
[data-theme="dark"] .dropdown a:hover, [data-theme="dark"] .dropdown a.active { color: var(--accent); }

.appbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; flex: 0 0 auto; }
.branch-select {
  appearance: none; -webkit-appearance: none;
  color: #fff; border: 1px solid rgba(255,255,255,.18);
  border-radius: 9px; padding: 7px 30px 7px 11px; font-size: 13px; max-width: 170px; cursor: pointer;
  background-color: rgba(255,255,255,.1);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%23ffffff' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 12px 12px;
}
.branch-select option { color: var(--ink); background: var(--surface); }
.branch-select:focus { box-shadow: 0 0 0 3px rgba(79,125,255,.35); border-color: rgba(255,255,255,.4); }
.iconbtn {
  background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.16);
  border-radius: 9px; width: 36px; height: 36px; cursor: pointer; font-size: 15px;
  display: inline-grid; place-items: center; transition: background .12s ease;
}
.iconbtn:hover { background: rgba(255,255,255,.2); }

/* main content area under top bar */
.main-top { max-width: 1500px; margin: 0 auto; width: 100%; }
.page-head { padding: 20px 24px 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-title { font-size: 22px; font-weight: 750; letter-spacing: -.02em; margin: 0; }
.main-top .view { padding: 16px 24px 28px; max-width: none; }

/* mobile: collapse the topnav into a drawer */
.menu-toggle { display: none; background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.16); border-radius: 9px; width: 38px; height: 38px; font-size: 18px; cursor: pointer; }

@media (max-width: 1280px) {
  .app-brand-name { max-width: 130px; }
  .topnav-link { padding: 8px 9px; font-size: 13px; }
}
@media (max-width: 1200px) {
  .menu-toggle { display: inline-grid; place-items: center; }
  .topnav {
    position: fixed; top: 56px; left: -320px; width: 300px; height: calc(100vh - 56px);
    flex-direction: column; align-items: stretch; gap: 2px;
    background: #1e2b45; padding: 12px; overflow-y: auto; z-index: 70;
    transition: left .22s cubic-bezier(.4,0,.2,1); box-shadow: var(--shadow-lg);
  }
  [data-theme="dark"] .topnav { background: #10151f; }
  .topnav.open { left: 0; }
  .topnav-item { width: 100%; }
  .topnav-link { width: 100%; justify-content: space-between; }
  .topnav-item .dropdown {
    position: static; opacity: 1; visibility: visible; transform: none;
    box-shadow: none; border: none; background: rgba(255,255,255,.05); margin: 2px 0 6px 8px; display: none;
  }
  .topnav-item.open .dropdown { display: block; }
  .dropdown a { color: #cdd6ea; }
  .dropdown a:hover, .dropdown a.active { background: rgba(79,125,255,.25); color: #fff; }
  .app-brand-name { max-width: 120px; }
  .scrim.show { display: block; position: fixed; inset: 0; top: 56px; background: rgba(10,15,25,.45); z-index: 60; }
  .page-head, .main-top .view { padding-left: 16px; padding-right: 16px; }
}
@media (max-width: 560px) {
  .appbar-inner { padding: 0 12px; gap: 4px; }
  .branch-select { max-width: 120px; font-size: 12px; }
  .page-title { font-size: 19px; }
}

@media print {
  .appbar, .scrim { display: none !important; }
  .main-top .view { padding: 0; }
  .page-head { padding: 0 0 10px; }
}

/* ============================================================
   Authentication pages (login / register / reset)
   ============================================================ */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background:
    radial-gradient(1200px 500px at 50% -10%, color-mix(in srgb, var(--accent) 14%, transparent), transparent),
    var(--bg);
}
.auth-card {
  width: min(420px, 94vw); background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; box-shadow: var(--shadow-lg); padding: 30px 28px;
}
.auth-logo { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; }
.auth-logo .brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 20px;
}
.auth-logo .t { font-weight: 800; font-size: 18px; letter-spacing: -.01em; }
.auth-logo .s { font-size: 12px; color: var(--muted); }
.auth-card h2 { margin: 0 0 4px; font-size: 20px; font-weight: 750; letter-spacing: -.02em; }
.auth-card .sub { color: var(--muted); font-size: 13.5px; margin-bottom: 20px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label.field { font-size: 12.5px; }
.auth-form .btn.primary { width: 100%; justify-content: center; padding: 11px; font-size: 14.5px; margin-top: 4px; }
.auth-error {
  background: color-mix(in srgb, var(--bad) 12%, var(--surface)); color: var(--bad);
  border: 1px solid color-mix(in srgb, var(--bad) 30%, transparent);
  border-radius: 10px; padding: 10px 13px; font-size: 13px;
}
.auth-note {
  background: var(--accent-soft); color: var(--accent-2);
  border-radius: 10px; padding: 10px 13px; font-size: 13px; word-break: break-all;
}
[data-theme="dark"] .auth-note { color: var(--accent); }
.auth-links { display: flex; justify-content: space-between; margin-top: 18px; font-size: 13px; flex-wrap: wrap; gap: 8px; }
.auth-links a { color: var(--accent-2); text-decoration: none; font-weight: 500; }
[data-theme="dark"] .auth-links a { color: var(--accent); }
.auth-links a:hover { text-decoration: underline; }
.pw-hint { font-size: 11.5px; color: var(--muted); }

/* ============================================================
   Billing / plans
   ============================================================ */
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-top: 6px; }
.plan-card {
  border: 1px solid var(--line); border-radius: 14px; padding: 18px; text-align: center;
  background: var(--surface-3); transition: border-color .12s ease, box-shadow .12s ease, transform .1s ease;
}
.plan-card:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); box-shadow: var(--shadow); transform: translateY(-2px); }
.plan-name { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.plan-price { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin: 8px 0 2px; }
.plan-per { font-size: 12.5px; color: var(--muted); }
.plan-blurb { font-size: 12.5px; color: var(--muted); margin: 10px 0 14px; min-height: 34px; }
.plan-btn { width: 100%; justify-content: center; }

/* trial banner (in-app top strip) */
.trial-banner {
  background: color-mix(in srgb, var(--warn) 16%, var(--surface));
  border-bottom: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  color: var(--ink); font-size: 13px; padding: 8px 24px; text-align: center;
}
.trial-banner a { color: var(--accent-2); font-weight: 600; text-decoration: none; margin-left: 8px; }
[data-theme="dark"] .trial-banner a { color: var(--accent); }
.trial-banner a:hover { text-decoration: underline; }

/* ---------- financial year select ---------- */
.fy-choice {
  display: flex; align-items: center; justify-content: space-between;
  border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
  text-decoration: none; color: var(--ink); background: var(--surface-3);
  transition: border-color .12s ease, background .12s ease, transform .08s ease;
}
.fy-choice:hover { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); }
.fy-badge {
  background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.18);
  border-radius: 9px; padding: 6px 11px; font-size: 12.5px; text-decoration: none; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; max-width: 130px; overflow: hidden; text-overflow: ellipsis;
}
.fy-badge:hover { background: rgba(255,255,255,.2); }

/* ---------- New Bill button (top bar) ---------- */
.btn-newbill {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--accent); color: #fff; text-decoration: none;
  border-radius: 9px; padding: 8px 14px; font-size: 13px; font-weight: 600;
  white-space: nowrap; flex: 0 0 auto; border: 1px solid var(--accent);
  transition: filter .12s ease, transform .08s ease;
}
.btn-newbill:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-newbill:active { transform: translateY(0); }

/* ---------- report helpers ---------- */
.dropdown-head {
  padding: 8px 12px 4px; font-size: 11px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  border-top: 1px solid var(--line); margin-top: 4px;
}
.dropdown-head:first-child { border-top: none; margin-top: 0; }
.only-print { display: none; }
tr.warn > td { background: rgba(240, 170, 40, .12); }
@media print {
  .only-print { display: block; margin: 0 0 10px; }
}

/* ---------- chart sizing ----------
   SVG charts use a viewBox, so "height:auto" makes them grow with the container
   width (huge on wide screens). These boxes pin the height instead. */
.chart-box {
  width: 100%; height: 300px;
  overflow-x: auto; overflow-y: hidden;
}
.chart-box > svg { display: block; width: 100%; height: 100%; }
/* Horizontal bar lists can be long - let them scroll instead of shrinking. */
.chart-box.tall { height: 420px; overflow-y: auto; }
.chart-box.tall > svg { height: auto; }
@media (max-width: 720px) { .chart-box { height: 240px; } .chart-box.tall { height: 320px; } }
@media print { .chart-box { height: 260px; overflow: visible; } }
