/* Design tokens: teal accent on a slate palette. */
:root {
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #0f172a;
    --text-2: #334155;
    --muted: #64748b;
    --muted-strong: #475569;
    --line: #e2e8f0;
    --line-soft: #f1f5f9;
    --accent: #0d9488;
    --accent-strong: #0f766e;
    --accent-deep: #115e59;
    --accent-soft: #f0fdfa;
    --focus: #0d9488;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px -6px rgba(15, 23, 42, .10);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

h1 { margin: 0; font-size: 24px; line-height: 1.25; font-weight: 700; }
h2 { margin: 0; font-size: 14px; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent-strong); }
a:hover { color: var(--accent-deep); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; word-break: break-all; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1:focus { outline: none; }

[hidden] { display: none !important; }

.sr-only {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
    flex: 0 0 260px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px 12px;
    background: var(--surface);
    border-right: 1px solid var(--line);
}

.app-body { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; }

.app-header {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    padding: 12px 32px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.header-actions { display: flex; align-items: center; gap: 8px; }
.header-actions form { margin: 0; }

.app-main {
    width: 100%;
    max-width: 1120px;
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 8px; }
.brand-mark {
    width: 32px; height: 32px; border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--accent-strong); color: #fff; font-weight: 700;
}
.brand-name { font-weight: 700; font-size: 16px; }

.side-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px; border-radius: var(--radius);
    font-size: 14px; font-weight: 500;
    color: var(--muted-strong); text-decoration: none;
}
.nav-link:hover { background: var(--line-soft); color: var(--text); }
.nav-link.on { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }

.count-badge {
    margin-left: auto;
    min-width: 20px; padding: 0 7px;
    border-radius: 999px;
    background: #b91c1c; color: #fff;
    font-size: 12px; font-weight: 600; line-height: 20px; text-align: center;
}
.bell .count-badge { margin-left: 4px; background: var(--muted-strong); }

.facility-chip {
    display: inline-flex; align-items: center; gap: 8px;
    height: 36px; padding: 0 14px;
    border: 1px solid var(--line); border-radius: 999px;
    font-size: 14px; font-weight: 500; color: var(--text-2);
}
.facility-chip svg { color: var(--muted); }
.facility-code { color: var(--muted); font-weight: 400; }
.facility-code::before { content: '· '; }

/* ---------- Page chrome ---------- */
.page-head { display: flex; flex-direction: column; gap: 4px; }
.page-head-row { flex-direction: row; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; }
.page-sub { font-size: 14px; color: var(--muted); max-width: 70ch; }
.muted { color: var(--muted); font-size: 13px; }
.breadcrumb { font-size: 13px; color: var(--muted); }
.breadcrumb a { text-decoration: none; }
.meta-row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-top: 8px; }
.meta-item { font-size: 13px; color: var(--text-2); }
.state-reason { margin-top: 6px; font-size: 13px; color: var(--muted); }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.empty-note { color: var(--muted); }

.card {
    background: var(--surface);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}
.card-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.empty-card { padding: 24px; color: var(--muted-strong); border-style: dashed; background: var(--bg); }

/* ---------- Buttons and form controls ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 36px; padding: 0 16px;
    border-radius: var(--radius); border: 1px solid var(--line);
    background: var(--surface); color: var(--text-2);
    font: 500 14px/1.2 'Inter', system-ui, sans-serif;
    text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--bg); color: var(--text); }
.btn.pri { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn.pri:hover { background: var(--accent-deep); border-color: var(--accent-deep); color: #fff; }
.btn:disabled, .btn.pri:disabled {
    background: var(--line-soft); border-color: var(--line); color: var(--muted-strong);
    cursor: not-allowed;
}
.wide-btn { width: 100%; height: 40px; }

.lbl { display: block; margin-bottom: 6px; padding: 0; font-size: 13px; font-weight: 500; color: var(--text-2); }
.control {
    width: 100%; height: 40px; padding: 0 12px;
    border: 1px solid #94a3b8; border-radius: var(--radius);
    background: var(--surface); color: var(--text);
    font: 400 14px 'Inter', system-ui, sans-serif;
}
.field { min-width: 0; }
.page-head-row .field { min-width: 180px; }
.hint { margin-top: 6px; font-size: 12px; color: var(--muted-strong); }
.form-error {
    padding: 10px 14px; border-radius: var(--radius);
    background: #fef2f2; color: #b91c1c; font-size: 13px; font-weight: 500;
}

/* ---------- Upload ---------- */
.form-card { padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.type-fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.type-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.opt {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 12px 14px; cursor: pointer;
    border: 1px solid #94a3b8; border-radius: var(--radius); background: var(--surface);
}
.opt:hover { background: var(--bg); }
.opt.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.opt:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.opt input { margin-top: 3px; accent-color: var(--accent-strong); }
.opt-title { display: block; font-size: 14px; font-weight: 600; }
.opt-text { display: block; margin-top: 2px; font-size: 12px; color: var(--muted-strong); }
.type-fieldset > .hint { margin-top: 10px; }

.dropzone {
    position: relative;
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    padding: 40px 24px; text-align: center;
    border: 2px dashed #94a3b8; border-radius: var(--radius-lg); background: var(--bg);
    color: var(--muted-strong);
}
.dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.dropzone-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
.dropzone-text { font-size: 14px; font-weight: 500; color: var(--text-2); }
.dropzone-hint { font-size: 12px; color: var(--muted-strong); }
.dropzone-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dropzone-btn { pointer-events: none; }

.file-row {
    display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
    padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius);
}
.file-row > svg { color: var(--accent); }
.file-name { flex: 1 1 240px; min-width: 0; font-size: 14px; font-weight: 500; word-break: break-all; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }

.summary-line {
    padding: 10px 14px; border-radius: var(--radius);
    background: var(--accent-soft); color: #134e4a; font-size: 13px;
}

/* ---------- Upload result panels ---------- */
.upload-panel { padding: 20px; border-left: 4px solid var(--accent); display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.upload-panel h2 { font-size: 16px; }
.panel-red { border-left-color: #dc2626; }
.panel-amber { border-left-color: #d97706; }
.panel-slate { border-left-color: #64748b; }
.panel-teal { border-left-color: var(--accent); }
.panel-list { margin: 0; padding-left: 20px; line-height: 1.6; }
.panel-state { display: flex; align-items: center; gap: 8px; }
.panel-unchanged { margin-top: 4px; font-size: 13px; color: var(--muted-strong); }

/* ---------- Banners ---------- */
.banner { padding: 14px 20px; border-radius: var(--radius-lg); border: 1px solid; font-size: 14px; line-height: 1.6; }
.banner-teal { background: var(--accent-soft); border-color: #99f6e4; color: #134e4a; }
.banner-amber { background: #fffbeb; border-color: #fde68a; color: #78350f; }
.banner-purple { background: #faf5ff; border-color: #ddd6fe; color: #4c1d95; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.banner-red { background: #fef2f2; border-color: #fecaca; color: #7f1d1d; }
.banner-slate { background: var(--line-soft); border-color: var(--line); color: var(--text-2); }
.banner-link { font-weight: 600; color: inherit; }
.banner .flag { font-weight: 600; }
.banner-card { padding: 16px 20px; background: #fffbeb; border-color: #fde68a; color: #78350f; }
.key-code { display: block; margin-top: 8px; padding: 8px 12px; background: var(--surface); border-radius: 8px; }

/* ---------- Badges (shape and text, never colour alone) ---------- */
.state-badge, .badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 2px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 500; white-space: nowrap;
}
.tone-green { background: #ecfdf5; color: #047857; }
.tone-amber { background: #fffbeb; color: #b45309; }
.tone-red { background: #fef2f2; color: #b91c1c; }
.tone-blue { background: var(--accent-soft); color: var(--accent-strong); }
.tone-slate { background: var(--line-soft); color: var(--muted-strong); }
.tone-purple { background: #f5f3ff; color: #6d28d9; }
.state-icon { flex: 0 0 auto; }
.state-icon .spin { transform-origin: 8px 8px; animation: spin 1.1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Tables ---------- */
.table-card { padding: 8px 8px 4px; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    text-align: left; padding: 10px 12px;
    font-size: 12px; font-weight: 600; color: var(--muted-strong);
    border-bottom: 1px solid var(--line); white-space: nowrap;
}
.data-table td { padding: 12px; font-size: 14px; vertical-align: top; border-bottom: 1px solid var(--line-soft); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: var(--bg); }
.data-table .sub { margin-top: 4px; font-size: 12px; color: var(--muted-strong); max-width: 36ch; }
.data-table .num a { font-weight: 600; text-decoration: none; }
.data-table .nowrap { white-space: nowrap; }
.ops-table { min-width: 960px; }
.data-table.compact td { padding: 8px 12px; }
.list-footer { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }

/* ---------- Filters ---------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: flex-end; }
.filter-group { border: 0; padding: 0; margin: 0; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    position: relative; display: inline-flex; align-items: center; gap: 6px;
    min-height: 36px; padding: 0 14px; cursor: pointer;
    border: 1px solid var(--line); border-radius: 999px;
    background: var(--surface); color: var(--text-2); font-size: 13px; font-weight: 500;
}
.chip:hover { background: var(--bg); }
.chip input { position: absolute; opacity: 0; width: 100%; height: 100%; inset: 0; margin: 0; cursor: pointer; }
.chip:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); font-weight: 600; }
.chip:has(input:checked)::before { content: '✓'; font-weight: 700; }
.chip:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.filter-bar .control { width: auto; min-width: 160px; }

/* ---------- Operation card ---------- */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; align-items: start; }
.detail-card { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.kv-grid { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.kv-grid dt { font-size: 12px; color: var(--muted-strong); }
.kv-grid dd { margin: 2px 0 0; font-size: 14px; font-weight: 500; word-break: break-word; }
.kv-grid .wide { grid-column: 1 / -1; }
.metric-list { display: flex; flex-direction: column; gap: 8px; }
.metric { display: flex; justify-content: space-between; font-size: 14px; }
.metric b { font-weight: 600; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.timeline li { display: flex; align-items: baseline; gap: 12px; }
.tl-dot { flex: 0 0 8px; height: 8px; width: 8px; border-radius: 50%; background: var(--accent); }
.tl-title { font-weight: 500; }
.tl-time { color: var(--muted-strong); font-size: 12px; }
.timeline-block { display: flex; flex-direction: column; gap: 8px; }

/* ---------- Current result ---------- */
.seg {
    display: inline-flex; flex-wrap: wrap; align-self: flex-start; gap: 2px; padding: 4px;
    background: var(--line-soft); border-radius: var(--radius);
}
.seg a {
    padding: 6px 14px; border-radius: 8px;
    font-size: 13px; font-weight: 500; color: var(--muted-strong); text-decoration: none;
}
.seg a:hover { color: var(--text); }
.seg a[aria-current='page'] { background: var(--surface); color: var(--accent-strong); font-weight: 600; box-shadow: 0 1px 2px rgba(15, 23, 42, .12); }
.version-card { padding: 16px 20px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; }
.version-card p { font-size: 14px; }
.v-no { font-weight: 700; font-size: 20px; }
.v-plus { color: #6d28d9; }

/* ---------- Notifications ---------- */
.notice-card { padding: 4px 20px; }
.notice-list { list-style: none; margin: 0; padding: 0; }
.notice-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.notice-list li:last-child { border-bottom: 0; }
.notice-list .unread { font-weight: 600; }
.notice-time { font-size: 12px; color: var(--muted-strong); white-space: nowrap; }
.notice-text { flex: 1 1 260px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 80vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 100%; max-width: 400px; padding: 32px; display: flex; flex-direction: column; gap: 16px; }
.login-card h1 { font-size: 20px; }
.login-brand { padding: 0; }
.login-form { display: flex; flex-direction: column; gap: 16px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .app-shell { flex-direction: column; }
    .app-sidebar { flex: none; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
    .brand { padding: 0; }
    .side-nav { flex-direction: row; flex-wrap: wrap; gap: 4px; }
    .app-header { padding: 12px 16px; }
    .app-main { padding: 20px 16px; }
    .form-grid, .type-options { grid-template-columns: 1fr; }
    .kv-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

.app-main:has(.login-wrap) { max-width: none; }

/* ---------- Shell additions ---------- */
.facility-name { color: var(--text-2); font-weight: 500; }
.facility-chip:has(.facility-select) { padding-right: 10px; }
.facility-chip:has(.facility-select:hover) { background: var(--bg); }
.facility-chip:has(.facility-select:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.facility-select {
    appearance: none; -webkit-appearance: none;
    border: 0; background: transparent; font: inherit; color: inherit;
    height: 100%; max-width: 360px; padding: 0 22px 0 0; cursor: pointer; text-overflow: ellipsis;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 2px center;
}
.facility-select:focus, .facility-select:focus-visible { outline: none; }

.nav-group {
    margin: 16px 0 6px; padding: 0 12px;
    font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
}
.user-card {
    margin-top: auto; display: flex; align-items: center; gap: 10px;
    border: 1px solid var(--line-soft); background: var(--bg); border-radius: var(--radius); padding: 10px 12px;
}
.avatar {
    flex: 0 0 32px; width: 32px; height: 32px; border-radius: 999px;
    display: flex; align-items: center; justify-content: center;
    background: #ccfbf1; color: var(--accent-strong); font-size: 12px; font-weight: 600;
}
.user-info { min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 12px; color: var(--muted); }

/* ---------- Upload tabs and panels ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tab {
    margin-bottom: -1px; padding: 10px 16px; font-size: 14px; font-weight: 500;
    color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--text); }
.tab[aria-current='page'] { color: var(--accent-strong); border-bottom-color: var(--accent); }

.tag { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.tag-red { color: #b91c1c; }
.tag-amber { color: #b45309; }
.tag-slate { color: var(--muted); }
.tag-teal { color: var(--accent-strong); }
.panel-version { font-size: 14px; font-weight: 600; }
.panel-metrics { display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 14px; }
.panel-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }

/* ---------- Current result additions ---------- */
.v-source { font-size: 13px; color: var(--muted-strong); }
.v-source .badge { font-size: 13px; }
.v-plus { font-size: 13px; font-weight: 500; }
.v-since { margin-left: auto; font-size: 13px; color: var(--muted); }
.plus10-banner { padding: 16px 20px; }
.slots-card { padding: 20px; }
.slots-table { min-width: 0; }
.slots-table td:last-child { white-space: nowrap; text-align: right; }
.slots-note { margin-top: 4px; font-size: 12px; }
.charts-note { min-height: 200px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; justify-content: center; }
.charts-note .muted { font-size: 13px; max-width: 560px; }

/* ---------- Operations additions ---------- */
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn-link { border: 0; background: none; padding: 0; font: inherit; color: var(--accent-strong); cursor: pointer; text-decoration: underline; }
.btn-link:hover { color: var(--accent-deep); }
.row-action { white-space: nowrap; }
.data-table td.num { white-space: nowrap; }
.op-head h1 { font-size: 24px; }
.list-footer.muted { font-size: 12px; }
.metric span::first-letter { text-transform: uppercase; }
.tl-body { flex: 1; }
.timeline li { align-items: flex-start; }
.tl-dot { margin-top: 6px; }
.timeline li:not(:last-child) { padding-bottom: 4px; }
.data-table .badge + .sub { margin-top: 4px; }

.slots-table .badge { white-space: normal; border-radius: 12px; text-align: left; }
.slots-table td { padding: 12px 8px; }

.notice-text::first-letter { text-transform: uppercase; }

/* ---------- Access: choice of a facility and own access ---------- */
.facility-list { list-style: none; margin: 0; padding: 0; }
.facility-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.facility-list li:last-child { border-bottom: 0; }
.facility-list .btn { margin-left: auto; }

/* ---------- Administration: forms inside a card ---------- */
h3 { margin: 0; font-size: 14px; font-weight: 600; }
.form-card > form { display: flex; flex-direction: column; gap: 20px; }
.empty-card .head-actions { margin-top: 12px; }
textarea.control { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; }

/* ---------- Design pass: the refusal of a section ---------- */
.denied { padding: 40px 32px; display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.denied-icon { width: 48px; height: 48px; border-radius: 999px; background: var(--line-soft); color: var(--muted-strong); display: inline-flex; align-items: center; justify-content: center; }
.denied .page-sub { max-width: 56ch; }
.denied-title { font-size: 20px; line-height: 1.25; font-weight: 700; }
.denied-path { margin-top: 2px; }
.denied .head-actions { margin-top: 8px; }

/* ---------- Design pass: choice of a facility, search fields, dates ---------- */
.control.search {
    padding-left: 38px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M21 21l-4.3-4.3'/%3E%3C/svg%3E") no-repeat left 12px center;
}
.control.date {
    padding-right: 40px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M16 3v4M8 3v4M3 11h18'/%3E%3C/svg%3E") no-repeat right 12px center;
}
.control.err { border-color: #dc2626; box-shadow: inset 0 0 0 1px #dc2626; }
.control:focus-visible { border-color: var(--focus); }
.control::placeholder { color: var(--muted); }
.hint.err { color: #b91c1c; font-weight: 500; }
.datefield { position: relative; }
.datefield .control { min-width: 168px; }
.datefield-native { position: absolute; top: 0; right: 0; width: 40px; height: 100%; opacity: 0; cursor: pointer; overflow: hidden; }
.datefield-native::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }

.combo { position: relative; }
.combo.open, .fwrap.open { z-index: 30; }
.combo-box, .fwrap { position: relative; }
.fwrap { display: inline-block; }
.combo-scrim { position: fixed; inset: 0; z-index: -1; }
.combo-pop {
    position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 2;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
    box-shadow: 0 16px 36px -10px rgba(15, 23, 42, .28); padding: 8px;
}
.fpop { right: auto; width: 440px; max-width: calc(100vw - 32px); padding: 12px; }
.combo-pop .opts { margin-top: 8px; }
.opts { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; }
.opt-row {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 8px 10px; border: 0; border-radius: 10px; background: none;
    font: inherit; font-size: 14px; color: var(--text-2); text-align: left; cursor: pointer;
}
.opt-row:hover { background: var(--bg); }
.opt-row.on { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.opt-row.on::after { content: '\2713'; margin-left: auto; font-weight: 700; }
.opt-row .code { color: var(--muted); font-weight: 400; }
.opt-row.on .code { color: var(--accent-strong); }
.popfoot { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line-soft); font-size: 12px; color: var(--muted-strong); }
.combo-empty { padding: 8px 10px; }
.facility-chip.pick { background: var(--surface); cursor: pointer; font-family: inherit; }
.facility-chip.pick:hover { background: var(--bg); }
.facility-chip.pick.open { border-color: var(--accent); box-shadow: 0 0 0 3px #ccfbf1; }
.facility-chip.pick.none { color: var(--muted-strong); }

/* ---------- Design pass: messages, users, side card, dialog ---------- */
.note { padding: 10px 14px; border-radius: var(--radius); font-size: 13px; font-weight: 500; line-height: 1.5; }
.note.red { background: #fef2f2; color: #b91c1c; }
.note.amber { background: #fffbeb; color: #92400e; }
.note.slate { background: var(--line-soft); color: var(--text-2); }
.note.teal { background: var(--accent-soft); color: #134e4a; }
.filters { display: flex; flex-direction: column; gap: 12px; }
.users-search { max-width: 420px; }
.state-col { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.rcs { display: flex; flex-wrap: wrap; gap: 4px; }
.rc { display: inline-flex; align-items: baseline; gap: 4px; padding: 2px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text-2); font-size: 12px; line-height: 1.5; }
.rc b { font-weight: 600; color: var(--text); }
.rc.more { background: var(--surface); color: var(--muted-strong); font-weight: 500; }
.users-table td:nth-child(3) { min-width: 220px; }

.scrim { position: fixed; inset: 0; z-index: 50; display: flex; justify-content: center; align-items: flex-start; padding: 12vh 20px 20px; background: rgba(15, 23, 42, .45); overflow-y: auto; }
.dlg { width: 100%; max-width: 520px; background: var(--surface); border-radius: var(--radius-lg); box-shadow: 0 24px 48px -12px rgba(15, 23, 42, .35); padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.dlg h2 { font-size: 16px; }
.dlg form { display: flex; flex-direction: column; gap: 16px; }
.dlg-sub { margin-top: 4px; }
.acts { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

.dim { position: fixed; inset: 0; z-index: 40; background: rgba(15, 23, 42, .30); }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 41; width: 540px; max-width: 100vw; overflow-y: auto; display: flex; flex-direction: column; background: var(--bg); border-left: 1px solid var(--line); box-shadow: -18px 0 36px -14px rgba(15, 23, 42, .30); }
.drawer:focus { outline: none; }
.dhead { display: flex; align-items: flex-start; gap: 12px; padding: 20px 24px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.drawer-avatar { width: 40px; height: 40px; flex: 0 0 40px; }
.drawer-who { min-width: 0; }
.drawer-who h2 { font-size: 16px; }
.drawer-who .sub { margin-top: 2px; }
.drawer-badges { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.xbtn { margin-left: auto; width: 36px; height: 36px; flex: 0 0 36px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); display: inline-flex; align-items: center; justify-content: center; color: var(--muted-strong); cursor: pointer; }
.xbtn:hover { background: var(--bg); }
.dbody { padding: 20px 24px 28px; display: flex; flex-direction: column; gap: 16px; }
.sec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.sech { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sec-form { display: flex; flex-direction: column; gap: 8px; }
.sec-split { border-top: 1px solid var(--line-soft); padding-top: 12px; }
.sec-split:first-child { border-top: 0; padding-top: 0; }
.sec .sec-form + .sec-form { margin-top: 4px; }
.rowx { display: flex; align-items: center; gap: 8px 10px; padding: 10px 0; border-top: 1px solid var(--line-soft); }
.rowx:first-of-type { border-top: 0; }
.rowx-main { flex: 1; min-width: 0; }
.rowx-block { display: block; }
.rowx-line { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.rowx-sub { margin-top: 6px; }
.rowx-actions { display: flex; gap: 6px; }
.term-edit { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 12px; margin: 2px 0 10px; }
.sec .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 560px) { .sec .form-grid { grid-template-columns: 1fr; } }

/* ---------- Design pass: registry of facilities ---------- */
.mono-cell { font-size: 13px; }
.rename-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rename-input { width: 320px; max-width: 100%; }
.dlg-list { margin: 0; padding-left: 20px; font-size: 14px; line-height: 1.7; }
.dlg-sub { margin-top: 6px; }

/* ---------- Design pass: extra access ---------- */
.list-title { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.request-form { display: flex; flex-direction: column; gap: 20px; max-width: 720px; }
.until-field { max-width: 260px; }
.acts-start { justify-content: flex-start; }
.review-table { table-layout: fixed; }
.review-table .c-auditor { width: 150px; }
.review-table .c-facility { width: 240px; }
.review-table .c-kind { width: 170px; }
.review-table .c-actions { width: 210px; }
.why { max-width: 36ch; }
.reject-row td { background: var(--bg); border-bottom: 1px solid var(--line); }
.reject-form { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; padding: 4px 0; }
.reject-form .field { flex: 1 1 420px; }
.reject-form .acts { padding-bottom: 22px; }

/* ---------- Design pass: journal ---------- */
.journal-filters { display: grid; grid-template-columns: 150px 150px 190px minmax(0, 1fr) 210px; gap: 12px 16px; align-items: end; }
.journal-filters .control { width: 100%; min-width: 0; }
.journal-filters .datefield .control { min-width: 0; }
@media (max-width: 1100px) { .journal-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- Design pass: sign-in, forms ---------- */
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.narrow-card { max-width: 640px; width: 100%; }
select.control {
    appearance: none; -webkit-appearance: none; padding-right: 36px; text-overflow: ellipsis;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
}

/* ---------- Design pass: details ---------- */
.sub { font-size: 12px; color: var(--muted-strong); }
.sech .btn-link { text-decoration: none; color: var(--muted); font-size: 13px; }
.sech .btn-link:hover { color: var(--text); }
.rowx-actions .btn, .rowx > .btn { white-space: nowrap; }
.rowx-sub .sub { margin-top: 0; }
.sec-form > h3 { margin-bottom: 0; }
.sec-split > h3 + .field { margin-top: 0; }
.dbody .sec-form { gap: 12px; }
