:root {
    --ink: #172027;
    --ink-soft: #52606a;
    --paper: #f2f1ed;
    --paper-white: #fbfbf8;
    --line: #d3d6d5;
    --accent: #10a7bd;
    --accent-dark: #087b8f;
    --danger: #cf3e36;
    --warning: #d19a17;
    --success: #278668;
    --sidebar: #182126;
    --font-heading: "Noto Sans Thai", sans-serif;
    --font-body: "IBM Plex Sans Thai", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: var(--font-body); }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 75%, white); outline-offset: 3px; }
.skip-link { position: fixed; top: -80px; left: 16px; z-index: 9999; padding: 12px 18px; background: var(--paper-white); color: var(--ink); }
.skip-link:focus { top: 12px; }

.brand-lockup { display: inline-flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; }
.brand-lockup strong, .brand-lockup small { display: block; }
.brand-lockup strong { font: 600 .84rem/1 var(--font-heading); letter-spacing: .09em; }
.brand-lockup small { margin-top: 5px; font-size: .69rem; opacity: .66; }
.brand-mark { position: relative; display: grid; grid-template-columns: repeat(2, 12px); grid-template-rows: repeat(2, 12px); width: 29px; height: 29px; }
.brand-mark i { display: block; background: var(--accent); }
.brand-mark i:first-child { grid-column: 1 / 3; width: 10px; justify-self: center; }
.brand-mark i:last-child { grid-row: 1 / 3; width: 10px; justify-self: center; transform: rotate(90deg); }
.brand-lockup--light { color: white; }

.section-index, .page-kicker, .nav-eyebrow { margin: 0; font: 500 .67rem/1.3 var(--font-body); letter-spacing: .18em; text-transform: uppercase; }
.section-index { color: var(--accent); }

/* Landing */
.landing-page { background: var(--paper); }
.landing-nav { position: absolute; inset: 0 0 auto; z-index: 10; height: 92px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 clamp(22px, 4vw, 72px); color: white; border-bottom: 1px solid rgb(255 255 255 / .26); }
.landing-nav > p { margin: 0; font-size: .75rem; letter-spacing: .08em; }
.landing-nav .text-link { justify-self: end; }
.text-link { display: inline-flex; align-items: center; gap: 18px; min-height: 44px; font-size: .84rem; text-decoration: none; border-bottom: 1px solid currentColor; }
.landing-hero { position: relative; min-height: 100svh; overflow: hidden; color: white; background: var(--ink); }
.landing-hero > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 56% center; animation: heroImageIn 1.2s cubic-bezier(.2,.8,.2,1) both; }
.hero-shade { position: absolute; inset: 0; background: linear-gradient(90deg, rgb(15 24 28 / .90) 0%, rgb(15 24 28 / .64) 36%, rgb(15 24 28 / .08) 66%); }
.hero-copy { position: absolute; z-index: 2; left: clamp(22px, 7.3vw, 140px); top: 50%; width: min(620px, 48vw); transform: translateY(-42%); }
.hero-copy .section-index { margin-bottom: 30px; }
.hero-copy h1 { margin: 0; font: 600 clamp(3rem, 5.7vw, 6.5rem)/.98 var(--font-heading); letter-spacing: -.055em; }
.hero-copy h1 span { color: #b9e5e9; }
.hero-copy > p:not(.section-index) { max-width: 510px; margin: 34px 0 36px; color: rgb(255 255 255 / .82); font-size: clamp(1rem, 1.25vw, 1.23rem); line-height: 1.75; }
.hero-action { display: inline-flex; justify-content: space-between; align-items: center; min-width: 230px; min-height: 54px; padding: 0 19px; color: var(--ink); background: var(--paper-white); text-decoration: none; font-weight: 600; transition: background .2s, color .2s, transform .2s; }
.hero-action:hover { color: white; background: var(--accent); transform: translateY(-2px); }
.hero-folio { position: absolute; z-index: 2; right: clamp(22px, 4vw, 72px); bottom: 34px; left: clamp(22px, 4vw, 72px); display: flex; justify-content: space-between; font-size: .65rem; letter-spacing: .15em; }

.landing-statement { display: grid; grid-template-columns: 1fr 5fr 2fr; gap: clamp(30px, 5vw, 90px); align-items: start; padding: clamp(100px, 12vw, 190px) clamp(22px, 7vw, 140px); border-bottom: 1px solid var(--line); }
.statement-index { font: 500 clamp(3.5rem, 6vw, 7rem)/1 var(--font-heading); color: #c7cac8; }
.landing-statement h2, .flow-heading h2, .landing-proof h2, .landing-cta h2 { margin: 20px 0 0; font: 600 clamp(2.1rem, 4vw, 5rem)/1.08 var(--font-heading); letter-spacing: -.045em; }
.landing-statement > p { margin: 38px 0 0; color: var(--ink-soft); font-size: 1.03rem; line-height: 1.8; }

.landing-flow { display: grid; grid-template-columns: 1fr 1.7fr; min-height: 760px; background: var(--paper-white); border-bottom: 1px solid var(--line); }
.flow-heading { position: sticky; top: 0; align-self: start; padding: 120px clamp(22px, 7vw, 140px); }
.flow-line { margin: 0; padding: 75px clamp(22px, 7vw, 120px) 75px 0; list-style: none; border-left: 1px solid var(--line); }
.flow-line li { position: relative; display: grid; grid-template-columns: 70px 1fr; gap: 5px 20px; min-height: 155px; padding: 33px 0 33px 65px; border-bottom: 1px solid var(--line); }
.flow-line li::before { content: ""; position: absolute; top: 48px; left: -5px; width: 9px; height: 9px; border: 2px solid var(--accent); background: var(--paper-white); border-radius: 50%; }
.flow-line span { grid-row: 1 / 3; color: var(--accent-dark); font-size: .76rem; letter-spacing: .12em; }
.flow-line strong { font: 600 1.42rem/1.3 var(--font-heading); }
.flow-line small { max-width: 440px; color: var(--ink-soft); font-size: .94rem; line-height: 1.7; }

.landing-proof { display: grid; grid-template-columns: 1fr 1fr; gap: 6vw; align-items: center; padding: clamp(100px, 12vw, 185px) clamp(22px, 7vw, 140px); background: var(--accent); color: #082e34; }
.proof-number { margin: 0; font: 600 clamp(8rem, 19vw, 21rem)/.75 var(--font-heading); letter-spacing: -.08em; }
.proof-number span { margin-left: 8px; font-size: .13em; letter-spacing: 0; }
.landing-proof .section-index { color: #083942; }
.landing-proof h2 { font-size: clamp(2rem, 3.4vw, 4rem); }
.landing-proof div > p:last-child { max-width: 520px; margin: 30px 0 0; line-height: 1.8; }
.landing-cta { padding: clamp(110px, 14vw, 220px) clamp(22px, 7vw, 140px); color: white; background: var(--ink); }
.landing-cta h2 { max-width: 930px; margin-bottom: 55px; font-size: clamp(3rem, 6vw, 7.5rem); }
.hero-action--dark { color: white; background: transparent; border: 1px solid rgb(255 255 255 / .45); }
.landing-footer { display: flex; justify-content: space-between; padding: 30px clamp(22px, 4vw, 72px); color: #adb4b7; background: var(--ink); border-top: 1px solid #364248; font-size: .74rem; letter-spacing: .07em; }
.reveal-section { opacity: 0; transform: translateY(32px); transition: opacity .8s ease, transform .8s cubic-bezier(.2,.8,.2,1); }
.reveal-section.is-visible { opacity: 1; transform: none; }

/* Login */
.auth-page { min-height: 100svh; background: var(--paper-white); }
.auth-layout { display: grid; grid-template-columns: 1.18fr .82fr; min-height: 100svh; }
.auth-context { display: flex; flex-direction: column; justify-content: space-between; min-height: 100svh; padding: clamp(30px, 5vw, 80px); color: white; background: var(--ink); }
.auth-context h1 { margin: 25px 0; font: 600 clamp(3rem, 5.5vw, 6.7rem)/1.02 var(--font-heading); letter-spacing: -.055em; }
.auth-context div > p:last-child { max-width: 520px; color: #bbc4c7; line-height: 1.8; }
.auth-meta { margin: 0; color: #8d999e; font-size: .66rem; letter-spacing: .15em; }
.auth-form-wrap { display: flex; align-items: center; justify-content: center; padding: 40px; }
.auth-form { width: min(420px, 100%); }
.auth-form h2 { margin: 18px 0 40px; font: 600 2.15rem/1.25 var(--font-heading); letter-spacing: -.035em; }
.form-field { margin-bottom: 25px; }
.form-field label { display: block; margin-bottom: 8px; color: var(--ink-soft); font-size: .82rem; }
.form-control, .form-select { min-height: 48px; border: 1px solid #c8cecf; border-radius: 2px; background: white; }
.form-control:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgb(16 167 189 / .15); }
.btn { border-radius: 2px; min-height: 44px; font-weight: 600; }
.btn-accent { color: white; background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-accent:hover { color: white; background: #06687a; }
.form-note { margin: 22px 0 0; text-align: center; color: var(--ink-soft); font-size: .77rem; }

/* App shell */
.app-body { min-height: 100svh; background: #e9eceb; }
.app-frame { display: grid; grid-template-columns: 270px 1fr; min-height: 100svh; }
.app-sidebar { position: sticky; top: 0; display: flex; flex-direction: column; height: 100svh; padding: 32px 24px 24px; color: white; background: var(--sidebar); z-index: 50; }
.app-nav { margin-top: 68px; }
.nav-eyebrow { margin-bottom: 18px; color: #819097; }
.app-nav a { display: flex; justify-content: space-between; align-items: center; min-height: 48px; padding: 0 4px; color: #acb6ba; text-decoration: none; border-bottom: 1px solid #303b40; transition: color .15s, padding .15s; }
.app-nav a:hover, .app-nav a.is-active { padding-left: 10px; color: white; }
.app-nav a.is-active { border-bottom-color: var(--accent); }
.sidebar-account { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; margin-top: auto; padding-top: 22px; border-top: 1px solid #344047; }
.sidebar-account strong, .sidebar-account small { display: block; }
.sidebar-account strong { overflow: hidden; font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-account small { color: #88969c; font-size: .7rem; }
.sidebar-account a,
.sidebar-account__logout { color: #aab4b8; font-size: .72rem; }
.sidebar-account__logout { min-height: 44px; padding: 0 2px; border: 0; background: transparent; text-decoration: underline; text-underline-offset: 2px; }
.presence-dot { width: 8px; height: 8px; background: var(--accent); border-radius: 50%; }
.app-workspace { min-width: 0; }
.workspace-header { display: flex; justify-content: space-between; align-items: center; min-height: 115px; padding: 24px clamp(22px, 4vw, 68px); background: var(--paper-white); border-bottom: 1px solid var(--line); }
.workspace-header h1 { margin: 8px 0 0; font: 600 clamp(1.65rem, 2.5vw, 2.65rem)/1.1 var(--font-heading); letter-spacing: -.035em; }
.page-kicker { color: var(--ink-soft); }
.live-indicator { display: flex; gap: 9px; align-items: center; color: var(--ink-soft); font-size: .76rem; }
.live-indicator span { width: 7px; height: 7px; background: var(--success); border-radius: 50%; box-shadow: 0 0 0 4px rgb(39 134 104 / .13); }
.header-status-group { display: flex; align-items: center; gap: 22px; }
.notification-chip { display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 0 11px; color: var(--ink-soft); background: #edf0ef; font-size: .72rem; text-decoration: none; }
.notification-chip:hover { color: var(--ink); background: #e2e7e5; }
.notification-chip > span { color: var(--accent); font-size: .62rem; }
.notification-chip strong { min-width: 18px; color: var(--ink); font-size: .82rem; text-align: center; }
.menu-toggle { display: none; min-height: 44px; border: 0; background: transparent; }
.workspace-main { padding: clamp(24px, 4vw, 65px); }

/* Operational components */
.metric-strip { display: grid; grid-template-columns: repeat(4, 1fr); margin-bottom: 46px; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line); }
.metric { min-width: 0; padding: 24px 25px 24px 0; }
.metric + .metric { padding-left: 25px; border-left: 1px solid var(--line); }
.metric small { display: block; color: var(--ink-soft); font-size: .76rem; }
.metric strong { display: block; margin-top: 8px; font: 600 clamp(2.1rem, 4vw, 4rem)/1 var(--font-heading); letter-spacing: -.05em; }
.metric span { font-size: .72rem; color: var(--ink-soft); }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 20px; }
.section-head h2 { margin: 0; font: 600 1.35rem/1.3 var(--font-heading); }
.section-head p { margin: 5px 0 0; color: var(--ink-soft); font-size: .83rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.panel { margin-bottom: 38px; padding: clamp(20px, 3vw, 36px); background: var(--paper-white); border-top: 2px solid var(--ink); }
.panel--plain { padding: 0; background: transparent; border-top: 0; }
.data-table-wrap { overflow-x: auto; background: var(--paper-white); border-top: 2px solid var(--ink); }
.data-table { width: 100%; min-width: 780px; border-collapse: collapse; }
.data-table th { padding: 14px 18px; color: var(--ink-soft); background: #eceeec; font-size: .71rem; font-weight: 500; letter-spacing: .06em; text-align: left; white-space: nowrap; }
.data-table td { padding: 17px 18px; border-bottom: 1px solid #e0e3e1; vertical-align: middle; font-size: .87rem; }
.data-table tbody tr { transition: background .2s; }
.data-table tbody tr:hover { background: #f3f7f6; }
.data-table tr.is-overdue { background: #fff0ee; }
.data-table tr.is-new-emergency { animation: emergencyPulse 1.3s ease 3; }
.patient-cell strong, .patient-cell small { display: block; }
.patient-cell small { margin-top: 3px; color: var(--ink-soft); }
.status-tag, .urgency-tag { display: inline-flex; align-items: center; min-height: 27px; padding: 3px 9px; font-size: .71rem; font-weight: 600; border-radius: 999px; }
.urgency-emergency { color: #922b27; background: #fbdedb; }
.urgency-urgent { color: #715000; background: #f7e9bd; }
.urgency-normal { color: #17684f; background: #dff1e8; }
.status-tag { color: #405159; background: #e5eaeb; }
.empty-state { padding: 65px 25px; text-align: center; color: var(--ink-soft); background: var(--paper-white); border-top: 2px solid var(--ink); }
.empty-state strong { display: block; margin-bottom: 8px; color: var(--ink); font: 600 1.2rem var(--font-heading); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 24px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.field-label { display: block; margin-bottom: 7px; color: var(--ink-soft); font-size: .78rem; font-weight: 500; }
.required::after { content: " *"; color: var(--danger); }
.choice-row { display: flex; flex-wrap: wrap; gap: 8px; }
.choice-chip { position: relative; }
.choice-chip input { position: absolute; opacity: 0; pointer-events: none; }
.choice-chip label { display: flex; align-items: center; min-height: 42px; padding: 8px 13px; border: 1px solid #cdd2d2; background: white; cursor: pointer; }
.choice-chip input:checked + label { color: white; background: var(--ink); border-color: var(--ink); }
.choice-chip input:focus-visible + label { outline: 3px solid var(--accent); outline-offset: 2px; }
.action-row { display: flex; justify-content: flex-end; gap: 10px; padding-top: 10px; }
.mobile-job { padding: 20px; background: var(--paper-white); border-top: 3px solid var(--ink); }
.mobile-job + .mobile-job { margin-top: 16px; }
.mobile-job__route { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; margin: 22px 0; }
.mobile-job__route div:last-child { text-align: right; }
.mobile-job__route small, .job-meta small { display: block; color: var(--ink-soft); }
.job-meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; padding: 18px 0; border-top: 1px solid var(--line); }
.next-action { width: 100%; min-height: 56px; margin-top: 16px; }
.availability-switch { display: inline-flex; padding: 4px; background: #dfe3e2; }
.availability-switch button { min-height: 44px; padding: 0 18px; border: 0; background: transparent; }
.availability-switch button.is-active { color: white; background: var(--ink); }
.toast-region { position: fixed; z-index: 1000; right: 20px; bottom: 20px; display: grid; gap: 10px; }
.chart-frame { position: relative; height: 320px; }
.report-chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px; }
.user-action-group { display: flex; flex-wrap: wrap; gap: 8px; min-width: 250px; }
.app-modal .modal-content { overflow: hidden; border: 0; border-top: 4px solid var(--accent); border-radius: 3px; box-shadow: 0 28px 80px rgb(13 24 29 / .28); }
.app-modal .modal-dialog-scrollable .modal-content > form { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; overflow: hidden; }
.app-modal .modal-dialog-scrollable .modal-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.app-modal .modal-header { align-items: flex-start; padding: 24px 28px 20px; background: var(--paper-white); border-bottom: 1px solid var(--line); }
.app-modal .modal-title { margin: 5px 0 0; font: 600 1.55rem/1.25 var(--font-heading); letter-spacing: -.025em; }
.app-modal__eyebrow { margin: 0; color: var(--accent-dark); font-size: .67rem; font-weight: 600; letter-spacing: .13em; text-transform: uppercase; }
.app-modal__identity { margin: 7px 0 0; color: var(--ink-soft); font-size: .78rem; }
.app-modal .modal-body { padding: 28px; }
.app-modal .modal-footer { gap: 8px; padding: 18px 28px; background: #f2f4f3; border-top: 1px solid var(--line); }
.app-modal__field-note { display: block; margin-top: 7px; color: var(--ink-soft); font-size: .72rem; line-height: 1.5; }
.app-modal__help { margin: 10px 0 0; color: var(--ink-soft); font-size: .76rem; line-height: 1.65; }
.app-modal__confirm-copy { margin: 0; color: var(--ink); font-size: .93rem; line-height: 1.75; }
.app-modal .btn-close { margin: 0; }
.app-modal--danger .modal-content { border-top-color: var(--danger); }
.app-modal--danger .app-modal__eyebrow { color: var(--danger); }
.user-delete-impact { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 26px; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line); }
.user-delete-impact > div { min-width: 0; padding: 18px 16px; }
.user-delete-impact > div + div { border-left: 1px solid var(--line); }
.user-delete-impact span, .user-delete-impact strong { display: block; }
.user-delete-impact span { margin-bottom: 6px; color: var(--ink-soft); font-size: .7rem; }
.user-delete-impact strong { overflow-wrap: anywhere; font: 600 .92rem/1.5 var(--font-heading); }
.user-delete-modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0 0 24px; padding: 0; border: 0; }
.user-delete-modes legend { grid-column: 1 / -1; margin-bottom: 2px; color: var(--ink-soft); font-size: .78rem; }
.user-delete-mode { display: flex; gap: 11px; min-height: 78px; padding: 14px; border: 1px solid #c8cecf; background: white; cursor: pointer; }
.user-delete-mode:has(input:checked) { border-color: var(--ink); box-shadow: inset 3px 0 var(--ink); }
.user-delete-mode:has(input:disabled) { opacity: .52; cursor: not-allowed; }
.user-delete-mode input { flex: 0 0 auto; margin-top: 4px; }
.user-delete-mode span, .user-delete-mode strong, .user-delete-mode small { display: block; }
.user-delete-mode strong { font: 600 .9rem/1.35 var(--font-heading); }
.user-delete-mode small { margin-top: 4px; color: var(--ink-soft); font-size: .7rem; line-height: 1.45; }
.user-delete-confirmation { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 20px; }
.user-delete-confirmation > div:first-child { grid-column: 1 / -1; }
.user-delete-warning { margin: 22px 0 0; padding: 12px 14px; color: #812923; background: #fae7e5; border-left: 3px solid var(--danger); font-size: .76rem; line-height: 1.6; }
.user-trash-section { margin-top: 54px; }
.user-trash-section .section-index { margin-bottom: 7px; }
.user-trash-table-wrap { border-top-color: #768087; }
.user-row--trashed { background: #f2f3f2; color: var(--ink-soft); }
.user-row--trashed:hover { background: #ecefee !important; }
.user-trash-reason { max-width: 270px; overflow-wrap: anywhere; line-height: 1.55; }
.user-trash-empty { padding-block: 38px; border-top-color: #768087; }
.app-toast { max-width: 360px; padding: 14px 18px; color: white; background: var(--ink); border-left: 4px solid var(--accent); box-shadow: 0 12px 30px rgb(0 0 0 / .18); animation: toastIn .25s ease both; }
.notification-list { background: var(--paper-white); border-top: 2px solid var(--ink); }
.notification-item { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; gap: 20px; align-items: center; padding: 24px 26px; border-bottom: 1px solid var(--line); }
.notification-item.is-unread { background: #f4fbfb; }
.notification-item__marker { width: 8px; height: 8px; background: #aab4b6; border-radius: 50%; }
.notification-item.is-unread .notification-item__marker { background: var(--accent); box-shadow: 0 0 0 5px rgb(16 167 189 / .12); }
.notification-item__meta { display: flex; flex-wrap: wrap; gap: 8px 18px; color: var(--ink-soft); font-size: .7rem; letter-spacing: .04em; }
.notification-item h3 { margin: 7px 0 4px; font: 600 1.05rem/1.4 var(--font-heading); }
.notification-item p { margin: 0; color: var(--ink-soft); font-size: .86rem; line-height: 1.65; }
.notification-item__link { display: inline-block; margin-top: 10px; color: var(--accent-dark); font-size: .78rem; font-weight: 600; }
.notification-item__read-label { color: var(--ink-soft); font-size: .74rem; }

/* System operations console */
.system-module { min-width: 0; }
.system-status-rail { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 26px; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--line); background: rgb(251 251 248 / .5); }
.system-status-rail > div { min-width: 0; padding: 20px 22px; }
.system-status-rail > div + div { border-left: 1px solid var(--line); }
.system-status-rail__label { display: block; margin-bottom: 9px; color: var(--ink-soft); font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; }
.system-status-rail strong, .system-status-rail small { display: block; }
.system-status-rail strong { overflow: hidden; font: 600 .97rem/1.35 var(--font-heading); text-overflow: ellipsis; white-space: nowrap; }
.system-status-rail small { margin-top: 5px; overflow: hidden; color: var(--ink-soft); font-size: .68rem; text-overflow: ellipsis; white-space: nowrap; }
.system-state-dot { display: inline-block; width: 8px; height: 8px; margin-right: 9px; background: var(--warning); border-radius: 50%; }
.system-state-dot--ready { background: var(--success); box-shadow: 0 0 0 4px rgb(39 134 104 / .12); }
.system-state-dot--maintenance, .system-state-dot--restoring, .system-state-dot--resetting { background: var(--warning); box-shadow: 0 0 0 4px rgb(209 154 23 / .13); }

.system-subnav { display: flex; gap: clamp(22px, 3.5vw, 52px); min-width: 0; margin-bottom: 34px; overflow-x: auto; border-bottom: 1px solid #bfc5c3; scrollbar-width: thin; }
.system-subnav a { position: relative; flex: 0 0 auto; min-height: 48px; padding: 14px 1px 12px; color: var(--ink-soft); font-size: .83rem; font-weight: 500; text-decoration: none; white-space: nowrap; }
.system-subnav a::after { content: ""; position: absolute; right: 50%; bottom: -1px; left: 50%; height: 2px; background: var(--accent); transition: right .18s ease, left .18s ease; }
.system-subnav a:hover, .system-subnav a[aria-current="page"] { color: var(--ink); }
.system-subnav a[aria-current="page"]::after { right: 0; left: 0; }

.system-workbench { min-width: 0; }
.system-workbench[aria-busy="true"] { opacity: .62; transition: opacity .15s ease; }
.system-section { min-width: 0; margin-bottom: 42px; padding: clamp(24px, 3vw, 42px); background: var(--paper-white); border-top: 2px solid var(--ink); }
.system-section--history { background: transparent; padding-right: 0; padding-left: 0; }
.system-section__heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 28px; margin-bottom: 28px; }
.system-section__heading h2 { margin: 7px 0 0; font: 600 clamp(1.45rem, 2vw, 2rem)/1.2 var(--font-heading); letter-spacing: -.025em; }
.system-section__heading p:not(.section-index) { max-width: 720px; margin: 7px 0 0; color: var(--ink-soft); font-size: .84rem; line-height: 1.65; }
.system-section__actions { display: flex; flex: 0 0 auto; gap: 8px; }
.system-section__actions .btn { min-width: 128px; }
.system-result-count { flex: 0 0 auto; color: var(--ink-soft); font-size: .76rem; }

.system-readiness { padding: 24px 0 0; border-top: 1px solid var(--line); }
.system-readiness > div:first-child { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: start; }
.system-readiness__mark { width: 10px; height: 10px; margin-top: 6px; background: var(--warning); border-radius: 50%; box-shadow: 0 0 0 5px rgb(209 154 23 / .13); }
.system-readiness.is-ready .system-readiness__mark { background: var(--success); box-shadow: 0 0 0 5px rgb(39 134 104 / .12); }
.system-readiness strong { font: 600 1rem/1.45 var(--font-heading); }
.system-readiness p { margin: 4px 0 0; color: var(--ink-soft); font-size: .79rem; line-height: 1.6; }
.system-readiness ul { margin: 20px 0 0 24px; padding: 0; color: #73560e; font-size: .79rem; line-height: 1.9; }
.system-readiness dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 24px 0 0; border-top: 1px solid var(--line); }
.system-readiness dl div { min-width: 0; padding: 18px 18px 0 0; }
.system-readiness dl div + div { padding-left: 18px; border-left: 1px solid var(--line); }
.system-readiness dt { color: var(--ink-soft); font-size: .68rem; font-weight: 500; }
.system-readiness dd { margin: 4px 0 0; overflow-wrap: anywhere; font-size: .78rem; }
.system-status-text { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.system-status-text::before { content: ""; width: 7px; height: 7px; background: var(--warning); border-radius: 50%; }
.system-status-text--ready::before { background: var(--success); }
.system-status-text--failed::before { background: var(--danger); }

.system-source-tabs { display: flex; gap: 8px; margin: -5px 0 22px; overflow-x: auto; }
.system-source-tabs a { flex: 0 0 auto; min-height: 40px; padding: 9px 13px; color: var(--ink-soft); border: 1px solid transparent; font-size: .76rem; text-decoration: none; }
.system-source-tabs a:hover { color: var(--ink); border-color: var(--line); }
.system-source-tabs a[aria-current="page"] { color: white; background: var(--ink); border-color: var(--ink); }
.system-scope-note { display: grid; grid-template-columns: 145px 1fr; gap: 18px; margin-bottom: 24px; padding: 15px 18px; color: var(--ink-soft); background: #eef1ef; border-left: 3px solid var(--accent); font-size: .76rem; line-height: 1.6; }
.system-scope-note strong { color: var(--ink); font-family: var(--font-heading); }

.system-filter { margin-bottom: 26px; padding: 24px; background: #f1f3f1; border-top: 1px solid #bfc5c3; }
.system-filter-grid { display: grid; grid-template-columns: repeat(4, minmax(145px, 1fr)); gap: 16px; }
.system-filter-grid__keyword { grid-column: span 2; }
.system-filter .form-control, .system-filter .form-select { min-height: 44px; font-size: .82rem; }
.system-filter__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.system-filter__actions .btn { min-width: 108px; }

.system-log-table-wrap { max-width: 100%; overflow-x: auto; background: var(--paper-white); border-top: 2px solid var(--ink); }
.system-log-table { min-width: 940px; }
.system-log-table td { max-width: 310px; }
.system-log-title { display: block; margin-top: 5px; font-family: var(--font-heading); font-weight: 600; }
.system-log-type { display: inline-block; color: var(--accent-dark); font-size: .68rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
.system-log-table code { color: var(--ink-soft); font-size: .7rem; }
.system-read-count { display: inline-flex; min-height: 28px; align-items: center; padding: 4px 9px; color: #17684f; background: #dff1e8; border-radius: 999px; font-size: .7rem; font-weight: 600; white-space: nowrap; }
.system-outcome { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.system-outcome::before { content: ""; width: 7px; height: 7px; background: var(--ink-soft); border-radius: 50%; }
.system-outcome--success::before { background: var(--success); }
.system-outcome--failure::before, .system-outcome--denied::before { background: var(--danger); }
.system-pagination { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-top: 20px; color: var(--ink-soft); font-size: .76rem; }
.system-pagination > div { display: flex; gap: 8px; }

.system-detail-body { display: grid; gap: 28px; }
.system-detail-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line); }
.system-detail-summary div { min-width: 0; padding: 16px 14px 16px 0; }
.system-detail-summary div + div { padding-left: 14px; border-left: 1px solid var(--line); }
.system-detail-summary dt, .system-audit-fields dt { color: var(--ink-soft); font-size: .68rem; font-weight: 500; }
.system-detail-summary dd { margin: 5px 0 0; overflow-wrap: anywhere; font-size: .83rem; font-weight: 600; }
.system-detail-section h3, .system-audit-diff h3 { margin: 0 0 10px; font: 600 .92rem/1.4 var(--font-heading); }
.system-detail-section p { margin: 0; color: var(--ink-soft); font-size: .83rem; line-height: 1.75; }
.system-message-copy { padding: 18px; color: var(--ink) !important; background: #f1f3f1; white-space: normal; }
.system-technical-copy { overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .72rem !important; }
.system-detail-empty { margin: 0; color: var(--ink-soft); font-size: .78rem; }
.system-reader-list { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.system-reader-list li { display: flex; justify-content: space-between; gap: 18px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.system-reader-list strong, .system-reader-list small { display: block; }
.system-reader-list small, .system-reader-list time { color: var(--ink-soft); font-size: .7rem; }
.system-audit-diff { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.system-audit-diff > section { min-width: 0; }
.system-audit-fields { margin: 0; border-top: 1px solid var(--line); }
.system-audit-fields div { display: grid; grid-template-columns: minmax(105px, .7fr) 1.3fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.system-audit-fields dd { margin: 0; overflow-wrap: anywhere; font-size: .75rem; }

.system-danger-zone { border-top: 3px solid var(--danger); }
.system-danger-zone .section-index, .system-danger-zone__state { color: var(--danger); }
.system-danger-zone__state { flex: 0 0 auto; padding: 7px 10px; border: 1px solid rgb(207 62 54 / .35); font-size: .7rem; font-weight: 600; }
.system-impact-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.system-impact-grid > section { min-width: 0; padding: 24px 28px 20px 0; }
.system-impact-grid > section + section { padding-right: 0; padding-left: 28px; border-left: 1px solid var(--line); }
.system-impact-grid__head { display: flex; gap: 12px; align-items: baseline; margin-bottom: 15px; }
.system-impact-grid__head span { color: var(--ink-soft); font-size: .58rem; font-weight: 600; letter-spacing: .14em; }
.system-impact-grid__head h3 { margin: 0; font: 600 1.05rem/1.4 var(--font-heading); }
.system-impact-grid ul { margin: 0; padding: 0; list-style: none; }
.system-impact-grid li { display: flex; justify-content: space-between; gap: 20px; padding: 10px 0; border-bottom: 1px solid #e4e6e4; font-size: .78rem; }
.system-impact-grid li span { min-width: 0; }
.system-impact-grid li small { display: block; margin-top: 2px; color: var(--ink-soft); }
.system-impact-grid li strong { flex: 0 0 auto; font-size: .73rem; }
.system-danger-zone__footer { display: flex; justify-content: space-between; align-items: center; gap: 24px; padding-top: 24px; }
.system-danger-zone__footer strong { font-family: var(--font-heading); }
.system-danger-zone__footer p { margin: 4px 0 0; color: var(--ink-soft); font-size: .78rem; line-height: 1.6; }
.system-danger-zone__footer .btn { flex: 0 0 auto; }
.system-completion-note { padding: 24px; background: #eef1ef; border-left: 3px solid var(--ink); }
.system-completion-note strong { font-family: var(--font-heading); }
.system-completion-note p { margin: 5px 0 0; color: var(--ink-soft); font-size: .8rem; line-height: 1.7; }

@keyframes heroImageIn { from { opacity: .35; transform: scale(1.04); } to { opacity: 1; transform: scale(1); } }
@keyframes emergencyPulse { 0%,100% { box-shadow: inset 4px 0 var(--danger); } 50% { background: #ffdcd7; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

@media (max-width: 1024px) {
    .landing-statement { grid-template-columns: .5fr 2fr; }
    .landing-statement > p { grid-column: 2; margin-top: 0; max-width: 560px; }
    .landing-flow { grid-template-columns: .8fr 1.2fr; }
    .flow-heading { padding-right: 40px; padding-left: 40px; }
    .metric-strip { grid-template-columns: repeat(2, 1fr); }
    .metric:nth-child(3) { padding-left: 0; border-left: 0; border-top: 1px solid var(--line); }
    .metric:nth-child(4) { border-top: 1px solid var(--line); }
    .system-status-rail { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .system-status-rail > div:nth-child(3) { border-top: 1px solid var(--line); border-left: 0; }
    .system-status-rail > div:nth-child(4) { border-top: 1px solid var(--line); }
    .system-filter-grid { grid-template-columns: repeat(2, minmax(145px, 1fr)); }
}

@media (max-width: 768px) {
    .landing-nav { height: 76px; grid-template-columns: 1fr auto; }
    .landing-nav > p { display: none; }
    .landing-hero > img { object-position: 63% center; }
    .hero-shade { background: linear-gradient(90deg, rgb(15 24 28 / .92), rgb(15 24 28 / .38)); }
    .hero-copy { top: 51%; width: calc(100% - 44px); transform: translateY(-42%); }
    .hero-copy h1 { font-size: clamp(2.65rem, 12vw, 4.7rem); }
    .hero-copy > p:not(.section-index) { max-width: 90%; font-size: .96rem; }
    .hero-folio { bottom: 20px; }
    .landing-statement { grid-template-columns: 1fr; padding-top: 90px; padding-bottom: 90px; }
    .statement-index { font-size: 3rem; }
    .landing-statement > p { grid-column: 1; }
    .landing-flow { display: block; min-height: 0; }
    .flow-heading { position: static; padding: 90px 22px 45px; }
    .flow-line { padding: 0 22px 65px 36px; margin-left: 22px; }
    .flow-line li { grid-template-columns: 45px 1fr; padding-left: 28px; }
    .landing-proof { grid-template-columns: 1fr; }
    .proof-number { font-size: 44vw; }
    .landing-footer { gap: 22px; flex-direction: column; }
    .auth-layout { grid-template-columns: 1fr; }
    .auth-context { min-height: 42svh; padding: 28px 24px 38px; }
    .auth-context h1 { margin: 50px 0 12px; font-size: 2.8rem; }
    .auth-context div > p:last-child, .auth-meta { display: none; }
    .auth-form-wrap { padding: 50px 24px; }
    .app-frame { display: block; }
    .app-sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 88vw); transform: translateX(-102%); transition: transform .25s ease; box-shadow: 14px 0 40px rgb(0 0 0 / .25); }
    .app-sidebar.is-open { transform: none; }
    .workspace-header { min-height: 94px; padding: 18px 20px; }
    .workspace-header > div:first-of-type { flex: 1; }
    .menu-toggle { display: block; margin-right: 10px; }
    .live-indicator { display: none; }
    .notification-chip { padding: 0 8px; }
    .notification-chip { font-size: 0; }
    .notification-chip strong, .notification-chip > span { font-size: .72rem; }
    .workspace-main { padding: 28px 18px 50px; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: 1; }
    .section-head { align-items: start; flex-direction: column; }
    .report-chart-grid { grid-template-columns: 1fr; }
    .notification-item { grid-template-columns: 8px minmax(0, 1fr); gap: 14px; padding: 20px 18px; }
    .notification-item__action { grid-column: 2; }
    .system-status-rail > div { padding: 17px 14px; }
    .system-section { padding: 24px 20px; }
    .system-section--history { padding-right: 0; padding-left: 0; }
    .system-section__heading { align-items: flex-start; flex-direction: column; }
    .system-section__actions { width: 100%; }
    .system-section__actions .btn { flex: 1; min-width: 0; }
    .system-scope-note { grid-template-columns: 1fr; gap: 3px; }
    .system-filter { padding: 20px 16px; }
    .system-filter-grid { grid-template-columns: 1fr; }
    .system-filter-grid__keyword { grid-column: 1; }
    .system-impact-grid { grid-template-columns: 1fr; }
    .system-impact-grid > section { padding-right: 0; }
    .system-impact-grid > section + section { padding-left: 0; border-top: 1px solid var(--line); border-left: 0; }
    .system-detail-summary { grid-template-columns: 1fr; }
    .system-detail-summary div { padding-right: 0; }
    .system-detail-summary div + div { padding-left: 0; border-top: 1px solid var(--line); border-left: 0; }
    .system-audit-diff { grid-template-columns: 1fr; }
    .system-danger-zone__footer { align-items: stretch; flex-direction: column; }
    .system-danger-zone__footer .btn { width: 100%; }
}

@media (max-width: 480px) {
    .landing-nav .brand-lockup small { display: none; }
    .hero-copy .section-index { margin-bottom: 18px; }
    .hero-copy h1 { font-size: 2.65rem; }
    .hero-copy > p:not(.section-index) { margin: 24px 0; line-height: 1.6; }
    .hero-action { min-width: 210px; min-height: 50px; }
    .hero-folio span:last-child { display: none; }
    .landing-statement h2, .flow-heading h2, .landing-proof h2 { font-size: 2.3rem; }
    .landing-cta h2 { font-size: 3rem; }
    .metric-strip { grid-template-columns: 1fr 1fr; }
    .metric { padding: 18px 12px 18px 0; }
    .metric + .metric { padding-left: 12px; }
    .metric strong { font-size: 2.2rem; }
    .job-meta { grid-template-columns: 1fr; }
    .user-action-group { min-width: 220px; }
    .app-modal .modal-content { min-height: 100svh; border-radius: 0; }
    .app-modal .modal-header { padding: 22px 20px 18px; }
    .app-modal .modal-body { padding: 24px 20px; }
    .app-modal .modal-footer { margin-top: auto; padding: 16px 20px calc(16px + env(safe-area-inset-bottom)); }
    .app-modal .modal-footer .btn { flex: 1; }
    .user-delete-impact, .user-delete-modes, .user-delete-confirmation { grid-template-columns: 1fr; }
    .user-delete-impact > div + div { border-top: 1px solid var(--line); border-left: 0; }
    .user-delete-modes legend, .user-delete-confirmation > div:first-child { grid-column: 1; }
    .system-status-rail { grid-template-columns: 1fr; }
    .system-status-rail > div + div, .system-status-rail > div:nth-child(3) { border-top: 1px solid var(--line); border-left: 0; }
    .system-subnav { gap: 22px; margin-right: -18px; margin-left: -18px; padding: 0 18px; }
    .system-filter__actions { align-items: stretch; flex-direction: column-reverse; }
    .system-filter__actions .btn { width: 100%; }
    .system-pagination { align-items: stretch; flex-direction: column; }
    .system-pagination > div .btn { flex: 1; }
    .system-reader-list li { align-items: flex-start; flex-direction: column; gap: 5px; }
    .system-audit-fields div { grid-template-columns: 1fr; gap: 3px; }
}

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

@media print {
    .app-sidebar, .workspace-header, .toolbar, .btn, .toast-region { display: none !important; }
    .app-frame { display: block; }
    .workspace-main { padding: 0; }
    body { background: white; }
}
