[hidden] { display: none !important; }
:root {
  --bg: #f5f6fa; --panel: #ffffff; --ink: #07092d; --muted: #616477; --line: #e1e3eb;
  --brand: #f98d17; --brand-ink: #07092d; --brand-text: #9c4800; --brand-soft: #fff0de; --danger: #b42318; --danger-soft: #fdecea;
  --warn: #a15c07; --warn-soft: #fdf3e2; --ok: #9c4800; --ok-soft: #fff0de;
  --radius: 10px; --shadow: 0 1px 2px rgba(7, 9, 45, .06), 0 4px 16px rgba(7, 9, 45, .05);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0c1020; --panel: #151a2d; --ink: #f1f2f8; --muted: #a9aec2; --line: #30374e;
    --brand: #f98d17; --brand-ink: #07092d; --brand-text: #f98d17; --brand-soft: #382514; --danger: #f2746a; --danger-soft: #3a1d1b;
    --warn: #e9a94a; --warn-soft: #3a2d17; --ok: #f98d17; --ok-soft: #382514; --shadow: none; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); }
a { color: var(--brand-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 10px; }
h3 { font-size: 13px; margin: 0 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.boot { padding: 40px; color: var(--muted); }

/* layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 16px 10px; position: sticky; top: 0; height: 100vh; overflow: auto; display: flex; flex-direction: column; }
.logo { display: flex; gap: 8px; align-items: center; font-weight: 700; font-size: 16px; padding: 4px 10px 16px; }
.company-logo { display: block; width: auto; height: auto; max-width: 100%; max-height: 100px; object-fit: contain; background: #fff; padding: 8px; border-radius: 6px; box-sizing: border-box; }
.logo .company-logo { max-height: 76px; }
.auth .company-logo { margin: 0 auto 18px; max-height: 120px; }
.doc .company-logo { max-width: 220px; max-height: 80px; margin-bottom: 8px; }
.logo i { width: 26px; height: 26px; border-radius: 7px; background: var(--brand); display: inline-block; }
.side nav a { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; color: var(--ink); font-weight: 500; }
.side nav a:hover { background: var(--bg); text-decoration: none; }
.side nav a.on { background: var(--brand-soft); color: var(--brand-text); }
.side .foot { margin-top: auto; padding: 10px; font-size: 12px; color: var(--muted); }
.side .foot a { color: var(--muted); }
main { padding: 22px 28px 60px; min-width: 0; }
.top { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; }
.top .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn.menu-btn { display: none; }
.row > select, .row > input:not(.grow):not([type=checkbox]) { width: auto; }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 20; inset: 0 30% 0 0; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.3); }
  .btn.menu-btn { display: inline-flex; }
  main { padding: 16px; }
}

/* components */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.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)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; align-items: start; }
@media (max-width: 1000px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .split { grid-template-columns: 1fr; } }
@media (max-width: 560px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }
.stat .n { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.stat .l { color: var(--muted); font-size: 12px; }
.stat.alert .n { color: var(--danger); }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 7px 12px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand-text); color: var(--brand-ink); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 4px 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand-text); }
textarea { min-height: 70px; resize: vertical; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--ink); font-weight: 500; margin: 0; }
.check input { width: auto; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 140px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); white-space: nowrap; }
.right { text-align: right; }
.hr { border-top: 1px solid var(--line); margin: 12px 0; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--bg); }
tr.overdue td:first-child { box-shadow: inset 3px 0 var(--danger); }
.table-wrap { overflow-x: auto; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--bg); border: 1px solid var(--line); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.pill.brand { background: var(--brand-soft); color: var(--brand-text); border-color: transparent; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs a { padding: 8px 12px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--brand-text); border-color: var(--brand-text); text-decoration: none; }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.lane { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-height: 120px; }
.lane.drop { outline: 2px dashed var(--brand); }
.lane h3 { display: flex; justify-content: space-between; }
.kcard { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px; margin-bottom: 8px; cursor: grab; }
.kcard.overdue { border-left: 3px solid var(--danger); }
.notes .note { padding: 9px 0; border-bottom: 1px solid var(--line); }
.notes .note:last-child { border: 0; }
.note .meta { font-size: 12px; color: var(--muted); }
.note.system { color: var(--muted); font-size: 13px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px 14px; }
.sig { border: 1px dashed var(--muted); border-radius: 8px; background: #fff; touch-action: none; width: 100%; height: 160px; }
.sig-img { max-width: 260px; background: #fff; border-radius: 6px; border: 1px solid var(--line); }
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 14px; align-items: start; }
@media (max-width: 1000px) { .pos { grid-template-columns: 1fr; } }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.tile { text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px; cursor: pointer; font: inherit; color: var(--ink); }
.tile:hover { border-color: var(--brand-text); }
.tile b { display: block; font-size: 13px; }
.totals td { border: 0; padding: 4px 10px; }
.totals .grand td { font-size: 18px; font-weight: 700; border-top: 1px solid var(--line); padding-top: 8px; }
.modal { position: fixed; inset: 0; background: rgba(10, 15, 12, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal .card { width: min(560px, 100%); max-height: 90vh; overflow: auto; }
.modal .card.wide { width: min(820px, 100%); }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; z-index: 60; font-weight: 600; }
.toast.err { background: var(--danger); color: #fff; }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .card { width: min(400px, 100%); }
.code { font-family: var(--mono); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; word-break: break-all; font-size: 12px; white-space: pre-wrap; }
.bar { height: 8px; background: var(--brand); border-radius: 4px; }
.p4c { border: 1px solid var(--brand); background: var(--brand-soft); }

/* Print only the document: hidden application layout must not create blank pages.
   Zero page margins suppress browser margin headers/footers in Chromium; document
   padding remains inside the page and the selected printer paper size is kept. */
#print-area { display: none; }
@page { margin: 0; }
@media print {
  html, body { min-height: 0; height: auto; margin: 0; padding: 0; background: #fff; }
  body > :not(#print-area) { display: none !important; }
  #print-area { display: block; position: static; inset: auto; width: auto; min-height: 0; height: auto; margin: 0; padding: 10mm; color: #000; background: #fff; font-size: 12px; overflow-wrap: anywhere; }
  #print-area.label { width: 62mm; max-width: 100%; padding: 0; }
  .doc .head, .doc tr { break-inside: avoid; }
  .doc thead { display: table-header-group; }
}
.doc { max-width: 720px; margin: 0 auto; }
.doc table td, .doc table th { border-bottom: 1px solid #ccc; color: #000; }
.doc .head { display: flex; justify-content: space-between; margin-bottom: 18px; }

/* ---- small screens: never scroll sideways */
main { min-width: 0; overflow-x: hidden; }
.card { min-width: 0; }
.tabs { overflow-x: auto; scrollbar-width: none; }
.tabs a { white-space: nowrap; }
.code, .small .mono { white-space: pre-wrap; word-break: break-all; }
.card > table, .card > div > table { max-width: 100%; }
@media (max-width: 820px) {
  .split, .pos { grid-template-columns: minmax(0, 1fr); }
  .pos > .card:last-child { order: -1; }          /* cart first on phones */
  .card { overflow-x: auto; }
  .top .actions { width: 100%; }
  .kanban { grid-auto-columns: minmax(210px, 80vw); }
}

/* Keep file-picker captions in the selected app language, not the OS locale. */
.localized-file { position:absolute; width:1px; height:1px; opacity:0; overflow:hidden; }
.localized-file:focus-visible + [data-file-name] { outline:2px solid var(--brand); }
.language-picker { display:flex; align-items:center; gap:8px; margin:10px 0; }
.language-picker select { width:auto; min-width:110px; }
