/* elements with the hidden attribute stay hidden, whatever their class says */
[hidden] { display: none !important; }

/* KOMSA standalone app — base styles */
:root {
  --navy: #15397F;
  --navy-deep: #0E2657;
  --amber: #F5B800;
  --amber-soft: #FFF6D6;
  --ink: #1B2230;
  --slate: #5A6B87;
  --line: #E1E6EF;
  --bg: #F3F5F9;
  --surface: #FFFFFF;
  --warn: #9A4A00;
  --warn-bg: #FEF1DA;
  --ok: #17693A;
  --ok-bg: #E4F4EA;
  --err: #A52A2A;
  --err-bg: #FCE8E8;
  --radius: 10px;
  --side-w: 264px;
  --font: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-num: "Barlow Condensed", "Barlow", system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); font-size: 16px; line-height: 1.5;
  color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--navy); }
.ico { width: 20px; height: 20px; flex: none; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; border-radius: 4px; }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100%; }
.side {
  width: var(--side-w); flex: none; background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; height: 100dvh;
}
.side-head {
  display: flex; align-items: center; gap: 12px;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 18px 16px;
  border-bottom: 1px solid var(--line);
}
.logo { border-radius: 8px; }
.brand { font-weight: 700; font-size: 17px; letter-spacing: .01em; flex: 1; }
.side .side-close { display: none; }
.side-nav { flex: 1; overflow-y: auto; padding: 12px 12px 20px; }
.nav-group {
  font-size: 13px; font-weight: 600; color: var(--slate);
  padding: 18px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: 8px;
  color: var(--ink); text-decoration: none; font-weight: 500;
  position: relative;
}
.nav-item .ico { color: var(--slate); }
.nav-item:hover { background: var(--bg); }
.nav-item.is-active { background: var(--navy); color: #fff; }
.nav-item.is-active .ico { color: var(--amber); }
.nav-item.is-pending span { color: var(--slate); }
.side-foot { border-top: 1px solid var(--line); padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px)); }
.who { display: flex; align-items: center; gap: 10px; }
.who-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.who-text strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-text small { color: var(--slate); }
.site-link { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 14px; color: var(--slate); text-decoration: none; }
.site-link .ico { width: 16px; height: 16px; }

.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  background: var(--navy); color: #fff; font-weight: 600;
  display: inline-grid; place-items: center; font-size: 15px;
}
.avatar.small { width: 36px; height: 36px; font-size: 14px; }
.icon-btn {
  border: 0; background: none; color: var(--ink); cursor: pointer;
  width: 40px; height: 40px; border-radius: 8px;
  display: inline-grid; place-items: center; text-decoration: none;
}
.icon-btn:hover { background: var(--bg); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  background: var(--surface);
  padding: calc(10px + env(safe-area-inset-top, 0px)) 24px 10px;
  border-bottom: 3px solid var(--amber);
}
.topbar .menu-btn { display: none; }
.page-title { flex: 1; margin: 0; font-size: 20px; font-weight: 600; }
.content { padding: 28px 24px 48px; max-width: 1200px; width: 100%; }
.content.bare { max-width: none; padding: 0; }

.scrim { display: none; }

/* ---------- Dashboard ---------- */
.welcome h2 { margin: 0; font-size: 34px; font-weight: 700; line-height: 1.15; }
.welcome p { margin: 6px 0 24px; color: var(--slate); font-size: 17px; }

.stats {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.stat {
  padding: 18px 20px 20px;
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  margin: 0 -1px -1px 0;
}
.stat-top { display: flex; justify-content: space-between; align-items: center; color: var(--slate); font-weight: 500; }
.stat-value {
  font-family: var(--font-num); font-weight: 700; font-size: 44px; line-height: 1.05;
  margin-top: 8px; font-variant-numeric: tabular-nums; color: var(--ink);
}
.stat-money { grid-column: span 2; }
.stat-money .stat-value { font-size: 36px; }
.stat-note { color: var(--slate); font-size: 14px; margin-top: 2px; }
.stat-warn { background: var(--warn-bg); }
.stat-warn .stat-top, .stat-warn .stat-value { color: var(--warn); }

.panel {
  margin-top: 24px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 20px 22px;
}
.panel h3 { margin: 0 0 14px; font-size: 18px; font-weight: 600; }
.muted { color: var(--slate); margin: 0; }

.table-wrap { overflow-x: auto; position: relative; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { text-align: left; font-weight: 600; color: var(--slate); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; background: var(--bg); font-size: 14px; white-space: nowrap; }
.pill-warn { background: var(--warn-bg); color: var(--warn); font-weight: 600; }

.quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.quick-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px; border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none; color: var(--ink);
}
.quick-item:hover { border-color: var(--navy); }
.quick-item small { display: block; color: var(--slate); font-size: 14px; }
.quick-icon { width: 44px; height: 44px; border-radius: 8px; background: #E8EDF6; color: var(--navy); display: grid; place-items: center; flex: none; }

/* ---------- Empty / placeholder ---------- */
.empty { max-width: 520px; margin: 40px auto; text-align: center; }
.empty-icon { width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 14px; background: var(--amber-soft); color: var(--navy); display: grid; place-items: center; }
.empty-icon .ico { width: 30px; height: 30px; }
.empty h2 { margin: 0 0 8px; font-size: 24px; }
.empty p { color: var(--slate); margin: 0 0 20px; }

/* ---------- Forms, buttons, flash ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
label { display: block; font-weight: 500; margin-bottom: 14px; }
input, select, textarea {
  display: block; width: 100%; margin-top: 6px;
  font: inherit; color: var(--ink);
  padding: 10px 12px; border: 1px solid #C9D2E0; border-radius: 8px; background: #fff;
}
input:focus, select:focus, textarea:focus { border-color: var(--navy); outline: 3px solid rgba(21,57,127,.15); outline-offset: 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; padding: 10px 18px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--navy); }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-deep); }
.btn-block { width: 100%; margin-top: 6px; }
.flash { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; font-weight: 500; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-warn { background: var(--warn-bg); color: var(--warn); }
.flash-error { background: var(--err-bg); color: var(--err); }

/* ---------- Login ---------- */
.login {
  min-height: 100vh; min-height: 100dvh;
  display: grid; place-content: center; gap: 24px;
  padding: 32px 20px;
  background:
    linear-gradient(180deg, var(--navy) 0 38%, var(--bg) 38% 100%);
}
.login-brand { text-align: center; color: #fff; }
.login-brand img { border-radius: 14px; }
.login-brand h1 { margin: 12px 0 2px; font-size: 26px; }
.login-brand p { margin: 0; color: #C9D4EA; }
.login-card { width: min(400px, 100vw - 40px); box-shadow: 0 12px 32px rgba(14,38,87,.12); }
.login-card h2 { margin: 0 0 18px; font-size: 22px; }

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
  .side {
    position: fixed; z-index: 20; left: 0; top: 0;
    transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.2);
  }
  body.side-open .side { transform: none; }
  body.side-open .scrim { display: block; position: fixed; inset: 0; z-index: 15; background: rgba(14,38,87,.35); }
  .side .side-close, .topbar .menu-btn { display: inline-grid; }
  .topbar { padding-left: 12px; padding-right: 16px; }
  .page-title { text-align: center; }
  .content { padding: 20px 16px 40px; }
  .welcome h2 { font-size: 28px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat-value { font-size: 38px; }
}
@media (prefers-reduced-motion: reduce) { .side { transition: none; } }

/* ---------- Record screens (phase 2) ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.toolbar-filters { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; min-width: 260px; }
.toolbar-filters input, .toolbar-filters select { margin: 0; width: auto; min-width: 150px; flex: 1 1 160px; max-width: 280px; }
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.table-panel { padding: 0; margin-top: 0; }
.table-panel table th:first-child, .table-panel table td:first-child { padding-left: 20px; }
.table-panel th { padding-top: 14px; }
.row-link { font-weight: 600; text-decoration: none; }
.row-link:hover { text-decoration: underline; }
.actions-col { text-align: right; width: 1%; white-space: nowrap; padding-right: 16px; }
.btn-small { padding: 5px 12px; font-size: 14px; }
.btn-danger { color: var(--err); border-color: #E7B9B9; }
.btn-danger:hover { background: var(--err-bg); border-color: var(--err); }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 16px; color: var(--slate); }
.count { color: var(--slate); font-size: 14px; margin: 10px 2px 0; }
.empty-panel { margin-top: 0; }
.empty-panel p { margin: 0; color: var(--slate); }

.back { margin: 0 0 14px; }
.back a { text-decoration: none; font-weight: 500; }
.form-note { color: var(--slate); margin: 0 0 14px; max-width: 70ch; }
.record-form { margin-top: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 20px; }
.field { margin-bottom: 14px; }
.field-wide { grid-column: 1 / -1; }
.field label, .field-label { display: block; font-weight: 500; margin-bottom: 0; }
.field .req { color: var(--err); }
.field .help { display: block; color: var(--slate); font-size: 14px; margin-top: 4px; }
.field .error { display: block; color: var(--err); font-size: 14px; font-weight: 500; margin-top: 4px; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--err); }
.readonly { margin-top: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); min-height: 44px; }
label.check { display: flex; align-items: center; gap: 10px; font-weight: 500; margin: 28px 0 0; }
label.check input { width: 20px; height: 20px; margin: 0; }
label.check.small { display: inline-flex; margin: 0 0 0 12px; font-size: 14px; color: var(--slate); }
label.check.small input { width: 16px; height: 16px; }
.files { list-style: none; padding: 0; margin: 8px 0 10px; }
.files li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; align-items: center; flex-wrap: wrap; }
.files a { font-weight: 500; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--line); }
.danger-zone { margin-top: 16px; display: flex; justify-content: flex-end; }

/* status pills */
.pill-active, .pill-occupied { background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.pill-available { background: #E6EEFB; color: var(--navy); font-weight: 600; }
.pill-draft, .pill-prospective { background: var(--amber-soft); color: #7A5A00; font-weight: 600; }
.pill-maintenance { background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.pill-expired, .pill-terminated, .pill-inactive { background: #ECEFF4; color: var(--slate); }

@media (max-width: 900px) {
  .form-grid { grid-template-columns: 1fr; }
  .hide-m { display: none; }
  label.check { margin-top: 4px; }
  .toolbar-filters input, .toolbar-filters select { max-width: none; }
  .toolbar-actions { width: 100%; }
  .toolbar-actions .btn-primary { flex: 1; }
}

/* ---------- Phase 3a: invoices ---------- */
.pill-sent { background: #E6EEFB; color: var(--navy); font-weight: 600; }
.pill-paid { background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.pill-partial { background: var(--amber-soft); color: #7A5A00; font-weight: 600; }
.pill-overdue { background: var(--err-bg); color: var(--err); font-weight: 600; }
.pill-void { background: #ECEFF4; color: var(--slate); text-decoration: line-through; }
.form-section { margin: 8px 0 12px; font-size: 17px; }
.form-section:not(:first-of-type) { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }

.invoice-toolbar { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.back-link { text-decoration: none; font-weight: 500; }
.lines-editor { margin: 0 0 20px; }
.lines-editor h3 { margin-top: 0; }
.lines-editor td { padding: 6px 6px; }
.lines-editor input, .lines-editor select { margin: 0; }
.lines-editor input.num { text-align: right; }
.lines-editor .vat-input { width: 80px; }

.invoice-doc {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 32px; max-width: 860px; color: #111827;
}
.inv-head { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; padding-bottom: 20px; border-bottom: 3px solid var(--amber); }
.inv-from { display: flex; gap: 14px; font-size: 14px; line-height: 1.45; }
.inv-from img { border-radius: 8px; flex: none; }
.inv-company { display: block; font-size: 18px; margin-bottom: 2px; }
.pre { white-space: pre-line; }
.inv-meta { text-align: right; }
.inv-meta h2 { margin: 0 0 8px; font-size: 24px; color: var(--navy); letter-spacing: .02em; }
.inv-meta dl { display: grid; grid-template-columns: auto auto; gap: 2px 14px; margin: 0 0 8px; font-size: 14px; justify-content: end; }
.inv-meta dt { color: var(--slate); }
.inv-meta dd { margin: 0; font-weight: 600; }
.inv-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; padding: 20px 0; font-size: 14px; line-height: 1.45; }
.inv-parties h3, .inv-foot h3 { margin: 0 0 6px; font-size: 13px; color: var(--slate); font-weight: 600; }
.inv-lines { margin-top: 4px; }
.inv-lines th { color: var(--slate); border-bottom: 2px solid var(--ink); }
.inv-totals { display: flex; justify-content: flex-end; margin-top: 12px; }
.inv-totals dl { display: grid; grid-template-columns: auto auto; gap: 6px 28px; margin: 0; min-width: 300px; font-variant-numeric: tabular-nums; }
.inv-totals dt { color: var(--slate); }
.inv-totals dd { margin: 0; text-align: right; }
.inv-totals .grand { font-size: 19px; font-weight: 700; color: var(--ink); border-top: 2px solid var(--ink); padding-top: 8px; }
.inv-foot { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 14px; line-height: 1.5; }
.inv-note { color: var(--slate); margin: 12px 0 0; }

.gen-form { margin-top: 0; }
.gen-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.gen-summary { margin: 20px 0 4px; }
.gen-card { padding: 0; overflow: hidden; }
.gen-card.is-done { opacity: .6; }
.gen-head { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--line); margin: 0; cursor: pointer; }
.gen-head input { width: 20px; height: 20px; margin: 0; flex: none; }
.gen-head span:nth-child(2) { flex: 1; min-width: 0; }
.gen-head small { display: block; color: var(--slate); font-weight: 400; }
.gen-due { font-family: var(--font-num); font-size: 24px; font-weight: 700; white-space: nowrap; }
.gen-card table td:first-child, .gen-card table th:first-child { padding-left: 18px; }
.gen-card table td:last-child, .gen-card table th:last-child { padding-right: 18px; }
.gen-note { margin: 0; padding: 8px 18px; background: var(--amber-soft); color: #7A5A00; font-size: 14px; font-weight: 500; }
.warn-list { margin: 6px 0 0; padding-left: 20px; font-weight: 400; }
.sticky-save { position: sticky; bottom: 0; z-index: 4; align-items: center; flex-wrap: wrap; border-top: 3px solid var(--amber); padding: 14px 18px; box-shadow: 0 -6px 20px rgba(14,38,87,.08); }

@media (max-width: 900px) {
  .gen-grid { grid-template-columns: 1fr 1fr; }
  .invoice-doc { padding: 20px 16px; }
  .inv-meta { text-align: left; }
  .inv-meta dl { justify-content: start; }
  .inv-parties { grid-template-columns: 1fr; gap: 14px; }
  .inv-totals dl { min-width: 0; width: 100%; }
}

@media print {
  @page { margin: 14mm; }
  body { background: #fff; }
  .side, .topbar, .scrim, .no-print, .flash { display: none !important; }
  .shell, .main { display: block; }
  .content { padding: 0; max-width: none; }
  .invoice-doc { border: 0; padding: 0; max-width: none; }
  .inv-parties { grid-template-columns: 1fr 1fr; }
  .inv-meta { text-align: right; }
  .inv-meta dl { justify-content: end; }
  a { color: inherit; text-decoration: none; }
}
.form-grid > .field { min-width: 0; }
.field input, .field select, .field textarea { max-width: 100%; min-width: 0; }

/* ---------- Phase 3b: payments, statements ---------- */
.pill-confirmed, .pill-issued { background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.pill-pending { background: var(--amber-soft); color: #7A5A00; font-weight: 600; }
.pill-reversed, .pill-cancelled { background: #ECEFF4; color: var(--slate); text-decoration: line-through; }
.nowrap { white-space: nowrap; }
.show-m, .show-m-block, .show-m-inline { display: none; }
.stmt-date { font-size: 12px; color: var(--slate); }
.table-title { margin: 0; padding: 18px 20px 6px; }
td.late { color: var(--warn); font-weight: 600; }
tfoot th { border-top: 2px solid var(--ink); border-bottom: 0; color: var(--ink); padding: 12px 10px; }
tfoot th:first-child { padding-left: 20px; }
.field-wide-2 { grid-column: span 2; }
details.panel summary { cursor: pointer; font-weight: 600; }

.stmt-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0; margin: 20px 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.stmt-summary div { padding: 12px 14px; border-right: 1px solid var(--line); }
.stmt-summary div:last-child { border-right: 0; }
.stmt-summary span { display: block; color: var(--slate); font-size: 13px; }
.stmt-summary strong { font-family: var(--font-num); font-size: 22px; font-variant-numeric: tabular-nums; }
.stmt-summary .stmt-balance { background: var(--navy); color: #fff; }
.stmt-summary .stmt-balance span { color: #C9D4EA; }
.stmt-lines td, .stmt-lines th { font-size: 14px; }
.stmt-open td { color: var(--slate); font-style: italic; }
.aging { margin-top: 22px; }
.aging h3 { margin: 0 0 10px; font-size: 15px; }
.aging-grid { display: grid; grid-template-columns: repeat(5, 1fr); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.aging-grid div { padding: 10px 12px; border-right: 1px solid var(--line); }
.aging-grid div:last-child { border-right: 0; }
.aging-grid span { display: block; font-size: 13px; color: var(--slate); }
.aging-grid strong { font-variant-numeric: tabular-nums; }
.aging-grid .aging-late { background: var(--warn-bg); }
.aging-grid .aging-late strong { color: var(--warn); }

@media (max-width: 900px) {
  .field-wide-2 { grid-column: 1 / -1; }
  .show-m { display: table-cell; }
  .show-m-block { display: block; }
  .show-m-inline { display: inline; }
  .hide-m-inline { display: none; }
  .aging-grid { grid-template-columns: 1fr 1fr; }
  .aging-grid div { border-bottom: 1px solid var(--line); }
  .stmt-summary { grid-template-columns: 1fr 1fr; }
  .stmt-summary div { border-bottom: 1px solid var(--line); }
}
@media print {
  .stmt-summary .stmt-balance { background: #fff; color: #111; border-left: 3px solid #111; }
  .stmt-summary .stmt-balance span { color: #555; }
  .aging-grid { grid-template-columns: repeat(5, 1fr); }
  .hide-m { display: table-cell !important; }
  .show-m, .show-m-block { display: none !important; }
}

/* ---------- Phase 3c: quotations, VAT ---------- */
.pill-accepted { background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.pill-declined, .pill-expired { background: #ECEFF4; color: var(--slate); }
.pill-pending, .pill-approved, .pill-checked { background: var(--amber-soft); color: #7A5A00; font-weight: 600; }
.pill-disputed { background: var(--err-bg); color: var(--err); font-weight: 600; }
.doc-desc { margin: 0 0 12px; }
.lines-editor .qty-input { width: 80px; }
.vat-note p { margin: 0; max-width: 90ch; }
.vat-block { margin-top: 20px; }
.vat-table small.sub { display: block; font-size: 12px; color: var(--slate); font-weight: 400; }
.vat-table .adj { display: inline-block; font-size: 11px; font-weight: 700; color: #7A5A00; background: var(--amber-soft); border-radius: 4px; padding: 0 4px; margin-left: 4px; vertical-align: middle; }
.vat-table tr.is-adjusting td { background: var(--amber-soft); }
.vat-refund { color: var(--ok); }
.vat-foot { padding: 12px 20px 16px; margin: 0; }
@media print { .vat-note, .gen-form { display: none; } .vat-block { break-inside: avoid; } }

/* ---------- Phase 4a: maintenance, H&S ---------- */
.pill-open { background: #E6EEFB; color: var(--navy); font-weight: 600; }
.pill-assigned, .pill-inprogress, .pill-scheduled { background: var(--amber-soft); color: #7A5A00; font-weight: 600; }
.pill-onhold, .pill-closed, .pill-removed { background: #ECEFF4; color: var(--slate); }
.pill-completed, .pill-ok, .pill-current, .pill-low { background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.pill-medium { background: #E6EEFB; color: var(--navy); }
.pill-high, .pill-servicedue, .pill-actionrequired { background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.pill-urgent, .pill-faulty { background: var(--err-bg); color: var(--err); font-weight: 700; }
.subtabs { display: flex; gap: 4px; margin: -8px 0 20px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.subtabs a { padding: 10px 14px; text-decoration: none; color: var(--slate); font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.subtabs a:hover { color: var(--ink); }
.subtabs a.is-active { color: var(--navy); border-bottom-color: var(--amber); }
small.stmt-date { display: block; }
@media (max-width: 900px) { .subtabs { flex-wrap: wrap; overflow-x: visible; } .subtabs a { padding: 10px 8px; font-size: 15px; } }

/* ---------- Phase 4b ---------- */
.list-total { margin: 12px 2px 0; color: var(--ink); }
.pill-submitted { background: var(--amber-soft); color: #7A5A00; font-weight: 600; }
.pill-published, .pill-final { background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.pill-archived, .pill-normal { background: #ECEFF4; color: var(--slate); }
.figures-form { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 16px; }
.figures-form label { margin: 0; font-weight: 600; }
.figures-form input { width: auto; margin: 0; }
.report-title { font-size: 24px; margin: 8px 0 14px; }
.report-body { font-size: 15px; line-height: 1.6; max-width: 80ch; }
.readonly.pre { white-space: pre-line; }

/* ---------- Staff clock-in ---------- */
.station-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; color: var(--slate); }
.scan-result { display: flex; flex-direction: column; gap: 4px; padding: 18px 20px; border-radius: var(--radius); margin-bottom: 16px; border-left: 6px solid; }
.scan-result strong { font-size: 24px; line-height: 1.2; }
.scan-on { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.scan-off { background: #E6EEFB; color: var(--navy); border-color: var(--navy); }
.scan-ignored { background: var(--amber-soft); color: #7A5A00; border-color: var(--amber); }
.scan-error { background: var(--err-bg); color: var(--err); border-color: var(--err); }
.scan-form { margin-top: 0; }
.scan-form label { font-weight: 600; font-size: 18px; }
.scan-form input#code { font-size: 22px; letter-spacing: .08em; padding: 14px; }
.scan-form video { width: 100%; max-width: 480px; margin-top: 12px; border-radius: 8px; background: #000; }
.pill-clockedon { background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.pill-clockedoff { background: #E6EEFB; color: var(--navy); font-weight: 600; }
.pill-repeat { background: #ECEFF4; color: var(--slate); }
.pill-onduty { background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.pill-needsreview { background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.duty-panel { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: 0 0 20px; border-left: 6px solid var(--line); }
.duty-panel.is-on { border-left-color: var(--ok); }
.duty-panel strong { display: block; font-size: 18px; }
.duty-panel span { color: var(--slate); }

.id-card {
  width: 85.6mm; height: 54mm; box-sizing: border-box; padding: 3.5mm 4mm 3mm;
  border: 1px solid var(--line); border-radius: 3mm; background: #fff; color: #111;
  display: flex; flex-direction: column; overflow: hidden; border-top: 4mm solid var(--navy);
}
.id-card-top { display: flex; align-items: center; gap: 2.5mm; font-weight: 700; font-size: 3.3mm; color: var(--navy); }
.id-card-top img { width: 7mm; height: 7mm; border-radius: 1.5mm; }
.id-card-name { font-size: 5mm; font-weight: 700; margin-top: 2.5mm; line-height: 1.1; }
.id-card-role { font-size: 3mm; color: var(--slate); }
.id-card-code { margin-top: auto; }
.id-card-code svg { width: 100%; height: 11mm; display: block; }
.id-card-foot { display: flex; justify-content: space-between; font-size: 2.4mm; margin-top: 1mm; }
.id-card-foot span:first-child { font-family: var(--font-num); font-weight: 700; letter-spacing: .05em; font-size: 3mm; }
@media print { .id-card { border-left-color: #999; border-right-color: #999; border-bottom-color: #999; -webkit-print-color-adjust: exact; print-color-adjust: exact; } }

/* ---------- Phase 5a: guards, visitors ---------- */
.pill-checkedin, .pill-active { background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.pill-checkedout, .pill-inactive { background: #ECEFF4; color: var(--slate); }
.pill-suspended { background: var(--err-bg); color: var(--err); font-weight: 600; }
.visitor-pass { width: 80mm; box-sizing: border-box; padding: 4mm; border: 1px solid var(--line); border-radius: 3mm; background: #fff; color: #111; }
.vp-head { display: flex; align-items: center; gap: 2mm; font-size: 3.4mm; border-bottom: 1mm solid var(--amber); padding-bottom: 2mm; }
.vp-head img { width: 7mm; height: 7mm; border-radius: 1.5mm; }
.vp-head span { flex: 1; font-weight: 600; }
.vp-head strong { background: var(--navy); color: #fff; padding: .6mm 2mm; border-radius: 1mm; letter-spacing: .1em; font-size: 3mm; }
.vp-name { font-size: 6mm; font-weight: 700; margin: 3mm 0 2mm; line-height: 1.1; }
.visitor-pass dl { display: grid; grid-template-columns: auto 1fr; gap: 1mm 3mm; margin: 0 0 3mm; font-size: 3.4mm; }
.visitor-pass dt { color: var(--slate); }
.visitor-pass dd { margin: 0; font-weight: 600; }
.vp-code svg { width: 100%; height: 12mm; display: block; }
.vp-code span { display: block; text-align: center; font-family: var(--font-num); font-weight: 700; letter-spacing: .08em; font-size: 3.4mm; }
.vp-foot { font-size: 2.8mm; color: var(--slate); margin: 2mm 0 0; }
@media print { .visitor-pass { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }

.error-list { margin: 6px 0 0; padding-left: 20px; font-weight: 400; }

/* ---------- Phase 5b: security records ---------- */
.pill-clockedin { background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.pill-clockin { background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.pill-clockout, .pill-clockedout { background: #E6EEFB; color: var(--navy); font-weight: 600; }
.pill-ignored, .pill-notin { background: #ECEFF4; color: var(--slate); }
.pill-critical { background: var(--err); color: #fff; font-weight: 700; }
.pill-investigating { background: var(--amber-soft); color: #7A5A00; font-weight: 600; }
.pill-resolved, .pill-acknowledged, .pill-confirmed { background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.pill-absent, .pill-disputed, .pill-lost { background: var(--err-bg); color: var(--err); font-weight: 600; }
.pill-cancelled, .pill-expired { background: #ECEFF4; color: var(--slate); }
.pill-pending { background: var(--amber-soft); color: #7A5A00; font-weight: 600; }
.table-link { float: right; font-size: 14px; font-weight: 600; }
.stat-link { text-decoration: none; color: inherit; }
.stat-sub { color: var(--slate); font-size: 13px; margin-top: 2px; }
.sec-filter { margin-bottom: 16px; }
.sec-filter select { width: auto; min-width: 220px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ob-snippet { margin-top: 4px; color: var(--ink); white-space: pre-line; }
.ob-list { list-style: none; margin: 0; padding: 0; }
.ob-list li { padding: 12px 20px; border-top: 1px solid var(--line); }

/* ---------- Phase 5c: patrols and security reports ---------- */
.pill-inprogress { background: var(--amber-soft); color: #7A5A00; font-weight: 600; }
.pill-missed { background: var(--err-bg); color: var(--err); font-weight: 600; }
.pill-archived { background: #ECEFF4; color: var(--slate); }
.patrol-head { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.gps-row { margin: 4px 0 16px; }
.check { display: flex; gap: 8px; align-items: center; margin: 6px 0; font-weight: 400; }
.check input { width: auto; margin: 0; }
fieldset.field { border: 0; padding: 0; margin: 0 0 16px; }
fieldset.field legend { font-weight: 600; margin-bottom: 6px; }
.section-title { font-size: 20px; margin: 4px 0 14px; }
.report-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-top: 20px; }
@media (max-width: 900px) { .report-grid { grid-template-columns: 1fr; } }
.bars { width: 100%; height: auto; }
.bars rect { fill: var(--navy); }
.bars text { font-size: 8px; fill: var(--slate); }
.vs-month { border-top: 1px solid var(--line); }
.vs-month summary { display: flex; justify-content: space-between; padding: 12px 20px; cursor: pointer; list-style: none; }
.vs-month summary::-webkit-details-marker { display: none; }
.vs-month summary span::before { content: "▸ "; color: var(--slate); }
.vs-month[open] summary span::before { content: "▾ "; }
.cp-labels { display: grid; grid-template-columns: repeat(auto-fill, 90mm); gap: 6mm; }
.cp-label { width: 90mm; box-sizing: border-box; padding: 4mm; border: 1px dashed #999; border-radius: 2mm; background: #fff; color: #111; break-inside: avoid; }
.cp-top { display: flex; align-items: center; gap: 2mm; font-size: 3mm; }
.cp-top span { flex: 1; font-weight: 600; }
.cp-top strong { font-size: 2.6mm; letter-spacing: .08em; color: var(--navy); }
.cp-name { font-size: 6mm; font-weight: 700; margin: 2.5mm 0; }
.cp-code svg { width: 100%; height: 14mm; display: block; }
.cp-code span { display: block; text-align: center; font-family: var(--font-num); font-weight: 700; letter-spacing: .08em; font-size: 3.4mm; }
.print-table th, .print-table td { font-size: 13px; }
@media print {
  .sec-print { font-size: 9pt; }
  .print-table th, .print-table td { font-size: 8pt; padding: 3px 5px; }
  .cp-label { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
@page { size: auto; }

/* ---------- Phase 6: AI tools ---------- */
.ai-intro { max-width: 80ch; margin-top: 0; }
.ai-layout { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .ai-layout { grid-template-columns: 1fr; } }
.ai-note { font-size: 13px; margin: 10px 0 0; }
.check-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.ai-out { min-height: 240px; }
.ai-out-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.ai-out-head h3 { margin: 0; }
.ai-out-actions { display: flex; gap: 8px; }
.md { line-height: 1.6; overflow-wrap: anywhere; }
.md h2, .md h3, .md h4, .md h5, .md h6 { margin: 1.1em 0 .4em; line-height: 1.25; }
.md h2 { font-size: 22px; } .md h3 { font-size: 19px; } .md h4 { font-size: 17px; }
.md ul, .md ol { padding-left: 22px; }
.md blockquote { border-left: 4px solid var(--line); margin: .6em 0; padding: .2em 12px; color: var(--slate); }
.md pre { background: #F4F6FA; padding: 12px; border-radius: 8px; overflow-x: auto; }
.md code { background: #F4F6FA; padding: 1px 4px; border-radius: 4px; font-size: .92em; }
.md table { margin: .6em 0; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1.2em 0; }

/* ---------- Phase 6b: public lead form ---------- */
html:has(body.public), body.public { background: var(--bg, #F3F5F9); min-height: 100%; }
.public-wrap { max-width: 640px; margin: 0 auto; padding: 24px 16px 40px; }
.public-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.public-head img { border-radius: 10px; }
.public-head strong { display: block; color: var(--navy); font-size: 18px; }
.public-head span { color: var(--slate); font-size: 14px; }
.public-wrap h1 { font-size: 26px; margin: 0 0 6px; color: var(--ink); }
.public-form .field input, .public-form .field select, .public-form .field textarea { width: 100%; }
.public-foot { text-align: center; color: var(--slate); font-size: 14px; margin-top: 24px; }
.public-done h1 { color: var(--ok); }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.small { font-size: 13px; }
.field-error { color: var(--err); font-size: 14px; margin: 4px 0 0; }

/* ---------- Public landing page ---------- */
body.lp { background: #fff; color: var(--ink); margin: 0; }
.skip { position: absolute; left: -9999px; top: 8px; background: var(--navy); color: #fff; padding: 8px 12px; border-radius: 6px; z-index: 10; }
.skip:focus { left: 8px; }
.lp-in { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.lp-top { position: sticky; top: 0; z-index: 5; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(6px); }
.lp-bar { display: flex; align-items: center; gap: 20px; height: 64px; }
.lp-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--navy); text-decoration: none; font-size: 17px; }
.lp-brand img { border-radius: 8px; }
.lp-nav { display: flex; gap: 22px; margin-left: auto; }
.lp-nav a { color: var(--slate); text-decoration: none; font-weight: 600; }
.lp-nav a:hover { color: var(--navy); }
.lp-login { white-space: nowrap; }
@media (max-width: 760px) { .lp-nav { display: none; } .lp-login { margin-left: auto; } .lp-brand span { font-size: 15px; } }
.lp-hero { background: linear-gradient(160deg, #0F2A5F 0%, #15397F 60%, #1D4A9C 100%); color: #fff; padding: 64px 0 72px; overflow: hidden; }
.lp-hero-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 40px; align-items: center; }
@media (max-width: 900px) { .lp-hero-grid { grid-template-columns: 1fr; } .lp-hero { padding: 40px 0 48px; } }
.lp-eyebrow { color: var(--amber); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; font-size: 13px; margin: 0 0 12px; }
.lp-hero h1 { font-size: clamp(32px, 5vw, 52px); line-height: 1.08; margin: 0 0 16px; color: #fff; }
.lp-lead { font-size: 18px; line-height: 1.55; color: #DCE5F5; max-width: 58ch; margin: 0 0 24px; }
.lp-cta { display: flex; flex-wrap: wrap; gap: 12px; }
.btn-lg { padding: 14px 22px; font-size: 16px; }
.lp-hero .btn-primary { background: var(--amber); border-color: var(--amber); color: #1A1A1A; }
.lp-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.5); }
.lp-ghost:hover { background: rgba(255,255,255,.1); color: #fff; }
.lp-trust { color: #B8C6E3; font-size: 14px; margin: 20px 0 0; }
.lp-mock { position: relative; height: 370px; }
@media (max-width: 900px) { .lp-mock { display: none; } }
.lp-card { position: absolute; background: #fff; color: var(--ink); border-radius: 12px; padding: 14px 16px; box-shadow: 0 12px 30px rgba(0,0,0,.25); display: flex; flex-direction: column; gap: 4px; min-width: 210px; }
.lp-card small { color: var(--slate); font-size: 12px; }
.lp-card strong { font-size: 16px; }
.lp-card .pill { align-self: flex-start; margin-top: 4px; }
.lp-card-a { top: 0; left: 8%; flex-direction: row; align-items: center; gap: 10px; }
.lp-card-a > div { display: flex; flex-direction: column; gap: 2px; }
.lp-card-b { top: 88px; right: 0; }
.lp-card-c { top: 176px; left: 0; }
.lp-card-d { top: 262px; right: 0; }
.lp-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--ok); flex: none; }
.lp-bar2 { height: 8px; background: #E8EDF6; border-radius: 4px; overflow: hidden; margin-top: 4px; }
.lp-bar2 i { display: block; height: 100%; background: var(--amber); }
.lp-sec { padding: 64px 0; }
@media (max-width: 760px) { .lp-sec { padding: 44px 0; } }
.lp-alt { background: #F4F6FA; }
.lp-sec h2 { font-size: clamp(26px, 3.4vw, 34px); margin: 0 0 8px; color: var(--ink); }
.lp-sub { color: var(--slate); font-size: 17px; margin: 0 0 28px; max-width: 62ch; }
.lp-grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
@media (max-width: 900px) { .lp-grid3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .lp-grid3 { grid-template-columns: 1fr; } }
.lp-svc { border: 1px solid var(--line); border-radius: 12px; padding: 22px; background: #fff; }
.lp-svc h3 { font-size: 18px; margin: 12px 0 6px; }
.lp-svc p { color: var(--slate); margin: 0; line-height: 1.55; }
.lp-ic { display: inline-flex; width: 44px; height: 44px; border-radius: 10px; background: #EAF0FB; color: var(--navy); align-items: center; justify-content: center; }
.lp-ic svg { width: 22px; height: 22px; }
.lp-two { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; align-items: start; }
@media (max-width: 860px) { .lp-two { grid-template-columns: 1fr; gap: 24px; } }
.lp-checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.lp-checks li { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px 14px 46px; position: relative; font-weight: 600; }
.lp-checks li::before { content: ""; position: absolute; left: 16px; top: 50%; width: 18px; height: 18px; margin-top: -9px; border-radius: 50%; background: var(--ok); box-shadow: inset 0 0 0 5px var(--ok-bg); }
.lp-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; counter-reset: s; }
@media (max-width: 900px) { .lp-steps { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .lp-steps { grid-template-columns: 1fr; } }
.lp-steps span { display: inline-flex; width: 36px; height: 36px; border-radius: 50%; background: var(--navy); color: #fff; font-weight: 700; align-items: center; justify-content: center; }
.lp-steps h3 { margin: 12px 0 4px; font-size: 18px; }
.lp-steps p { margin: 0; color: var(--slate); line-height: 1.5; }
.lp-who article { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 22px; }
.lp-who h3 { margin: 0 0 10px; }
.lp-who ul { margin: 0; padding-left: 20px; line-height: 1.8; }
.lp-own { margin-top: 24px; display: flex; gap: 20px; align-items: center; justify-content: space-between; background: var(--navy); color: #fff; border-radius: 12px; padding: 22px 24px; flex-wrap: wrap; }
.lp-own h3 { margin: 0 0 4px; color: #fff; }
.lp-own p { margin: 0; color: #DCE5F5; max-width: 60ch; }
.lp-own .btn { background: var(--amber); border-color: var(--amber); color: #1A1A1A; }
.lp-contact { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.lp-contact li { display: flex; gap: 10px; align-items: center; }
.lp-contact svg { width: 20px; height: 20px; color: var(--navy); }
.lp-form { margin: 0; }
.lp-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 520px) { .lp-row { grid-template-columns: 1fr; } }
.lp-foot { background: #0F2A5F; color: #C9D5EC; padding: 36px 0 20px; }
.lp-foot a { color: #fff; }
.lp-foot-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 20px; }
@media (max-width: 760px) { .lp-foot-grid { grid-template-columns: 1fr; } }
.lp-foot-grid > div { display: flex; flex-direction: column; gap: 6px; }
.lp-foot strong { color: #fff; }
.lp-small { font-size: 13px; margin-top: 24px; color: #9FB0D2; }

/* ---------- Test site banner ---------- */
.test-banner { background: #FFD43B; color: #1A1A1A; text-align: center; font-size: 14px; padding: 6px 12px; position: relative; z-index: 50; }
.test-banner strong { letter-spacing: .06em; }

/* month/property filter rows: compact on wide screens, full width on phones */
.inline-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-filters input, .inline-filters select { width: auto; min-width: 180px; margin: 0; }
@media (max-width: 600px) { .inline-filters input, .inline-filters select { width: 100%; } }
.toolbar.inline-filters, .inline-filters { justify-content: flex-start; }

/* ---------- Landlord branding on documents ---------- */
.inv-from-landlord { align-items: flex-start; }
.landlord-logo { max-width: 220px; max-height: 72px; width: auto; height: auto; object-fit: contain; }
.managed-by { color: var(--slate); font-size: 13px; margin-bottom: 2px; }
.logo-preview { background: #fff; border: 1px dashed var(--line); border-radius: 8px; padding: 16px; display: inline-block; margin-bottom: 12px; }
.logo-preview img { max-width: 320px; max-height: 110px; display: block; }
.logo-form { margin-bottom: 8px; }
@media print { .landlord-logo { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }
.inv-head { flex-wrap: wrap; }
.doc-warn { order: 3; flex-basis: 100%; margin: 12px 0 0; }
