:root {
    --navy: #16324f;
    --blue: #2f5d7e;
    --cyan: #8cc4df;
    --orange: #f28c28;
    --surface: #f4f7f9;
    --surface-raised: #fff;
    --light: #d9eaf4;
    --line: #d9e1e7;
    --text: #233342;
    --muted: #6d7c89;
    --success: #247654;
    --warning: #956315;
    --danger: #ad3037;
    --critical: #cf3f45;
    --stage-a: #b4533c;
    --stage-b: #a96d0d;
    --stage-c: #247654;
    --sidebar-width: 232px;
    --shadow: 0 2px 9px rgba(22, 50, 79, .09);
    --shadow-dialog: 0 25px 80px rgba(13, 38, 57, .36);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: light; scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; min-height: 100vh; color: var(--text); background: var(--surface); font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: var(--blue); text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 3px solid color-mix(in srgb, var(--cyan) 70%, #fff); outline-offset: 2px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: -100px; left: 10px; z-index: 200; padding: 9px 13px; border-radius: 4px; color: #fff; background: var(--navy); font-weight: 750; }
.skip-link:focus { top: 10px; }

/* Shared STS shell */
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; display: flex; width: var(--sidebar-width); height: 100dvh; flex-direction: column; color: #dce8ef; background: var(--navy); }
.brand { display: flex; height: 108px; flex: 0 0 108px; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 8px 14px; border-bottom: 1px solid #ffffff1d; color: #fff; }
.brand img { display: block; width: 176px; max-height: 78px; object-fit: contain; }
.brand-module { color: #d9eaf4; font-size: 9px; font-weight: 850; letter-spacing: 3px; }
.sidebar nav { flex: 1 1 auto; overflow: auto; padding: 10px 8px; scrollbar-color: #ffffff33 transparent; }
.nav-item { display: grid; grid-template-columns: 24px minmax(0, 1fr); align-items: center; gap: 11px; width: 100%; min-height: 38px; margin: 1px 0; padding: 7px 10px; border: 0; border-radius: 5px; color: #dce8ef; background: transparent; text-align: left; font-weight: 650; }
.nav-item:hover:not(:disabled), .nav-item.active { color: #fff; background: #ffffff14; }
.nav-item.active { box-shadow: inset 3px 0 0 var(--cyan); }
.nav-icon { display: grid; width: 24px; height: 24px; place-items: center; border-radius: 4px; background: #ffffff12; font-size: 10px; font-weight: 850; }
.nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user { flex: 0 0 auto; padding: 14px 18px; border-top: 1px solid #ffffff1d; }
.sidebar-user strong, .sidebar-user > small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user > small { color: #a8c2d2; }
.sidebar-user-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.sidebar-user-actions form { margin: 0; }
.sidebar-action { display: inline-flex; padding: 0; border: 0; color: #fff; background: transparent; font-size: 12px; font-weight: 650; }
.sidebar-action:hover { color: var(--cyan); filter: none; }
.nav-backdrop { display: none; }
.shell { min-width: 0; margin-left: var(--sidebar-width); }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; min-height: 82px; align-items: center; gap: 18px; padding: 13px 24px; border-bottom: 1px solid var(--line); background: #fff; }
.menu-toggle { display: none; padding: 4px; border: 0; color: var(--navy); background: transparent; font-size: 23px; }
.project-control { display: grid; min-width: 220px; }
.project-control label { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; }
.project-control select { width: min(340px, 30vw); margin-left: -5px; padding: 5px; border: 1px solid transparent; color: var(--navy); background: transparent; font-weight: 750; }
.topbar-context { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; }
.connection-status { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.connection-status i { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.connection-status.offline i { background: var(--danger); }
.connection-status.syncing i { background: var(--orange); animation: pulse 1s infinite; }
.global-search { width: min(280px, 25vw); margin-left: auto; }
.global-search input { width: 100%; padding: 8px 11px; border: 1px solid var(--line); border-radius: 5px; }

/* Layout and primitives */
.view { max-width: 1800px; min-height: calc(100vh - 82px); margin-inline: auto; padding: 20px 24px 42px; }
.page-title { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.page-title h1 { margin: 2px 0; color: var(--text); font-size: clamp(23px, 2.2vw, 29px); line-height: 1.2; }
.page-subtitle { max-width: 780px; margin: 4px 0 0; color: var(--muted); }
.eyebrow { margin: 0; color: var(--blue); font-size: 10px; font-weight: 850; letter-spacing: 1.4px; text-transform: uppercase; }
.actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 13px; border: 1px solid var(--blue); border-radius: 4px; color: #fff; background: var(--blue); font-weight: 750; text-decoration: none; }
button:hover:not(:disabled), .button:hover { filter: brightness(.94); }
.secondary { border-color: var(--blue); color: var(--blue); background: #fff; }
.danger { border-color: #e8bcbc; color: var(--danger); background: #fff; }
.text-action { padding: 4px 5px; border: 0; color: var(--blue); background: transparent; white-space: nowrap; }
.compact { padding: 6px 9px; font-size: 12px; }
.button-block { width: 100%; }
.panel { min-width: 0; margin: 0 0 18px; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: #fff; box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 15px 17px; border-bottom: 1px solid var(--line); }
.panel-head h2, .panel-head h3 { margin: 0; font-size: 16px; }
.panel-head p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.panel-body { padding: 16px 18px; }
.span-2 { grid-column: span 2; }
.content-grid, .admin-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 18px; }
.dashboard-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.dashboard-grid .panel { margin: 0; }
.metrics { display: grid; gap: 12px; margin-bottom: 18px; }
.metrics-6 { grid-template-columns: repeat(6, minmax(120px, 1fr)); }
.metrics-4 { grid-template-columns: repeat(4, minmax(140px, 1fr)); }
.metrics article { min-width: 0; padding: 13px 14px; border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 5px; background: #fff; box-shadow: var(--shadow); }
.metrics article.stage-a { border-left-color: var(--stage-a); }
.metrics article.stage-b, .metrics article.warning { border-left-color: var(--stage-b); }
.metrics article.stage-c { border-left-color: var(--stage-c); }
.metrics article.danger { border-left-color: var(--danger); }
.metrics article > span { display: block; overflow: hidden; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .35px; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.metrics strong { display: block; margin-top: 4px; font-size: 24px; line-height: 1.15; }
.metrics small { display: block; min-height: 16px; margin-top: 3px; color: var(--muted); font-size: 10px; }

/* Status, badges, tables */
.badge, .status-pill, .stage-pill { display: inline-flex; align-items: center; justify-content: center; min-height: 21px; padding: 2px 8px; border-radius: 999px; color: #50636f; background: #edf2f5; font-size: 10px; font-weight: 800; line-height: 1.25; text-transform: uppercase; white-space: nowrap; }
.badge.success, .badge.complete, .badge.signed, .badge.published, .badge.finalized, .badge.closed, .badge.approved { color: var(--success); background: #e4f4ed; }
.badge.warning, .badge.pending, .badge.pending-approval, .badge.in-progress, .badge.deferred { color: #87560c; background: #fff2df; }
.badge.danger, .badge.overdue, .badge.rejected, .badge.blocked, .badge.critical { color: var(--danger); background: #ffeaeb; }
.badge.info, .badge.issued, .badge.draft, .badge.submitted { color: var(--blue); background: #eaf5fb; }
.badge.restricted { gap: 4px; color: #773563; background: #f7e9f3; }
.stage-pill { min-width: 24px; padding-inline: 7px; color: #fff !important; }
.stage-pill.stage-a { background: var(--stage-a); }
.stage-pill.stage-b { background: var(--stage-b); }
.stage-pill.stage-c { background: var(--stage-c); }
.table-wrap { width: 100%; overflow: auto; }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; white-space: nowrap; }
.data-table th { position: sticky; top: 0; z-index: 2; padding: 9px 10px; border-bottom: 1px solid var(--line); color: #415563; background: #edf3f6; text-align: left; font-size: 10px; font-weight: 800; letter-spacing: .35px; text-transform: uppercase; }
.data-table td { padding: 9px 10px; border-bottom: 1px solid #e9eef1; vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover:not(.state-row) td { background: #f7fafb; }
.data-table td.wrap { min-width: 220px; max-width: 440px; overflow: hidden; text-overflow: ellipsis; white-space: normal; }
.data-table td.actions-cell { text-align: right; }
.row-actions { display: flex; justify-content: flex-end; gap: 5px; }
.row-actions button, .row-actions a { padding: 5px 7px; font-size: 11px; }
.reference { color: var(--blue); font-weight: 800; }
.muted { color: var(--muted); }
.overdue-text { color: var(--danger); font-weight: 750; }
.progress { display: grid; grid-template-columns: minmax(80px, 1fr) auto; align-items: center; gap: 8px; min-width: 125px; }
.progress-bar { width: 100%; height: 7px; overflow: hidden; appearance: none; border: 0; border-radius: 99px; background: #e3e9ed; }
.progress-bar::-webkit-progress-bar { border-radius: 99px; background: #e3e9ed; }
.progress-bar::-webkit-progress-value { border-radius: 99px; background: var(--blue); }
.progress-bar::-moz-progress-bar { border-radius: 99px; background: var(--blue); }
.progress small { color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }

/* Filters, tabs and notices */
.filter-bar { display: flex; align-items: end; flex-wrap: wrap; gap: 10px 14px; margin-bottom: 14px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 5px; background: #fff; }
.filter-bar.joined { margin-bottom: 0; border-radius: 0; border-top: 0; }
.joined-panel { border-top: 0; border-radius: 0 0 6px 6px; }
.filter-bar label { display: grid; gap: 3px; color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .2px; text-transform: uppercase; }
.filter-bar input, .filter-bar select { min-width: 150px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 4px; color: var(--text); background: #fff; text-transform: none; }
.filter-bar .search-filter { min-width: min(330px, 100%); flex: 1; }
.filter-bar .filter-checkbox { display: flex; min-height: 34px; flex-direction: row; align-items: center; gap: 7px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 4px; color: var(--text); background: #f8fafb; text-transform: none; }
.filter-bar .filter-checkbox input { width: auto; min-width: 0; margin: 0; }
.filter-action { align-self: end; }
.tabs { display: flex; gap: 2px; overflow-x: auto; padding: 5px 5px 0; border-radius: 5px 5px 0 0; background: #dfe8ed; }
.tabs button { gap: 7px; flex: 0 0 auto; padding: 8px 11px; border: 0; border-radius: 4px 4px 0 0; color: #415563; background: #edf2f5; font-size: 12px; }
.tabs button[aria-selected="true"] { color: var(--navy); background: #fff; }
.notice, .alert, .status-banner { margin: 0 0 16px; padding: 11px 13px; border: 1px solid #cbe2ee; border-radius: 5px; color: #285e7c; background: #eef7fc; }
.notice strong, .alert strong { color: inherit; }
.alert-danger { border-color: #f2c7ca; color: #8f2830; background: #ffedef; }
.alert-warning { border-color: #ebd39f; color: #714c0d; background: #fff7e8; }
.confidentiality-notice { border-color: #e7cde0; color: #6b305a; background: #fbf1f8; }
.status-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.status-banner.frozen { border-color: #bfdfce; color: var(--success); background: #edf8f2; }
.status-banner.pending { border-color: #ebd39f; color: var(--warning); background: #fff7e8; }

/* Commissioning */
.stage-strip { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; align-items: stretch; gap: 8px; margin-bottom: 18px; }
.stage-strip > div:not(.stage-arrow) { display: grid; grid-template-columns: 38px 1fr; column-gap: 11px; align-items: center; min-width: 0; padding: 11px 14px; border: 1px solid var(--line); border-top: 3px solid; border-radius: 5px; background: #fff; box-shadow: var(--shadow); }
.stage-strip > .stage-a { border-top-color: var(--stage-a); }
.stage-strip > .stage-b { border-top-color: var(--stage-b); }
.stage-strip > .stage-c { border-top-color: var(--stage-c); }
.stage-strip span { grid-row: 1 / 3; display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50%; color: #fff; font-weight: 900; }
.stage-strip .stage-a span { background: var(--stage-a); }
.stage-strip .stage-b span { background: var(--stage-b); }
.stage-strip .stage-c span { background: var(--stage-c); }
.stage-strip strong { font-size: 13px; }
.stage-strip small { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.stage-arrow { display: grid; place-items: center; color: var(--muted); font-size: 20px; }
.commissioning-layout { display: grid; grid-template-columns: minmax(280px, 390px) minmax(0, 1fr); gap: 18px; align-items: start; }
.scope-panel { position: sticky; top: 100px; max-height: calc(100vh - 120px); }
.scope-toolbar { display: flex; gap: 7px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.scope-toolbar input { min-width: 0; flex: 1; padding: 7px 9px; border: 1px solid var(--line); border-radius: 4px; }
.scope-tree { max-height: calc(100vh - 260px); overflow: auto; padding: 8px; }
.tree-node { position: relative; display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; border: 1px solid transparent; border-radius: 4px; }
.tree-node[aria-level="2"] { margin-left: 15px; }
.tree-node[aria-level="3"] { margin-left: 30px; }
.tree-node[aria-level="4"] { margin-left: 45px; }
.tree-node[aria-level="5"] { margin-left: 60px; }
.tree-node[aria-level="6"] { margin-left: 75px; }
.tree-node:hover, .tree-node.selected { border-color: #c8e4f3; background: #eaf5fb; }
.tree-toggle { width: 22px; padding: 5px 2px; border: 0; color: var(--blue); background: transparent; }
.tree-select { display: grid; min-width: 0; padding: 7px 5px; border: 0; color: var(--text); background: transparent; text-align: left; font-weight: 650; }
.tree-select small { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.tree-progress { padding-right: 7px; color: var(--muted); font-size: 10px; }
.scope-detail { min-width: 0; }
.scope-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.scope-summary > div { padding: 12px; border: 1px solid var(--line); border-radius: 5px; background: #f9fbfc; }
.scope-summary span { display: block; color: var(--muted); font-size: 10px; font-weight: 750; text-transform: uppercase; }
.scope-summary strong { display: block; margin-top: 4px; font-size: 20px; }
.gate-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.gate-card { padding: 13px; border: 1px solid var(--line); border-left: 4px solid var(--stage-b); border-radius: 5px; }
.gate-card.ready { border-left-color: var(--success); }
.gate-card.blocked { border-left-color: var(--danger); }
.gate-card h3 { margin: 0 0 8px; font-size: 13px; }
.gate-card dl { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 0; }
.gate-card dt { color: var(--muted); font-size: 11px; }
.gate-card dd { margin: 0; font-weight: 750; }

/* Dashboard and HSE */
.compact-list, .activity-feed { display: grid; gap: 0; padding-block: 5px; }
.list-item, .feed-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px 12px; padding: 10px 2px; border-bottom: 1px solid #edf1f4; }
.list-item:last-child, .feed-item:last-child { border-bottom: 0; }
.list-item p, .feed-item p { margin: 1px 0 0; color: var(--muted); font-size: 11px; }
.list-item time, .feed-item time { grid-column: 2; grid-row: 1 / 3; align-self: center; color: var(--muted); font-size: 10px; }
.feed-item { grid-template-columns: 8px minmax(0, 1fr) auto; }
.feed-item::before { content: ''; width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; background: var(--blue); }
.feed-item > div { grid-column: 2; }
.feed-item time { grid-column: 3; }
.hse-action-grid, .report-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.hse-action-grid button, .report-cards button { display: grid; grid-template-columns: 36px minmax(0, 1fr); column-gap: 11px; align-items: center; padding: 13px; border: 1px solid var(--line); color: var(--text); background: #fff; text-align: left; box-shadow: var(--shadow); }
.hse-action-grid button:hover, .hse-action-grid button.active, .report-cards button:hover { border-color: #a8cfdf; background: #f8fcfe; filter: none; }
.hse-action-grid button > span, .report-cards button > span { grid-row: 1 / 3; display: grid; width: 34px; height: 34px; place-items: center; border-radius: 4px; color: #fff; background: var(--blue); font-size: 11px; font-weight: 850; }
.hse-action-grid strong, .report-cards strong { font-size: 13px; }
.hse-action-grid small, .report-cards small { overflow: hidden; color: var(--muted); font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.definition-list { display: grid; gap: 10px; }
.definition-list > div { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding-bottom: 8px; border-bottom: 1px solid #edf1f4; }
.definition-list span { color: var(--muted); }

/* Loading, empty and error states */
.loading-state, .empty-state, .error-state { display: grid; min-height: 88px; place-items: center; align-content: center; gap: 5px; padding: 22px; color: var(--muted); text-align: center; white-space: normal; }
.loading-state::before { content: ''; width: 20px; height: 20px; border: 2px solid #c7d5dd; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
.loading-state.compact-state { display: inline-flex; min-height: 0; padding: 4px; }
.empty-state strong, .error-state strong { color: var(--text); }
.empty-state p, .error-state p { max-width: 480px; margin: 0; }
.empty-state::before { content: '—'; display: grid; width: 30px; height: 30px; place-items: center; border: 1px dashed #aebdc6; border-radius: 50%; }
.error-state { color: var(--danger); }
.error-state::before { content: '!'; display: grid; width: 28px; height: 28px; place-items: center; border-radius: 50%; color: #fff; background: var(--danger); font-weight: 900; }
.state-row td { padding: 0; }
.skeleton { min-height: 16px; border-radius: 4px; background: linear-gradient(90deg, #edf1f4 25%, #f8fafb 37%, #edf1f4 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }

/* Dialogs and forms */
dialog { width: min(720px, calc(100vw - 30px)); max-height: min(900px, calc(100dvh - 28px)); overflow: auto; padding: 0; border: 0; border-radius: 9px; color: var(--text); background: #fff; box-shadow: var(--shadow-dialog); }
dialog.large { width: min(980px, calc(100vw - 30px)); }
dialog.xlarge { width: min(1320px, calc(100vw - 30px)); }
dialog::backdrop { background: #0c2032a6; backdrop-filter: blur(2px); }
dialog form { margin: 0; }
.dialog-head { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 17px 21px; border-bottom: 1px solid var(--line); background: #fff; }
.dialog-head h2 { margin: 0; font-size: 18px; }
.dialog-head p { margin: 3px 0 0; color: var(--muted); }
.icon { padding: 3px 6px; border: 0; color: var(--muted); background: transparent; font-size: 24px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 20px 22px; }
.form-stack { display: grid; gap: 14px; padding: 20px 22px; }
.form-grid label, .form-stack label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 650; }
.form-grid label.wide { grid-column: 1 / -1; }
.form-grid input, .form-grid select, .form-grid textarea, .form-stack input, .form-stack select, .form-stack textarea { display: block; width: 100%; min-width: 0; padding: 8px 9px; border: 1px solid #bbc7cf; border-radius: 4px; color: var(--text); background: #fff; font-weight: 400; }
.form-grid textarea, .form-stack textarea { min-height: 78px; resize: vertical; }
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus, .form-stack input:focus { border-color: var(--blue); outline: 2px solid #b8d7e7; outline-offset: 0; }
.form-grid .checkbox { display: flex; align-items: start; grid-template-columns: 18px 1fr; gap: 9px; padding: 10px; border: 1px solid var(--line); border-radius: 4px; color: var(--text); background: #f8fafb; }
.checkbox input { width: auto; margin-top: 2px; }
.fieldset { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; padding: 10px; border: 1px solid var(--line); border-radius: 4px; }
.fieldset legend { padding: 0 5px; color: var(--muted); font-size: 12px; font-weight: 700; }
.field-help { display: block; color: var(--muted); font-size: 10px; font-weight: 500; }
.dialog-actions { position: sticky; bottom: 0; z-index: 3; display: flex; justify-content: flex-end; gap: 8px; padding: 14px 21px; border-top: 1px solid var(--line); background: #fff; }
dialog > .alert, dialog form > .alert { margin: 15px 21px 0; }
.record-detail { min-height: 280px; padding: 20px 22px; }
.record-section { margin-bottom: 20px; }
.record-section h3 { margin: 0 0 8px; font-size: 14px; }
.record-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.record-fields > div { min-width: 0; padding: 9px 11px; border: 1px solid var(--line); border-radius: 4px; }
.record-fields span { display: block; color: var(--muted); font-size: 9px; font-weight: 800; text-transform: uppercase; }
.record-fields strong { display: block; overflow-wrap: anywhere; margin-top: 3px; }
.record-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.subhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.subhead h3 { margin: 0; font-size: 14px; }
.template-items, .form-repeaters { display: grid; gap: 12px; padding: 0 22px 20px; }
.repeater { display: grid; gap: 8px; margin-top: 10px; }
.repeater-row { display: grid; grid-template-columns: 42px minmax(0, 1fr) 135px auto; gap: 7px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 4px; background: #f8fafb; }
.repeater-row input, .repeater-row select { width: 100%; padding: 7px; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.template-check-row { grid-template-columns: 32px minmax(100px, .65fr) minmax(190px, 1.5fr) 125px minmax(160px, 1fr) auto; }
.field-repeater-row { grid-template-columns: 32px repeat(3, minmax(100px, 1fr)) auto; }

/* Login */
.login-page { display: grid; min-height: 100dvh; place-items: center; padding: 24px; background: linear-gradient(135deg, var(--navy), #274f6e); }
.login-card { width: min(430px, 100%); padding: 29px; border-radius: 8px; background: #fff; box-shadow: 0 18px 50px #071b2c66; }
.login-logo-panel { display: grid; justify-items: center; gap: 3px; margin-bottom: 20px; padding: 13px 18px; border-radius: 6px; background: var(--navy); }
.login-logo-panel img { display: block; width: min(100%, 310px); height: auto; }
.login-logo-panel span { color: var(--light); font-size: 9px; font-weight: 850; letter-spacing: 3px; }
.login-heading { margin-bottom: 19px; text-align: center; }
.login-heading h1 { margin: 2px 0; color: var(--navy); font-size: 27px; }
.login-heading > p:last-child { margin: 4px 0 0; color: var(--muted); }
.login-form { display: grid; gap: 7px; }
.login-form label { margin-top: 5px; color: #52626e; font-size: 12px; font-weight: 750; }
.login-form input { width: 100%; padding: 10px; border: 1px solid #bbc7cf; border-radius: 4px; }
.login-form button { margin-top: 8px; }
.login-sso-copy { color: var(--muted); text-align: center; }
.login-divider { display: flex; align-items: center; gap: 9px; margin: 20px 0 12px; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.login-divider::before, .login-divider::after { content: ''; height: 1px; flex: 1; background: var(--line); }
.login-security-note { margin: 18px 0 0; color: var(--muted); font-size: 10px; text-align: center; }
.alert-reference { display: block; margin-top: 5px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* Notifications */
#toast { position: fixed; right: 20px; bottom: 20px; z-index: 150; max-width: min(430px, calc(100vw - 40px)); padding: 11px 15px; border-radius: 5px; color: #fff; background: var(--navy); box-shadow: 0 10px 30px #0d263955; opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .18s, transform .18s; }
#toast.show { opacity: 1; transform: translateY(0); }
#toast[data-tone="error"] { background: var(--danger); }
#toast[data-tone="success"] { background: var(--success); }
#toast[data-tone="warning"] { background: var(--warning); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
@keyframes pulse { 50% { opacity: .35; } }

@media (max-width: 1280px) {
    .metrics-6 { grid-template-columns: repeat(3, 1fr); }
    .hse-action-grid, .report-cards { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .topbar-context { display: none; }
}

@media (max-width: 1000px) {
    .metrics-4 { grid-template-columns: repeat(2, 1fr); }
    .stage-strip { grid-template-columns: 1fr; }
    .stage-arrow { height: 12px; transform: rotate(90deg); }
    .commissioning-layout { grid-template-columns: 1fr; }
    .scope-panel { position: static; max-height: none; }
    .scope-tree { max-height: 420px; }
    .gate-grid { grid-template-columns: 1fr; }
    .record-fields { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 780px) {
    .sidebar { left: calc(-1 * var(--sidebar-width)); transition: transform .2s ease; }
    .sidebar.open { transform: translateX(var(--sidebar-width)); box-shadow: 12px 0 30px #0c203255; }
    .nav-backdrop { position: fixed; inset: 0; z-index: 25; display: block; border: 0; border-radius: 0; background: #0c203273; opacity: 0; pointer-events: none; transition: opacity .2s; }
    .sidebar.open + .nav-backdrop { opacity: 1; pointer-events: auto; }
    .shell { margin-left: 0; }
    .topbar { min-height: 68px; gap: 10px; padding: 9px 13px; }
    .menu-toggle { display: inline-flex; flex: 0 0 auto; }
    .project-control { min-width: 0; flex: 1; }
    .project-control select { width: 100%; }
    .global-search { width: 42px; margin-left: 0; }
    .global-search input { width: 42px; padding-left: 32px; background: #fff no-repeat center/16px; }
    .global-search input:focus { position: absolute; right: 12px; width: calc(100vw - 74px); padding-left: 10px; box-shadow: 0 4px 15px #0c20322e; }
    .view { min-height: calc(100vh - 68px); padding: 16px 14px 34px; }
    .page-title { align-items: start; flex-direction: column; margin-bottom: 16px; }
    .page-title .actions { width: 100%; justify-content: flex-start; }
    .content-grid, .admin-grid, .dashboard-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .metrics-6 { grid-template-columns: repeat(2, 1fr); }
    .stage-strip > div:not(.stage-arrow) { grid-template-columns: 34px minmax(0, 1fr); }
    dialog, dialog.large, dialog.xlarge { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
    .form-grid { grid-template-columns: 1fr; padding: 17px; }
    .form-grid label.wide { grid-column: auto; }
    .dialog-head, .dialog-actions { padding-inline: 17px; }
    .record-fields { grid-template-columns: 1fr; }
    .repeater-row { grid-template-columns: 34px minmax(0, 1fr) auto; }
    .repeater-row input, .repeater-row select { grid-column: 2; }
    .repeater-row button { grid-column: 3; grid-row: 1; }
    .fieldset { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
    .metrics-6, .metrics-4, .hse-action-grid, .report-cards, .scope-summary { grid-template-columns: 1fr; }
    .metrics { gap: 8px; }
    .metrics article { display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 10px; padding-block: 10px; }
    .metrics article > strong { grid-column: 2; grid-row: 1 / 3; margin: 0; }
    .metrics article > small { min-height: 0; }
    .filter-bar { align-items: stretch; flex-direction: column; }
    .filter-bar label, .filter-bar input, .filter-bar select { width: 100%; min-width: 0; }
    .dialog-actions { display: grid; grid-template-columns: 1fr; }
    .dialog-actions button { width: 100%; }
    .login-page { padding: 12px; }
    .login-card { padding: 22px; }
    #toast { right: 12px; bottom: 12px; max-width: calc(100vw - 24px); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media print {
    .sidebar, .topbar, .page-title .actions, .filter-bar, .tabs, #toast, dialog { display: none !important; }
    .shell { margin: 0; }
    .view { display: none; max-width: none; padding: 0; }
    .view.active { display: block; }
    .panel, .metrics article { break-inside: avoid; box-shadow: none; }
    body { color: #000; background: #fff; font-size: 10pt; }
}
