:root {
  --brand: #1E3A5F; --brand-dark: #152B47; --brand-soft: #E8EEF6; --brand-glow: rgba(30,58,95,.18);
  --accent: #059669; --accent-hover: #047857; --accent-bright: #10B981; --accent-soft: #E6F7F0; --accent-glow: rgba(16,185,129,.2);
  --red: #D7191F; --red-dark: #A8121A; --red-soft: #FDEBEC; --red-glow: rgba(215,25,31,.18);
  --ink: #1B1B1F; --ink-2: #4A4A52; --ink-3: #7A7A85; --line: #E3E8EF; --line-2: #EEF1F6;
  --bg: #F5F7FA; --card: #FFFFFF; --sidebar: #1E3A5F; --sidebar-ink: #C7D3E3;
  --green: #1E8E4A; --green-soft: #E6F4EA; --amber: #B86E00; --amber-soft: #FFF3DF; --blue: #1F5FBF; --blue-soft: #E8F0FC; --grey-soft: #EFEEEC;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(27,27,31,.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; } a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
p { margin: 0 0 10px; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
.muted { color: var(--ink-3); } .small { font-size: 13px; } .right { text-align: right; } .center { text-align: center; }
.mono { font-family: var(--mono); font-size: 13px; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
@media (max-width: 640px) { .hide-sm { display: none !important; } }
.flex { display: flex; gap: 10px; align-items: center; } .between { justify-content: space-between; } .wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.stack > * + * { margin-top: 10px; }
.mt { margin-top: 16px; } .mb { margin-bottom: 16px; }

/* boot */
.boot { height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; background: #fff; }
.spinner { width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* auth */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero { background: radial-gradient(1200px 600px at 10% 10%, #2E5283 0%, var(--brand) 45%, var(--brand-dark) 100%); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-hero img { width: min(420px, 80%); }
.auth-hero h2 { font-size: 30px; line-height: 1.2; font-weight: 700; max-width: 520px; }
.auth-hero ul { list-style: none; padding: 0; margin: 22px 0 0; display: grid; gap: 10px; max-width: 520px; }
.auth-hero li { padding-left: 26px; position: relative; opacity: .95; }
.auth-hero li::before { content: ""; position: absolute; left: 0; top: 7px; width: 14px; height: 14px; border-radius: 50%; background: rgba(16,185,129,.25); box-shadow: inset 0 0 0 3px var(--accent-bright); }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: #fff; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .logo-sm { display: none; margin-bottom: 24px; }
.auth-card h1 { margin-bottom: 4px; }
.auth-switch { margin-top: 18px; font-size: 14px; color: var(--ink-2); }
.auth-foot { font-size: 13px; opacity: .8; }
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth-card .logo-sm { display: block; width: 200px; }
}

/* layout */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-ink); padding: 10px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.sidebar .brand { padding: 2px 8px 8px; }
.sidebar .brand img { width: 186px; display: block; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 8px; color: var(--sidebar-ink); font-weight: 500; font-size: 14px; }
.nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; color: #fff; }
.nav a.active { background: var(--accent); color: #fff; }
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav .group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #7F93AD; padding: 9px 10px 3px; }
.nav .badge { margin-left: auto; background: rgba(255,255,255,.14); color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 999px; }
.nav a.active .badge { background: rgba(255,255,255,.25); }
.sidebar .foot { margin-top: auto; padding: 8px 10px 0; font-size: 12px; color: #7F93AD; flex: none; }
.sidebar .foot strong, .sidebar .foot .em { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .foot strong { color: #fff; font-weight: 600; font-size: 13px; }
.sidebar .nav { flex: 1; }
.main { min-width: 0; padding: 20px 28px 60px; }
.topbar { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.topbar h1 { flex: 1; }
.btn.menu-btn { display: none; }
.trial { background: #EEF3FA; color: var(--brand); border: 1px solid #CBD8EA; padding: 8px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.trial a { color: var(--accent); font-weight: 600; }
.trial.bad { background: var(--red-soft); color: var(--red-dark); border-color: #F3B9BC; }
.bottom-nav { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 40; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .sidebar.open { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 39; }
  .main { padding: 14px 14px 90px; }
  .btn.menu-btn { display: inline-flex; }
  .topbar { flex-wrap: wrap; } .topbar h1 { font-size: 19px; }
  .topbar .btn-row .btn { padding: 8px 10px; font-size: 13px; }
  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line); z-index: 30; padding-bottom: env(safe-area-inset-bottom); }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 6px; font-size: 11px; color: var(--ink-3); }
  .bottom-nav a svg { width: 22px; height: 22px; }
  .bottom-nav a.active { color: var(--accent); }
}

/* cards & grids */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 16px; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); } }
.stat { padding: 16px 18px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); cursor: pointer; transition: transform .1s; }
.stat:hover { transform: translateY(-1px); border-color: #d9d6d2; }
.stat .label { font-size: 12.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 4px; letter-spacing: -.02em; color: var(--brand); }
.stat .sub { font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.stat.alert .value { color: var(--red); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 8px; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: #FAF9F7; border-color: #d2cfca; text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; } .btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { border-color: transparent; background: transparent; } .btn.ghost:hover { background: var(--grey-soft); }
.btn.danger { color: var(--red); } .btn.danger:hover { background: var(--red-soft); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.icon { padding: 7px; }
.btn svg { width: 16px; height: 16px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* forms */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.input, input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=time], input[type=tel], input[type=url], input[type=search], select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; background: #fff; outline: none; transition: border-color .12s, box-shadow .12s; min-width: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--accent-bright); box-shadow: 0 0 0 3px var(--accent-glow); }
textarea { min-height: 80px; resize: vertical; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); } input[type=checkbox] { width: 16px; height: 16px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.error { color: var(--red); font-size: 13.5px; background: var(--red-soft); border: 1px solid #F3B9BC; padding: 8px 10px; border-radius: 8px; }
.help { font-size: 12.5px; color: var(--ink-3); }

/* search box */
.search { position: relative; }
.search input { padding-left: 34px; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink-3); }

/* tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -18px; padding: 0 18px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tr.click { cursor: pointer; } tr.click:hover td { background: #FBFAF8; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 600; border-bottom: 0; }
.empty { padding: 30px; text-align: center; color: var(--ink-3); }
.empty strong { display: block; color: var(--ink-2); margin-bottom: 4px; }

/* chips */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--grey-soft); color: var(--ink-2); white-space: nowrap; }
.chip.green { background: var(--green-soft); color: var(--green); } .chip.amber { background: var(--amber-soft); color: var(--amber); }
.chip.red { background: var(--red-soft); color: var(--red-dark); } .chip.blue { background: var(--brand-soft); color: var(--brand); }
.chip.grey { background: var(--grey-soft); color: var(--ink-3); }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.filters .tab { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; text-decoration: none; line-height: 1.3; }
.filters .tab svg { width: 15px; height: 15px; flex: none; }
.filters .tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* doc editor lines */
.lines th, .lines td { padding: 6px 6px; }
.lines input { padding: 7px 8px; }
.lines .qty { width: 80px; } .lines .price { width: 100px; } .lines .pct { width: 70px; } .lines .vat { width: 78px; }
.lines td.desc { min-width: 300px; width: 100%; }
.lines td.desc .l-desc { width: 100%; min-width: 280px; }
@media (max-width: 760px) { .lines td.desc { min-width: 230px; } .lines td.desc .l-desc { min-width: 210px; } }
.avail { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }
.avail b { color: var(--ink-2); }
.avail .ok { color: var(--green); } .avail .low { color: var(--red); }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 4px 24px; max-width: 320px; margin-left: auto; font-size: 14.5px; }
.totals .big { font-size: 18px; font-weight: 700; }
.autocomplete { position: relative; }
.ac-list { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); max-height: 260px; overflow-y: auto; }
.ac-item { padding: 8px 10px; cursor: pointer; font-size: 14px; display: flex; justify-content: space-between; gap: 10px; }
.ac-item:hover, .ac-item.active { background: var(--accent-soft); }
.ac-item .muted { font-size: 12px; }

/* doc view */
.doc-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.doc-head .num { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 14px; }
.kv dt { color: var(--ink-3); } .kv dd { margin: 0; }
.activity { list-style: none; padding: 0; margin: 0; }
.activity li { padding: 8px 0; border-bottom: 1px solid var(--line-2); font-size: 14px; display: flex; gap: 10px; }
.activity .when { color: var(--ink-3); font-size: 12px; white-space: nowrap; min-width: 92px; }
.activity li.comment { background: var(--brand-soft); border-radius: 8px; padding: 8px 10px; border: 0; margin: 4px 0; }
.progress { height: 6px; background: var(--line-2); border-radius: 4px; overflow: hidden; min-width: 60px; }
.progress i { display: block; height: 100%; background: var(--accent); }

/* modal */
.modal-scrim { position: fixed; inset: 0; background: rgba(27,27,31,.5); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
@media (max-width: 640px) { .modal-scrim { align-items: flex-end; padding: 0; } .modal { border-radius: 14px 14px 0 0; max-height: 94vh; } }

/* toast */
#toast-root { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
#toast-root .toast.undo { pointer-events: auto; }
.toast { background: var(--brand); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow); animation: up .2s ease; }
.toast.err { background: var(--red); }
@keyframes up { from { opacity: 0; transform: translateY(8px); } }

/* charts */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 10px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; font-size: 11px; color: var(--ink-3); }
.bars .bar i { width: 100%; background: var(--brand); border-radius: 4px 4px 0 0; min-height: 2px; opacity: .9; }
.bars .bar i.alt { background: #B9B6B1; }
.bars .bar span { white-space: nowrap; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--ink-3); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* onboarding list */
.todo { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.todo li { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.todo li.done { opacity: .55; text-decoration: line-through; }
.todo .n { width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex: none; }

/* print view */
.print-page { background: #fff; color: #111; max-width: 820px; margin: 0 auto; padding: 36px 40px; font-size: 13.5px; }
.print-bar { background: var(--brand); color: #fff; padding: 10px 16px; display: flex; gap: 10px; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 5; }
.print-head { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.print-head img { max-height: 70px; max-width: 240px; }
.print-title { font-size: 26px; font-weight: 800; letter-spacing: -.02em; color: var(--brand); text-transform: uppercase; }
.print-meta { font-size: 13px; margin-top: 6px; }
.print-meta div { display: flex; gap: 10px; } .print-meta span:first-child { color: #666; min-width: 90px; }
.print-parties { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-bottom: 22px; }
.print-parties h4 { margin: 0 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #777; }
.print-page table th { color: #444; border-bottom: 2px solid var(--brand); font-size: 11.5px; }
.print-page table td { border-bottom: 1px solid #eee; padding: 8px 8px; }
.print-totals { margin-left: auto; width: 280px; margin-top: 10px; }
.print-totals div { display: flex; justify-content: space-between; padding: 4px 0; }
.print-totals .grand { border-top: 2px solid #111; font-weight: 800; font-size: 16px; margin-top: 4px; padding-top: 8px; }
.print-foot { margin-top: 30px; padding-top: 14px; border-top: 1px solid #ddd; font-size: 12.5px; color: #555; display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.print-note { background: #FAF9F7; padding: 10px 12px; border-radius: 8px; margin-top: 16px; font-size: 13px; }
.sig { margin-top: 36px; display: grid; grid-template-columns: 1fr 1fr; gap: 30px; }
.sig div { border-top: 1px solid #333; padding-top: 6px; font-size: 12px; color: #555; }
@media print {
  body { background: #fff; }
  .print-bar, .no-print { display: none !important; }
  .print-page { max-width: none; padding: 0; }
  @page { margin: 14mm; }
}

.exp-list { max-height: 220px; overflow: auto; border: 1px solid var(--line-2); border-radius: 8px; }
.exp-list td { padding: 7px 8px; font-size: 13px; }
.btn.disabled, a.btn.disabled { opacity: .45; pointer-events: none; }

.field.check { flex-direction: row; align-items: center; }

/* jobs board */
.job-board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.job-col { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.job-card { display: block; padding: 12px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); transition: border-color .12s, transform .1s; }
.job-card:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); }
.todo li .step { width: 18px; height: 18px; }
@media (max-width: 1000px) { .job-board { grid-template-columns: minmax(0, 1fr); } }

.ac-head { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); padding: 8px 10px 2px; font-weight: 600; }
.ac-foot { font-size: 12px; color: var(--ink-3); padding: 6px 10px 8px; border-top: 1px solid var(--line-2); }
.ac-save { color: var(--accent); font-weight: 600; } .ac-save svg { width: 14px; height: 14px; vertical-align: -2px; }

/* compliance */
.comp-list { display: grid; gap: 8px; margin-top: 8px; }
.comp-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; transition: border-color .12s, background .12s; }
.comp-item:hover { border-color: var(--accent); }
.comp-item.locked { cursor: default; }
.comp-item.done { background: var(--accent-soft); border-color: #BFE8D6; }
.comp-item.fail { background: var(--red-soft); border-color: #F3B9BC; }
.comp-item.na { background: var(--grey-soft); }
.comp-item .grow { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.comp-mark { flex: 0 0 22px; height: 22px; border: 2px solid var(--line); border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; color: #fff; margin-top: 1px; }
.comp-item.done .comp-mark { background: var(--accent); border-color: var(--accent); }
.comp-item.fail .comp-mark { background: var(--red); border-color: var(--red); }
.comp-item.na .comp-mark { background: var(--ink-3); border-color: var(--ink-3); }
.comp-go { color: var(--ink-3); font-size: 20px; line-height: 1; align-self: center; }
.comp-val { color: var(--ink-2); }
.comp-ev { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; align-items: center; }
.comp-ev img { width: 36px; height: 36px; object-fit: cover; border-radius: 5px; border: 1px solid var(--line); }
.comp-req { font-size: 15px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg-btn { padding: 8px 12px; background: #fff; border: 0; border-right: 1px solid var(--line); font: inherit; font-size: 13.5px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.seg-btn:last-child { border-right: 0; }
.seg-btn.on { background: var(--accent); color: #fff; }
.seg-btn.bad.on { background: var(--red); }

/* photos & documents */
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.file-grid.sm { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.file-tile { position: relative; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.file-thumb { display: flex; align-items: center; justify-content: center; height: 110px; background: var(--grey-soft); overflow: hidden; }
.file-grid.sm .file-thumb { height: 80px; }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-ico { display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 56px; border-radius: 6px; background: var(--brand); color: #fff; font-weight: 800; font-size: 12px; letter-spacing: .04em; }
.file-ico.sm { width: 36px; height: 36px; font-size: 10px; border-radius: 5px; }
.file-meta { padding: 7px 8px 8px; font-size: 12.5px; }
.file-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }
.file-del { position: absolute; top: 4px; right: 4px; background: rgba(255,255,255,.9) !important; }

/* people & equipment */
.state-ok { color: var(--green); } .state-due_soon { color: var(--amber); } .state-overdue { color: var(--red); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.scheme { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.scheme summary { cursor: pointer; list-style: none; gap: 14px; } .scheme summary::-webkit-details-marker { display: none; }

/* undo toast */
.toast.undo { display: flex; align-items: center; gap: 14px; padding: 10px 10px 10px 16px; background: var(--brand); }
.toast.undo .undo-btn { background: #fff; color: var(--brand); border: 0; border-radius: 8px; padding: 7px 12px; font-weight: 700; cursor: pointer; font-size: 13px; }
.toast.undo .undo-btn:hover { background: var(--accent-soft); }
.toast.undo .undo-secs { display: inline-block; min-width: 20px; text-align: right; opacity: .7; font-variant-numeric: tabular-nums; }

/* week planner */
.plan-board { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; align-items: start; }

.plan-side { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin-bottom: 10px; }
.plan-side .plan-col { min-height: 0; }
.plan-side .plan-cards { flex-direction: row; flex-wrap: wrap; }
.plan-side .plan-card { width: 220px; }
.plan-col { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px; min-height: 160px; transition: background .12s, border-color .12s; }
.plan-col.today { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }
.plan-col.late { background: var(--red-soft); border-color: #F3B9BC; }
.plan-col.unsched { background: var(--amber-soft); }
.plan-col.over { background: var(--accent-soft); border-color: var(--accent); }
.plan-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 13.5px; margin-bottom: 6px; }
.plan-head .n { background: var(--grey-soft); color: var(--ink-2); border-radius: 999px; padding: 1px 8px; font-size: 12px; }
.plan-cards { display: flex; flex-direction: column; gap: 8px; }
.plan-card { display: block; padding: 8px 9px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); font-size: 13px; cursor: grab; transition: border-color .12s, transform .1s; }
.plan-card:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); }
.plan-card.dragging { opacity: .5; }
.plan-card .plan-title { font-weight: 600; margin: 4px 0 2px; line-height: 1.3; }
.plan-card .plan-note { color: var(--amber); margin-top: 3px; }
.plan-empty { color: var(--ink-3); font-size: 12.5px; padding: 8px 0; }
.mt-xs { margin-top: 4px; } .mb-xs { margin-bottom: 6px; } .ml { margin-left: 8px; }
@media (max-width: 1100px) { .plan-board { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); } }
@media (max-width: 640px) { .plan-board { grid-template-columns: repeat(2, minmax(0, 1fr)); } .plan-side .plan-card { width: 100%; } }
.file-grid > p { grid-column: 1 / -1; }
.mod { padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; }
.mod.on { border-color: #BFE8D6; background: var(--accent-soft); }
.pat-grid input, .pat-grid select { padding: 6px 7px; font-size: 13px; }
.pat-grid td { padding: 4px 4px; }
.pf { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.pf button { border: 0; background: #fff; padding: 5px 8px; font: inherit; font-size: 12px; font-weight: 700; color: var(--ink-3); cursor: pointer; border-right: 1px solid var(--line); }
.pf button:last-child { border-right: 0; }
.pf button.p { background: var(--accent); color: #fff; } .pf button.f { background: var(--red); color: #fff; } .pf button.s { background: var(--ink-3); color: #fff; }
.pat-fail td { background: var(--red-soft); }

.card, .main, .content { min-width: 0; }
@media (max-width: 760px) { .print-page { padding: 14px; font-size: 12px; } .print-page table { font-size: 11px; } .print-head { flex-wrap: wrap; gap: 10px; } .print-head .right { text-align: left; } }
.filters select.tab { width: auto; max-width: 260px; }
td .mono, td.mono { white-space: nowrap; }
.card-title h2 { margin: 0; }
.grid { align-items: start; }
.kv dd { min-width: 0; overflow-wrap: anywhere; }

/* phone: each document line becomes a stacked block instead of a sideways-scrolling table */
@media (max-width: 640px) {
  table.lines, table.lines tbody { display: block; }
  table.lines thead { display: none; }
  table.lines tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 8px; padding: 10px 0 12px; border-bottom: 1px solid var(--line); position: relative; }
  table.lines td { display: block; padding: 0; border: 0; min-width: 0; }
  table.lines td.desc { grid-column: 1 / -1; padding-right: 40px; }
  table.lines td.desc .l-desc { min-width: 0; }
  table.lines td[data-l]::before { content: attr(data-l); display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 600; margin-bottom: 3px; }
  table.lines td.l-net { text-align: left; font-weight: 600; padding-top: 18px; }
  table.lines td.l-x { position: absolute; top: 8px; right: 0; }
  .lines .qty, .lines .price, .lines .pct, .lines .vat, .lines .l-type { width: 100% !important; }
  .table-wrap:has(> table.lines) { overflow: visible; }
}
@media screen and (max-width: 760px) { .print-page table { display: block; overflow-x: auto; max-width: 100%; } .print-page .print-meta { max-width: 100%; } }
@media screen and (max-width: 760px) { .print-page { overflow-x: hidden; } .print-page .print-head > div { min-width: 0; } .print-page .print-totals { max-width: 100%; } }

/* job costing */
.neg{color:var(--red)}
.stat .value.neg{color:var(--red)}
details.mt-xs summary{cursor:pointer;padding:4px 0}
table.small td,table.small th{padding:6px 8px;font-size:13px}
.btn.icon.sm{padding:4px;width:26px;height:26px}
.btn.icon.sm svg{width:14px;height:14px}
.kv-box{background:var(--bg-2,#f6f7f9);border:1px solid var(--line);border-radius:10px;padding:10px 12px}
.kv-box dl.kv{margin:0}

/* compliance record (rebuilt) */
.comp-head { display: flex; gap: 16px; align-items: center; padding: 4px 0 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.ring { --p: 0; flex: 0 0 64px; width: 64px; height: 64px; border-radius: 50%; background: conic-gradient(var(--amber) calc(var(--p) * 1%), var(--grey-soft) 0); display: grid; place-items: center; }
.ring.ok { background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--grey-soft) 0); }
.ring.bad { background: conic-gradient(var(--red) calc(var(--p) * 1%), var(--grey-soft) 0); }
.ring span { width: 48px; height: 48px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.comp-scheme { margin-top: 14px; }
.comp-scheme-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.comp-scheme-head h3 { font-size: 13px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; margin: 0; }
.comp-item .comp-mark svg { width: 13px; height: 13px; color: var(--ink-3); }
.comp-item.open .comp-mark { border-style: dashed; }
.chip.kind { background: #EEF2F7; color: var(--ink-2); font-weight: 500; text-transform: none; letter-spacing: 0; }
.comp-hint:empty { display: none; }
.comp-sug { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--grey-soft); color: var(--ink-2); margin: 2px 4px 0 0; }
.comp-sug.ok { background: var(--accent-soft); color: #136B4A; }
.comp-sug.warn { background: var(--amber-soft, #FFF4D6); color: #8A5A00; }
.comp-sug.bad { background: var(--red-soft); color: #9B1C22; }
.comp-who .chip { vertical-align: middle; }
.sig-wrap { position: relative; margin-top: 6px; border: 1.5px dashed var(--line); border-radius: 10px; background: #fff; height: 170px; overflow: hidden; }
.sig-wrap canvas { width: 100%; height: 100%; display: block; cursor: crosshair; }
.sig-line { position: absolute; left: 24px; right: 24px; bottom: 36px; border-top: 1px solid #cfd6e0; pointer-events: none; }
.sup-row { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.sup-row label.check { align-items: flex-start; }
.sup-row .sup-certs:empty { display: none; }
.file-tile.pick { cursor: pointer; text-align: left; font: inherit; }
.file-tile.pick:hover { border-color: var(--accent); }
.comp-dlg textarea { min-height: 70px; }
@media (max-width: 640px) { .comp-head { gap: 12px; } .ring { flex-basis: 56px; width: 56px; height: 56px; } .ring span { width: 42px; height: 42px; font-size: 12px; } }

/* scheme editor */
.sc-row { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-top: 6px; background: #fff; }
.sc-main { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.sc-main .sc-clause { width: 76px; font-family: var(--mono); font-size: 12px; }
.sc-main .sc-label { flex: 1 1 220px; min-width: 0; }
.sc-main .sc-kind { width: auto; max-width: 220px; }
.sc-grip { color: var(--ink-3); cursor: default; user-select: none; font-size: 12px; letter-spacing: -2px; }
.sc-extra { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.sc-extra .sc-help { flex: 1 1 260px; min-width: 0; font-size: 13px; }
.sc-opt { display: none; align-items: center; gap: 6px; }
.sc-opt input, .sc-opt select { font-size: 13px; }
.sc-row[data-kind="person"] .sc-opt-person, .sc-row[data-kind="document"] .sc-opt-document, .sc-row[data-kind="photo"] .sc-opt-photo, .sc-row[data-kind="reading"] .sc-opt-reading, .sc-row[data-kind="signoff"] .sc-opt-signoff, .sc-row[data-kind="reference"] .sc-opt-reference, .sc-row[data-kind="check"] .sc-opt-check { display: inline-flex; }
.sc-opt-person { flex: 1 1 240px; min-width: 0; } .sc-opt-person .sc-training { width: 100%; min-width: 0; }
@media (max-width: 640px) { .sc-main .sc-clause { width: 60px; } .sc-main .btn-row { margin-left: auto; } }

@media (max-height: 760px) and (min-width: 901px) { .nav a { padding: 4px 10px; font-size: 13px; } .nav .group { padding: 6px 10px 2px; } .sidebar .brand img { width: 150px; } }

/* crew picker (multi-select dropdown) and crew chips */
.multi { position: relative; }
.multi > summary { list-style: none; cursor: pointer; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 7px 30px 7px 10px; min-height: 38px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; position: relative; font-size: 14px; }
.multi > summary::-webkit-details-marker { display: none; }
.multi > summary::after { content: ''; position: absolute; right: 12px; top: 50%; width: 7px; height: 7px; border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2); transform: translateY(-70%) rotate(45deg); }
.multi[open] > summary { border-color: var(--accent); }
.multi .multi-list { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.14); max-height: 260px; overflow-y: auto; padding: 4px; }
.multi .multi-list label { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.multi .multi-list label:hover { background: var(--bg, #f4f6f9); }
.multi .multi-list input { width: 16px; height: 16px; flex: none; }
.multi .multi-none { color: var(--muted, #6b7a90); }
.crew { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.crew-chip { display: inline-flex; align-items: center; gap: 5px; background: #E8F0FB; color: #1B3A66; border-radius: 999px; padding: 2px 9px 2px 3px; font-size: 12px; font-weight: 600; line-height: 1.5; }
.crew-chip i { font-style: normal; width: 18px; height: 18px; border-radius: 50%; background: #1B3A66; color: #fff; font-size: 9px; display: inline-flex; align-items: center; justify-content: center; letter-spacing: 0; }
.crew-chip.solo { padding: 2px 9px; }
.modal .multi-list { position: static; box-shadow: none; margin-top: 4px; max-height: 200px; }
#plan-who { width: auto; min-width: 150px; max-width: 220px; padding: 6px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.crew-chip { white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }

.sidebar .foot .copy { display: block; margin-top: 6px; font-size: 10.5px; opacity: .7; line-height: 1.3; }
.auth-foot .copy { font-size: 11.5px; opacity: .75; }
.auth-foot a { color: inherit; text-decoration: underline; }
