/* =========================================================
   Tally Suite — "Ledger" theme
   Emerald + amber on warm paper. Flat surfaces,ruled-line
   textures,light sidebar. Tokens → base → entry screens →
   app shell → components.
   ========================================================= */

:root {
  color-scheme: light;
  --bg: #f5f4ef;
  --surface: #ffffff;
  --surface-2: #faf9f5;
  --surface-3: #efeee7;
  --border: #e4e2d9;
  --border-strong: #cfccbf;
  --rule: rgba(4, 120, 87, 0.07);

  --text: #17211c;
  --text-2: #4a5850;
  --muted: #86918a;

  --brand: #047857;
  --brand-strong: #065f46;
  --brand-deep: #053d2e;
  --brand-soft: rgba(4, 120, 87, 0.09);
  --accent: #d97706;
  --accent-soft: rgba(217, 119, 6, 0.12);

  --good: #15803d; --good-soft: rgba(21, 128, 61, 0.11);
  --warn: #b45309; --warn-soft: rgba(180, 83, 9, 0.12);
  --bad: #c2410c;  --bad-soft: rgba(194, 65, 12, 0.10);
  --info: #0369a1; --info-soft: rgba(3, 105, 161, 0.10);

  --series-1: #2a78d6;
  --series-2: #eb6834;

  --shadow-sm: 0 1px 0 rgba(23, 33, 28, 0.04);
  --shadow: 0 1px 2px rgba(23, 33, 28, 0.06), 0 8px 24px -16px rgba(23, 33, 28, 0.18);
  --shadow-lg: 0 30px 60px -30px rgba(5, 61, 46, 0.45);

  --radius: 10px;
  --radius-sm: 7px;
  --sidebar-w: 252px;
  --font: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d1311; --surface: #141c19; --surface-2: #18211e; --surface-3: #1f2a26;
    --border: #26322d; --border-strong: #33423b; --rule: rgba(52, 211, 153, 0.05);
    --text: #ecf2ee; --text-2: #b4c2ba; --muted: #7d8b84;
    --brand: #34d399; --brand-strong: #6ee7b7; --brand-deep: #052e22; --brand-soft: rgba(52, 211, 153, 0.12);
    --accent: #fbbf24; --accent-soft: rgba(251, 191, 36, 0.13);
    --good: #4ade80; --good-soft: rgba(74, 222, 128, 0.13);
    --warn: #fbbf24; --warn-soft: rgba(251, 191, 36, 0.13);
    --bad: #fb923c;  --bad-soft: rgba(251, 146, 60, 0.13);
    --info: #38bdf8; --info-soft: rgba(56, 189, 248, 0.12);
    --series-1: #3987e5; --series-2: #d95926;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4); --shadow-lg: 0 30px 60px -30px rgba(0, 0, 0, 0.8);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1311; --surface: #141c19; --surface-2: #18211e; --surface-3: #1f2a26;
  --border: #26322d; --border-strong: #33423b; --rule: rgba(52, 211, 153, 0.05);
  --text: #ecf2ee; --text-2: #b4c2ba; --muted: #7d8b84;
  --brand: #34d399; --brand-strong: #6ee7b7; --brand-deep: #052e22; --brand-soft: rgba(52, 211, 153, 0.12);
  --accent: #fbbf24; --accent-soft: rgba(251, 191, 36, 0.13);
  --good: #4ade80; --good-soft: rgba(74, 222, 128, 0.13);
  --warn: #fbbf24; --warn-soft: rgba(251, 191, 36, 0.13);
  --bad: #fb923c;  --bad-soft: rgba(251, 146, 60, 0.13);
  --info: #38bdf8; --info-soft: rgba(56, 189, 248, 0.12);
  --series-1: #3987e5; --series-2: #d95926;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4); --shadow-lg: 0 30px 60px -30px rgba(0, 0, 0, 0.8);
}

/* ---------------- Base ---------------- */
*,*::before,*::after { box-sizing: border-box; }
html,body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1,h2,h3,h4 { margin: 0; letter-spacing: -0.015em; }
svg { flex-shrink: 0; }
.mono { font-family: var(--mono); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.mt { margin-top: 20px; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes stamp { 0% { opacity: 0; transform: scale(1.6) rotate(-12deg); } 100% { opacity: 1; transform: scale(1) rotate(-6deg); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 var(--accent-soft); } 50% { box-shadow: 0 0 0 8px transparent; } }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: 700 13px var(--font);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  white-space: nowrap;
  text-decoration: none !important;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18); }
.btn-primary:hover { background: var(--brand-strong); }
:root[data-theme="dark"] .btn-primary { color: #052e22; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-primary { color: #052e22; } }
.btn-outline { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { filter: brightness(.95); }
.btn-danger { background: transparent; color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; }
.btn-xs { height: 27px; padding: 0 9px; font-size: 11.5px; gap: 5px; border-radius: 6px; }
.btn-xs svg { width: 13px; height: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
  cursor: pointer;
}
.icon-btn:hover { color: var(--brand); border-color: var(--brand); }
.icon-btn svg { width: 17px; height: 17px; }
.chip-btn { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border-radius: 6px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); font: 700 12px var(--font); cursor: pointer; }
.chip-btn:hover { color: var(--brand); border-color: var(--brand); }
.chip-btn svg { width: 14px; height: 14px; }

/* ---------------- Forms ---------------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12px; font-weight: 700; color: var(--text-2); letter-spacing: .01em; }
.req { color: var(--accent); }
.field input,.field select,.field textarea {
  width: 100%; height: 42px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font: 600 13.5px var(--font);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { height: auto; min-height: 80px; padding: 10px 12px; resize: vertical; }
.field input:focus,.field select:focus,.field textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.field input.error,.field select.error { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
input::placeholder,textarea::placeholder { text-transform: none; color: var(--muted); font-weight: 500; }
.err-msg { display: none; font-size: 12px; color: var(--bad); font-weight: 600; }
.err-msg.show { display: block; }
.field-hint { font-size: 11.5px; color: var(--muted); }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.field-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.checkbox { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; font-weight: 600; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--brand); }

.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 62px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); height: 28px; padding: 0 10px; border: 0; border-radius: 5px; background: var(--surface-3); color: var(--text-2); font: 700 11px var(--font); text-transform: uppercase; letter-spacing: .06em; cursor: pointer; }
.pw-toggle:hover { color: var(--brand); }
.strength { display: flex; gap: 4px; margin-top: 2px; }
.strength span { flex: 1; height: 4px; background: var(--surface-3); transition: background .25s; }
.strength.s1 span:nth-child(-n+1) { background: var(--bad); }
.strength.s2 span:nth-child(-n+2) { background: var(--accent); }
.strength.s3 span:nth-child(-n+3) { background: var(--info); }
.strength.s4 span:nth-child(-n+4) { background: var(--good); }
.strength-label { font-size: 11.5px; color: var(--muted); font-weight: 600; }

.alert-bar {
  display: none; align-items: center; gap: 10px;
  padding: 10px 14px; margin-bottom: 18px;
  border-left: 3px solid var(--bad); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--bad-soft); color: var(--bad);
  font-size: 13px; font-weight: 700;
}
.alert-bar.show { display: flex; animation: rise .25s; }
.alert-bar svg { width: 17px; height: 17px; }

.section-label {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 10px;
  margin: 8px 0 2px;
  font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--brand);
}
.section-label::before { content: ""; width: 14px; height: 2px; background: var(--accent); }
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* =========================================================
   ENTRY SCREENS (sign in / register)
   Full-height split: ruled ledger panel + form column.
   ========================================================= */
.entry { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr); }
.entry-art {
  position: relative; overflow: hidden;
  background-color: var(--brand-deep);
  background-image:
    linear-gradient(90deg, transparent 63px, rgba(251, 191, 36, 0.35) 63px, rgba(251, 191, 36, 0.35) 65px, transparent 65px),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.055) 0 1px, transparent 1px 34px);
  color: #d1fae5;
  padding: 44px 56px 40px 96px;
  display: flex; flex-direction: column;
}
.entry-brand { display: flex; align-items: center; gap: 12px; color: #fff; }
.entry-brand .mark { width: 40px; height: 40px; border-radius: 8px; background: #fbbf24; color: #053d2e; font-weight: 800; font-size: 20px; display: flex; align-items: center; justify-content: center; }
.entry-brand strong { font-size: 17px; font-weight: 800; display: block; line-height: 1.1; }
.entry-brand span { font-size: 11.5px; color: #6ee7b7; font-weight: 600; letter-spacing: .04em; }
.entry-art h2 { margin-top: auto; color: #fff; font-size: 34px; line-height: 1.15; font-weight: 800; max-width: 440px; }
.entry-art h2 em { font-style: normal; color: #fbbf24; }
.entry-art .entry-lead { color: #a7f3d0; font-size: 14.5px; max-width: 430px; margin: 12px 0 28px; }

.ledger-mock { background: #fffdf7; color: #17211c; border-radius: 8px; box-shadow: 0 24px 50px -20px rgba(0, 0, 0, .55); max-width: 440px; overflow: hidden; transform: rotate(-1.2deg); }
.ledger-mock-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: #ecfdf5; border-bottom: 2px solid #047857; font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: #065f46; }
.ledger-mock table { width: 100%; border-collapse: collapse; font-size: 12px; }
.ledger-mock td { padding: 7px 14px; border-bottom: 1px solid #ece9df; }
.ledger-mock td.amt { font-family: var(--mono); text-align: right; white-space: nowrap; }
.ledger-mock td.dr { color: #047857; }
.ledger-mock td.cr { color: #c2410c; }
.ledger-mock tr:last-child td { border-bottom: 0; font-weight: 800; background: #faf7ec; }
.entry-foot { margin-top: 34px; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: #6ee7b7; font-weight: 600; }
.entry-foot span::before { content: "✓ "; color: #fbbf24; }

.entry-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--bg); }
.entry-form { width: 100%; max-width: 400px; animation: rise .35s ease; }
.entry-form.wide { max-width: 640px; }
.entry-kicker { font-size: 11px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }
.entry-title { font-size: 28px; font-weight: 800; }
.entry-sub { color: var(--muted); margin: 6px 0 26px; font-size: 14px; }
.entry-form .stack-fields { display: grid; gap: 16px; }
.entry-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin: 2px 0 6px; }
.entry-submit { width: 100%; height: 46px; font-size: 14px; margin-top: 8px; }
.entry-switch { margin-top: 22px; padding-top: 18px; border-top: 1px dashed var(--border-strong); font-size: 13px; color: var(--muted); }
.demo-box { margin-top: 18px; display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--accent-soft); border-radius: var(--radius-sm); font-size: 12.5px; color: var(--text-2); }
.demo-box b { font-family: var(--mono); color: var(--text); font-weight: 600; }
.demo-box .chip-btn { margin-left: auto; }

/* ---------------- Status screens (verify / success / approval) ---------------- */
.state-page {
  min-height: 100vh; padding: 40px 16px;
  display: flex; align-items: center; justify-content: center;
  background-color: var(--bg);
  background-image: repeating-linear-gradient(0deg, var(--rule) 0 1px, transparent 1px 32px);
}
.state-card { width: 100%; max-width: 460px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); overflow: hidden; animation: rise .35s ease; }
.state-head { display: flex; align-items: center; gap: 14px; padding: 22px 26px; background: var(--brand-deep); color: #ecfdf5; border-bottom: 3px solid #fbbf24; }
.state-head .state-icon { width: 46px; height: 46px; border-radius: 50%; background: rgba(255, 255, 255, .1); color: #fbbf24; display: flex; align-items: center; justify-content: center; }
.state-head .state-icon svg { width: 24px; height: 24px; }
.state-head .entry-kicker { margin: 0 0 2px; color: #6ee7b7; }
.state-head h1 { font-size: 20px; color: #fff; }
.state-body { padding: 24px 26px 26px; }
.state-body > p { margin: 0 0 18px; color: var(--text-2); }
.state-link { margin-top: 18px; text-align: center; font-size: 13px; color: var(--muted); }

.ticket { position: relative; margin: 0 0 20px; padding: 16px 18px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface-2); }
.ticket::before,.ticket::after { content: ""; position: absolute; top: 50%; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); border: 1px solid var(--border-strong); transform: translateY(-50%); }
.ticket::before { left: -9px; clip-path: inset(0 0 0 50%); }
.ticket::after { right: -9px; clip-path: inset(0 50% 0 0); }
.ticket-label { font-size: 10.5px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.ticket-value { font-family: var(--mono); font-size: 26px; font-weight: 600; color: var(--brand); letter-spacing: .08em; margin: 4px 0 8px; word-break: break-all; }
.ticket-value.small { font-size: 15px; letter-spacing: 0; color: var(--text); }
.ticket .stamp { position: absolute; right: 16px; top: 14px; padding: 3px 9px; border: 2px solid var(--accent); color: var(--accent); border-radius: 4px; font-size: 11px; font-weight: 800; letter-spacing: .12em; animation: stamp .45s cubic-bezier(.2, 1.4, .4, 1) both .2s; }

.timeline { list-style: none; margin: 0 0 20px; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 34px; font-size: 13px; color: var(--text-2); }
.timeline li::before { content: ""; position: absolute; left: 10px; top: 22px; bottom: 0; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline li:last-child { padding-bottom: 0; }
.timeline .dot { position: absolute; left: 0; top: 0; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border-strong); background: var(--surface); display: flex; align-items: center; justify-content: center; }
.timeline .dot svg { width: 12px; height: 12px; }
.timeline strong { display: block; color: var(--text); font-size: 13.5px; }
.timeline li.done .dot { background: var(--brand); border-color: var(--brand); color: #fff; }
.timeline li.done::before { background: var(--brand); }
.timeline li.now .dot { border-color: var(--accent); background: var(--accent-soft); animation: pulse 1.8s infinite; }
.timeline li.now .dot::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

/* =========================================================
   APP SHELL — light sidebar
   ========================================================= */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: transform .25s ease;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.brand-mark { width: 36px; height: 36px; border-radius: 8px; background: var(--brand-deep); color: #fbbf24; font-weight: 800; font-size: 18px; display: flex; align-items: center; justify-content: center; }
.brand-text strong { display: block; font-size: 15.5px; font-weight: 800; line-height: 1.15; }
.brand-text span { font-size: 11px; color: var(--muted); font-weight: 600; }
.tenant-chip { margin: 14px 14px 4px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--brand-soft); display: flex; align-items: center; gap: 10px; }
.tenant-chip svg { width: 18px; height: 18px; color: var(--brand); }
.tenant-chip div { min-width: 0; }
.tenant-chip strong { display: block; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tenant-chip span { font-family: var(--mono); font-size: 11px; color: var(--brand); font-weight: 600; }
.nav { flex: 1; overflow-y: auto; padding: 4px 10px 12px; }
.nav-section { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); padding: 16px 12px 6px; }
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 8px 12px; margin: 1px 0;
  border-radius: var(--radius-sm); color: var(--text-2);
  font-size: 13.5px; font-weight: 600;
  text-decoration: none !important;
  transition: background .15s, color .15s;
}
.nav-item svg { width: 17px; height: 17px; color: var(--muted); }
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active { background: var(--brand-soft); color: var(--brand-strong); font-weight: 800; }
.nav-item.active svg { color: var(--brand); }
.nav-item.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.avatar { width: 34px; height: 34px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-weight: 800; display: flex; align-items: center; justify-content: center; text-transform: uppercase; }
.who { flex: 1; min-width: 0; }
.who strong { display: block; font-size: 13px; }
.who span { font-size: 11.5px; color: var(--muted); }
.logout-btn { width: 32px; height: 32px; border-radius: 7px; border: 1px solid var(--border); background: transparent; color: var(--text-2); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.logout-btn:hover { color: var(--bad); border-color: var(--bad); }
.logout-btn svg { width: 16px; height: 16px; }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.sidebar-backdrop { display: none; }
.content { padding: 26px 28px 48px; width: 100%; max-width: 1440px; animation: rise .3s ease; }

/* ---------------- Page header ---------------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.page-head h2 { font-size: 22px; font-weight: 800; }
.page-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- Cards ---------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-title { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 14px; }
.card-title .ct-icon { width: 30px; height: 30px; border-radius: 7px; background: var(--brand-soft); color: var(--brand); display: flex; align-items: center; justify-content: center; }
.card-title .ct-icon svg { width: 16px; height: 16px; }
.card-title small { display: block; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.card-body { padding: 18px; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-main-side { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.grid-side-main { grid-template-columns: minmax(300px, 0.8fr) minmax(0, 1.6fr); }

/* ---------------- Stats: one joined ledger strip ---------------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 22px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.stat-card { position: relative; padding: 18px 20px 16px; border-right: 1px solid var(--border); }
.stat-card:last-child { border-right: 0; }
.stat-card::before { content: ""; position: absolute; left: 20px; top: 0; width: 28px; height: 3px; background: var(--tint, var(--brand)); }
.stat-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.stat-icon { width: 30px; height: 30px; border-radius: 7px; display: flex; align-items: center; justify-content: center; }
.stat-icon svg { width: 16px; height: 16px; }
.stat-label { font-size: 11px; color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.stat-value { font-size: 24px; font-weight: 600; font-family: var(--mono); letter-spacing: -0.02em; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 2px; font-weight: 600; }
.tone-brand { background: var(--brand-soft); color: var(--brand); }
.tone-accent { background: var(--accent-soft); color: var(--accent); }
.tone-good { background: var(--good-soft); color: var(--good); }
.tone-warn { background: var(--warn-soft); color: var(--warn); }
.tone-bad { background: var(--bad-soft); color: var(--bad); }
.tone-info { background: var(--info-soft); color: var(--info); }

/* ---------------- Tables (ruled ledger rows) ---------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 800; padding: 10px 14px; background: var(--surface-2); border-bottom: 2px solid var(--border-strong); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: color-mix(in srgb, var(--brand) 4%, transparent); }
.table tbody tr:last-child td { border-bottom: 0; }
.table th.num,.table td.num { text-align: right; }
.table tfoot td { font-weight: 800; padding: 11px 14px; border-top: 3px double var(--border-strong); background: var(--surface-2); }
.table .cell-strong { font-weight: 700; }
.table .cell-sub { display: block; font-size: 11.5px; color: var(--muted); font-weight: 500; }
.table input,.table select { height: 34px; padding: 0 9px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); color: var(--text); font: 600 12.5px var(--font); width: 100%; outline: none; }
.table select { padding-right: 4px; }
.table input:focus,.table select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.table input.num { font-family: var(--mono); }
.table .it-name { min-width: 170px; }
.table:has(#itemBody) { min-width: 700px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state svg { width: 40px; height: 40px; color: var(--border-strong); margin-bottom: 8px; }
.empty-state strong { display: block; color: var(--text-2); font-size: 14px; margin-bottom: 2px; }

/* ---------------- Badges ---------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 800; white-space: nowrap; letter-spacing: .02em; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 1px; background: currentColor; }
.badge.plain::before { display: none; }
.badge-good { background: var(--good-soft); color: var(--good); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-brand { background: var(--brand-soft); color: var(--brand); }
.badge-muted { background: var(--surface-3); color: var(--text-2); }

/* ---------------- Tabs: underline style ---------------- */
.segmented { display: inline-flex; gap: 2px; border-bottom: 1px solid var(--border); }
.segmented button { border: 0; background: transparent; padding: 9px 14px; margin-bottom: -1px; border-bottom: 2px solid transparent; font: 700 13px var(--font); color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 7px; }
.segmented button svg { width: 15px; height: 15px; }
.segmented button:hover { color: var(--text); }
.segmented button.active { color: var(--brand); border-bottom-color: var(--accent); }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search-box { position: relative; }
.search-box svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted); }
.search-box input { height: 34px; padding: 0 12px 0 32px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: 600 13px var(--font); width: 220px; outline: none; }
.search-box input:focus { border-color: var(--brand); }
.select-sm { height: 34px; padding: 0 8px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: 600 13px var(--font); outline: none; }

/* ---------------- Totals ---------------- */
.totals { display: grid; gap: 7px; min-width: 260px; margin-left: auto; }
.totals-row { display: flex; justify-content: space-between; gap: 20px; font-size: 13px; color: var(--text-2); font-weight: 600; }
.totals-row span:last-child { font-family: var(--mono); color: var(--text); }
.totals-row.grand { padding-top: 10px; margin-top: 4px; border-top: 3px double var(--border-strong); font-size: 16px; font-weight: 800; color: var(--text); }
.totals-row.grand span:last-child { color: var(--brand); }

/* ---------------- Dropzone ---------------- */
.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 32px 20px; text-align: center; cursor: pointer; background: repeating-linear-gradient(0deg, var(--rule) 0 1px, transparent 1px 28px), var(--surface-2); transition: border-color .15s, background-color .15s; }
.dropzone:hover,.dropzone.drag { border-color: var(--brand); background-color: var(--brand-soft); }
.dropzone-icon { width: 52px; height: 52px; border-radius: 50%; margin: 0 auto 12px; background: var(--brand-deep); color: #fbbf24; display: flex; align-items: center; justify-content: center; }
.dropzone-icon svg { width: 24px; height: 24px; }
.dropzone strong { display: block; font-size: 15px; }
.dropzone p { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }
.dropzone input { display: none; }

/* ---------------- Wizard: joined step rail ---------------- */
.wizard { display: flex; margin-bottom: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.wizard-step { flex: 1; display: flex; align-items: center; gap: 10px; padding: 12px 16px; color: var(--muted); font-weight: 700; font-size: 13px; border-right: 1px solid var(--border); position: relative; }
.wizard-step:last-child { border-right: 0; }
.wizard-step .ws-num { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border-strong); display: flex; align-items: center; justify-content: center; font: 600 11px var(--mono); }
.wizard-step.active { color: var(--text); background: var(--brand-soft); }
.wizard-step.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--accent); }
.wizard-step.active .ws-num { border-color: var(--brand); background: var(--brand); color: #fff; }
.wizard-step.done { color: var(--brand); }
.wizard-step.done .ws-num { border-color: var(--brand); color: var(--brand); }
.done-mark { width: 60px; height: 60px; border-radius: 50%; margin: 0 auto 14px; background: var(--brand-deep); color: #fbbf24; display: flex; align-items: center; justify-content: center; }
.done-mark svg { width: 28px; height: 28px; }

.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-icon { width: 34px; height: 34px; border-radius: 7px; display: flex; align-items: center; justify-content: center; font: 600 10.5px var(--mono); }
.list-icon svg { width: 16px; height: 16px; }
.list-main { flex: 1; min-width: 0; }
.list-main strong { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-main span { font-size: 11.5px; color: var(--muted); font-weight: 600; }

/* ---------------- Printable document ---------------- */
.doc-preview { overflow-x: auto; background: #fffdf8; color: #17211c; border-radius: 8px; padding: 24px; border: 1px solid #e4e2d9; font-size: 12.5px; box-shadow: var(--shadow); }
.doc-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 20px; padding-bottom: 14px; border-bottom: 3px double #047857; margin-bottom: 16px; }
.doc-head h3 { white-space: nowrap; font-size: 19px; color: #047857; letter-spacing: .12em; }
.doc-head .doc-co { font-weight: 800; font-size: 15px; }
.doc-meta { text-align: right; font-size: 12px; color: #4a5850; }
.doc-meta b { color: #17211c; font-family: var(--mono); }
.doc-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.doc-parties .lbl { font-size: 10px; text-transform: uppercase; letter-spacing: .12em; color: #b45309; font-weight: 800; }
.doc-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.doc-table th { background: #ecfdf5; color: #065f46; text-align: left; padding: 7px 8px; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; border-bottom: 1px solid #047857; }
.doc-table td { padding: 7px 8px; border-bottom: 1px solid #ece9df; }
.doc-table .num { text-align: right; }
.doc-totals { margin: 14px 0 0 auto; width: 260px; }
.doc-totals div { display: flex; justify-content: space-between; padding: 3px 0; }
.doc-totals .grand { border-top: 3px double #17211c; margin-top: 6px; padding-top: 7px; font-weight: 800; font-size: 14px; color: #047857; }
.doc-words { margin-top: 12px; font-size: 11.5px; color: #4a5850; font-style: italic; }
.doc-foot { margin-top: 24px; display: flex; justify-content: space-between; align-items: flex-end; font-size: 11px; color: #86918a; }
.doc-stamp { display: inline-block; padding: 4px 10px; border: 2px solid #d97706; color: #d97706; border-radius: 4px; font-weight: 800; transform: rotate(-6deg); letter-spacing: .12em; }

/* ---------------- Modal ---------------- */
.modal-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(5, 30, 22, .5); display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.open { display: flex; }
.modal { width: 100%; max-width: 560px; max-height: calc(100vh - 40px); overflow-y: auto; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); border-top: 4px solid var(--brand); animation: rise .2s ease; }
.modal.lg { max-width: 820px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; font-weight: 800; }
.modal-body { padding: 20px; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); }

/* ---------------- Toast ---------------- */
.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 380px; padding: 12px 16px; border-radius: 8px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-left: 4px solid var(--good); box-shadow: var(--shadow-lg); font-size: 13px; font-weight: 700; animation: rise .25s; }
.toast svg { width: 18px; height: 18px; color: var(--good); }
.toast.bad { border-left-color: var(--bad); }
.toast.bad svg { color: var(--bad); }
.toast.info { border-left-color: var(--info); }
.toast.info svg { color: var(--info); }

/* ---------------- Misc components ---------------- */
.note-box { background: var(--surface-2); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; padding: 12px 16px; margin-bottom: 18px; }
.note-title { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 13px; margin-bottom: 6px; }
.note-title svg { width: 16px; height: 16px; color: var(--accent); }
.note-box ul { margin: 0; padding-left: 18px; color: var(--text-2); font-size: 12.5px; display: grid; gap: 3px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 13px; margin: 0; }
.kv dt { color: var(--muted); font-weight: 700; }
.kv dd { margin: 0; font-weight: 700; word-break: break-all; }
.qr { width: 132px; height: 132px; border-radius: 6px; background: #fff; padding: 8px; border: 1px solid var(--border); image-rendering: pixelated; }
.ewb-card { overflow: hidden; }
.ewb-card-top { background: var(--brand-deep); color: #a7f3d0; padding: 14px 18px; display: flex; justify-content: space-between; align-items: center; border-bottom: 3px solid #fbbf24; }
.ewb-card-top .mono { font-size: 18px; font-weight: 600; letter-spacing: .1em; color: #fff; }
.validity-bar { height: 8px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.validity-bar span { display: block; height: 100%; background: var(--brand); }
.platform-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.platform { border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 14px; cursor: pointer; display: flex; align-items: center; gap: 10px; background: var(--surface); font-weight: 800; font-size: 13.5px; }
.platform:hover { border-color: var(--brand); }
.platform.active { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); background: var(--brand-soft); }
.platform .pf-logo { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: 16px; }
.balance-indicator { display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 6px; font-weight: 800; font-size: 13px; }

/* ---------------- Responsive ---------------- */
@media (max-width: 1180px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-card:nth-child(2) { border-right: 0; }
  .stat-card:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
  .grid-main-side, .grid-side-main { grid-template-columns: minmax(0, 1fr); }
  .field-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(5, 30, 22, .45); }
  .main { margin-left: 0; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .platform-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .entry { grid-template-columns: minmax(0, 1fr); }
  .entry-art { padding: 26px 22px 26px 64px; background-image: linear-gradient(90deg, transparent 40px, rgba(251, 191, 36, 0.35) 40px, rgba(251, 191, 36, 0.35) 42px, transparent 42px), repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.055) 0 1px, transparent 1px 34px); }
  .entry-art h2 { margin-top: 22px; font-size: 24px; }
  .entry-art .entry-lead { margin-bottom: 0; }
  .ledger-mock,.entry-foot { display: none; }
  .wizard-step { font-size: 12px; padding: 10px; }
}
@media (max-width: 640px) {
  .content { padding: 18px 16px 40px; }
  .stat-value { font-size: 18px; }
  .stat-card { padding: 16px 14px 14px; }
  .field-grid,.field-grid.cols-3,.field-grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
  .search-box input { width: 100%; }
  .doc-parties { grid-template-columns: 1fr; }
  .totals { min-width: 0; width: 100%; }
  .wizard { flex-direction: column; }
  .wizard-step { border-right: 0; border-bottom: 1px solid var(--border); }
}

@media print {
  .sidebar,.page-head,.toast-stack { display: none !important; }
  .main { margin: 0; }
  body { background: #fff; }
  .doc-preview { box-shadow: none; border: 0; }
}

/* =========================================================
   PERMISSIONS,USERS & ROLES
   ========================================================= */
/* Controls a role can't use are removed entirely (body gets no-create / no-edit / no-delete). */
.no-create [data-perm~="create"],.no-edit [data-perm~="edit"],.no-delete [data-perm~="delete"] { display: none !important; }
.view-only { height: 30px; padding: 0 10px; gap: 6px; }
.view-only svg { width: 13px; height: 13px; }

.user-cell { display: flex; align-items: center; gap: 11px; min-width: 200px; }
.user-avatar { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 12.5px; flex-shrink: 0; }
.user-cell strong { display: block; font-size: 13.5px; }
.user-cell span { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.you-tag { font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-left: 6px; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; font-weight: 700; color: var(--text-2); }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 38px; height: 22px; border-radius: 99px; background: var(--border-strong); position: relative; transition: background .15s; flex-shrink: 0; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--brand-soft); }

.role-summary { margin-top: 2px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px dashed var(--border-strong); font-size: 12px; color: var(--text-2); }
.role-summary b { color: var(--text); }

/* Role list */
.role-list { display: flex; flex-direction: column; }
.role-item { display: block; width: 100%; text-align: left; padding: 14px 18px; border: 0; border-bottom: 1px solid var(--border); background: transparent; color: var(--text); font-family: inherit; cursor: pointer; position: relative; }
.role-item:last-child { border-bottom: 0; }
.role-item:hover { background: var(--surface-2); }
.role-item.active { background: var(--brand-soft); }
.role-item.active::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.role-item-top { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.role-item-top strong { font-size: 14px; }
.role-item-top .count { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; font: 600 11.5px var(--mono); color: var(--muted); }
.role-item-top .count svg { width: 13px; height: 13px; }
.role-item p { margin: 0; font-size: 12px; color: var(--muted); font-weight: 600; }
.perm-meter { height: 4px; border-radius: 2px; background: var(--surface-3); margin-top: 8px; overflow: hidden; }
.perm-meter span { display: block; height: 100%; background: var(--brand); }

/* Permission grid */
.perm-table th.c,.perm-table td.c { text-align: center; width: 84px; }
.perm-table .grp td { background: var(--surface-2); font-size: 10.5px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--brand); padding: 8px 14px; }
.perm-table td .mod { font-weight: 700; }
.perm-table td .mod-note { display: block; font-size: 11px; color: var(--muted); font-weight: 500; }
.perm-table .col-toggle { display: block; margin: 4px auto 0; border: 0; background: none; color: var(--brand); font: 700 10px var(--font); letter-spacing: .04em; cursor: pointer; text-transform: none; }
.perm-table .col-toggle:hover { text-decoration: underline; }
.perm-table .na { color: var(--border-strong); font-weight: 700; }
.pcheck { position: relative; display: inline-flex; width: 22px; height: 22px; cursor: pointer; }
.pcheck input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.pcheck span { width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--border-strong); background: var(--surface); display: flex; align-items: center; justify-content: center; transition: background .12s, border-color .12s; }
.pcheck span::after { content: ""; width: 10px; height: 6px; border-left: 2.5px solid #fff; border-bottom: 2.5px solid #fff; transform: rotate(-45deg) translate(1px, -1px); opacity: 0; }
.pcheck input:checked + span { background: var(--brand); border-color: var(--brand); }
.pcheck input:checked + span::after { opacity: 1; }
.pcheck input:focus-visible + span { box-shadow: 0 0 0 3px var(--brand-soft); }
.pcheck input:disabled { cursor: not-allowed; }
.pcheck input:disabled + span { opacity: .55; }
.dirty-dot { display: none; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--accent); }
.dirty-dot.show { display: inline-flex; }
.dirty-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.member-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.member-chips span { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 3px; border-radius: 99px; background: var(--surface-3); font-size: 12px; font-weight: 700; }
.member-chips i { width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-style: normal; font-size: 10px; font-weight: 800; display: flex; align-items: center; justify-content: center; }

/* =========================================================
   RESPONSIVE — phones,tablets,touch,large screens
   Breakpoints: ≥1600 wide · ≤1180 laptop/tablet landscape ·
   ≤960 tablet (off-canvas sidebar) · ≤760 small tablet ·
   ≤480 phone. Plus pointer:coarse for touch sizing.
   ========================================================= */
html { -webkit-text-size-adjust: 100%; }
img,canvas,svg { max-width: 100%; }
.table-wrap { -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.segmented { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segmented::-webkit-scrollbar { display: none; }
.segmented button { flex-shrink: 0; }

/* Wide monitors: keep content centred instead of hugging the sidebar. */
@media (min-width: 1600px) {
  .content { margin: 0 auto; }
}

/* Tablets and below: tables scroll sideways rather than squashing columns. */
@media (max-width: 960px) {
  body.nav-open { overflow: hidden; }
  .sidebar { width: min(84vw, 300px); padding-bottom: env(safe-area-inset-bottom); }
  .content { padding: 22px 20px 44px; }
  .page-head { align-items: flex-start; }
  .table-wrap > .table { min-width: 680px; }
  .table-wrap > .table.perm-table { min-width: 520px; }
  .modal.lg { max-width: 100%; }
}

@media (max-width: 760px) {
  .page-head { flex-direction: column; align-items: stretch; gap: 14px; }
  .page-head > .segmented { align-self: flex-start; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; }
  .card-head { align-items: stretch; }
  .card-head > .toolbar,.card-head > .search-box { width: 100%; }
  .toolbar .search-box { flex: 1 1 180px; }
  .toolbar .search-box input { width: 100%; }
  .toolbar .btn,.toolbar .select-sm { flex: 1 1 auto; }
  .card-foot { justify-content: stretch; }
  .card-foot .btn { flex: 1 1 auto; }
  .card-foot > span[style*="flex:1"] { display: none; }
  .grid { gap: 14px; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dt { margin-top: 8px; }

  /* Modals become bottom sheets. */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal,.modal.lg { max-width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .modal-foot { position: sticky; bottom: 0; flex-wrap: wrap; }
  .modal-foot .btn { flex: 1 1 auto; }
  .modal-foot > span[style*="flex:1"] { display: none; }

  .toast-stack { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); }
  .toast { min-width: 0; max-width: none; }
  .view-only span,.view-only { font-size: 0; gap: 0; padding: 0 8px; }
  .view-only svg { width: 15px; height: 15px; }
  .transfer { gap: 10px; }
}

@media (max-width: 480px) {
  .content { padding: 16px 12px 40px; }
  .page-head h2 { font-size: 19px; }
  .page-head p { font-size: 12.5px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-card { padding: 14px 12px 12px; }
  .stat-card::before { left: 12px; }
  .stat-label { font-size: 10px; letter-spacing: .05em; }
  .stat-value { font-size: 16px; }
  .stat-sub { font-size: 11px; }
  .stat-icon { display: none; }
  .card-body { padding: 14px; }
  .card-head { padding: 12px 14px; }
  .table td,.table th { padding: 10px 12px; }
  .platform-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .platform { padding: 10px; font-size: 12.5px; }
  .doc-preview { padding: 16px; }
  .doc-totals { width: 100%; }
  .entry-main { padding: 28px 16px; }
  .entry-title { font-size: 24px; }
  .entry-art { padding: 22px 16px 22px 56px; }
  .entry-art h2 { font-size: 21px; }
  .demo-box { flex-direction: column; align-items: flex-start; }
  .demo-box .chip-btn { margin-left: 0; }
  .state-head { padding: 18px; }
  .state-body { padding: 18px; }
  .ticket-value { font-size: 22px; }
  .perm-table th.c,.perm-table td.c { width: 58px; padding-left: 4px; padding-right: 4px; }
  .dropzone { padding: 24px 14px; }
}

/* Touch screens: bigger hit targets,no keyboard-shortcut hints. */
@media (pointer: coarse) {
  .btn-xs { height: 34px; padding: 0 11px; }
  .btn-sm { height: 38px; }
  .icon-btn { width: 40px; height: 40px; }
  .nav-item { padding: 11px 12px; }
  .pcheck, .pcheck span { width: 26px; height: 26px; }
  .field input, .field select { font-size: 16px; } /* stops iOS zooming into inputs */
  .table input, .table select { height: 38px; font-size: 15px; }
  kbd { display: none; }
}

/* Short landscape phones: let the entry panel and sidebar scroll. */
@media (max-height: 520px) and (orientation: landscape) {
  .entry-art { display: none; }
  .entry { grid-template-columns: 1fr; }
  .sidebar .nav { padding-bottom: 20px; }
}

/* Tables marked .fit-sm become stacked cards on small screens instead of scrolling. */
@media (max-width: 760px) {
  .table-wrap > .table.fit-sm { min-width: 0; }
  .table.fit-sm thead, .table.fit-sm .hide-sm { display: none; }
  .table.fit-sm tbody tr { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 14px; border-bottom: 1px solid var(--border); }
  .table.fit-sm tbody tr:last-child { border-bottom: 0; }
  .table.fit-sm tbody td { display: block; padding: 0; border: 0; }
  .table.fit-sm tbody td:first-child { flex: 1 1 100%; }
  .table.fit-sm tbody td:last-child { flex: 1 1 100%; }
  .table.fit-sm .user-cell { min-width: 0; }
  .table.fit-sm .user-cell > div { min-width: 0; }
  .table.fit-sm .user-cell > div > span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .table.fit-sm .row-actions { justify-content: flex-start; flex-wrap: wrap; }
  .table.fit-sm .empty-state { width: 100%; }
}

/* ---------------- Pagination ---------------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); font-size: 12.5px; color: var(--text-2); }
.pager-info b { color: var(--text); font-family: var(--mono); font-weight: 600; }
.pager-ctrl { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.pager-size { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--muted); }
.pager-size select { height: 30px; padding: 0 6px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); color: var(--text); font: 600 12.5px var(--mono); outline: none; }
.pager-pages { display: flex; align-items: center; gap: 4px; }
.pager-btn { min-width: 30px; height: 30px; padding: 0 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text-2); font: 600 12.5px var(--mono); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.pager-btn svg { width: 14px; height: 14px; }
.pager-btn:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.pager-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; }
:root[data-theme="dark"] .pager-btn.active { color: #052e22; }
.pager-btn:disabled { opacity: .4; cursor: not-allowed; }
.pager-gap { padding: 0 4px; color: var(--muted); }
.modal .pager { border-radius: 0; }
@media (max-width: 760px) {
  .pager { flex-direction: column; align-items: stretch; text-align: center; padding: 12px 14px; }
  .pager-ctrl { justify-content: space-between; }
}
@media (pointer: coarse) {
  .pager-btn { min-width: 36px; height: 36px; }
  .pager-size select { height: 36px; }
}

.field.span-2 { grid-column: span 2; }
.card-body > .section-label { margin: 0 0 14px; }

/* ---------------- Phone: list tables become labelled cards ---------------- */
@media (max-width: 760px) {
  .field.span-2 { grid-column: 1 / -1; }
  .table-wrap > .table.stack-sm { min-width: 0; }
  .table.stack-sm thead { display: none; }
  .table.stack-sm tbody tr { display: block; padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .table.stack-sm tbody tr:last-child { border-bottom: 0; }
  .table.stack-sm tbody td { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 4px 0; border: 0; text-align: right; min-width: 0 !important; max-width: none !important; }
  .table.stack-sm tbody td::before { content: attr(data-label); flex-shrink: 0; font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); text-align: left; }
  .table.stack-sm tbody td[data-label=""] { justify-content: flex-end; }
  .table.stack-sm tbody td[data-label=""]::before { display: none; }
  .table.stack-sm tbody td:first-child { padding-bottom: 8px; margin-bottom: 4px; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
  .table.stack-sm tbody td[colspan] { display: block; border: 0; margin: 0; }
  .table.stack-sm tbody td > div[style*="display:grid"] { flex: 1; max-width: 75%; }
  .table.stack-sm .cell-sub { text-align: right; }
  .table.stack-sm td:first-child .cell-sub { text-align: left; }
  .table.stack-sm tbody td select, .table.stack-sm tbody td input:not([type=checkbox]) { width: 62%; }
  .table.stack-sm .row-actions { justify-content: flex-end; flex-wrap: wrap; }
  .table.stack-sm tfoot, .table.stack-sm tfoot tr { display: block; }
  .table.stack-sm tfoot td { display: flex; justify-content: space-between; border: 0; padding: 4px 14px; }
  .table.stack-sm tfoot td:empty { display: none; }
  .table.stack-sm tfoot td::before { content: attr(data-label); font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
  .table.stack-sm tfoot td[data-label=""]::before { display: none; }
  .table.stack-sm tfoot tr { padding: 8px 0; border-top: 3px double var(--border-strong); background: var(--surface-2); }
}
@media (max-width: 760px) {
  .table:has(#itemBody) { min-width: 0; }
  .table.stack-sm tbody td:first-child[data-label=""] { float: right; border: 0; margin: 0 0 0 10px; padding: 0; }
  .table.stack-sm tbody td:first-child[data-label=""] + td { font-size: 13.5px; }
  .table.stack-sm tbody td .it-name { min-width: 0; }
  #itemBody tr,#jLines tr { background: var(--surface-2); border-radius: 8px; margin: 10px 0; border: 1px solid var(--border) !important; }
}
@media (max-width: 760px) {
  .table.stack-sm tbody td { width: auto !important; }
  .table.stack-sm tbody td select,.table.stack-sm tbody td input:not([type=checkbox]) { width: auto; flex: 0 1 62%; min-width: 0; }
}
@media (max-width: 760px) {
  #itemBody tr,#jLines tr { margin: 10px 14px; }
}

/* Toasts are informational: never let them block clicks on the buttons underneath. */
.toast-stack { pointer-events: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pager-btn.active { color: #052e22; } }

/* ---------------- Profile link & page ---------------- */
.who-link { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 4px 6px; margin: -4px -6px; border-radius: var(--radius-sm); color: inherit; text-decoration: none !important; font-weight: inherit; }
.who-link:hover,.who-link.active { background: var(--surface-3); }
.who-link.active .who strong { color: var(--brand); }
.top-avatar { width: 36px; height: 36px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; text-decoration: none !important; border: 1px solid transparent; }
.top-avatar:hover { border-color: var(--accent); }

.profile-card { text-align: center; overflow: hidden; }
.profile-cover { height: 84px; background-color: var(--brand-deep); background-image: linear-gradient(90deg, transparent 40px, rgba(251, 191, 36, 0.4) 40px, rgba(251, 191, 36, 0.4) 42px, transparent 42px), repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.06) 0 1px, transparent 1px 22px); }
.profile-avatar { width: 84px; height: 84px; margin: -42px auto 10px; border-radius: 18px; border: 4px solid var(--surface); background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 28px; font-weight: 800; position: relative; }
:root .profile-avatar { background-color: #fdf3e2; }
:root[data-theme="dark"] .profile-avatar { background-color: #2a2414; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .profile-avatar { background-color: #2a2414; } }
.profile-card h3 { font-size: 19px; font-weight: 800; }
.profile-card .handle { font-family: var(--mono); color: var(--muted); font-size: 13px; margin-top: 2px; }
.profile-badges { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; margin: 12px 0 4px; }
.profile-facts { list-style: none; margin: 16px 0 0; padding: 0; text-align: left; border-top: 1px solid var(--border); }
.profile-facts li { display: flex; justify-content: space-between; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--border); font-size: 13px; }
.profile-facts li span:first-child { color: var(--muted); font-weight: 700; }
.profile-facts li span:last-child { font-weight: 700; text-align: right; }
.access-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.access-item { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--surface-2); }
.access-item strong { display: block; font-size: 13px; margin-bottom: 6px; }
.access-item.none { opacity: .55; }
.access-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.theme-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.theme-opt { border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 12px; cursor: pointer; background: var(--surface); text-align: left; font: 700 13px var(--font); color: var(--text); display: flex; flex-direction: column; gap: 8px; }
.theme-opt .swatch { height: 40px; border-radius: 6px; border: 1px solid var(--border); }
.theme-opt.active { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); background: var(--brand-soft); }
@media (max-width: 480px) { .theme-options { grid-template-columns: 1fr; } .theme-opt { flex-direction: row; align-items: center; } .theme-opt .swatch { width: 54px; height: 32px; } }

/* =========================================================
   FEBITALLY LAYOUT (base.html) & IMPORT / LEDGERS / SETTINGS
   ========================================================= */
.brand-mark { flex-shrink: 0; }
.sidebar-foot { border-top: 1px solid var(--border); }
.tally-status { display: flex; align-items: center; gap: 9px; padding: 10px 18px; font-size: 12px; font-weight: 700; color: var(--text-2); text-decoration: none !important; border-bottom: 1px solid var(--border); }
.tally-status:hover { background: var(--surface-2); color: var(--text); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--border-strong); flex-shrink: 0; box-shadow: 0 0 0 3px var(--surface-3); animation: pulse 1.6s infinite; }
.dot.ok { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); animation: none; }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); animation: none; }
.sidebar-user { display: flex; align-items: center; gap: 6px; padding: 10px 12px 12px 14px; }

/* No top bar on desktop: the page heading leads (base.html). */
.mobile-bar { display: none; }
.content { padding-top: 22px; }
.page-head h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
@media (max-width: 960px) {
  .mobile-bar { display: flex; position: sticky; top: 0; z-index: 30; height: 56px; padding: 0 12px; align-items: center; justify-content: space-between; gap: 10px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
  .mobile-brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 15px; }
  .mobile-brand .brand-mark { width: 28px; height: 28px; font-size: 14px; border-radius: 7px; }
  .page-head h1 { font-size: 20px; }
}

/* Confirm + response dialogs */
.modal.confirm { max-width: 440px; }
.confirm-body { display: flex; gap: 14px; align-items: flex-start; }
.confirm-body h3 { font-size: 16px; font-weight: 800; margin-bottom: 4px; }
.confirm-body p { margin: 0 0 4px; color: var(--text-2); font-size: 13.5px; }
.confirm-icon { width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 18px; }
.confirm-icon.danger { background: var(--bad-soft); color: var(--bad); }
.btn-danger-solid { background: var(--bad); color: #fff; }
.btn-danger-solid:hover { filter: brightness(.95); }
.console { margin: 0; padding: 14px 16px; border-radius: var(--radius-sm); background: #0f1714; color: #c8f2dd; font: 500 12px/1.55 var(--mono); white-space: pre-wrap; word-break: break-word; max-height: 60vh; overflow: auto; border: 1px solid #1f2d27; }
.small { font-size: 12px; }
.help { font-size: 11.5px; color: var(--muted); margin-top: 4px; line-height: 1.45; }
.help code,.small code { font-family: var(--mono); background: var(--surface-3); padding: 1px 5px; border-radius: 4px; font-size: 11px; }
.format-chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); font: 700 11px var(--mono); letter-spacing: .06em; text-decoration: none !important; }
.row { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.row > .field { flex: 1 1 200px; }
.row-top { align-items: flex-start; }
.spacer { flex: 1; }

/* Alerts */
.alert { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 11px 14px; border-radius: var(--radius-sm); border-left: 3px solid; font-size: 13px; font-weight: 600; line-height: 1.5; }
.alert-error { background: var(--bad-soft); color: var(--bad); border-color: var(--bad); }
.alert-warning { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.alert-info { background: var(--info-soft); color: var(--info); border-color: var(--info); }
.alert-success { background: var(--good-soft); color: var(--good); border-color: var(--good); }
.alert .btn { margin-left: auto; flex-shrink: 0; }

/* Steps (import) */
.steps { display: flex; margin-bottom: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.step { flex: 1; display: flex; align-items: center; gap: 10px; padding: 12px 16px; color: var(--muted); font-weight: 700; font-size: 13px; border-right: 1px solid var(--border); position: relative; }
.step:last-child { border-right: 0; }
.step .n { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border-strong); display: flex; align-items: center; justify-content: center; font: 600 11px var(--mono); flex-shrink: 0; }
.step.active { color: var(--text); background: var(--brand-soft); }
.step.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--accent); }
.step.active .n { border-color: var(--brand); background: var(--brand); color: #fff; }
.step.done { color: var(--brand); }
.step.done .n { border-color: var(--brand); color: var(--brand); }

/* Filter pills,chips,bulk bar */
.filters { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 3px; background: var(--surface-3); border-radius: 9px; }
.filters button { border: 0; background: transparent; padding: 6px 11px; border-radius: 7px; font: 700 12.5px var(--font); color: var(--text-2); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.filters button .c { font: 600 11px var(--mono); color: var(--muted); }
.filters button.active { background: var(--surface); color: var(--brand); box-shadow: var(--shadow-sm); }
.filters button.active .c { color: var(--brand); }
.count-pill { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--brand); color: #fff; font: 700 10.5px var(--mono); display: inline-flex; align-items: center; justify-content: center; }
.filter-panel { padding: 14px; margin-bottom: 14px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-2); }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.filter-grid input,.filter-grid select { height: 36px !important; font-size: 13px !important; }
.range { display: flex; align-items: center; gap: 6px; }
.range input { min-width: 0; }
.bulk-bar,.filter-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 9px 12px; margin-bottom: 12px; border-radius: var(--radius-sm); font-size: 13px; }
.bulk-bar { background: var(--brand-deep); color: #d1fae5; }
.bulk-bar .btn { background: rgba(255, 255, 255, .1); color: #fff; border-color: rgba(255, 255, 255, .2); }
.bulk-bar .btn:hover { background: rgba(255, 255, 255, .2); }
.bulk-count { font-weight: 800; color: #fbbf24; margin-right: 4px; }
.filter-bar { background: var(--info-soft); color: var(--text-2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 4px 0 10px; border-radius: 99px; background: var(--surface); border: 1px solid var(--border-strong); font-size: 12px; font-weight: 700; }
.chip button { width: 18px; height: 18px; border-radius: 50%; border: 0; background: var(--surface-3); color: var(--text-2); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; line-height: 1; }
.chip button:hover { background: var(--bad-soft); color: var(--bad); }

/* Results area with loading overlay */
.has-overlay { position: relative; }
.loading-overlay { position: absolute; inset: 0; z-index: 6; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--surface) 75%, transparent); }
.loading-box { text-align: center; padding: 18px 22px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.spinner { width: 34px; height: 34px; margin: 0 auto 10px; border-radius: 50%; border: 3px solid var(--brand-soft); border-top-color: var(--brand); animation: spin .8s linear infinite; }
.loading-title { font-weight: 800; font-size: 14px; }
.results-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); font-size: 13px; }
.results-foot .sum b { font-family: var(--mono); font-weight: 600; }
.results-foot .sum > span + span { margin-left: 14px; }
kbd { display: inline-block; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--border-strong); border-bottom-width: 2px; background: var(--surface); font: 600 10.5px var(--mono); color: var(--text-2); }

/* Entry table bits */
.entry-ledger { min-width: 210px; }
.entry-ledger input { height: 32px !important; }
.entry-ledger.missing input { border-color: var(--warn) !important; background: var(--warn-soft) !important; }
.entry-ledger .miss { display: block; margin-top: 3px; font-size: 11px; font-weight: 700; color: var(--warn); }
.entry-narr { cursor: pointer; border-bottom: 1px dashed transparent; }
.entry-narr:hover { border-bottom-color: var(--brand); color: var(--brand); }
.row-error { font-size: 11.5px; color: var(--bad); font-weight: 600; margin-top: 3px; max-width: 260px; }
tr.is-pushed td,tr.is-skipped td { color: var(--muted); }
tr.is-skipped .entry-narr { text-decoration: line-through; }
.status-pending { background: var(--warn-soft); color: var(--warn); }
.status-validated { background: var(--info-soft); color: var(--info); }
.status-failed { background: var(--bad-soft); color: var(--bad); }
.status-pushed { background: var(--good-soft); color: var(--good); }
.status-skipped { background: var(--surface-3); color: var(--text-2); }

/* Mapping modal */
.modal.xwide { max-width: 1100px; }
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin: 10px 0 18px; }
.map-table { max-height: 260px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.map-table table { width: 100%; border-collapse: collapse; font-size: 12px; }
.map-table th,.map-table td { padding: 6px 9px; border-bottom: 1px solid var(--border); white-space: nowrap; text-align: left; }
.map-table th { position: sticky; top: 0; background: var(--surface-2); font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.map-table td.rn { color: var(--muted); font-family: var(--mono); width: 40px; }
.map-table tr.header-row td { background: var(--accent-soft); font-weight: 800; }
.map-table tr.above td { color: var(--muted); }
#map-raw tbody tr { cursor: pointer; }
#map-raw tbody tr:hover td { background: var(--surface-2); }
.map-table .num { text-align: right; font-family: var(--mono); }
.section-title { font-size: 13px; font-weight: 800; margin: 16px 0 8px; display: flex; align-items: center; gap: 8px; }

/* Progress */
.prog-stage { font-weight: 700; margin-bottom: 10px; }
.prog-track { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-bottom: 8px; }
.prog-bar { height: 100%; width: 0; background: var(--brand); border-radius: 99px; transition: width .2s; }
.prog-bar.indeterminate { width: 35%; animation: indet 1.1s ease-in-out infinite; }
@keyframes indet { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }

/* Bank modal facts,choice list,misc */
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; padding: 12px 14px; margin: 0 0 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; }
.facts dt { color: var(--muted); font-weight: 700; }
.facts dd { margin: 0; font-weight: 700; word-break: break-word; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; color: var(--text-2); cursor: pointer; }
.check input { width: 15px; height: 15px; accent-color: var(--brand); }
.choice-list { display: grid; gap: 8px; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 11px 13px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); cursor: pointer; }
.choice:hover { border-color: var(--brand); }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.choice input { margin-top: 3px; accent-color: var(--brand); }
.choice b { display: block; font-size: 13.5px; }
.choice .muted { display: block; margin-top: 2px; }
.input-group { display: flex; gap: 8px; }
.input-group input { flex: 1; min-width: 0; height: 42px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: 600 13.5px var(--font); outline: none; }
.input-group input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.dropzone.disabled { opacity: .5; pointer-events: none; }
.file-chosen { display: inline-flex; align-items: center; gap: 8px; margin-top: 10px; padding: 5px 12px; border-radius: 99px; background: var(--good-soft); color: var(--good); font-weight: 700; font-size: 12.5px; }

/* Sortable table headers */
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--text); }
.table th.sortable::after { content: "\2195"; margin-left: 5px; opacity: .35; }
.table th.sortable.asc::after { content: "\2191"; opacity: 1; color: var(--brand); }
.table th.sortable.desc::after { content: "\2193"; opacity: 1; color: var(--brand); }

/* Settings */
.steps-list { padding-left: 18px; margin: 0; line-height: 1.75; font-size: 13px; color: var(--text-2); }
.steps-list b { color: var(--text); }
textarea.code { font: 500 12px/1.5 var(--mono) !important; }

@media (max-width: 760px) {
  .steps { flex-direction: column; }
  .step { border-right: 0; border-bottom: 1px solid var(--border); }
  .facts { grid-template-columns: 1fr; gap: 2px; }
  .facts dt { margin-top: 6px; }
  .bulk-bar .btn,.filter-bar .btn { flex: 1 1 auto; }
  .results-foot .kbd-hint { display: none; }
  .entry-ledger { min-width: 0; flex: 0 1 62%; }
  .modal.xwide { max-width: 100%; }
}

/* Card titles and dashboard grids (dashboard.html / ledgers.html / settings.html) */
.h2 { font-size: 15px; font-weight: 800; margin: 0; }
.h2 .muted { font-weight: 600; font-size: 13px; }
.card-head > a { font-size: 12.5px; font-weight: 700; }
.stat-grid.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid.two-col { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); align-items: start; }
tr.clickable { cursor: pointer; }
.page-head { align-items: center; }
@media (max-width: 1180px) {
  .stat-grid.cols-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat-grid.cols-5 .stat-card { border-bottom: 1px solid var(--border); }
  .stat-grid.cols-5 .stat-card:nth-child(2) { border-right: 1px solid var(--border); }
  .stat-grid.cols-5 .stat-card:nth-child(3n) { border-right: 0; }
  .grid.two-col { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .stat-grid.cols-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-grid.cols-5 .stat-card:nth-child(3n) { border-right: 1px solid var(--border); }
  .stat-grid.cols-5 .stat-card:nth-child(2n) { border-right: 0; }
  .page-head { align-items: stretch; }
}

/* Dashboard tables stack on laptops,sit side by side on wide screens. */
.grid.two-col.dash-grid { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1500px) { .grid.two-col.dash-grid { grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr); } }
/* Import review table: keep the wide columns in check. */
.narr-cell { min-width: 170px; max-width: 260px; }
.status-cell { white-space: nowrap; }
.status-cell .row-error { white-space: normal; min-width: 180px; }
.entry-ledger { min-width: 180px; }
.vtype-select { min-width: 104px; }
.table.compact th,.table.compact td { padding-left: 8px; padding-right: 8px; }
.table.compact th:first-child,.table.compact td:first-child { padding-left: 16px; }
.table.compact .status-cell .cell-sub { font-size: 10.5px; }
.table.compact .narr-cell { min-width: 160px; max-width: 230px; }
.status-cell { white-space: normal; min-width: 110px; }
.status-cell .badge { white-space: nowrap; }
.status-cell .row-error { min-width: 0; max-width: 170px; font-size: 11px; }
.status-cell .cell-sub { white-space: nowrap; }
.ref-sub { display: none; }
@media (max-width: 1499px) {
  .table.compact .ref-col { display: none; }
  .table.compact .ref-sub { display: block; }
}
@media (max-width: 760px) { .table.compact .ref-sub { display: none; } .table.compact td.ref-col { display: flex; } }
