:root {
  --bg: #F8FAFC;
  --card: #FFFFFF;
  --fg: #0F172A;
  --muted: #64748B;
  --border: #E4E7EB;
  --hover: #F1F5F9;
  --primary: #1E3A5F;
  --primary-fg: #FFFFFF;
  --accent: #2563EB;
  --accent-soft: #DBEAFE;
  --accent-fg: #1D4ED8;
  --danger: #DC2626;
  --danger-soft: #FEE2E2;
  --danger-fg: #B91C1C;
  --success: #059669;
  --success-soft: #D1FAE5;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .15);
  --sidebar-w: 240px;
}

* { box-sizing: border-box; }

/* any display rule outranks the UA sheet's [hidden], so .btn and friends need this */
[hidden] { display: none !important; }

body {
  margin: 0;
  font: 400 14px/1.5 "IBM Plex Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
}

h1 { margin: 0; font-size: 22px; font-weight: 600; }
h2 { margin: 0 0 12px; font-size: 16px; font-weight: 600; }
a { color: var(--accent); }

:is(a, button, input, select, textarea, [tabindex]):focus-visible,
.segmented input:focus-visible + label {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.icon { flex: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.stack { display: grid; gap: 16px; }
.label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  transition: width 200ms ease-out;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 12px;
  background: var(--primary);
  color: var(--primary-fg);
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px 10px 4px;
  color: #fff;
}
.brand .logo { width: 96px; height: 96px; }
.brand-name { font-size: 14px; font-weight: 600; color: #fff; text-align: center; }

.sb-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: flex-end;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: rgba(255, 255, 255, .7);
  cursor: pointer;
  transition: background 150ms;
}

.sb-toggle:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.sb-toggle .icon + .icon { display: none; }

.sb-hamburger {
  display: none;  /* mobile only */
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: rgba(255, 255, 255, .85);
  cursor: pointer;
}
.sb-hamburger:hover { background: rgba(255, 255, 255, .08); color: #fff; }

@media (min-width: 769px) {
  html.sb-collapsed { --sidebar-w: 64px; }
  html.sb-collapsed .brand { padding: 4px 0 6px; }
  html.sb-collapsed .brand-name { display: none; }
  html.sb-collapsed .brand .logo { width: 40px; height: 40px; }
  html.sb-collapsed .sb-toggle { align-self: center; }
  html.sb-collapsed .sidebar a { justify-content: center; padding: 0; }
  html.sb-collapsed .sidebar a span { display: none; }
  html.sb-collapsed .sb-toggle .icon { display: none; }
  html.sb-collapsed .sb-toggle .icon + .icon { display: block; }
}

.sidebar a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, .85);
  text-decoration: none;
  transition: background 150ms;
}

.sidebar a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.sidebar a[aria-current="page"] { background: rgba(255, 255, 255, .14); color: #fff; }

.sidebar a[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
}

.content { margin-left: var(--sidebar-w); padding: 32px; transition: margin-left 200ms ease-out; }
.container { max-width: 1200px; }

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 16px;
  margin-bottom: 24px;
}

.page-head .sub { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.card {
  padding: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-flush { padding: 0; overflow: hidden; }
.card h2 { margin-bottom: 4px; }
.card .sub { margin: 0 0 16px; font-size: 13px; color: var(--muted); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: 500 14px/1 "IBM Plex Sans", system-ui, sans-serif;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background 150ms, color 150ms;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-fg); }
.btn-secondary { background: var(--card); border-color: var(--border); color: var(--fg); }
.btn-secondary:hover { background: var(--hover); }
.btn-edit { background: var(--accent-soft); color: var(--accent-fg); }
.btn-edit:hover { background: var(--accent); color: #fff; }
.btn-delete { background: var(--danger-soft); color: var(--danger-fg); }
.btn-delete:hover { background: var(--danger); color: #fff; }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; }
.data .btn-sm { height: 36px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--muted);
  cursor: pointer;
}

.icon-btn:hover { background: var(--hover); color: var(--fg); }

.table-wrap { overflow-x: auto; overflow-y: hidden; }  /* x-scroll only; overflow-x:auto alone forces overflow-y to compute as auto, flashing a phantom vertical bar */

table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }

table.data th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .04em;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
  color: var(--muted);
}

table.data th.num, table.data th:last-child { text-align: right; }
table.data td { height: 44px; padding: 4px 16px; border-bottom: 1px solid var(--border); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--hover); }
table.data .row-actions { display: flex; gap: 8px; justify-content: flex-end; }
table.data td.name a { font-weight: 500; text-decoration: none; }
table.data td.name a:hover { text-decoration: underline; }
table.data td.stacked { font-size: 12.5px; line-height: 1.4; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }
.empty .btn { margin-top: 12px; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--hover);
  color: var(--muted);
  font-size: 12px;
  line-height: 18px;
  white-space: nowrap;
}

.badge-success { background: var(--success-soft); color: var(--success); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 6px 0 12px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-fg);
  font-size: 13px;
  white-space: nowrap;
}

.chip a { display: inline-flex; color: inherit; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.field > label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}

.field input, .field select, .field textarea {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--fg);
  font: 400 14px/1.5 "IBM Plex Sans", system-ui, sans-serif;
}

.field textarea { height: auto; padding: 10px 12px; resize: vertical; }
.field-help { font-size: 12px; color: var(--muted); }
.invalid, input[aria-invalid="true"] { border-color: var(--danger) !important; }

.check { display: flex; align-items: center; gap: 10px; height: 36px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }

table.lines td { height: auto; padding: 4px 8px; }
table.lines td.sn, table.lines td.rm { width: 40px; }
table.lines td.qty, table.lines td.unit, table.lines td.rate { width: 96px; }
table.lines td.amount { width: 110px; }
table.lines tbody tr:hover { background: none; }

table.lines input {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--fg);
  font: 400 14px/1.5 "IBM Plex Sans", system-ui, sans-serif;
}

table.lines input.num { text-align: right; font-variant-numeric: tabular-nums; }
table.lines .icon-btn { width: 36px; height: 36px; }

.lines-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0 20px;
}

.lines-foot b { font-size: 16px; font-variant-numeric: tabular-nums; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px 20px;
}

.wide { grid-column: 1 / -1; }

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}

.segmented { display: inline-flex; }
.segmented input { position: absolute; width: 0; height: 0; opacity: 0; }

.segmented label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms, color 150ms;
}

.segmented label:first-of-type { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.segmented label:last-of-type { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin-left: -1px; }

.segmented input:checked + label {
  position: relative;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.toast-stack {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 380px;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--muted);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  animation: toast-in 150ms ease-out;
}

.toast.out { animation: toast-out 150ms ease-out both; }
.toast p { margin: 0; flex: 1; }
.toast-error { border-left-color: var(--danger); }
.toast-success { border-left-color: var(--success); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(16px); }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateX(16px); }
}

/* ponytail: overflow must stay visible so the Nepali calendar popover can escape the
   dialog box; a form taller than the viewport would not scroll. */
dialog.modal {
  width: min(560px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  background: var(--card);
  color: var(--fg);
  overflow: visible;
}

dialog.modal::backdrop { background: rgba(15, 23, 42, .45); }

/* dialog.modal sets a width, so this has to match its specificity to win */
dialog.modal-sm { width: 480px; max-width: calc(100vw - 32px); }

/* the body is the only scroller, so the head and foot stay put while the lines grow */
dialog.modal-lg { width: min(960px, calc(100vw - 32px)); max-height: calc(100vh - 32px); }
dialog[open].modal-lg { display: flex; flex-direction: column; }
.modal-lg > form { display: flex; flex-direction: column; min-height: 0; }
.modal-lg .modal-head, .modal-lg .modal-foot { flex: none; }
.modal-lg .modal-body { flex: 1; min-height: 0; overflow: auto; }
/* a scroll container's automatic minimum size is 0, so as long as the wrap is one the
   grid shrinks its track and the table paints over the rest of the body */
.modal-lg .table-wrap { overflow: visible; }
.modal-lg .modal-foot { align-items: center; }
.modal-lg #invoice-delete { margin-right: auto; }
.modal-body .defs { grid-template-columns: 1fr 1fr; gap: 10px 24px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-head h2 { margin: 0; }
.modal-body { display: grid; gap: 16px; padding: 20px; }
.modal-body .sub { margin: 0; font-size: 13px; color: var(--muted); }

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.date-field { align-items: flex-start; }

.date-group {
  display: inline-flex;
  align-items: center;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
}

.date-group:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.date-slot { display: flex; align-items: center; gap: 6px; padding: 0 10px; color: var(--muted); }
.date-slot + .date-slot { border-left: 1px solid var(--border); }
.date-slot .icon { cursor: pointer; }

.field .date-text {
  width: 7.5em;
  height: 34px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--fg);
  font: 400 13.5px/1 "IBM Plex Sans", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}

.date-text:focus-visible { outline: none; }
.date-text.invalid { color: var(--danger); }

.cal-toggle {
  height: 36px;
  padding: 0 10px;
  border: 0;
  border-left: 1px solid var(--border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--hover);
  color: var(--muted);
  font: 600 12px/1 "IBM Plex Sans", system-ui, sans-serif;
  cursor: pointer;
}

.cal-toggle:hover { color: var(--fg); }

#cal-pop {
  position: fixed;
  z-index: 1000;
  width: 252px;
  padding: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

.cal-head { display: flex; align-items: center; margin-bottom: 6px; }
.cal-head b { flex: 1; text-align: center; font-size: 13.5px; font-weight: 600; }
.cal-head .icon-btn { width: 28px; height: 28px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }

.cal-dow span {
  height: 24px;
  font-size: 11px;
  line-height: 24px;
  text-align: center;
  color: var(--muted);
}

.cal-days button {
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--fg);
  font: 400 13px/1 "IBM Plex Sans", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.cal-days button:hover { background: var(--hover); }
.cal-days button.today { border-color: var(--accent); }
.cal-days button.sel { background: var(--accent); color: #fff; }
.cal-foot { display: flex; justify-content: center; margin-top: 6px; }

.cal-today {
  padding: 4px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--accent);
  font: 500 13px/1 "IBM Plex Sans", system-ui, sans-serif;
  cursor: pointer;
}

.cal-today:hover { background: var(--hover); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.charts { display: grid; grid-template-columns: 2fr 3fr; gap: 16px; }
@media (max-width: 1000px) { .charts { grid-template-columns: 1fr; } }
.kpi-value { margin-top: 8px; font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }

.chart-box {
  height: 240px;
  width: 100%;
  min-width: 280px;
  min-height: 160px;
  margin-top: 12px;
  resize: both;
  overflow: hidden;
}

.customer-banner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: linear-gradient(135deg, var(--primary), #2B4C7E);
  color: #fff;
}

.customer-banner .label { color: rgba(255, 255, 255, .7); }
.customer-banner h1 { font-size: 24px; }
.customer-banner .badge { background: rgba(255, 255, 255, .16); color: #fff; }
.cb-name { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 4px 0 20px; }

.cb-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 12px 24px;
  max-width: 460px;
  margin: 0;
}

.cb-grid dd { margin: 2px 0 0; }
.cb-grid .wide { grid-column: 1 / -1; }
.cb-grid dd.unset { color: rgba(255, 255, 255, .55); }
.cb-side { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; }
.cb-balance { margin-top: 4px; font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
/* minmax(0, ...) so the widest label cannot widen its own column and unbalance the four */
.cb-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 16px; }
.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.card-head h2 { margin: 0; }

.ledger-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.ledger-filter .search-field { margin-left: auto; }

.card-foot {
  margin: 0;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}
.toolbar .grow { flex: 1; min-width: 160px; }
.search-field { position: relative; display: flex; min-width: 200px; }

.search-field input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--fg);
  font: 400 14px/1.5 "IBM Plex Sans", system-ui, sans-serif;
}

.search-field .icon {
  position: absolute;
  top: 10px;
  left: 12px;
  color: var(--muted);
  pointer-events: none;
}

.defs { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 24px; margin: 0; }
.defs dd { margin: 2px 0 0; word-break: break-all; font-variant-numeric: tabular-nums; }

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}

.pager-info b { color: var(--fg); font-weight: 500; }
.pager-nav { display: inline-flex; gap: 2px; }

.pager-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border-radius: 6px;
  color: var(--fg);
  text-decoration: none;
}

.pager-num:hover { background: var(--bg); }

.pager-num.is-current {
  border: 1px solid var(--accent);
  color: var(--accent-fg);
  background: var(--accent-soft);
}

.pager .icon-btn { width: 28px; height: 28px; }
.pager .is-disabled { opacity: .35; pointer-events: none; }
.pager-gap { padding: 0 4px; }

.pager-goto { display: inline-flex; align-items: center; gap: 6px; }
.pager input { width: 72px; height: 32px; }

.pager select {
  height: 32px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--fg);
  font-size: 13px;
}

@view-transition { navigation: auto; }
::view-transition-old(root) { animation-duration: 120ms; }
::view-transition-new(root) { animation-duration: 180ms; }

.loader {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1001;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: loader-slide 1.2s ease-out infinite;
}

@keyframes loader-slide {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}

.btn.is-loading { opacity: .75; cursor: default; }

.btn.is-loading::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: rotate 600ms linear infinite;
}

@keyframes rotate { to { transform: rotate(1turn); } }

.skeleton {
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--hover), var(--border), var(--hover)) 0 0 / 200% 100%;
  animation: shimmer 1.2s ease-out infinite;
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

tbody tr { --i: 0; animation: fade-up 180ms ease-out both calc(var(--i) * 20ms); }
tbody tr.hl { animation: fade-up 180ms ease-out both, hl 1.6s ease-out both; }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(4px); }
}

@keyframes hl {
  from { background: var(--accent-soft); }
  to { background: transparent; }
}

@media (max-width: 640px) {
  dialog.modal-lg {
    width: 100vw;
    max-width: none;
    height: 100dvh;
    max-height: none;
    margin: 0;
    border-radius: 0;
  }

  .lines thead { display: none; }
  .lines, .lines tbody, .lines tr, .lines td { display: block; }

  .lines tbody tr {
    display: grid;
    grid-template-columns: 1fr 1fr 36px;
    gap: 8px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
  }

  table.lines td { padding: 0; border: 0; width: auto; }
  .lines td.sn { grid-area: 1 / 1 / 2 / 3; font-size: 12px; color: var(--muted); }
  .lines td.rm { grid-area: 1 / 3 / 2 / 4; justify-self: end; }
  .lines td.item { grid-area: 2 / 1 / 3 / 4; }
  .lines td.qty { grid-area: 3 / 1 / 4 / 2; }
  .lines td.unit { grid-area: 3 / 2 / 4 / 4; }
  .lines td.rate { grid-area: 4 / 1 / 5 / 2; }
  .lines td.amount { grid-area: 4 / 2 / 5 / 4; text-align: right; font-weight: 600; }

  .lines td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    font-size: 12px;
    color: var(--muted);
  }
}

@media (max-width: 480px) {
  .ledger-filter .search-field { width: 100%; margin-left: 0; }
  .modal-body .defs { grid-template-columns: 1fr; }
  .cb-actions .btn { padding: 0 8px; }  /* "Print statement" would not fit half the banner otherwise */
}

@media (max-width: 768px) {
  .sidebar {
    position: static;
    inset: auto;
    width: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
    padding: 8px 16px;
  }

  .brand { flex-direction: row; gap: 8px; padding: 0; }
  .brand .logo { width: 34px; height: 34px; }
  .brand-name { font-size: 15px; }
  .sb-toggle { display: none; }
  .sb-hamburger { display: flex; margin-left: auto; }

  /* menu collapsed by default; hamburger reveals it as a full-width dropdown */
  .sidebar a { display: none; flex-basis: 100%; margin-top: 2px; }
  html.nav-open .sidebar a { display: flex; }
  .customer-banner { padding: 20px 16px; }
  .cb-grid { grid-template-columns: 1fr; }
  .card-head, .ledger-filter { padding: 16px; }
  .card-foot { padding: 12px 16px; }
  .content { margin-left: 0; padding: 16px; }
  .toast-stack { left: 16px; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.breadcrumb { margin-bottom: 16px; font-size: 13px; }
.breadcrumb ol { display: flex; flex-wrap: wrap; align-items: center; margin: 0; padding: 0; list-style: none; }
.breadcrumb li { display: inline-flex; align-items: center; color: var(--muted); }
.breadcrumb li:not(:first-child)::before { content: "/"; margin: 0 8px; color: var(--border); }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb [aria-current="page"] { color: var(--fg); }

.print-error { margin: 8px 0 0; font-size: 13px; color: var(--danger); }

.btn:disabled { opacity: .55; cursor: not-allowed; }

/* sidebar user block + logout */
.sb-user {
  margin-top: auto;
  padding: 12px 10px;
  border-top: 1px solid rgba(255, 255, 255, .12);
}
.sb-user-info { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; overflow: hidden; }
.sb-user-info b { font-size: 13px; color: #fff; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.sb-user-info span { font-size: 11px; text-transform: capitalize; color: rgba(255, 255, 255, .6); }
.sb-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: rgba(255, 255, 255, .7);
  font: 500 14px/1 "IBM Plex Sans", system-ui, sans-serif;
  cursor: pointer;
  transition: background 150ms;
}
.sb-logout:hover { background: rgba(255, 255, 255, .08); color: #fff; }

@media (min-width: 769px) {
  html.sb-collapsed .sb-user { padding: 12px 0; }
  html.sb-collapsed .sb-user-info { display: none; }
  html.sb-collapsed .sb-logout { justify-content: center; padding: 0; }
  html.sb-collapsed .sb-logout span { display: none; }
}

@media (max-width: 768px) {
  .sb-user { display: none; flex-basis: 100%; margin: 6px 0 0; padding: 8px 0 0; border-top: 1px solid rgba(255, 255, 255, .12); }
  html.nav-open .sb-user { display: block; }
  .sb-logout { width: 100%; }
}

/* login page */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 16px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  padding: 24px 28px 28px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.login-card h1 { margin-bottom: 16px; font-size: 18px; }
.login-card .field > label { text-transform: none; letter-spacing: normal; }

/* password show/hide toggle */
.pw-field { position: relative; }
.pw-field input { padding-right: 42px; }
.pw-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.pw-toggle:hover { color: var(--primary); }
.pw-toggle .pw-eye-off { display: none; }
.pw-toggle.is-shown .pw-eye { display: none; }
.pw-toggle.is-shown .pw-eye-off { display: flex; }
.login-card .field { margin-bottom: 14px; }
.login-card .btn-primary { width: 100%; margin-top: 4px; }
.login-error {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger-fg);
  font-size: 13px;
}

/* help center */
.help-layout { display: grid; grid-template-columns: 210px 1fr; gap: 32px; align-items: start; }
.help-toc { position: sticky; top: 32px; }
.help-toc h2 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.help-toc ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }
.help-toc a { display: block; padding: 6px 10px; border-radius: var(--radius-sm); color: var(--fg); text-decoration: none; font-size: 14px; }
.help-toc a:hover { background: var(--hover); color: var(--accent); }
.help-content { display: grid; gap: 20px; min-width: 0; }
.help-section { scroll-margin-top: 24px; }
.help-section > h2 { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 4px; font-size: 18px; }
.help-section > .sub { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.help-section h3 { margin: 18px 0 6px; font-size: 15px; }
.help-steps { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.help-steps li { line-height: 1.55; }
.help-shot { display: block; width: 100%; margin: 12px 0 4px; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.help-shot.mobile { max-width: 320px; }
.help-cap { margin: 0 0 8px; font-size: 12px; color: var(--muted); }
.help-note { margin: 12px 0 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent-fg); font-size: 13px; }
.help-perm { padding: 2px 8px; border-radius: 999px; background: var(--hover); color: var(--muted); font-size: 11px; font-weight: 500; }

@media (max-width: 768px) {
  .help-layout { grid-template-columns: 1fr; gap: 16px; }
  .help-toc { position: static; }
}

@media print {
  .sidebar, .help-toc, .help-print, .breadcrumb, .toast-stack, #loader { display: none !important; }
  body { background: #fff; }
  .content { margin-left: 0; padding: 0; }
  .help-layout { display: block; }
  .help-content { gap: 16px; }
  .help-section { box-shadow: none; border: 0; padding: 0; }
  .help-section > h2, .help-section h3 { break-after: avoid; }
  .help-shot { break-inside: avoid; max-width: 520px; }
  a { color: inherit; }
}
