:root {
  --bg: #f3f4f7;
  --panel: #ffffff;
  --panel-2: #f8f9fb;
  --text: #1b2232;
  --muted: #687185;
  --line: #e2e5eb;
  --line-2: #d3d8e1;
  --primary: #2250d0;
  --primary-ink: #ffffff;
  --primary-soft: #e8eefc;
  --accent: #f5b400;
  --danger: #c62f2f;
  --danger-soft: #fdecec;
  --ok: #18804a;
  --ok-soft: #e5f5ec;
  --warn: #a8640a;
  --warn-soft: #fdf3e2;
  --info: #1f6fae;
  --info-soft: #e6f1fa;
  --side: #151b2b;
  --side-ink: #c9cfdc;
  --side-active: #262f46;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not(.light) {
    --bg: #0f131c; --panel: #181e2a; --panel-2: #1d2432; --text: #e6e9f0; --muted: #98a1b3;
    --line: #2a3242; --line-2: #364052; --primary: #5b84f0; --primary-soft: #1e2a47;
    --danger-soft: #3a1d20; --ok-soft: #173326; --warn-soft: #3a2c14; --info-soft: #172c3f;
    --side: #0b0f17; --side-active: #1f2738; --shadow: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text); -webkit-tap-highlight-color: transparent;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -4px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.spacer { flex: 1; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.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; } .span3 { grid-column: span 3; } .spanall { grid-column: 1 / -1; }
@media (max-width: 900px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .span3 { grid-column: 1 / -1; } }
@media (max-width: 560px) { .g2, .g3 { grid-template-columns: minmax(0, 1fr); } .span2 { grid-column: auto; } }

/* ---------- Layout ---------- */
#app { min-height: 100%; }
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; font-weight: 700; font-size: 15px; }
.brand .logo { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: #151b2b; display: grid; place-items: center; flex: none; overflow: hidden; }
.brand .logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.brand small { display: block; font-weight: 400; color: var(--side-ink); font-size: 11.5px; }
.nav { padding: 6px 10px 16px; display: flex; flex-direction: column; gap: 2px; }
.nav .sec { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #7d879c; padding: 14px 10px 4px; }
.nav a { display: flex; gap: 11px; align-items: center; padding: 8px 10px; border-radius: 8px; color: var(--side-ink); font-weight: 500; }
.nav a:hover { background: var(--side-active); text-decoration: none; color: #fff; }
.nav a.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav a .count { margin-left: auto; background: var(--accent); color: #151b2b; border-radius: 99px; font-size: 11px; padding: 0 7px; font-weight: 700; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; background: var(--panel); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 10px 22px; padding-top: calc(10px + var(--safe-t)); }
.topbar .search { position: relative; flex: 1; max-width: 520px; }
.topbar .search input { width: 100%; padding-left: 36px; background: var(--panel-2); }
.topbar .search svg { position: absolute; left: 11px; top: 10px; color: var(--muted); }
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); max-height: 60vh; overflow: auto; z-index: 50; }
.search-results a { display: flex; gap: 10px; padding: 9px 12px; color: var(--text); border-bottom: 1px solid var(--line); align-items: center; }
.search-results a:hover, .search-results a.sel { background: var(--primary-soft); text-decoration: none; }
.search-results .type { font-size: 11px; text-transform: uppercase; color: var(--muted); width: 64px; flex: none; }
.clock-pill { display: inline-flex; gap: 6px; align-items: center; background: var(--ok-soft); color: var(--ok); border-radius: 99px; padding: 5px 11px; font-weight: 600; font-size: 12.5px; }
.userbtn { display: flex; align-items: center; gap: 8px; background: none; border: 0; color: var(--text); cursor: pointer; padding: 4px; border-radius: 8px; font: inherit; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 12px; flex: none; }
#view { padding: 22px; max-width: 1400px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin-right: auto; }
.page-head .sub { color: var(--muted); font-size: 13px; width: 100%; margin-top: -8px; }
.bottomnav { display: none; }
.topbar .menu-btn { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .sidebar.open { display: flex; position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 90; box-shadow: var(--shadow-lg); }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 80; }
  .topbar .menu-btn { display: inline-flex; }
  .topbar { padding: 8px 12px; padding-top: calc(8px + var(--safe-t)); gap: 8px; }
  .topbar .uname { display: none; }
  #view { padding: 14px 12px calc(84px + var(--safe-b)); }
  .bottomnav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--panel); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
  .bottomnav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px; font-size: 11px; color: var(--muted); font-weight: 500; }
  .bottomnav a.active { color: var(--primary); }
  .bottomnav a:hover { text-decoration: none; }
  .bottomnav svg.i { width: 22px; height: 22px; }
  h1 { font-size: 19px; }
}

/* ---------- Controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line-2); background: var(--panel); color: var(--text); padding: 7px 13px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; min-height: 36px; text-decoration: none !important; }
.btn:hover { background: var(--panel-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.sm { padding: 4px 9px; min-height: 30px; font-size: 13px; }
.btn.icon { padding: 6px; min-width: 36px; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 8px 8px 0; }
.btn-group .btn.on { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); z-index: 1; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px;
  padding: 7px 10px; min-height: 36px; width: 100%; outline: none;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
input[type=checkbox] { width: 18px; height: 18px; min-height: 0; accent-color: var(--primary); }
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--muted); min-width: 0; }
label.chk { display: flex; gap: 8px; align-items: center; font-weight: 500; color: var(--text); cursor: pointer; }
@media (max-width: 900px) { input, select, textarea { font-size: 16px; } }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 9px 12px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; cursor: pointer; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- Cards & lists ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card > .hd { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.card > .hd h2, .card > .hd h3 { margin-right: auto; }
.card > .bd { padding: 16px; }
.card > .bd.flush { padding: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); color: var(--text); display: block; }
a.kpi:hover { text-decoration: none; border-color: var(--line-2); }
.kpi .lbl { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.kpi .val { font-size: 23px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .note { font-size: 12px; color: var(--muted); }
.kpi.warn .val { color: var(--warn); } .kpi.bad .val { color: var(--danger); } .kpi.good .val { color: var(--ok); }
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--line); color: var(--text); min-height: 54px; }
.item:last-child { border-bottom: 0; }
a.item:hover, .item.click:hover { background: var(--panel-2); text-decoration: none; cursor: pointer; }
.item .main-col { flex: 1; min-width: 0; }
.item .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .s { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .r { text-align: right; flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.item .time { font-weight: 700; font-variant-numeric: tabular-nums; width: 52px; flex: none; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.list-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input[type=search] { max-width: 320px; }
.badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 99px; padding: 2px 9px; font-size: 11.5px; font-weight: 650; white-space: nowrap; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.badge.blue { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge.green { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.amber { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.red { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.violet { background: #f0e9fd; color: #6a3bc4; border-color: transparent; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 2px 4px 2px 8px; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; font-weight: 600; }
.chip button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 3px; font-size: 15px; line-height: 1; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.dl dt { color: var(--muted); font-size: 13px; }
.dl dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .split { grid-template-columns: minmax(0, 1fr); } }
.sticky-actions { position: sticky; bottom: 0; background: var(--panel); border-top: 1px solid var(--line); padding: 10px 16px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; border-radius: 0 0 var(--radius) var(--radius); }
@media (max-width: 900px) { .sticky-actions { bottom: calc(58px + var(--safe-b)); } }
.contact-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.notice { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.notice.info { background: var(--info-soft); color: var(--info); }
.notice.err { background: var(--danger-soft); color: var(--danger); }

/* ---------- Line editor ---------- */
.lines { width: 100%; border-collapse: collapse; }
.lines th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 6px; border-bottom: 1px solid var(--line); }
.lines td { padding: 5px 4px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.lines td input, .lines td select { min-height: 34px; padding: 5px 7px; }
.lines .c-kind { width: 98px; } .lines .c-qty { width: 76px; } .lines .c-price { width: 100px; } .lines .c-vat { width: 66px; } .lines .c-disc { width: 66px; } .lines .c-total { width: 100px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; } .lines .c-x { width: 38px; }
.lines td.num, .lines input.num { text-align: right; font-variant-numeric: tabular-nums; }
.totals { margin-left: auto; width: 290px; max-width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; padding: 12px 6px 0; font-variant-numeric: tabular-nums; }
.totals .grand { font-size: 17px; font-weight: 700; border-top: 1px solid var(--line); padding-top: 6px; }
.kind-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
@media (max-width: 760px) {
  .lines thead { display: none; }
  .lines, .lines tbody { display: block; }
  .lines tr { display: grid; grid-template-columns: 1fr 1fr 1fr 40px; grid-template-areas: "desc desc desc x" "kind qty price price" "vat disc total total"; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .lines td { border: 0; padding: 0; width: auto !important; }
  .lines td.c-desc { grid-area: desc; } .lines td.c-x { grid-area: x; } .lines td.c-kind { grid-area: kind; align-self: end; }
  .lines td.c-qty { grid-area: qty; } .lines td.c-price { grid-area: price; } .lines td.c-vat { grid-area: vat; } .lines td.c-disc { grid-area: disc; }
  .lines td.c-total { grid-area: total; align-self: end; padding-bottom: 8px; }
  .lines td[data-l]::before { content: attr(data-l); display: block; font-size: 11px; color: var(--muted); }
}
.ac { position: relative; }
.ac-list { position: absolute; z-index: 60; top: 100%; left: 0; min-width: 100%; width: max-content; max-width: min(520px, 92vw); background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px; box-shadow: var(--shadow-lg); max-height: 280px; overflow: auto; }
.ac-list div { padding: 8px 11px; cursor: pointer; border-bottom: 1px solid var(--line); }
.ac-list div:hover, .ac-list div.sel { background: var(--primary-soft); }
.ac-list small { display: block; color: var(--muted); }

/* ---------- Calendar ---------- */
.cal-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.cal-head .title { font-weight: 700; font-size: 16px; margin-right: auto; }
.cal { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow); }
.cal-grid { display: grid; position: relative; min-width: 760px; }
.cal-grid .colhead { position: sticky; top: 0; z-index: 3; background: var(--panel); border-bottom: 1px solid var(--line); padding: 8px; text-align: center; font-weight: 600; font-size: 13px; border-left: 1px solid var(--line); }
.cal-grid .colhead.today { color: var(--primary); }
.cal-grid .colhead small { display: block; font-weight: 400; color: var(--muted); }
.cal-grid .times { border-right: 1px solid var(--line); }
.cal-grid .times div:first-child { transform: none; padding-top: 2px; }
.cal-grid .times div { height: 44px; font-size: 11.5px; color: var(--muted); text-align: right; padding: 0 6px; transform: translateY(-7px); }
.cal-col { position: relative; border-left: 1px solid var(--line); }
.cal-col .slot { height: 22px; border-bottom: 1px dashed var(--line); cursor: pointer; }
.cal-col .slot:nth-child(2n) { border-bottom-style: solid; }
.cal-col .slot:hover { background: var(--primary-soft); }
.cal-col.off { background: repeating-linear-gradient(45deg, transparent 0 8px, var(--panel-2) 8px 16px); }
.cal-ev { position: absolute; left: 3px; right: 3px; border-radius: 6px; padding: 3px 6px; font-size: 12px; overflow: hidden; cursor: pointer; color: #fff; border-left: 4px solid rgba(0,0,0,.25); box-shadow: 0 1px 2px rgba(0,0,0,.15); line-height: 1.3; }
.cal-ev b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-ev.cancelled, .cal-ev.no_show { opacity: .45; text-decoration: line-through; }
.cal-ev.completed { opacity: .7; }
.cal-ev.requested { background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.18) 0 6px, transparent 6px 12px); border-left-color: var(--accent); }
.now-line { position: absolute; left: 0; right: 0; border-top: 2px solid var(--danger); z-index: 2; pointer-events: none; }
.daystrip { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px; scrollbar-width: none; }
.daystrip a { flex: none; width: 48px; text-align: center; padding: 6px 0; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); color: var(--text); }
.daystrip a small { display: block; color: var(--muted); font-size: 11px; }
.daystrip a b { font-size: 16px; }
.daystrip a.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.daystrip a.on small { color: #dfe6ff; }
.daystrip a.has::after { content: ""; display: block; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); margin: 2px auto 0; }
.daystrip a:hover { text-decoration: none; }

/* ---------- Modal & toast ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(10, 14, 24, .5); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow-y: auto; }
.modal { background: var(--panel); border-radius: 14px; width: 100%; max-width: 560px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; }
.modal.wide { max-width: 860px; }
.modal .mh { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); gap: 10px; }
.modal .mh h2 { margin-right: auto; }
.modal .mb { padding: 18px; }
.modal .mf { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal .mf .left { margin-right: auto; }
@media (max-width: 640px) {
  .modal-back { padding: 0; align-items: flex-end; }
  .modal, .modal.wide { max-width: none; border-radius: 16px 16px 0 0; max-height: 94vh; }
  .modal .mb { overflow-y: auto; }
  .modal .mf { padding-bottom: calc(12px + var(--safe-b)); }
}
#toast-root { position: fixed; z-index: 200; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
@media (max-width: 900px) { #toast-root { bottom: calc(76px + var(--safe-b)); } }
.toast { background: #1b2232; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-weight: 500; max-width: 90vw; animation: pop .18s ease-out; }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, #151b2b 0%, #24314f 100%); }
.auth .card { width: 100%; max-width: 400px; padding: 28px; }
.auth .brand { color: var(--text); padding: 0 0 18px; font-size: 18px; }
.auth .brand small { color: var(--muted); }

/* ---------- Misc ---------- */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.photos .ph { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--panel-2); border: 1px solid var(--line); display: grid; place-items: center; text-align: center; font-size: 12px; padding: 4px; }
.photos .ph img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; cursor: zoom-in; }
.photos .ph button { position: absolute; top: 4px; right: 4px; z-index: 2; background: rgba(0,0,0,.55); color: #fff; border: 0; border-radius: 6px; width: 26px; height: 26px; cursor: pointer; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 180px; padding-top: 10px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bars .bar span { width: 100%; max-width: 46px; background: var(--primary); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .bar small { font-size: 10.5px; color: var(--muted); margin-top: 4px; white-space: nowrap; }
.bars .bar em { font-style: normal; font-size: 10.5px; color: var(--muted); margin-bottom: 3px; white-space: nowrap; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
table.t td { padding: 8px 12px; border-bottom: 1px solid var(--line); }
table.t tr:last-child td { border-bottom: 0; }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tablewrap { overflow-x: auto; }
.tests { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.tests fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px 12px; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tests legend { font-weight: 700; font-size: 13px; padding: 0 4px; }
.tests label.f { font-size: 11.5px; }
.sheet-menu { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.sheet-menu a { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 6px; border: 1px solid var(--line); border-radius: 12px; color: var(--text); font-weight: 600; font-size: 12.5px; text-align: center; }
.sheet-menu a:hover { text-decoration: none; background: var(--panel-2); }
.sheet-menu svg.i { width: 24px; height: 24px; color: var(--primary); }
.fab { display: none; }
@media (max-width: 900px) {
  .fab { display: grid; place-items: center; position: fixed; right: 16px; bottom: calc(72px + var(--safe-b)); width: 54px; height: 54px; border-radius: 50%; background: var(--primary); color: #fff; box-shadow: var(--shadow-lg); z-index: 25; border: 0; }
  .fab svg.i { width: 26px; height: 26px; }
  .hide-m { display: none !important; }
}
@media (min-width: 901px) { .hide-d { display: none !important; } }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 300; display: grid; place-items: center; cursor: zoom-out; }
.lightbox img { max-width: 96vw; max-height: 92vh; }

/* ---------- Print ---------- */
#print-root { display: none; }
@media print {
  @page { size: A4; margin: 14mm 13mm; }
  body { background: #fff; color: #000; }
  #app, #modal-root, #toast-root { display: none !important; }
  #print-root { display: block; }
}
.doc { font: 10.5pt/1.4 "Segoe UI", Arial, sans-serif; color: #111; }
.doc h1 { font-size: 20pt; letter-spacing: .02em; }
.doc .top { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 18px; }
.doc .co { font-size: 9.5pt; color: #333; }
.doc .co b { font-size: 13pt; color: #111; display: block; margin-bottom: 2px; }
.doc .co img { max-height: 64px; max-width: 220px; display: block; margin-bottom: 6px; }
.doc .meta { text-align: right; }
.doc .meta table { margin-left: auto; border-collapse: collapse; font-size: 9.5pt; }
.doc .meta td { padding: 1px 0 1px 12px; }
.doc .boxes { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.doc .box { border: 1px solid #ccc; border-radius: 4px; padding: 8px 10px; font-size: 9.5pt; min-height: 70px; }
.doc .box .h { font-size: 8pt; text-transform: uppercase; letter-spacing: .08em; color: #666; margin-bottom: 3px; }
.doc table.items { width: 100%; border-collapse: collapse; font-size: 9.5pt; }
.doc table.items th { background: #f0f0f0; text-align: left; padding: 5px 6px; border-bottom: 1px solid #999; font-size: 8.5pt; text-transform: uppercase; letter-spacing: .04em; }
.doc table.items td { padding: 5px 6px; border-bottom: 1px solid #ddd; vertical-align: top; }
.doc table.items .n { text-align: right; white-space: nowrap; }
.doc .sum { display: flex; justify-content: space-between; gap: 20px; margin-top: 12px; page-break-inside: avoid; }
.doc .sum table { border-collapse: collapse; min-width: 240px; }
.doc .sum td { padding: 3px 0 3px 16px; text-align: right; }
.doc .sum tr.g td { font-size: 13pt; font-weight: 700; border-top: 2px solid #111; padding-top: 5px; }
.doc .sec { margin-top: 14px; page-break-inside: avoid; }
.doc .sec .h { font-weight: 700; font-size: 9pt; text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid #ccc; margin-bottom: 4px; padding-bottom: 2px; }
.doc .foot { margin-top: 22px; font-size: 8.5pt; color: #444; border-top: 1px solid #ccc; padding-top: 8px; }
.doc .stamp { display: inline-block; border: 2px solid #c62f2f; color: #c62f2f; padding: 2px 10px; font-weight: 700; transform: rotate(-4deg); font-size: 13pt; }
.doc .sig { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 36px; }
.doc .sig div { border-top: 1px solid #333; padding-top: 4px; font-size: 9pt; }
.doc .lines-blank td { height: 22px; }
