/* CAG CMMS -- base styles. Deliberately plain CSS with tokens up top, so the
   look can be reworked later without touching templates. */
:root {
  --bg: #f4f6f8; --surface: #fff; --text: #1d2733; --muted: #6b7785;
  --border: #dde3e9; --accent: #1f6feb; --accent-soft: #e7f0fe;
  --ok: #1a7f37; --warn: #b26a00; --bad: #c62828;
  --radius: 8px; --shadow: 0 1px 2px rgba(16,24,40,.06);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 0 0 12px; display: flex; justify-content: space-between; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

.env-banner { background: #fff4d6; color: #7a4f00; text-align: center; font-size: 12px; padding: 3px; font-weight: 600; letter-spacing: .03em; }

.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { font-weight: 800; font-size: 18px; color: var(--text); }
.brand span, .login h1 span { color: var(--accent); font-weight: 600; }
.global-search { flex: 1; max-width: 560px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.topbar-user { margin-left: auto; display: flex; gap: 12px; align-items: center; }
.topbar-user form { margin: 0; }
button.link { background: none; border: none; color: var(--accent); cursor: pointer; padding: 0; font: inherit; }

.shell { display: grid; grid-template-columns: 190px 1fr 240px; min-height: calc(100vh - 80px); }
.sidenav { background: var(--surface); border-right: 1px solid var(--border); padding: 16px 10px; display: flex; flex-direction: column; gap: 2px; }
.sidenav a, .sidenav .soon { padding: 8px 12px; border-radius: 6px; color: var(--text); }
.sidenav a:hover { background: var(--bg); }
.sidenav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidenav .soon { color: var(--muted); cursor: default; }
.sidenav .soon::after { content: " · soon"; font-size: 11px; }
.sidenav hr { border: none; border-top: 1px solid var(--border); width: 100%; }
.content { padding: 24px; min-width: 0; }
.content.narrow { max-width: 380px; margin: 10vh auto; }
.open-work { background: var(--surface); border-left: 1px solid var(--border); padding: 16px; }
.open-work h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 20px; overflow-x: auto; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.tile-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.tile-value { font-size: 20px; font-weight: 700; margin-top: 4px; }
.tile-value.small { font-size: 14px; }
.more { font-size: 13px; font-weight: 400; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.audit { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 20px; }
.changes s { color: var(--bad); }
.changes pre { max-width: 420px; white-space: pre-wrap; font-size: 12px; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--bg); }
.badge.insert { background: #e6f4ea; color: var(--ok); }
.badge.update { background: var(--accent-soft); color: var(--accent); }
.badge.delete { background: #fdecea; color: var(--bad); }

.filters { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
input, select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font: inherit; background: var(--surface); }
label { display: block; margin-bottom: 12px; font-weight: 600; }
label input { display: block; width: 100%; margin-top: 4px; font-weight: 400; }
button.primary { background: var(--accent); color: #fff; border: none; padding: 10px 16px; border-radius: 6px; font: inherit; font-weight: 600; cursor: pointer; width: 100%; }
.error { color: var(--bad); }
.pager { display: flex; gap: 16px; align-items: center; margin-bottom: 20px; }

@media (max-width: 1000px) {
  .shell { grid-template-columns: 1fr; }
  .sidenav { flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .open-work { display: none; }
}

/* ---- Stage 1: lists, forms, asset page ---- */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.page-head h1 { margin: 0; }
.actions { display: flex; gap: 8px; }
.btn { display: inline-block; padding: 8px 14px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.grow { flex: 1; min-width: 200px; }
.small { font-size: 12px; }
.pad { padding: 10px 12px; }
label.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; margin: 0; white-space: nowrap; }
label.check input, label input[type=checkbox] { display: inline-block; width: auto; margin: 0; }

.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; background: #e6f4ea; color: var(--ok); }
.flash.error { background: #fdecea; color: var(--bad); }

table.list tbody tr { cursor: pointer; }
table.list tbody tr:hover { background: var(--bg); }
tr.inactive td { color: var(--muted); }
.list-meta { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
th a { color: inherit; }
#asset-rows { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; overflow-x: auto; }

.pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); vertical-align: middle; }
.pill.warn { background: #fff4d6; color: var(--warn); }
.pill.ok { background: #e6f4ea; color: var(--ok); }

.due { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; }
.due-ok { background: #e6f4ea; color: var(--ok); }
.due-due_soon { background: #fff4d6; color: var(--warn); }
.due-overdue { background: #fdecea; color: var(--bad); }
.due-unscheduled { background: var(--bg); color: var(--muted); border: 1px dashed var(--border); }
.due-na { background: var(--bg); color: var(--muted); }

.global-search-wrap { position: relative; flex: 1; max-width: 560px; margin: 0; }
.global-search-wrap .global-search { width: 100%; max-width: none; }
.dropdown { position: absolute; top: 100%; left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(16,24,40,.12); z-index: 50; margin-top: 4px; max-height: 70vh; overflow-y: auto; }
.dropdown a { display: block; padding: 8px 12px; color: var(--text); border-bottom: 1px solid var(--border); }
.dropdown a:hover { background: var(--accent-soft); }
.dropdown .more-link { color: var(--accent); font-weight: 600; }

.asset-form fieldset { border: 1px solid var(--border); }
.asset-form legend { font-weight: 700; padding: 0 6px; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px 16px; margin-bottom: 8px; }
.field label { margin-bottom: 4px; font-size: 13px; }
.field input:not([type=checkbox]), .field select, .field textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font: inherit; }
.field.checkbox { display: flex; flex-direction: row-reverse; justify-content: flex-end; align-items: center; gap: 8px; }
.field.checkbox label { margin: 0; }
.field.wide { grid-column: 1 / -1; }
.field small { display: block; margin-top: 2px; }
.field.has-error input, .field.has-error select { border-color: var(--bad); }
.req { color: var(--bad); }

.asset-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.asset-id { font-size: 26px; font-weight: 800; letter-spacing: .02em; display: flex; gap: 8px; align-items: center; }
.asset-name { font-size: 17px; font-weight: 600; margin: 2px 0 4px; }
.head-right { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.badges { display: flex; gap: 6px; }
.badges .due { font-size: 13px; padding: 4px 10px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab { background: none; border: none; padding: 10px 14px; font: inherit; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.hidden { display: none; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.detail-grid .card { margin-bottom: 0; }
dl { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; margin: 0; }
dt { color: var(--muted); font-size: 13px; }
dd { margin: 0; }
.danger-zone { margin-top: 20px; }
.danger-zone summary { color: var(--bad); cursor: pointer; }
.danger-zone form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.danger-zone p { flex-basis: 100%; }

.tree, .tree ul { list-style: none; padding-left: 18px; margin: 4px 0; }
.tree { padding-left: 0; }
.tree li { padding: 3px 0; }
.inline-add input { padding: 4px 8px; font-size: 13px; border-style: dashed; }

/* ---- Stage 1b: quick add, serials, vendors ---- */
.nav-label { padding: 10px 12px 2px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.quick-add-toggle { font-size: 12px; font-weight: 600; margin-left: 6px; }
.quick-add { display: flex; gap: 6px; margin-top: 6px; }
.quick-add.hidden { display: none; }
.quick-add input { flex: 1; padding: 6px 8px; border: 1px dashed var(--accent); border-radius: 6px; font: inherit; }
.quick-add .btn { padding: 6px 10px; }
h3.sub { font-size: 14px; margin: 16px 0 4px; }
table.serials { width: auto; }
table.serials td { padding: 4px 8px 4px 0; border: none; vertical-align: middle; }
table.serials input:not([type=checkbox]) { width: 240px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font: inherit; }
.flash.info { background: var(--accent-soft); color: var(--text); }
.span-all { grid-column: 1 / -1; }

/* ---- Stage 2: work orders ---- */
.status { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 99px; background: var(--bg); color: var(--muted); vertical-align: middle; }
.status.tiny { font-size: 10px; padding: 1px 6px; }
.status-open { background: var(--accent-soft); color: var(--accent); }
.status-in_progress { background: #e8f0ff; color: #3451b2; }
.status-on_hold { background: #fff4d6; color: var(--warn); }
.status-in_review { background: #f3e8ff; color: #7a3fb0; }
.status-closed { background: #e6f4ea; color: var(--ok); }
.status-cancelled { background: #fdecea; color: var(--bad); }
.actions.wrap { flex-wrap: wrap; justify-content: flex-end; }
.actions form { margin: 0; }
.small-actions { font-size: 13px; }
.inline-reason summary { cursor: pointer; color: var(--muted); }
.inline-reason form { display: flex; gap: 6px; margin-top: 6px; }
.flash.warn { background: #fff4d6; color: var(--warn); }
.workflow { display: flex; gap: 0; align-items: flex-start; overflow-x: auto; }
.wf-step { flex: 1; display: flex; gap: 8px; min-width: 150px; position: relative; padding-right: 12px; color: var(--muted); }
.wf-step::after { content: ""; position: absolute; top: 7px; left: 20px; right: 4px; height: 2px; background: var(--border); z-index: 0; }
.wf-step:last-child::after { display: none; }
.wf-step b { color: inherit; position: relative; background: var(--surface); padding-right: 6px; z-index: 1; }
.wf-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border); background: var(--surface); flex-shrink: 0; z-index: 1; }
.wf-step.done { color: var(--ok); }
.wf-step.done .wf-dot { background: var(--ok); border-color: var(--ok); }
.wf-step.current { color: var(--accent); }
.wf-step.current .wf-dot { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sign-box { border-left: 4px solid var(--accent); }
.sign-form { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.work-field { margin-bottom: 12px; }
.work-field label { margin-bottom: 4px; font-size: 13px; }
.work-field textarea, .work-field select { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font: inherit; }
.indicator { font-weight: 400; font-size: 12px; margin-left: 6px; }
.indicator .saved { color: var(--ok); }
.list-plain { margin-bottom: 10px; }
.labor-add { margin: 0; }
.sig { padding: 8px 0; border-bottom: 1px solid var(--border); }
.sig.superseded { opacity: .55; text-decoration: line-through; }
.sig.superseded .small { text-decoration: none; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 5px 0; border-bottom: 1px dashed var(--border); }
.asset-preview { padding: 8px 12px; border-radius: 6px; font-size: 13px; }
.asset-preview.ok { background: #e6f4ea; }
.asset-preview.bad { background: #fdecea; color: var(--bad); }
.rows-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; overflow-x: auto; }
a.tile { color: var(--text); }
a.tile:hover { border-color: var(--accent); }
.tile-bad .tile-value { color: var(--bad); }
.tray-item { display: block; padding: 8px 10px; margin: 0 -6px 6px; border-radius: 6px; border: 1px solid var(--border); color: var(--text); }
.tray-item:hover { border-color: var(--accent); }
.tray-item.current { background: var(--accent-soft); border-color: var(--accent); }
.tray-sub { margin-top: 18px !important; }
.overdue-text { color: var(--bad); font-weight: 600; }
code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* ---- Round 2 (2026-09-24 test notes) ---- */
.flash.warning { background: #fff4d6; color: var(--warn); }
.flash.info { background: var(--accent-soft); color: var(--text); }
.inline-add { display: flex; gap: 4px; align-items: center; }
.tiny-btn { padding: 3px 8px; font-size: 12px; }
.center-link { text-align: center; margin-top: 12px; }

/* Open Work tray collapses to a thin strip */
.shell.tray-collapsed { grid-template-columns: 190px 1fr 42px; }
@media (max-width: 1000px) { .shell.tray-collapsed { grid-template-columns: 1fr; } }
.tray-toggle { display: flex; align-items: center; gap: 6px; width: 100%; background: none; border: none; padding: 0 0 8px; cursor: pointer; font: inherit;
  font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.tray-toggle:hover { color: var(--accent); }
.tray-arrow { display: inline-block; transition: transform .15s; transform: rotate(90deg); }
.tray-count { margin-left: auto; background: var(--accent-soft); color: var(--accent); border-radius: 99px; padding: 0 7px; font-size: 11px; }
.tray-collapsed .open-work { padding: 12px 6px; }
.tray-collapsed .tray-body { display: none; }
.tray-collapsed .tray-toggle { flex-direction: column; gap: 10px; }
.tray-collapsed .tray-arrow { transform: rotate(180deg); }
.tray-collapsed .tray-title { writing-mode: vertical-rl; }
.tray-collapsed .tray-count { margin-left: 0; }

/* Pickers (asset on WO form, part on WO) */
.picker { border: 1px solid var(--border); border-radius: 6px; max-height: 320px; overflow-y: auto; }
.picker-item { display: block; width: 100%; text-align: left; background: var(--surface); border: none; border-bottom: 1px solid var(--border);
  padding: 8px 12px; font: inherit; cursor: pointer; color: var(--text); }
.picker-item:hover, .picker-item:focus { background: var(--accent-soft); outline: none; }
.picker-wrap { position: relative; }
.picker-wrap input.full { width: 100%; }
.dd-head { padding: 6px 12px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--bg); display: flex; justify-content: space-between; }
.dd-head a.more { display: inline; padding: 0; border: none; color: var(--accent); text-transform: none; letter-spacing: 0; }

.work-dates { display: flex; gap: 12px; flex-wrap: wrap; }
.work-dates .work-field { margin-bottom: 4px; }
.work-dates input { padding: 7px 10px; }
.status-at_vendor { background: #e0f2f1; color: #00695c; }
.timeline li.failed { color: var(--bad); }
.stock-move { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 12px; }
.stock-move .filters { margin-bottom: 8px; }
.part-add { align-items: flex-start; }
.tile-warn .tile-value { color: var(--warn); }

/* ---- Stage 3: calibration ---- */
.cal-section h2 .actions { font-size: 13px; }
.cal-start { justify-content: flex-start; align-items: center; }
.cal-start .filters { margin: 0; }
.cal-header input, .cal-header select { padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; font: inherit; }
.cal-param { border: 1px solid var(--border); border-radius: 6px; margin-bottom: 14px; overflow-x: auto; }
.cal-param-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 10px; background: var(--bg); border-bottom: 1px solid var(--border); }
.cal-param-head .actions { align-items: center; }
.cal-table { width: 100%; }
.cal-table th, .cal-table td { padding: 5px 7px; vertical-align: middle; }
.cal-table th.ph-af, .cal-table td.ph-af { background: #f7f9fc; }
.cal-table th.ph-al, .cal-table td.ph-al { background: #f6fbf7; }
.cal-table input.num { width: 92px; padding: 5px 7px; border: 1px solid var(--border); border-radius: 5px; font: inherit; text-align: right; }
.cal-table input.num:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 2px var(--accent-soft); }
.dev { font-weight: 600; font-size: 12px; white-space: nowrap; }
.dev.ok { color: var(--ok); }
.dev.bad { color: var(--bad); background: #fdecea; padding: 1px 5px; border-radius: 4px; }
.tiny-text { font-size: 11px; }
.cal-summary { margin: 4px 0 12px; }
.cal-tools { justify-content: flex-start; margin-bottom: 10px; }
.param-add { flex-wrap: wrap; }
.param-add input, .param-add select { padding: 6px 8px; }
.cal-comments textarea { width: 100%; }
.std-attach { margin-bottom: 2px; }
.std-attach .picker { position: absolute; left: 0; right: 0; z-index: 40; background: var(--surface); box-shadow: 0 8px 24px rgba(16,24,40,.12); }
.picker-item[disabled] { cursor: not-allowed; opacity: .6; }
.part-add #part-results .dropdown { position: absolute; }
.table-scroll { overflow-x: auto; }
.tpl-params td { padding: 4px; }
.tpl-params input, .tpl-params select { width: 100%; min-width: 70px; padding: 6px; border: 1px solid var(--border); border-radius: 5px; font: inherit; }
.tpl-params input[type=checkbox] { width: auto; min-width: 0; }
.dev.na { color: var(--muted); }
.sig-pad { width: 100%; max-width: 600px; height: auto; aspect-ratio: 600 / 180; border: 1px dashed var(--border); border-radius: 6px; background: #fff; touch-action: none; cursor: crosshair; display: block; margin-bottom: 8px; }
.sig-preview { border: 1px solid var(--border); border-radius: 6px; padding: 8px; background: #fff; display: inline-block; }
.sig-preview img { max-height: 70px; max-width: 320px; display: block; }
.att-actions { white-space: nowrap; }
.att-actions details { display: inline-block; margin-right: 8px; vertical-align: top; }
.att-removed { margin: 6px 0 10px; }
.att-removed summary { cursor: pointer; color: var(--muted); font-size: 13px; }

/* ---- Stage 4: scheduling ---- */
.inline-pair { display: flex; gap: 6px; }
.inline-pair input { width: 90px !important; }
.sched-group.bad { border-left: 4px solid var(--bad); }
.sched-group.warn { border-left: 4px solid var(--warn); }
table.month { table-layout: fixed; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table.month th { text-align: center; }
table.month td { height: 104px; vertical-align: top; border: 1px solid var(--border); padding: 4px; overflow: hidden; }
table.month td.out { background: var(--bg); color: var(--muted); }
table.month td.today { box-shadow: inset 0 0 0 2px var(--accent); }
.daynum { font-size: 12px; font-weight: 700; margin-bottom: 3px; }
.cal-chip { display: block; font-size: 11px; padding: 2px 5px; border-radius: 4px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
span.cal-chip { display: inline-block; }
.cal-chip.wo { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.cal-chip.wo.overdue { background: #fdecea; color: var(--bad); }
.cal-chip.sched { background: #fff4d6; color: var(--warn); }
.cal-chip.projected { background: var(--bg); color: var(--muted); border: 1px dashed var(--border); }

/* Checkbox lists (Also covers, review roles) */
.field ul[id] { list-style: none; padding: 0; margin: 4px 0; display: flex; flex-direction: column; gap: 4px; }
.field ul[id] label { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; margin: 0; }
.field ul[id] input[type=checkbox] { width: auto !important; margin-top: 3px; }
td.pick { width: 28px; cursor: default; }
td.pick input { width: 16px; height: 16px; }

/* ---- Stage 7: client portal ---- */
body.portal { display: flex; flex-direction: column; min-height: 100vh; }
.portal-top { display: flex; align-items: center; gap: 24px; padding: 12px 28px; background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.portal-brand { display: flex; align-items: center; gap: 12px; }
.portal-brand img { max-height: 40px; max-width: 120px; }
.portal-org { font-weight: 800; font-size: 17px; color: var(--accent); }
.portal-sub { font-size: 12px; color: var(--muted); }
.portal-nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.portal-nav a, .portal-nav .soon { padding: 8px 14px; border-radius: 6px; color: var(--text); }
.portal-nav a:hover { background: var(--bg); }
.portal-nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.portal-nav .soon { color: var(--muted); } .portal-nav .soon::after { content: " · soon"; font-size: 11px; }
.portal-user { display: flex; gap: 12px; align-items: center; }
.portal-user form { margin: 0; }
.portal-main { padding: 24px 28px; max-width: 1200px; width: 100%; margin: 0 auto; flex: 1; }
.portal-foot { text-align: center; color: var(--muted); font-size: 12px; padding: 16px; border-top: 1px solid var(--border); }
.preview-banner { background: #3451b2; color: #fff; text-align: center; padding: 6px; font-size: 13px; }
.preview-banner a { color: #fff; font-weight: 700; text-decoration: underline; }
.portal-settings { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.portal-user-add { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.portal-user-add input { padding: 6px 8px; }
.plain-list { list-style: none; padding: 0; margin: 0; }

/* ---- PM checklists ---- */
.checklist-table { width: 100%; }
.checklist-table td { vertical-align: middle; padding: 5px 7px; }
.checklist-table tr.cl-section td { background: var(--bg); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.checklist-table select, .checklist-table input { padding: 5px 7px; border: 1px solid var(--border); border-radius: 5px; font: inherit; }
.checklist-table input.num { width: 90px; text-align: right; }
.checklist-table input.cl-note { width: 100%; min-width: 140px; }
.res { font-size: 12px; font-weight: 700; margin-left: 4px; }
.res-pass { color: var(--ok); } .res-fail { color: var(--bad); } .res-corrected { color: var(--warn); } .res-na { color: var(--muted); }
.drag { cursor: grab; color: var(--muted); }
.drag .handle { font-size: 16px; padding: 0 4px; }
.drag .mv { font-size: 13px; padding: 0 2px; }
tr.dragging { opacity: .4; }
.portal-filters { align-items: flex-end; }
.portal-filters label { margin: 0; font-size: 12px; color: var(--muted); font-weight: 600; }
.portal-filters label input, .portal-filters label select { display: block; margin-top: 3px; font-size: 14px; color: var(--text); }
.portal-filters label.grow input { width: 100%; }
.filter-buttons { display: flex; gap: 6px; }
.quick-ranges { margin: -4px 0 12px; color: var(--muted); }
.tpl-params td:nth-child(2) input { min-width: 120px; }
.sign-identity { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* ---- Saved views / column picker ---- */
.sv-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; }
.sv-bar form { margin: 0; }
.sv-select { margin: 0; font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; font-weight: 600; }
.sv-select select { min-width: 220px; }
.sv-pop { position: relative; }
.sv-pop > summary { list-style: none; }
.sv-pop > summary::-webkit-details-marker { display: none; }
.sv-panel { position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 8px 24px rgba(16,24,40,.14); padding: 12px; width: 320px; }
.sv-panel label { font-size: 13px; }
.sv-panel label input:not([type=checkbox]) { width: 100%; }
.sv-cols { list-style: none; margin: 0 0 10px; padding: 0; max-height: 50vh; overflow-y: auto; }
.sv-cols li { display: flex; gap: 6px; align-items: center; padding: 3px 4px; border-radius: 4px; cursor: grab; }
.sv-cols li:hover { background: var(--bg); }
.sv-cols .handle { color: var(--muted); }

/* ---- Users & roles ---- */
.role-matrix th.c, .role-matrix td.c { text-align: center; }
.role-matrix .yes { color: var(--ok); font-weight: 800; }
.role-matrix tr.coming td { color: var(--muted); background: var(--bg); }
.inline-reason form.wrap { flex-wrap: wrap; }
.row-actions { white-space: nowrap; text-align: right; width: 1%; }
.row-actions details[open] form { min-width: 360px; }
.row-actions details { display: inline-block; margin-left: 10px; text-align: left; white-space: normal; vertical-align: top; }
.row-actions details[open] { display: block; margin: 4px 0; }
.place-actions { display: inline-block; font-size: 12px; margin-left: 6px; }
.place-actions[open] { display: block; margin: 4px 0 6px; }
div.check-grid { display: flex; flex-wrap: wrap; gap: 4px 14px; list-style: none; padding: 0; margin: 4px 0; }
div.check-grid label, div.check-grid > div { display: inline-flex; align-items: center; gap: 4px; font-weight: normal; }
.inline-reason form.team-form { flex-direction: column; align-items: stretch; }
.team-form .row { display: flex; gap: 6px; }
.ok-text { color: var(--ok); font-weight: 600; }
.bad-text { color: var(--bad); font-weight: 600; }
.warn-text { color: var(--warn); }
.steps { margin: 0 0 12px 18px; padding: 0; }
.steps li { margin-bottom: 4px; }
.import-summary { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.import-summary .tile { min-width: 110px; }
.import-summary .tile.on { outline: 2px solid var(--accent); }
.import-summary .tile.bad .tile-value { color: var(--bad); }
.import-rows td { vertical-align: top; }
.pill.bad { background: #fdecea; color: var(--bad); }
th.pick, td.pick { width: 28px; text-align: center; }
td.pick input, th.pick input { cursor: pointer; }
.batch-bar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 12px; margin-bottom: 10px; background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--radius); }
.batch-form .edit-row { display: grid; grid-template-columns: 280px 1fr; gap: 8px; align-items: center; padding: 4px 0; border-bottom: 1px solid var(--border); }
.batch-form .edit-row select, .batch-form .edit-row input:not([type=checkbox]) { max-width: 360px; }

/* ---- Purchase orders ---- */
.status-po-draft { background: var(--bg); color: var(--muted); }
.status-po-ordered { background: var(--accent-soft); color: var(--accent); }
.status-po-partial { background: #fff4d6; color: var(--warn); }
.status-po-received { background: #e6f4ea; color: var(--ok); }
.status-po-closed { background: #e6f4ea; color: var(--ok); }
.status-po-cancelled { background: #fdecea; color: var(--bad); }
td.num, th.num { text-align: right; white-space: nowrap; }
input.qty { width: 80px; text-align: right; }
tr.voided td { color: var(--muted); text-decoration: line-through; }
tr.total td { font-weight: 700; border-top: 2px solid var(--border); }
.po-bar { align-items: center; margin: 10px 0 0; }
.po-bar label { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 400; }
.po-bar label input, .po-bar label select { display: inline-block; width: auto; margin: 0; }
.po-bar button.primary { width: auto; }
.po-details label select, .po-details label textarea { display: block; width: 100%; margin-top: 4px; font-weight: 400; }
input.qty.wide { width: 100px; }

/* ---- Sign-in: SSO button, 2FA ---- */
.login .sso-btn { display: block; text-align: center; width: 100%; padding: 10px 16px; }
.login .or { text-align: center; color: var(--muted); font-size: 13px; margin: 14px 0 10px; }
.login.wide { max-width: 560px; }
.login .break-glass summary { cursor: pointer; margin-bottom: 8px; }
.code-input { font-size: 20px; letter-spacing: .2em; font-family: ui-monospace, monospace; max-width: 180px; }
.mfa-steps { padding-left: 20px; }
.mfa-steps li { margin-bottom: 14px; }
.qr { margin: 10px 0; }
.qr svg { display: block; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.mfa-key { display: inline-block; font-size: 15px; letter-spacing: .08em; padding: 6px 8px; background: var(--bg); border-radius: 5px; margin-top: 6px; word-break: break-all; }
.mfa-confirm { align-items: center; margin-top: 8px; }
.mfa-confirm button.primary { width: auto; }
.backup-codes { columns: 2; list-style: none; padding: 0; font-size: 17px; }
.backup-codes li { padding: 4px 0; }

/* ---- Help ---- */
.help-btn { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%;
            border: 1.5px solid var(--accent); color: var(--accent); font-weight: 700; text-decoration: none; margin-right: 6px; }
.help-btn:hover { background: var(--accent); color: #fff; }
.help-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 20px; align-items: start; }
.help-side { position: sticky; top: 12px; max-height: calc(100vh - 110px); overflow-y: auto; padding: 12px; }
.help-side a { display: block; padding: 3px 6px; border-radius: 5px; color: var(--text); text-decoration: none; font-size: 14px; }
.help-side a:hover { background: var(--bg); }
.help-side a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.help-sec { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 12px 6px 4px; }
.help-side input.full { width: 100%; }
.help-main { min-width: 0; max-width: 860px; }
.help-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.help-item { margin-bottom: 10px; }
.help-hit { margin-bottom: 10px; }
.help-hit mark { background: #fff4b8; padding: 0 1px; }
.help-summary { font-size: 16px; color: var(--muted); }
.help-toc ul { margin: 6px 0 0; padding-left: 18px; columns: 2; }
.help-body { line-height: 1.6; }
.help-body h2 { margin-top: 26px; padding-top: 6px; border-top: 1px solid var(--border); }
.help-body h2:first-child { margin-top: 0; border-top: 0; }
.help-body h3 { margin-top: 18px; }
.help-body li { margin-bottom: 4px; }
.help-body table { border-collapse: collapse; margin: 10px 0; }
.help-body th, .help-body td { border: 1px solid var(--border); padding: 5px 9px; text-align: left; vertical-align: top; }
.help-body th { background: var(--bg); }
.help-body code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 90%; }
.help-body blockquote { margin: 12px 0; padding: 8px 14px; border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: 0 6px 6px 0; }
.help-body blockquote p { margin: 4px 0; }
.help-nav { display: flex; justify-content: space-between; margin: 16px 0 30px; }
@media (max-width: 800px) { .help-layout { grid-template-columns: 1fr; } .help-side { position: static; max-height: none; } }
@media print { .help-side, .help-nav, .help-toc { display: none; } .help-layout { display: block; } }
.login h1.portal-brand { font-size: 22px; line-height: 1.25; }
.login h1.portal-brand span { display: block; font-size: 15px; color: var(--muted); font-weight: 600; }
.field-label { display: block; margin-bottom: 4px; font-size: 13px; font-weight: 600; }

/* ---- Notifications bell ---- */
.bell-wrap { position: relative; display: inline-block; margin-right: 6px; }
.bell-btn { position: relative; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px; line-height: 0; border-radius: 6px; }
.bell-btn:hover { color: var(--accent); background: var(--bg); }
.bell-count { position: absolute; top: -3px; right: -5px; background: var(--bad); color: #fff; border-radius: 99px; font-size: 10px; font-weight: 700; padding: 1px 5px; line-height: 1.4; }
.bell-menu { position: absolute; right: 0; top: 34px; width: 360px; max-height: 70vh; overflow-y: auto; z-index: 60; padding: 0; box-shadow: 0 10px 30px rgba(16,24,40,.18); text-align: left; }
.bell-head, .bell-foot { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.bell-foot { border-bottom: 0; border-top: 1px solid var(--border); font-size: 13px; justify-content: flex-start; gap: 4px; }
.bell-item { display: flex; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); }
.bell-item:hover { background: var(--bg); }
.bell-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; }
.bell-item.unread .bell-dot { background: var(--accent); }
.bell-item.unread .bell-title { font-weight: 700; }
.bell-text { display: flex; flex-direction: column; min-width: 0; }
.bell-title { font-size: 14px; }
.bell-body, .bell-when { font-size: 12px; color: var(--muted); }
tr.unread-row td { background: var(--accent-soft); }
pre.email-body { white-space: pre-wrap; font: 13px/1.5 ui-monospace, monospace; background: var(--bg); padding: 12px; border-radius: 6px; }
@media (max-width: 600px) { .bell-menu { position: fixed; left: 8px; right: 8px; width: auto; top: 60px; } }

/* ---- Probe stations ---- */
.station-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); margin-right: 4px; vertical-align: middle; }
.station-dot.online { background: var(--ok); box-shadow: 0 0 0 3px rgba(26,127,55,.15); }
.probe-picker { align-items: center; margin-bottom: 6px; }
.probe-picker label { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 400; }
.probe-picker select { width: auto; }
.probe-job { margin: 8px 0; padding: 8px 12px; background: var(--accent-soft); border-radius: 6px; font-size: 14px; }
.probe-job.done { background: var(--bg); }
.spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--accent); border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; margin-right: 6px; vertical-align: -1px; }
@keyframes spin { to { transform: rotate(360deg); } }
.probe-block { margin: 10px 0; }
.probe-write { align-items: flex-end; margin-top: 8px; }
.probe-write label { margin: 0; }
.probe-write input { width: 130px; }
.probe-write button.primary { width: auto; }
.small-btn { padding: 3px 9px; font-size: 13px; }
.key-card { border: 2px solid var(--warn); }
