:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #dfe3ea;
  --border-strong: #c5ccd8;
  --text: #1b2330;
  --muted: #627084;
  --accent: #022e7d;
  --accent-hover: #01215c;
  --accent-soft: #e5ecf8;
  --brand-orange: #e4650a;
  --ok: #1d7a46;
  --ok-soft: #e3f4ea;
  --warn: #9a5b00;
  --warn-soft: #fff3dc;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --radius: 10px;
  --radius-s: 7px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .05);
  --nav-w: 232px;
  --top-h: 56px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151b;
    --surface: #1a2029;
    --surface-2: #202834;
    --border: #2d3644;
    --border-strong: #3d4757;
    --text: #e6eaf0;
    --muted: #97a3b4;
    --accent: #4fb0e8;
    --accent-hover: #7cc4ef;
    --accent-soft: #15283f;
    --ok: #52c285;
    --ok-soft: #173326;
    --warn: #e6a740;
    --warn-soft: #3a2c12;
    --danger: #f2766b;
    --danger-soft: #3d1c1a;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.5rem; font-weight: 650; }
h2 { font-size: 1.08rem; font-weight: 620; }
h3 { font-size: .95rem; font-weight: 620; margin: 14px 0 6px; }
p { margin: 0; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.text-danger { color: var(--danger); font-weight: 600; }
.text-ok { color: var(--ok); font-weight: 600; }
.text-warn { color: var(--warn); }
.danger-text { color: var(--danger) !important; }
.reg { font-variant-numeric: tabular-nums; letter-spacing: .02em; white-space: nowrap; }
.row { display: flex; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; gap: 12px; }
.row.end, td.end { justify-content: flex-end; text-align: right; }
.gap { gap: 16px; }
.gap-s { gap: 6px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.narrow { max-width: 640px; }
.pad { padding: 12px 16px; }
.loading { padding: 48px 16px; text-align: center; color: var(--muted); }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 14px; }
.empty.small { padding: 18px; }
.icon { flex: none; }

/* inputs */
input[type=text], input[type=password], input[type=number], input[type=email], input[type=tel], input[type=search], input[type=date], input:not([type]), select, textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  padding: 9px 11px;
  min-height: 42px;
}
textarea { resize: vertical; min-height: 70px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
input:disabled { opacity: .65; }
select.sm { min-height: 34px; padding: 5px 8px; width: auto; font-size: .88rem; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-label { font-weight: 560; font-size: .9rem; }
.hint { font-size: .8rem; color: var(--muted); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.grid-2, .grid-3 { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.form-error { color: var(--danger); background: var(--danger-soft); padding: 9px 12px; border-radius: var(--radius-s); font-size: .9rem; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-weight: 560; font-size: .92rem;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-s);
  padding: 8px 14px; min-height: 40px; cursor: pointer;
  text-decoration: none !important; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
@media (prefers-color-scheme: dark) { .btn.primary { color: #0d1620; } }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.sm { min-height: 34px; padding: 5px 10px; font-size: .86rem; }
.btn.lg { min-height: 50px; padding: 12px 24px; font-size: 1rem; }
.btn.block { width: 100%; }
.btn.dashed { border-style: dashed; background: transparent; color: var(--muted); }
.btn.icon-only { padding: 6px; min-width: 34px; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .76rem; font-weight: 600; line-height: 1;
  padding: 4px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
  white-space: nowrap; vertical-align: middle;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
h2 .badge, strong + .badge, span + .badge { margin-left: 6px; }

/* layout */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--top-h); display: flex; align-items: center; gap: 8px;
  padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--accent); font-weight: 750; letter-spacing: .01em; text-decoration: none !important; min-width: 0; }
.brand-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-logo { width: 34px; height: 34px; flex: none; }
.auth-logo { width: 92px; height: 92px; margin-bottom: 4px; }
.nav-toggle { display: none; }
.layout { display: flex; min-height: calc(100vh - var(--top-h)); }
.nav {
  position: sticky; top: var(--top-h); align-self: flex-start;
  width: var(--nav-w); flex: none; height: calc(100vh - var(--top-h));
  display: flex; flex-direction: column; gap: 2px; padding: 14px 10px;
  background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto;
}
.nav-link {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 9px 12px; border-radius: var(--radius-s);
  color: var(--text); font: inherit; font-weight: 520; text-align: left;
  background: none; border: 0; cursor: pointer; text-decoration: none !important;
}
.nav-link span:not(.nav-badge) { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-link .icon { color: var(--muted); }
.nav-link:hover { background: var(--surface-2); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); }
.nav-link.active .icon { color: var(--accent); }
.nav-badge { background: var(--danger); color: #fff; border-radius: 999px; font-size: .72rem; font-weight: 700; padding: 2px 7px; }
.nav-spacer { flex: 1; min-height: 16px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.nav-scrim { display: none; }
main { flex: 1; min-width: 0; padding: 24px 28px 64px; max-width: 1180px; outline: none; }

@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; }
  .nav {
    position: fixed; left: 0; top: var(--top-h); z-index: 40;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 10px 30px rgba(0,0,0,.18);
  }
  body.nav-open .nav { transform: none; }
  body.nav-open .nav-scrim { display: block; position: fixed; inset: var(--top-h) 0 0 0; background: rgba(0,0,0,.3); z-index: 35; }
  main { padding: 16px 16px 72px; }
  h1 { font-size: 1.3rem; }
}

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin-top: 4px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sticky-head { position: sticky; top: var(--top-h); z-index: 20; background: var(--bg); padding: 10px 0; margin-top: -10px; border-bottom: 1px solid var(--border); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.card .stack > h2 { margin-bottom: 2px; }

.summary { margin: 0 0 22px; }
.summary-text { font-size: 1.08rem; line-height: 1.6; }
.summary-text p + p { margin-top: 2px; }
.summary-text a { font-weight: 600; }
.summary-track { height: 4px; background: var(--border); border-radius: 999px; overflow: hidden; margin-top: 12px; max-width: 520px; }
.summary-fill { height: 100%; background: var(--ok); }

.list { list-style: none; margin: 0; padding: 0; }
.list li + li { border-top: 1px solid var(--border); }
.list-link { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 4px; color: var(--text); text-decoration: none !important; }
.list-link:hover { background: var(--surface-2); }

/* alerts */
.alert-list { list-style: none; margin: 0; padding: 0; }
.alert-list.card { padding: 4px 16px; }
.alert-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; }
.alert-item + .alert-item { border-top: 1px solid var(--border); }
.alert-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); margin-top: 7px; flex: none; }
.alert-item.resolved .alert-dot { background: var(--ok); }
.alert-main { flex: 1; min-width: 0; }
.alert-title { display: flex; gap: 8px; flex-wrap: wrap; font-weight: 520; }
.alert-meta { font-size: .83rem; margin-top: 2px; }
.alert-resolution { margin-top: 6px; font-size: .85rem; color: var(--muted); }
.alert-resolution .note { margin-top: 4px; padding: 6px 10px; background: var(--surface-2); border-radius: var(--radius-s); color: var(--text); white-space: pre-wrap; }
.alert-actions { flex: none; }

/* tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface-2); }
.table tr.inactive td { opacity: .6; }
.table td.row { display: table-cell; }
.table td.row > * + * { margin-left: 6px; }
.inline-icon { display: inline-flex; align-items: center; gap: 3px; margin-right: 8px; }
@media (max-width: 640px) { .hide-sm { display: none; } .table th, .table td { padding: 9px 8px; } }

.matrix { border-collapse: separate; border-spacing: 0; width: 100%; }
.matrix th, .matrix td { padding: 6px; text-align: center; border-bottom: 1px solid var(--border); }
.matrix thead th { font-size: .8rem; color: var(--muted); font-weight: 600; }
.matrix tbody th { text-align: left; font-weight: 600; padding-right: 14px; }
.matrix tr:last-child th, .matrix tr:last-child td { border-bottom: 0; }
.cell { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-width: 92px; padding: 6px 10px; border-radius: var(--radius-s); font: inherit; font-size: .83rem; font-weight: 560; cursor: pointer; text-decoration: none !important; }
.cell.done { background: var(--ok-soft); color: var(--ok); }
.cell.done.warn { background: var(--danger-soft); color: var(--danger); }
.cell.todo { background: transparent; border: 1px dashed var(--border-strong); color: var(--muted); }
.cell.todo:hover { border-color: var(--accent); color: var(--accent); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tab { background: none; border: 0; font: inherit; font-weight: 560; color: var(--muted); padding: 9px 14px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.filters > input[type=search] { flex: 1 1 200px; width: auto; }
.filters > select, .filters > input[type=date] { width: auto; flex: 0 1 auto; min-height: 38px; padding: 6px 10px; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.search { margin-bottom: 14px; }

.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.choice-card {
  display: flex; gap: 14px; align-items: flex-start; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; font: inherit; color: var(--text); cursor: pointer; box-shadow: var(--shadow);
}
.choice-card:hover { border-color: var(--accent); }
.choice-card .icon { color: var(--accent); margin-top: 2px; }
.choice-title { font-weight: 650; font-size: 1.02rem; }

/* fill */
.fill-head { position: sticky; top: var(--top-h); z-index: 20; background: var(--bg); padding: 12px 0 10px; margin: -12px 0 14px; border-bottom: 1px solid var(--border); }
.fill-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.progress { height: 6px; background: var(--border); border-radius: 999px; overflow: hidden; margin-bottom: 5px; }
.progress-bar { height: 100%; background: var(--accent); width: 0; transition: width .25s; }
.form-desc { margin-bottom: 16px; font-size: .9rem; }
.fill-section { padding: 0; overflow: hidden; }
.fill-section .card-head { padding: 12px 16px; margin: 0; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.sec-count { font-size: .8rem; font-weight: 600; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 2px 9px; }
.sec-count.complete { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.fi { padding: 14px 16px; border-bottom: 1px solid var(--border); scroll-margin-top: 140px; }
.fi:last-child { border-bottom: 0; }
.fi-label { font-weight: 560; margin-bottom: 8px; }
.fi-help { margin: -4px 0 8px; }
.req { color: var(--danger); }
.fi.missing { background: var(--danger-soft); }
.fi.missing .fi-label::after { content: " (required)"; color: var(--danger); font-weight: 500; font-size: .85rem; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg-btn {
  font: inherit; font-weight: 560; font-size: .92rem;
  min-height: 42px; padding: 8px 16px; border-radius: var(--radius-s);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer;
}
.seg-btn:hover { border-color: var(--accent); }
.seg-btn.sel.is-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.seg-btn.sel.is-alert { background: var(--danger); border-color: var(--danger); color: #fff; }
@media (prefers-color-scheme: dark) { .seg-btn.sel.is-ok, .seg-btn.sel.is-alert { color: #10151c; } }
.qty-row, .num-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.qty-row input.qty { width: 110px; flex: none; }
.num-row input { max-width: 200px; }
.unit { color: var(--muted); font-weight: 560; }
.warn-text { color: var(--danger); margin-top: 6px; font-weight: 560; }
.switch-row { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch-row input { width: 22px; height: 22px; }
.photo-box { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.photo-add { color: var(--accent); padding-left: 4px; }
.photo-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.photo { position: relative; width: 96px; height: 96px; border-radius: var(--radius-s); overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); }
.photo img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; display: block; }
.photo-del { position: absolute; top: 3px; right: 3px; min-height: 0; padding: 4px; background: rgba(0,0,0,.6); color: #fff; border: 0; border-radius: 6px; }
.photo-del:hover { background: var(--danger); }
.sig-wrap { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.sig-box { position: relative; width: 100%; max-width: 520px; }
.sig-canvas { display: block; width: 100%; height: 170px; background: #fff; border: 1px dashed var(--border-strong); border-radius: var(--radius-s); touch-action: none; cursor: crosshair; }
.sig-hint { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; font-size: 1.1rem; color: #9aa3ae; }
.submit-bar { display: flex; justify-content: flex-end; padding: 8px 0 24px; }
@media (max-width: 640px) { .submit-bar .btn { width: 100%; } }

/* report document */
.report-doc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px 36px; max-width: 900px; box-shadow: var(--shadow); }
@media (max-width: 640px) { .report-doc { padding: 18px 16px; } }
.report-header { text-align: center; border-bottom: 2px solid var(--text); padding-bottom: 14px; margin-bottom: 16px; }
.report-company { display: flex; align-items: center; justify-content: center; gap: 12px; font-size: 1.35rem; font-weight: 700; color: var(--accent); }
.report-logo { width: 56px; height: 56px; }
.report-header h1 { font-size: 1.1rem; font-weight: 500; color: var(--muted); margin-top: 2px; }
.report-vehicle { margin-top: 10px; font-size: 1.02rem; }
.report-desc { font-size: .9rem; color: var(--muted); text-align: center; margin-bottom: 18px; }
.report-meta { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0 0 8px; }
.report-meta dt { font-weight: 600; }
.report-meta dd { margin: 0; }
.sig-img { max-height: 90px; max-width: 280px; background: #fff; border-radius: 4px; }
.report-section { margin-top: 22px; break-inside: auto; }
.report-section h2 { font-size: 1.05rem; padding-bottom: 6px; border-bottom: 1px solid var(--border-strong); margin-bottom: 4px; }
.report-table { width: 100%; border-collapse: collapse; }
.report-table th, .report-table td { padding: 7px 4px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.report-table th { font-weight: 450; width: 62%; }
.report-table td { font-weight: 600; }
.report-table tr.flagged th, .report-table tr.flagged td { color: var(--danger); }
.report-table tr.flagged td::before { content: "⚑ "; }
.report-table .photo-row td { padding: 4px 4px 10px; }
.report-alerts { background: var(--danger-soft); border-radius: var(--radius-s); padding: 4px 14px 2px; }
.report-alerts h2 { border-bottom-color: transparent; padding-top: 10px; color: var(--danger); }
.report-alerts .alert-item + .alert-item { border-top-color: rgba(0,0,0,.08); }
.report-comments { white-space: pre-wrap; }
.report-footer { margin-top: 28px; padding-top: 10px; border-top: 1px solid var(--border); text-align: center; }

/* forms list & builder */
.form-row { display: flex; align-items: center; gap: 12px; margin: 0; padding: 12px 14px; }
.form-row.inactive { opacity: .7; }
.form-row-main { flex: 1; min-width: 0; color: var(--text); text-decoration: none !important; }
.order-btns { display: flex; flex-direction: column; }
.order-btns .btn { min-height: 26px; padding: 2px; }
@media (max-width: 640px) { .form-row { flex-wrap: wrap; } .form-row-main { flex-basis: calc(100% - 60px); } }
.builder-section { padding: 0; overflow: hidden; }
.section-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.section-num { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; font-size: .85rem; flex: none; }
@media (prefers-color-scheme: dark) { .section-num { color: #0d1620; } }
.section-title { font-weight: 620; font-size: 1rem; }
.section-foot { display: flex; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.field-row { border-bottom: 1px solid var(--border); }
.field-row:last-child { border-bottom: 0; }
.field-row.open { background: var(--surface-2); }
.field-row-head { display: flex; align-items: center; gap: 4px; padding: 2px 8px 2px 0; }
.field-row-toggle { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: none; border: 0; font: inherit; color: var(--text); text-align: left; cursor: pointer; }
.field-num { width: 22px; text-align: right; font-size: .82rem; flex: none; }
.field-row-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field-row-tags { display: flex; align-items: center; gap: 6px; flex: none; }
.tag-icon { display: inline-flex; color: var(--muted); }
.tag-icon.text-warn { color: var(--warn); }
.field-row-actions { display: flex; flex: none; }
@media (max-width: 640px) {
  .field-row-head { flex-wrap: wrap; }
  .field-row-tags .badge { display: none; }
  .field-row-actions { width: 100%; justify-content: flex-end; padding: 0 0 6px; }
}
.field-editor { display: flex; flex-direction: column; gap: 12px; padding: 4px 16px 16px 46px; }
@media (max-width: 640px) { .field-editor { padding: 4px 12px 14px; } }
.options-editor { display: flex; flex-direction: column; gap: 6px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-s); background: var(--surface); }
.opt-head { display: flex; justify-content: space-between; padding-right: 76px; font-weight: 560; }
.opt-row { display: flex; align-items: center; gap: 6px; }
.opt-row input[type=text] { min-height: 36px; padding: 6px 10px; }
.opt-alert { display: grid; place-items: center; width: 44px; flex: none; cursor: pointer; }

/* modal, toast, lightbox */
.overlay { position: fixed; inset: 0; background: rgba(10, 15, 25, .5); z-index: 100; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 520px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.modal.wide { max-width: 760px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 6px 20px; }
.modal-body { padding: 8px 20px 16px; overflow-y: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.modal-actions .btn.danger-text { margin-right: auto; }
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 200; transform: translate(-50%, 30px);
  background: #1b2330; color: #fff; padding: 11px 18px; border-radius: 10px; font-weight: 520;
  box-shadow: 0 10px 30px rgba(0,0,0,.25); opacity: 0; pointer-events: none; transition: all .2s; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }
@media (prefers-color-scheme: dark) { .toast { background: #e6eaf0; color: #11151b; } .toast.error { background: #f2766b; color: #11151b; } }
.lightbox { position: fixed; inset: 0; z-index: 150; background: rgba(0,0,0,.92); display: grid; place-items: center; padding: 40px 16px; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 100px); object-fit: contain; cursor: zoom-out; }
.lb-caption { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; color: #ddd; font-size: .9rem; }
.lightbox .btn { position: absolute; background: rgba(255,255,255,.15); border: 0; color: #fff; }
.lb-close { top: 14px; right: 14px; }
.lb-prev { left: 12px; top: 50%; }
.lb-next { right: 12px; top: 50%; }
.lb-next .icon { transform: rotate(180deg); }

/* auth */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 30px 26px; box-shadow: var(--shadow); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.auth-card form { width: 100%; text-align: left; margin-top: 14px; }

@media print {
  @page { margin: 14mm; }
  :root { --text: #000; --muted: #444; --border: #ccc; --border-strong: #999; --surface: #fff; --bg: #fff; --danger: #b42318; --danger-soft: #fdecea; }
  body { background: #fff; font-size: 11pt; }
  .topbar, .nav, .no-print, .nav-scrim, .alert-actions, .toast { display: none !important; }
  .layout { display: block; }
  main { padding: 0; max-width: none; }
  .report-doc { border: 0; padding: 0; box-shadow: none; max-width: none; }
  .report-section h2 { break-after: avoid; }
  .report-table tr { break-inside: avoid; }
  .photo { width: 120px; height: 120px; }
  a { color: inherit; }
}
