/* Centel Account: a ledger-paper look. Charcoal rail, warm paper canvas, ink text,
   one orange accent for actions, monospaced figures so columns of money line up. */
:root {
  --bg: #F4F2EE;
  --panel: #FFFFFF;
  --panel-2: #FAF9F7;
  --ink: #1B1D21;
  --ink-2: #4A4E57;
  --muted: #80848D;
  --line: #E4E1DB;
  --line-2: #EFEDE8;
  --rail: #14161A;
  --rail-ink: #C9CCD2;
  --rail-hi: #FFFFFF;
  --accent: #F76707;
  --accent-ink: #FFFFFF;
  --accent-soft: #FFF0E5;
  --good: #1F8A5B;
  --good-soft: #E5F4EC;
  --warn: #B7791F;
  --warn-soft: #FDF3DD;
  --bad: #C92A2A;
  --bad-soft: #FDECEC;
  --info: #2F5FBF;
  --info-soft: #E9EFFB;
  --shadow: 0 1px 2px rgba(20, 22, 26, .06), 0 4px 16px rgba(20, 22, 26, .05);
  --r: 12px;
  --font: 'IBM Plex Sans Thai', system-ui, -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101113; --panel: #18191C; --panel-2: #1D1F23; --ink: #ECEDEF; --ink-2: #B4B7BE; --muted: #868A93;
    --line: #2A2C31; --line-2: #222428; --rail: #0B0C0E; --accent-soft: #3A2414; --good-soft: #13291F; --warn-soft: #2E2512;
    --bad-soft: #321718; --info-soft: #172238; --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101113; --panel: #18191C; --panel-2: #1D1F23; --ink: #ECEDEF; --ink-2: #B4B7BE; --muted: #868A93;
  --line: #2A2C31; --line-2: #222428; --rail: #0B0C0E; --accent-soft: #3A2414; --good-soft: #13291F; --warn-soft: #2E2512;
  --bad-soft: #321718; --info-soft: #172238; --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.55 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.r { text-align: right; }
.c { text-align: center; }
.boot { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.rail { background: var(--rail); color: var(--rail-ink); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; color: var(--rail-hi); font-weight: 700; letter-spacing: .01em; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: #23262C; display: grid; place-items: center; }
.brand small { display: block; font-weight: 400; color: var(--rail-ink); font-size: 11px; opacity: .7; }
.biz-switch { margin: 0 4px 12px; padding: 10px 12px; border-radius: 10px; background: #1E2126; border: 1px solid #2A2E35; color: var(--rail-hi); text-align: left; cursor: pointer; display: flex; gap: 10px; align-items: center; }
.biz-switch img, .biz-switch .ph { width: 28px; height: 28px; border-radius: 6px; object-fit: cover; background: #2C3038; flex: none; display: grid; place-items: center; font-size: 12px; }
.biz-switch span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.nav-h { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6C717B; padding: 14px 12px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--rail-ink); font-size: 14px; }
.nav a:hover { background: #1E2126; color: var(--rail-hi); }
.nav a.on { background: #262A31; color: var(--rail-hi); box-shadow: inset 3px 0 0 var(--accent); }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.rail-foot { margin-top: auto; padding: 12px; font-size: 12px; color: #6C717B; }
.rail-foot button { background: none; border: 0; color: var(--rail-ink); padding: 0; cursor: pointer; text-decoration: underline; }

.main { min-width: 0; padding: 24px 32px 80px; }
.topbar { display: none; }
.page-h { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-h h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.page-h .sub { color: var(--muted); font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Controls ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-weight: 500; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--ink-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.dark { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--line-2); }
.btn.danger { color: var(--bad); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 16px; height: 16px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: 12px; color: var(--ink-2); font-weight: 500; }
.field small { color: var(--muted); font-size: 12px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=month], input[type=search], select, textarea {
  height: 38px; padding: 0 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); width: 100%; min-width: 0; outline: none;
}
textarea { height: auto; min-height: 76px; padding: 9px 11px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input.num { text-align: right; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.seg { display: inline-flex; background: var(--line-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 5px 12px; border-radius: 7px; cursor: pointer; color: var(--ink-2); font-size: 13px; }
.seg button.on { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }
.grid { display: grid; gap: 14px; }
.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)); }
.span2 { grid-column: span 2; }

/* ---------- Cards and tables ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card h2 { font-size: 15px; margin: 0 0 12px; font-weight: 600; }
.card-h { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.card-h h2 { margin: 0; }
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel-2); }
.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--panel-2); }
.tbl td.num, .tbl th.num { text-align: right; white-space: nowrap; }
.tbl tfoot td { font-weight: 600; border-top: 1px solid var(--line); border-bottom: 0; background: var(--panel-2); }
.tbl .sec td { background: var(--panel-2); font-weight: 600; color: var(--ink-2); }
.tbl .sub td { padding-left: 28px; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }
.chip { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 99px; font-size: 12px; font-weight: 500; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.info { background: var(--info-soft); color: var(--info); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.doc-no { font-family: var(--mono); font-size: 13px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line-2); }
.filters input[type=search] { max-width: 260px; }
.filters input[type=month], .filters select { width: auto; }

/* ---------- Dashboard ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.kpi { padding: 16px 18px; }
.kpi .k { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }
.kpi .v { font-family: var(--mono); font-size: 24px; font-weight: 600; margin-top: 6px; letter-spacing: -.02em; }
.kpi .d { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.accent { background: var(--rail); color: #fff; border-color: var(--rail); }
.kpi.accent .k, .kpi.accent .d { color: #9AA0AA; }
.dash { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 14px; }
.chart { padding: 8px 18px 16px; }
.chart svg { width: 100%; height: 200px; display: block; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); padding: 0 18px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.quick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.quick a { display: flex; gap: 10px; align-items: center; padding: 12px 14px; text-decoration: none; border-radius: var(--r); border: 1px dashed var(--line); background: var(--panel); }
.quick a:hover { border-color: var(--accent); border-style: solid; }
.quick .ic { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-family: var(--mono); font-size: 12px; }
.quick b { font-weight: 600; display: block; font-size: 13.5px; }
.quick small { color: var(--muted); font-size: 12px; }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 18px; border-bottom: 1px solid var(--line-2); }
.mini-list li:last-child { border-bottom: 0; }

/* ---------- Document editor ---------- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.lines { width: 100%; border-collapse: collapse; }
.lines th { font-size: 12px; color: var(--muted); font-weight: 500; text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.lines td { padding: 6px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.lines input, .lines select { height: 34px; }
.lines textarea { min-height: 34px; height: 34px; margin-top: 4px; font-size: 13px; }
.lines .w-qty { width: 76px; } .lines .w-unit { width: 76px; } .lines .w-price { width: 112px; } .lines .w-disc { width: 88px; }
.lines .w-wht { width: 80px; } .lines .w-amt { width: 112px; text-align: right; padding-top: 14px; }
.lines .w-x { width: 36px; }
.lines td.l-name { min-width: 220px; }
.l-acc { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 12px; color: var(--muted); }
.l-acc span { flex: none; }
.l-acc select { height: 30px; font-size: 12.5px; padding: 0 8px; }
.lines .rm { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 8px; border-radius: 6px; }
.lines .rm:hover { background: var(--bad-soft); color: var(--bad); }
.add-line { margin: 10px 0 0; }
.side { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 14px; }
.sum-tbl { width: 100%; border-collapse: collapse; }
.sum-tbl td { padding: 5px 0; }
.sum-tbl td:last-child { text-align: right; font-family: var(--mono); }
.sum-tbl .grand td { font-size: 18px; font-weight: 700; border-top: 1px solid var(--line); padding-top: 10px; }
.sum-tbl .net td { color: var(--accent); font-weight: 600; }
.words { font-size: 12px; color: var(--muted); margin-top: 6px; }
.contact-pick { position: relative; }
.suggest { position: absolute; z-index: 30; left: 0; right: 0; top: 100%; margin-top: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.12); max-height: 280px; overflow: auto; }
.suggest button { display: block; width: 100%; text-align: left; padding: 9px 12px; border: 0; background: none; cursor: pointer; }
.suggest button:hover, .suggest button.hi { background: var(--panel-2); }
.suggest small { color: var(--muted); display: block; font-size: 12px; }
.scan-drop { border: 1.5px dashed var(--line); border-radius: var(--r); padding: 16px; text-align: center; cursor: pointer; background: var(--panel-2); }
.scan-drop:hover { border-color: var(--accent); }
.scan-drop b { display: block; }
.scan-drop svg { width: 28px; height: 28px; color: var(--accent); }
.note-box { padding: 10px 12px; border-radius: 10px; background: var(--info-soft); color: var(--info); font-size: 13px; }
.note-box.warn { background: var(--warn-soft); color: var(--warn); }

/* ---------- Document view ---------- */
.view { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.paper-wrap { overflow-x: auto; padding-bottom: 8px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; }
.journal-mini { width: 100%; font-size: 12.5px; border-collapse: collapse; }
.journal-mini td { padding: 4px 0; border-bottom: 1px dashed var(--line-2); }
.journal-mini td.num { text-align: right; font-family: var(--mono); width: 84px; white-space: nowrap; }
.rel a { display: flex; justify-content: space-between; padding: 6px 0; text-decoration: none; font-size: 13px; }

/* ---------- Printed document (A4) ---------- */
.paper { --pp-accent: #E8590C; position: relative; width: 210mm; min-height: 297mm; margin: 0 auto; padding: 14mm 14mm 12mm; background: #fff; color: #1B1D21; box-shadow: var(--shadow); border: 1px solid var(--line); font-size: 12.5px; line-height: 1.5; display: flex; flex-direction: column; }
.paper .pp-head { display: flex; justify-content: space-between; gap: 18px; padding-bottom: 12px; border-bottom: 2px solid #1B1D21; }
.pp-brand { display: flex; gap: 12px; max-width: 60%; }
.pp-logo { width: 64px; height: 64px; object-fit: contain; flex: none; }
.pp-biz { font-size: 16px; font-weight: 700; }
.pp-addr, .pp-small { font-size: 11.5px; color: #4A4E57; }
.pp-title { text-align: right; }
.pp-title h1 { margin: 2px 0 0; font-size: 19px; font-weight: 700; color: var(--pp-accent); }
.pp-en { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: #80848D; }
.pp-copy { display: inline-block; font-size: 10.5px; border: 1px solid #1B1D21; padding: 1px 8px; border-radius: 4px; }
.pp-info { display: flex; justify-content: space-between; gap: 18px; padding: 12px 0; }
.pp-party { flex: 1; padding: 10px 12px; background: #F7F6F3; border-radius: 6px; }
.pp-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: #80848D; margin-bottom: 2px; }
.pp-name { font-weight: 600; font-size: 13.5px; }
.pp-meta { display: grid; grid-template-columns: auto auto; gap: 3px 14px; margin: 0; align-content: start; min-width: 200px; }
.pp-meta dt { color: #80848D; }
.pp-meta dd { margin: 0; text-align: right; font-family: var(--mono); font-size: 12px; }
.pp-lines { width: 100%; border-collapse: collapse; margin-top: 4px; }
.pp-lines th { background: #1B1D21; color: #fff; font-weight: 500; font-size: 11.5px; padding: 6px 8px; text-align: left; }
.pp-lines th.r, .pp-lines td.r { text-align: right; }
.pp-lines th.c, .pp-lines td.c { text-align: center; }
.pp-lines td { padding: 7px 8px; border-bottom: 1px solid #E4E1DB; vertical-align: top; }
.pp-lines td.r { font-family: var(--mono); font-size: 12px; white-space: nowrap; }
.pp-item { font-weight: 500; }
.pp-desc { font-size: 11.5px; color: #4A4E57; }
.pp-unit { font-family: var(--font); color: #80848D; }
.pp-sum { display: flex; justify-content: space-between; gap: 18px; margin-top: 10px; }
.pp-words { flex: 1; padding-top: 6px; }
.pp-baht { font-weight: 600; margin: 2px 0 6px; }
.pp-totals { border-collapse: collapse; min-width: 270px; }
.pp-totals th { text-align: left; font-weight: 400; color: #4A4E57; padding: 3px 0; }
.pp-totals td { text-align: right; font-family: var(--mono); padding: 3px 0 3px 18px; }
.pp-grand th, .pp-grand td { font-weight: 700; color: #1B1D21; border-top: 1.5px solid #1B1D21; padding-top: 6px; font-size: 13.5px; }
.pp-net th, .pp-net td { font-weight: 700; color: var(--pp-accent); }
.pp-notes { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 14px; padding-top: 10px; border-top: 1px dashed #E4E1DB; font-size: 12px; }
.pp-sign { margin-top: auto; padding-top: 28px; display: flex; justify-content: space-around; gap: 16px; text-align: center; }
.pp-sign > div { flex: 1; max-width: 220px; }
.pp-line { border-bottom: 1px solid #1B1D21; height: 34px; margin-bottom: 4px; }
.pp-sign-one { justify-content: flex-end; }
.pp-sign-one > div { max-width: 320px; }
.pp-void { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%) rotate(-18deg); font-size: 84px; font-weight: 700; color: rgba(201, 42, 42, .18); border: 6px solid rgba(201, 42, 42, .18); padding: 0 30px; border-radius: 16px; pointer-events: none; }
.pp-wht .pp-copy { align-self: flex-end; }
.pp-wht-title { text-align: center; font-size: 18px; margin: 10px 0 0; }
.pp-wht-sub { text-align: center; margin-bottom: 12px; }
.pp-wht-no { margin-left: 18px; font-family: var(--mono); }
.pp-wht-party { border: 1px solid #1B1D21; border-radius: 4px; padding: 8px 10px; margin-bottom: 8px; }
.pp-wht-forms { margin: 10px 0; }
.pp-box { display: inline-grid; place-items: center; width: 14px; height: 14px; border: 1px solid #1B1D21; font-size: 11px; vertical-align: -2px; }

/* ---------- Dialogs, toast, auth ---------- */
.dlg-back { position: fixed; inset: 0; background: rgba(15, 16, 19, .45); display: grid; place-items: center; z-index: 60; padding: 16px; }
.dlg { background: var(--panel); border-radius: 16px; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.dlg.wide { width: min(820px, 100%); }
.dlg-h { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line-2); position: sticky; top: 0; background: var(--panel); z-index: 1; }
.dlg-h h3 { margin: 0; font-size: 16px; }
.dlg-b { padding: 18px 20px; }
.dlg-f { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line-2); position: sticky; bottom: 0; background: var(--panel); }
.x { border: 0; background: none; font-size: 20px; cursor: pointer; color: var(--muted); padding: 4px 8px; border-radius: 6px; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--panel); padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .2s; z-index: 80; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.err { background: var(--bad); color: #fff; }
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art { background: var(--rail); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-art h1 { font-size: 34px; line-height: 1.25; margin: 0 0 12px; max-width: 460px; }
.auth-art p { color: #A6ACB6; max-width: 420px; }
.auth-art .ledger { position: absolute; right: -40px; bottom: -20px; width: 420px; opacity: .9; }
.auth-form { display: grid; place-items: center; padding: 32px 20px; }
.auth-form .card { width: min(400px, 100%); padding: 28px; }
.auth-form h2 { margin: 0 0 4px; font-size: 20px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 14px 0; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.err-text { color: var(--bad); font-size: 13px; min-height: 18px; }
.biz-list { display: grid; gap: 8px; }
.biz-list button { display: flex; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); cursor: pointer; text-align: left; }
.biz-list button:hover { border-color: var(--accent); }
.logo-pick { display: flex; gap: 14px; align-items: center; }
.logo-pick .lp { width: 72px; height: 72px; border-radius: 12px; border: 1px dashed var(--line); display: grid; place-items: center; overflow: hidden; background: var(--panel-2); color: var(--muted); font-size: 12px; }
.logo-pick img { width: 100%; height: 100%; object-fit: contain; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--ink); border-color: var(--accent); font-weight: 600; }
.rep-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.rep-grid a { padding: 16px 18px; text-decoration: none; }
.rep-grid a:hover { border-color: var(--accent); }
.rep-grid b { display: block; margin-bottom: 2px; }
.rep-grid small { color: var(--muted); }
.rep-h { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin: 22px 0 10px; }

/* ---------- Small screens ---------- */
@media (max-width: 1440px) {
  .editor { grid-template-columns: minmax(0, 1fr); }
  .editor .side { position: static; }
}
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash, .editor, .view { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; }
  .rep-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .shell.menu .rail { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); }
  .topbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 40; background: var(--rail); color: #fff; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); }
  .topbar svg { width: 22px; height: 22px; display: block; }
  .topbar button { background: none; border: 0; color: #fff; padding: 4px; cursor: pointer; }
  .topbar b { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .main { padding: 16px 16px 80px; }
  .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); }
  .span2 { grid-column: auto; }
  .quick { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth { grid-template-columns: 1fr; }
  .auth-art { padding: 28px 20px; min-height: 0; }
  .auth-art h1 { font-size: 24px; }
  .auth-art .ledger { display: none; }
  .rep-grid { grid-template-columns: minmax(0, 1fr); }
  .lines thead { display: none; }
  .lines, .lines tbody, .lines tr, .lines td { display: block; width: 100% !important; }
  .lines tr { border: 1px solid var(--line); border-radius: 10px; padding: 8px; margin-bottom: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .lines td { border: 0; padding: 0; }
  .lines td.l-name { grid-column: span 2; }
  .lines td[data-l]::before { content: attr(data-l); display: block; font-size: 11px; color: var(--muted); }
  .lines .w-amt { padding-top: 0; text-align: left; }
  .paper-wrap .paper { transform-origin: top left; }
}

/* ---------- Print: only the paper ---------- */
@page { size: A4; margin: 0; }
@media print {
  body { background: #fff; }
  #app, #toast, .dlg-back { display: none !important; }
  #print { display: block !important; }
  #print .paper { box-shadow: none; border: 0; margin: 0; min-height: 296mm; page-break-after: always; transform: none !important; }
  #print .paper:last-child { page-break-after: auto; }
  #print .print-report { padding: 12mm; font-size: 11px; }
  #print .print-report table { width: 100%; border-collapse: collapse; }
  #print .print-report th, #print .print-report td { border-bottom: 1px solid #ccc; padding: 4px 6px; }
}
#print { display: none; }
