:root {
  /* Red Line: black navigation, white pages, red for the one action that matters */
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f6f6f6;
  --border: #e5e5e5;
  --text: #111111;
  --muted: #5c5c5c;
  --primary: #d0021b;      /* red that reads on white (5.6:1) */
  --primary-2: #9a0114;
  --primary-soft: #fff1f2;
  --accent: #e30613;       /* brand red: bars, underlines, the logo */
  --ink: #111111;          /* black bars, table heads */
  --ink-2: #222222;
  --ink-text: #c9c9c9;
  --ok: #15803d;      --ok-soft: #dcfce7;
  --warn: #b45309;    --warn-soft: #fef3c7;
  --danger: #c8102e;  --danger-soft: #ffe4e6;
  --info: #3f3f46;    --info-soft: #f1f1f2;
  --neutral-soft: #f0f0f0;
  --radius: 4px;
  --shadow: none;
  --font: "Inter", "Noto Sans Lao", "Phetsarath OT", "Saysettha OT", "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0c0e; --surface: #17171a; --surface-2: #1e1e22; --border: #2a2a2f; --text: #f4f4f5; --muted: #a1a1aa;
    --primary: #ff5a5f; --primary-2: #ff8a8e; --primary-soft: #2a0b0d; --ink: #000000; --ink-2: #17171a;
    --ok-soft: #0f2e1d; --warn-soft: #33250b; --danger-soft: #3a1414; --info-soft: #232327; --neutral-soft: #232327;
    --ok: #4ade80; --warn: #fbbf24; --danger: #ff5a5f; --info: #d4d4d8;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c0c0e; --surface: #17171a; --surface-2: #1e1e22; --border: #2a2a2f; --text: #f4f4f5; --muted: #a1a1aa;
  --primary: #ff5a5f; --primary-2: #ff8a8e; --primary-soft: #2a0b0d; --ink: #000000; --ink-2: #17171a;
  --ok-soft: #0f2e1d; --warn-soft: #33250b; --danger-soft: #3a1414; --info-soft: #232327; --neutral-soft: #232327;
  --ok: #4ade80; --warn: #fbbf24; --danger: #ff5a5f; --info: #d4d4d8;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 14px; line-height: 1.55; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }

/* ---------- layout ---------- */
.layout { min-height: 100vh; display: flex; flex-direction: column; }
.appbar { background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 40; }
.appbar-top { display: flex; align-items: center; gap: 14px; padding: 0 28px; min-height: 56px; border-bottom: 1px solid #2a2a2a; }
.appbar-top .spacer { flex: 1; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-bar { width: 6px; height: 26px; background: var(--accent); }
.brand b { font-size: 16px; font-weight: 800; letter-spacing: .5px; }
.menu-btn { display: none; border: 0; background: none; color: #fff; padding: 8px; margin-left: -8px; cursor: pointer; min-height: 44px; }
.menu-btn svg { width: 22px; height: 22px; }
.appbar-nav { padding: 0 20px; }
.topnav { display: flex; flex-wrap: wrap; }
.nav-item > a, .nav-grp-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 48px; padding: 0 14px; color: var(--ink-text); font: inherit; font-size: 14px; font-weight: 600; background: none; border: 0; cursor: pointer; white-space: nowrap; }
.nav-item > a svg { display: none; }
.nav-item > a:hover, .nav-grp-btn:hover, .nav-grp:focus-within .nav-grp-btn { color: #fff; text-decoration: none; }
.nav-item > a.active, .nav-grp.active .nav-grp-btn { color: #fff; box-shadow: inset 0 -3px 0 var(--accent); }
.caret { font-size: 10px; opacity: .7; }
.nav-grp { position: relative; }
.nav-menu { display: none; position: absolute; left: 0; top: 100%; min-width: 250px; background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--accent); box-shadow: 0 16px 40px rgba(0,0,0,.18); padding: 6px 0; z-index: 60; }
.nav-grp:hover .nav-menu, .nav-grp:focus-within .nav-menu { display: block; }
.nav-grp.shut .nav-menu { display: none; }
.nav-menu a { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 0 16px; color: var(--text); font-weight: 500; }
.nav-menu a svg { width: 17px; height: 17px; color: var(--muted); flex: none; }
.nav-menu a:hover { background: var(--surface-2); text-decoration: none; }
.nav-menu a.active { color: var(--primary); font-weight: 700; box-shadow: inset 3px 0 0 var(--accent); }
.nav-menu a.active svg { color: var(--primary); }
.content { padding: 28px 28px 64px; max-width: 1400px; width: 100%; margin: 0 auto; }
.branch-pick { display: flex; align-items: center; gap: 6px; color: var(--ink-text); font-size: 13px; }
.branch-pick svg { width: 16px; height: 16px; }
.branch-pick select { background: var(--ink-2); color: #fff; border-color: #3a3a3a; min-height: 36px; }
.branch-pick select { min-width: 180px; }
.rates-chip { font-size: 12.5px; color: var(--ink-text); border: 1px solid #3a3a3a; border-radius: 2px; padding: 3px 10px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rates-chip:hover { text-decoration: none; color: #fff; border-color: #5a5a5a; }
.cur-badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 0 6px; border-radius: 4px; background: var(--info-soft); color: var(--info); margin-left: 4px; vertical-align: 1px; }
.in-qty { color: var(--ok); font-weight: 700; }
.out-qty { color: var(--warn); font-weight: 700; }
.user-chip {display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 2px; border: 1px solid #3a3a3a; background: var(--ink-2); color: #fff; cursor: pointer; }
.avatar { width: 28px; height: 28px; border-radius: 2px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 13px; }
.user-chip small { color: var(--ink-text); display: block; font-size: 11px; line-height: 1.1; }
.dropdown { position: relative; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 200px; padding: 6px; z-index: 50; }
.dropdown-menu button { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: none; border-radius: 6px; color: var(--text); font: inherit; cursor: pointer; }
.dropdown-menu button:hover { background: var(--surface-2); }

/* ---------- page ---------- */
.page-head { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head { padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.page-head h1 { font-size: 26px; font-weight: 800; letter-spacing: -.2px; }
.page-head .sub { color: var(--muted); margin-top: 2px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.back { color: var(--muted); font-size: 13px; display: inline-block; margin-bottom: 4px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 15px; font-weight: 800; }
.card-head .actions { margin-left: auto; display: flex; gap: 6px; }
.card-body { padding: 16px; }
.card + .card, .stack > * + * { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-detail { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); align-items: start; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .search { flex: 1; min-width: 200px; max-width: 360px; }
.toolbar .right { margin-left: auto; display: flex; gap: 8px; }

/* ---------- KPI ---------- */
.kpi { padding: 16px 18px; border-top: 3px solid var(--ink); }
.kpi.tone-danger { border-top-color: var(--accent); background: var(--primary-soft); }
.kpi .label { color: var(--muted); font-size: 12.5px; }
.kpi .value { font-size: 24px; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.kpi.tone-warn .value { color: var(--warn); }
.kpi.tone-danger .value { color: var(--danger); }
.kpi.tone-ok .value { color: var(--ok); }

/* ---------- buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; min-height: 38px; border-radius: 2px; border: 1.5px solid var(--text); background: var(--surface); color: var(--text); font: inherit; font-weight: 700; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--primary-2); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ok { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.ok:hover { background: #333; }
.btn.sm { padding: 4px 10px; min-height: 30px; font-size: 13px; border-width: 1px; }
.btn.ghost { border-color: transparent; }
.btn.ghost { border-color: transparent; background: none; }
.btn svg { width: 16px; height: 16px; }

input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--primary) 35%, transparent); border-color: var(--primary); }
input[type=checkbox] { width: auto; }
textarea { min-height: 70px; resize: vertical; }
.num, input.money { text-align: right; font-variant-numeric: tabular-nums; }

.form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 4px; grid-column: span 2; min-width: 0; }
.field.s1 { grid-column: span 1; } .field.s3 { grid-column: span 3; } .field.s4 { grid-column: 1 / -1; }
.field > label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.field > label .req { color: var(--danger); }
.field .help { font-size: 12px; color: var(--muted); }
.field.check { flex-direction: row; align-items: center; gap: 8px; padding-top: 22px; }
.field.check > label { color: var(--text); font-size: 14px; }
.form-error { grid-column: 1 / -1; background: var(--danger-soft); color: var(--danger); padding: 8px 12px; border-radius: 8px; }
.form-section { grid-column: 1 / -1; font-weight: 600; padding-top: 6px; border-top: 1px dashed var(--border); margin-top: 4px; }

/* lookup */
.lookup { position: relative; }
.lookup-list { position: absolute; left: 0; right: 0; top: calc(100% + 2px); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); max-height: 280px; overflow-y: auto; z-index: 70; }
.lookup-list div { padding: 7px 10px; cursor: pointer; border-bottom: 1px solid var(--border); }
.lookup-list div:last-child { border-bottom: 0; }
.lookup-list div:hover, .lookup-list div.hl { background: var(--primary-soft); }
.lookup-list small { display: block; color: var(--muted); }
.lookup-list .empty { color: var(--muted); cursor: default; }
.lookup-selected { display: flex; align-items: center; justify-content: space-between; gap: 8px; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; background: var(--surface-2); min-height: 36px; }
.lookup-selected small { color: var(--muted); }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: 12px; font-weight: 700; color: #fff; background: var(--ink); white-space: nowrap; position: sticky; top: 0; }
.table td.r, .table th.r { text-align: right; font-variant-numeric: tabular-nums; }
.table td.c, .table th.c { text-align: center; }
.table tbody tr.click { cursor: pointer; }
.table tbody tr.click:hover { background: var(--surface-2); }
.table tfoot td { font-weight: 700; background: var(--surface-2); }
.table .muted, .muted { color: var(--muted); }
.table small { color: var(--muted); display: block; font-size: 12px; }
.empty-state { padding: 36px 16px; text-align: center; color: var(--muted); }
.pager { display: flex; align-items: center; gap: 8px; justify-content: flex-end; padding: 10px 12px; color: var(--muted); }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 2px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--neutral-soft); color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.primary { background: var(--primary-soft); color: var(--primary); }

/* ---------- detail list ---------- */
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; font-variant-numeric: tabular-nums; }
.totals .grand { font-size: 17px; font-weight: 700; border-top: 1px solid var(--border); padding-top: 6px; }
.totals div:nth-child(even) { text-align: right; }
.steps { display: flex; gap: 4px; flex-wrap: wrap; margin: 4px 0 16px; }
.steps span { padding: 5px 12px; border-radius: 2px; background: var(--neutral-soft); color: var(--muted); font-size: 12.5px; font-weight: 500; }
.steps span.done { background: var(--neutral-soft); color: var(--text); }
.steps span.cur { background: var(--ink); color: #fff; box-shadow: inset 0 -3px 0 var(--accent); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.tabs button { border: 0; background: none; font: inherit; padding: 9px 14px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; }
.tabs button.active { color: var(--text); font-weight: 800; border-bottom: 3px solid var(--accent); }

/* ---------- chart ---------- */
.bars { display: flex; align-items: flex-end; gap: 14px; height: 190px; padding: 10px 4px 0; }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .pair { display: flex; gap: 4px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.bars .bar { width: 40%; max-width: 26px; border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.bars .bar.s1 { background: var(--text); }
.bars .bar.s2 { background: var(--accent); }
.bars .lbl { font-size: 11.5px; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.hbar { display: grid; grid-template-columns: 160px 1fr auto; gap: 10px; align-items: center; padding: 4px 0; }
.hbar .track { background: var(--neutral-soft); border-radius: 4px; height: 10px; overflow: hidden; }
.hbar .fill { background: var(--text); height: 100%; border-radius: 0; }
.hbar .lab { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(2, 8, 23, .5); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 100; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 4px; border-top: 4px solid var(--accent); width: 100%; max-width: 640px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.lg { max-width: 920px; }
.modal.sm { max-width: 440px; }
.modal-head { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 17px; font-weight: 800; }
.modal-head .x { margin-left: auto; border: 0; background: none; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; }
.modal-body { padding: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 4px 4px; }

/* ---------- toast ---------- */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); max-width: 380px; animation: tin .2s ease-out; }
.toast.error { background: var(--danger); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--ink); }
.login .card { border-top: 4px solid var(--accent); }
.login .card { width: 100%; max-width: 380px; padding: 28px; }
.login .brand { color: var(--text); padding: 0 0 18px; }
.login .brand small { color: var(--muted); }
.login form { display: grid; gap: 12px; }
.login label { font-size: 13px; color: var(--muted); display: grid; gap: 4px; }

.alert { padding: 10px 14px; border-radius: 2px; background: var(--warn-soft); color: var(--warn); margin-bottom: 14px; }
.alert.info { background: var(--info-soft); color: var(--info); }
.alert.danger { background: var(--danger-soft); color: var(--danger); }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { border: 1px solid var(--border); background: var(--surface); padding: 5px 12px; border-radius: 2px; font: inherit; font-size: 13px; cursor: pointer; color: var(--muted); }
.chips button.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.text-ok { color: var(--ok); } .text-danger { color: var(--danger); } .text-warn { color: var(--warn); }
.strong { font-weight: 700; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 16px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-detail { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .appbar-top { padding: 0 16px; gap: 10px; }
  .menu-btn { display: inline-flex; }
  .brand b { font-size: 14px; }
  .appbar-nav { display: none; max-height: calc(100vh - 56px); overflow-y: auto; padding: 8px 0 16px; }
  .layout.nav-open .appbar-nav { display: block; }
  .topnav { flex-direction: column; }
  .nav-item > a, .nav-grp-btn { width: 100%; padding: 0 20px; }
  .nav-grp-btn { color: #8a8a8a; font-size: 12px; min-height: 36px; margin-top: 6px; pointer-events: none; }
  .nav-grp-btn .caret { display: none; }
  .nav-menu, .nav-grp.shut .nav-menu { display: block; position: static; min-width: 0; background: none; border: 0; box-shadow: none; padding: 0; }
  .nav-menu a { color: #e5e5e5; padding: 0 28px; }
  .nav-menu a svg { color: #8a8a8a; }
  .nav-menu a:hover { background: #1f1f1f; }
  .nav-menu a.active { color: #fff; background: #1f1f1f; }
  .nav-item > a.active, .nav-grp.active .nav-grp-btn { box-shadow: none; }
  .content { padding: 16px 16px 60px; }
  .page-head h1 { font-size: 22px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field, .field.s3 { grid-column: 1 / -1; }
  .branch-pick span, .user-chip .who { display: none; }
  .branch-pick select { min-width: 0; max-width: 150px; }
  .hbar { grid-template-columns: 100px 1fr auto; }
}
@media (max-width: 480px) {
  .g4 { grid-template-columns: 1fr 1fr; }
  .kpi .value { font-size: 18px; }
}

@media (max-width: 600px) {
  .rates-chip { display: none; }
  /* phone top bar: one line — short brand, warning as an icon, narrow branch picker */
  .brand b { max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .appbar-top .badge { max-width: 30px; overflow: hidden; white-space: nowrap; padding: 2px 6px; }
  .branch-pick > svg { display: none; }
  .branch-pick select { max-width: 110px; min-width: 0; }
  .user-chip { padding: 2px; }
}

/* ---------- attached documents ---------- */
.doc-list { display: grid; gap: 2px; }
.doc-row { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: start; padding: 8px 0; border-bottom: 1px solid var(--border); }
.doc-row:last-of-type { border-bottom: 0; }
.doc-status { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: var(--neutral-soft); color: var(--muted); }
.doc-status.ok { background: var(--ok-soft); color: var(--ok); }
.doc-status.missing { background: var(--warn-soft); color: var(--warn); }
.doc-main { min-width: 0; }
.doc-file { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; margin-top: 3px; }
.doc-file a { overflow-wrap: anywhere; }
.doc-file small { color: var(--muted); }

/* ---------- journal entries ---------- */
.je { border-bottom: 1px solid var(--border); padding: 10px 14px; }
.je-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 4px; }
.je-memo { flex: 1; min-width: 180px; }
.je-lines td { padding: 4px 12px; border-bottom: 0; font-size: 13px; }

/* ---------- bank reconciliation ---------- */
.bank-card { cursor: pointer; }
.bank-card.sel { outline: 2px solid var(--primary); }
.rec-grid .table tbody tr.sel { background: var(--primary-soft); }
.rec-grid .table tbody tr.hint { background: var(--ok-soft); }

/* payroll run grid: many numeric columns */
.payroll-grid .table th, .payroll-grid .table td { padding: 7px 8px; font-size: 13px; }
.payroll-grid .table td { white-space: nowrap; }
.payroll-grid .table td:first-child { min-width: 180px; }
.payroll-grid .table td input { width: 96px; padding: 5px 7px; text-align: right; }
.payroll-grid .table td small { display: block; max-width: 160px; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }

/* ---------- time & attendance ---------- */
.btn.lg { padding: 12px 28px; font-size: 17px; font-weight: 600; border-radius: 10px; }
.chk-row { display: flex; flex-wrap: wrap; gap: 6px 16px; padding-top: 4px; }
.chk-inline { display: inline-flex; align-items: center; gap: 4px; font-weight: 400; cursor: pointer; }
.tc-top { grid-template-columns: minmax(280px, 380px) 1fr; align-items: start; }
.tc-punch { padding: 20px; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.tc-clock { font-size: 44px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 1px; line-height: 1.1; }
.tc-times { display: flex; gap: 12px; width: 100%; }
.tc-time { flex: 1; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px; display: flex; flex-direction: column; }
.tc-time small { color: var(--muted); }
.tc-time b { font-size: 22px; font-variant-numeric: tabular-nums; }
.tc-actions { display: flex; gap: 10px; justify-content: center; }
.ts-grid .table th, .ts-grid .table td { padding: 5px 4px; font-size: 12px; }
.ts-grid .table td:first-child { min-width: 150px; white-space: nowrap; padding-left: 10px; }
.ts-grid .table td small, .ts-grid .table th small { display: block; color: var(--muted); font-weight: 400; }
.ts-grid th.ts-off { background: var(--neutral-soft); }
.ts-cell { display: inline-block; min-width: 20px; text-align: center; font-weight: 700; border-radius: 4px; }
td.ts-cell { display: table-cell; }
td.ts-cell.click { cursor: pointer; }
td.ts-cell.click:hover { outline: 2px solid var(--primary); outline-offset: -2px; }
.ts-cell sup { color: var(--primary); font-size: 10px; }
.st-present { color: var(--ok); } .st-late { color: var(--warn); background: var(--warn-soft); }
.st-absent, .st-missing_out { color: var(--danger); background: var(--danger-soft); }
.st-leave { color: var(--info); background: var(--info-soft); } .st-off, .st-na, .st-upcoming { color: var(--muted); }
.st-off_work { color: var(--primary); background: var(--primary-soft); } .st-not_in { color: var(--warn); }
.ts-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0 0 10px; font-size: 12px; }
@media (max-width: 900px) { .tc-top { grid-template-columns: 1fr; } }

/* kiosk: full-screen clock-in station */
body.kiosk-mode .appbar { display: none; }
body.kiosk-mode .content { max-width: none; }
.kiosk { max-width: 520px; margin: 0 auto; text-align: center; display: flex; flex-direction: column; gap: 14px; }
.kiosk-head { display: flex; justify-content: space-between; align-items: center; text-align: left; }
.kiosk-date { color: var(--muted); font-size: 18px; margin-top: 10px; }
.kiosk-clock { font-size: 72px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.kiosk-form { display: flex; flex-direction: column; gap: 10px; }
.kiosk-input { font-size: 26px; text-align: center; padding: 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); letter-spacing: 2px; }
.kiosk-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kiosk-key { font: inherit; font-size: 26px; font-weight: 600; padding: 14px 0; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.kiosk-key:active { background: var(--primary-soft); }
.kiosk-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kiosk-actions .btn { justify-content: center; padding: 18px; font-size: 22px; }
.kiosk-msg { padding: 16px; border-radius: 12px; font-size: 18px; }
.kiosk-msg.ok { background: var(--ok-soft); color: var(--ok); }
.kiosk-msg.danger { background: var(--danger-soft); color: var(--danger); }
.kiosk-msg .big { font-size: 30px; font-weight: 700; }
.kiosk-msg .warn { color: var(--warn); font-weight: 600; }
.kiosk-input.active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

/* monthly attendance report */
.att-chart { display: flex; gap: 3px; align-items: stretch; height: 170px; padding: 4px 0; overflow-x: auto; }
.att-day { flex: 1 0 18px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.att-day.off { background: var(--neutral-soft); border-radius: 4px; }
.att-day small { font-size: 10px; color: var(--muted); }
.att-bars { flex: 1; width: 100%; display: flex; flex-direction: column-reverse; }
.att-bars .seg:first-child { border-radius: 0 0 3px 3px; }
.seg.ontime { background: var(--ok); } .seg.late { background: var(--warn); } .seg.absent { background: var(--danger); }
.seg.leave { background: var(--info); } .seg.offwork { background: var(--primary); }
.att-key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: -1px; }
ol.rank { margin: 0; padding-left: 20px; } ol.rank li { padding: 4px 0; } ol.rank li > span { display: inline-block; min-width: 55%; }
.chips-static { display: flex; flex-wrap: wrap; gap: 6px; }
.steps-list { margin: 0 0 8px; padding-left: 20px; line-height: 1.9; } .steps-list code { font-size: 12px; background: var(--neutral-soft); padding: 1px 5px; border-radius: 4px; }

/* setup wizard & go-live checklist */
.login .card.wz { max-width: 720px; }
.wz-steps { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.wz-steps .cur { color: var(--primary); font-weight: 700; } .wz-steps .done { color: var(--ok); }
.wz-body { display: grid; gap: 12px; }
.wz-body label { font-size: 13px; color: var(--muted); display: grid; gap: 4px; }
.wz-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; }
.wz-branch { border: 1px solid var(--border); border-radius: 8px; padding: 10px; display: grid; gap: 8px; margin-bottom: 8px; }
.wz-actions-inline { display: flex; gap: 6px; align-items: center; }
.wz-nav { display: flex; justify-content: space-between; margin-top: 16px; }
.golive-head { display: flex; justify-content: space-between; margin-bottom: 8px; }
.golive-bar { height: 8px; background: var(--neutral-soft); border-radius: 99px; overflow: hidden; }
.golive-bar > div { height: 100%; background: var(--ok); }
ul.golive { list-style: none; margin: 0; padding: 0; }
ul.golive li { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--border); }
ul.golive li:last-child { border-bottom: 0; }
ul.golive .tick { font-weight: 700; color: var(--danger); text-align: center; }
ul.golive li.done .tick { color: var(--ok); }
ul.golive small { display: block; color: var(--muted); }
ul.golive .badge { margin-left: 6px; }
.imp-sum { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.imp-go { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 6px; }

/* user manuals */
.manual-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.manual-tile { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; text-decoration: none; color: var(--text); border: 1px solid var(--border); }
.manual-tile small { color: var(--muted); }
.manual-tile.primary { border-color: var(--primary); background: var(--primary-soft); }
.manual-tile:hover { border-color: var(--primary); }
.manual-wrap { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; align-items: start; }
.manual-toc { position: sticky; top: 70px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; max-height: calc(100vh - 90px); overflow: auto; }
.manual-toc a { color: var(--text); text-decoration: none; } .manual-toc a:hover { color: var(--primary); }
.manual { padding: 22px 28px; line-height: 1.85; font-size: 15px; max-width: 880px; }
.manual h1 { font-size: 24px; color: var(--primary); margin: 0 0 10px; }
.manual h2 { font-size: 19px; margin: 28px 0 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.manual h3 { font-size: 16px; margin: 18px 0 6px; }
.manual img { max-width: 100%; border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); }
.manual figure { margin: 14px 0; } .manual figcaption { font-size: 12px; color: var(--muted); text-align: center; margin-top: 4px; }
.manual blockquote { margin: 12px 0; padding: 10px 14px; border-left: 4px solid var(--info); background: var(--info-soft); border-radius: 0 8px 8px 0; }
.manual blockquote.warn { border-color: var(--warn); background: var(--warn-soft); }
.manual li.task { list-style: none; margin-left: -1.1em; }
.manual code { background: var(--neutral-soft); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.manual pre { background: var(--neutral-soft); padding: 10px 12px; border-radius: 8px; overflow-x: auto; }
.manual pre code { background: none; padding: 0; }
@media (max-width: 900px) { .manual-wrap { grid-template-columns: 1fr; } .manual-toc { display: none; } .manual { padding: 16px; font-size: 15px; } }
.filter-row { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.alert-preview { white-space: pre-wrap; font-family: inherit; margin: 0; line-height: 1.7; } .pre-line { white-space: pre-line; }

/* training system (TRAINING=1): always-visible ribbon so practice data is never mistaken for real data */
.training-ribbon { position: fixed; top: 0; left: 50%; transform: translateX(-50%); z-index: 9999; pointer-events: none;
  background: #b45309; color: #fff; font-weight: 700; font-size: 13px; padding: 3px 14px; border-radius: 0 0 10px 10px; box-shadow: 0 2px 8px rgba(0,0,0,.25); white-space: nowrap; }
body.training-mode .appbar { border-top: 4px solid #b45309; }
@media print { .training-ribbon { display: none; } }

/* photos (vehicles, parts) and payment slips */
.photo-strip { display: flex; flex-wrap: wrap; gap: 10px; }
.photo-strip .photo { position: relative; width: 112px; height: 84px; border-radius: 8px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); }
.photo-strip .photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-strip .photo .photo-pdf { display: flex; align-items: center; justify-content: center; height: 100%; font-size: 13px; }
.photo-strip .photo button { position: absolute; top: 2px; right: 2px; background: rgba(255, 255, 255, .9); padding: 0 6px; }
.photo-count { font-size: 11px; color: var(--muted); }
/* customer credit grade */
.credit-alert { display: flex; gap: 10px; align-items: flex-start; }
.credit-alert b { white-space: nowrap; }
/* item editor rows (accessories, counter sale) */
.items-editor { grid-column: 1 / -1; }
.items-editor table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.items-editor th, .items-editor td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left; font-size: 13px; }
.items-editor td.r, .items-editor th.r { text-align: right; }
.items-editor input { width: 90px; text-align: right; }
.queue-section { margin-bottom: 16px; }
.mini-table { width: 100%; border-collapse: collapse; margin: 0 0 12px; font-size: 13px; }
.mini-table th, .mini-table td { padding: 5px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.mini-table th { background: var(--surface-2); font-weight: 600; }
.mini-table td.r, .mini-table th.r { text-align: right; }
