:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #17201c;
  background: #eef1ef;
  --surface: #ffffff;
  --surface-subtle: #f6f8f7;
  --surface-strong: #12241e;
  --line: #d6ddd9;
  --line-strong: #aebbb5;
  --text: #17201c;
  --text-muted: #5d6b65;
  --accent: #14664e;
  --accent-strong: #0c4938;
  --accent-soft: #e8f5ef;
  --warning: #855d0b;
  --warning-soft: #fff6d9;
  --critical: #b42318;
  --critical-soft: #fff0ee;
  --focus: #0067c5;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(18, 36, 30, .06);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--surface-strong); }
body { min-height: 100vh; margin: 0; background: var(--surface-subtle); }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--accent-strong); }
code, kbd, pre { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }
code { overflow-wrap: anywhere; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.skip-link { position: fixed; z-index: 100; top: 8px; left: 8px; padding: 9px 12px; color: #fff; background: var(--focus); border-radius: 4px; transform: translateY(-160%); }
.skip-link:focus { transform: translateY(0); }
.internal-shell { min-height: 100vh; display: grid; grid-template-rows: auto auto 1fr auto; }

.topbar { min-height: 64px; padding: 8px 18px; display: flex; align-items: center; justify-content: space-between; gap: 20px; color: #fff; background: var(--surface-strong); border-bottom: 1px solid #294139; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.brand__mark { width: 34px; height: 34px; display: grid; place-items: center; color: var(--surface-strong); background: #7be0b9; border-radius: 7px; font-weight: 900; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: .9rem; letter-spacing: .01em; }
.brand small { margin-top: 2px; color: #a8bbb4; font-size: .68rem; }
.topbar__context { display: flex; align-items: center; gap: 20px; }
.topbar__context > div { max-width: 250px; }
.topbar__context span, .topbar__context strong { display: block; }
.topbar__context span { color: #8fa69d; font-size: .62rem; text-transform: uppercase; letter-spacing: .08em; }
.topbar__context strong { margin-top: 2px; overflow: hidden; color: #f7fbf9; font-size: .72rem; text-overflow: ellipsis; white-space: nowrap; }
.topbar .button--secondary { color: #f7fbf9; background: #263c34; border-color: #496158; }

.connectivity-banner { min-height: 40px; padding: 8px 18px; display: flex; align-items: center; gap: 12px; color: #5c3f06; background: var(--warning-soft); border-bottom: 1px solid #e4ca7b; font-size: .75rem; }
.connectivity-banner strong { text-transform: uppercase; letter-spacing: .08em; }
.shell-body { min-height: 0; display: grid; grid-template-columns: 228px minmax(0, 1fr); }
.module-nav { padding: 14px 10px; display: flex; flex-direction: column; gap: 6px; background: #edf1ef; border-right: 1px solid var(--line); }
.module-nav__heading { padding: 4px 8px 10px; }
.module-nav__heading strong { display: block; margin-top: 3px; font-size: .78rem; }
.module-link { min-height: 58px; padding: 9px 8px 9px 11px; display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 7px; color: var(--text); border: 1px solid transparent; border-radius: 6px; text-decoration: none; }
.module-link:hover { background: rgba(255,255,255,.65); border-color: var(--line); }
.module-link.is-active { color: var(--accent-strong); background: var(--surface); border-color: var(--line-strong); box-shadow: var(--shadow); }
.module-link strong, .module-link small { display: block; }
.module-link strong { font-size: .75rem; }
.module-link small { margin-top: 4px; color: var(--text-muted); font-size: .63rem; line-height: 1.25; }
.module-link kbd { padding: 2px 4px; color: var(--text-muted); background: var(--surface-subtle); border: 1px solid var(--line); border-radius: 3px; font-size: .58rem; }
.module-link i { color: var(--critical); font-size: .5rem; font-style: normal; letter-spacing: .06em; }
.module-link.is-denied { opacity: .68; }
.boundary-note { margin-top: auto; padding: 11px; color: #45534d; background: #e2e8e5; border: 1px solid #cbd5d0; border-radius: 6px; }
.boundary-note strong, .boundary-note span { display: block; }
.boundary-note strong { font-size: .65rem; text-transform: uppercase; letter-spacing: .06em; }
.boundary-note span { margin-top: 5px; font-size: .61rem; line-height: 1.45; }

main { min-width: 0; padding: 18px; overflow: auto; }
.workspace-heading { max-width: 1600px; margin: 0 auto 14px; display: flex; align-items: end; justify-content: space-between; gap: 16px; }
.workspace-heading h1 { margin: 3px 0 0; font-size: 1.45rem; line-height: 1.1; }
.workspace-heading__meta { display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-size: .65rem; }
.workspace-stack { max-width: 1600px; margin: 0 auto; display: grid; gap: 14px; }
.eyebrow { color: var(--text-muted); font-size: .61rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.muted { color: var(--text-muted); }
.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.text-critical { color: var(--critical); }

.panel { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.panel__header { min-height: 56px; padding: 11px 14px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); }
.panel__header h1, .panel__header h2, .panel__header h3 { margin: 3px 0 0; font-size: .9rem; }
.panel__header h2 code { font-size: .72rem; }
.panel__body { padding: 14px; font-size: .76rem; line-height: 1.55; }
.panel__body p { margin: 0; }
.panel__body p + p { margin-top: 8px; }
.panel__note { padding: 8px 14px; color: var(--text-muted); background: var(--surface-subtle); border-top: 1px solid var(--line); font-size: .64rem; line-height: 1.4; }
.record-count { color: var(--text-muted); font-size: .65rem; font-variant-numeric: tabular-nums; }

.button { min-height: 34px; padding: 7px 11px; border: 1px solid var(--line-strong); border-radius: 5px; font-size: .7rem; font-weight: 800; cursor: pointer; }
.button:disabled { cursor: not-allowed; opacity: .52; }
.button--primary { color: #fff; background: var(--accent); border-color: var(--accent-strong); }
.button--secondary { color: var(--text); background: var(--surface); }
.button--critical { color: #fff; background: var(--critical); border-color: #881910; }

.status-badge { width: fit-content; min-height: 22px; padding: 3px 7px; display: inline-flex; align-items: center; gap: 5px; color: #33423c; background: #edf1ef; border: 1px solid #d4dcd8; border-radius: 999px; font-size: .57rem; font-weight: 850; letter-spacing: .035em; white-space: nowrap; }
.status-badge > span { width: 6px; height: 6px; background: currentColor; border-radius: 50%; }
.status-badge--positive { color: #0b5b42; background: #e6f6ef; border-color: #b9ddce; }
.status-badge--warning { color: #725008; background: var(--warning-soft); border-color: #e3cd89; }
.status-badge--critical { color: #982016; background: var(--critical-soft); border-color: #e7bbb7; }

.tenant-hero { padding: 16px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.tenant-hero h2 { margin: 3px 0 4px; font-size: 1.35rem; }
.tenant-hero p { margin: 0; color: var(--text-muted); font-size: .68rem; }
.tenant-hero__status { display: grid; justify-items: end; gap: 7px; }
.tenant-hero__status small { color: var(--text-muted); font-size: .6rem; }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 8px; }
.metric-grid--compact { padding: 12px 14px; grid-template-columns: repeat(3, minmax(130px, 1fr)); }
.metric { min-height: 75px; padding: 11px; display: flex; flex-direction: column; justify-content: space-between; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); }
.metric span { color: var(--text-muted); font-size: .63rem; }
.metric strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.metric--attention { border-left: 3px solid #c18b19; }
.metric--critical { border-left: 3px solid var(--critical); }
.metric__time { font-size: .76rem !important; }
.control-grid { display: grid; gap: 12px; padding: 18px; }
.control-card { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: color-mix(in srgb, var(--panel) 78%, transparent); }
.control-card > div { display: grid; gap: 5px; }
.control-card span { color: var(--muted); font-size: .82rem; line-height: 1.5; }
.contract-boundary { border-style: dashed; }
.evidence-grid { margin: 0; padding: 14px; display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px; border-bottom: 1px solid var(--line); }
.evidence-grid > div { min-width: 0; padding: 10px; background: var(--surface-subtle); border: 1px solid #e4e9e6; border-radius: 5px; }
.evidence-grid dt { color: var(--text-muted); font-size: .58rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.evidence-grid dd { margin: 5px 0 0; font-size: .68rem; font-weight: 700; line-height: 1.45; overflow-wrap: anywhere; }
.command-form { padding: 14px; background: #fff9f8; border-top: 1px solid #edcfcb; }
.command-form label, .inline-form label { color: var(--text-muted); font-size: .62rem; font-weight: 750; }
.command-form label > span { display: block; margin-bottom: 5px; }
.command-form textarea { width: 100%; min-height: 86px; padding: 8px; resize: vertical; color: var(--text); background: #fff; border: 1px solid var(--line-strong); border-radius: 5px; font-size: .7rem; line-height: 1.4; }
.command-form__actions { margin-top: 9px; display: flex; align-items: center; gap: 12px; }
.command-form__actions span { color: var(--text-muted); font-size: .62rem; }
.inline-form { padding: 12px 14px; display: grid; grid-template-columns: auto minmax(160px, 1fr) auto; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); }
.inline-form input { min-width: 0; height: 36px; padding: 7px 9px; color: var(--text); background: #fff; border: 1px solid var(--line-strong); border-radius: 5px; }
.two-column { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; }
.section-heading h2, .section-heading h3 { margin: 3px 0 0; font-size: .82rem; }
.boundary-card { border-left: 4px solid #53645d; }

.table-scroll { width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: .67rem; }
th { padding: 8px 10px; color: var(--text-muted); background: var(--surface-subtle); border-bottom: 1px solid var(--line); font-size: .58rem; letter-spacing: .055em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid #e9eeeb; vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8faf9; }
td strong, td small { display: block; }
td small { margin-top: 3px; color: var(--text-muted); font-size: .58rem; }
td code { font-size: .6rem; }
tr.is-selected { background: var(--accent-soft); box-shadow: inset 3px 0 var(--accent); }
.record-link { display: block; color: inherit; text-decoration: none; }
.record-link:hover strong { text-decoration: underline; }

.detail-grid { margin: 0; padding: 12px 14px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.detail-grid--operation { grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.detail-grid > div { min-width: 0; padding: 9px; background: var(--surface-subtle); border: 1px solid #e4e9e6; border-radius: 5px; }
.detail-grid__wide { grid-column: 1 / -1; }
.detail-grid dt, .inspector-list dt { color: var(--text-muted); font-size: .58rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.detail-grid dd, .inspector-list dd { margin: 5px 0 0; font-size: .68rem; font-weight: 700; line-height: 1.45; }

.search-form { padding: 13px 14px 15px; }
.search-form label, .replay-control label { display: block; margin-bottom: 5px; color: var(--text-muted); font-size: .62rem; font-weight: 750; }
.search-form > div { display: flex; gap: 8px; }
.search-form input { width: 100%; min-width: 0; height: 36px; padding: 7px 9px; color: var(--text); background: #fff; border: 1px solid var(--line-strong); border-radius: 5px; }
.record-section { padding: 14px; border-top: 1px solid var(--line); }
.record-section > .section-heading { margin-bottom: 10px; }
.record-section .table-scroll { margin: 0 -14px -14px; width: calc(100% + 28px); }
.json-evidence { max-height: 280px; margin: 8px 0 0; padding: 11px; overflow: auto; color: #dce9e4; background: #172a23; border-radius: 5px; font-size: .63rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }

.split-workspace { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(320px, .75fr); gap: 14px; align-items: start; }
.list-pane { min-width: 0; }
.inspector { position: sticky; top: 0; }
.inspector-list { margin: 0; padding: 3px 14px 12px; }
.inspector-list > div { padding: 9px 0; border-bottom: 1px solid #e7ece9; }
.inspector-list > div:last-child { border: 0; }
.replay-control { padding: 13px 14px 15px; background: #fff9f8; border-top: 1px solid #edcfcb; }
.replay-control textarea { width: 100%; min-height: 92px; padding: 8px; resize: vertical; color: var(--text); background: #fff; border: 1px solid var(--line-strong); border-radius: 5px; font-size: .7rem; line-height: 1.4; }
.replay-control .button { width: 100%; margin-top: 9px; }
.form-help { margin: 7px 0 0; color: var(--text-muted); font-size: .61rem; line-height: 1.45; }

.state-panel { max-width: 1600px; min-height: 110px; margin: 0 auto; padding: 16px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; color: #34423d; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.state-panel h2 { margin: 0; font-size: .86rem; }
.state-panel p { margin: 5px 0 0; color: var(--text-muted); font-size: .7rem; line-height: 1.45; }
.state-panel code { display: inline-block; margin-top: 6px; font-size: .62rem; }
.state-panel__icon { min-width: 34px; height: 30px; padding: 0 6px; display: grid; place-items: center; color: #fff; background: #66766f; border-radius: 4px; font-size: .55rem; font-weight: 900; letter-spacing: .04em; }
.state-panel--denied { border-left: 4px solid #5b6862; }
.state-panel--conflict, .state-panel--offline { border-left: 4px solid var(--warning); background: #fffcf2; }
.state-panel--failed { border-left: 4px solid var(--critical); background: #fffafa; }
.state-panel--failed .state-panel__icon { background: var(--critical); }
.loading-mark { width: 22px; height: 22px; border: 3px solid #c6d2cd; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.empty-state { min-height: 150px; padding: 24px; display: grid; place-items: center; align-content: center; text-align: center; }
.empty-state > span { font-size: 1.6rem; color: #8b9892; }
.empty-state h2 { margin: 5px 0 0; font-size: .82rem; }
.empty-state p { max-width: 500px; margin: 5px 0 0; color: var(--text-muted); font-size: .68rem; line-height: 1.5; }
.partial-state, .notice, .state-inline { padding: 9px 13px; display: flex; align-items: baseline; gap: 9px; color: #60450d; background: var(--warning-soft); border-bottom: 1px solid #ead598; font-size: .65rem; }
.partial-state strong, .notice strong, .state-inline strong { white-space: nowrap; }
.notice { max-width: 1600px; margin: 0 auto; color: #0b5b42; background: var(--accent-soft); border: 1px solid #b8dfcf; border-radius: 5px; }
.state-inline { display: grid; color: #4d5a55; background: #f0f3f1; border: 1px solid var(--line); border-radius: 5px; line-height: 1.4; }

.app-footer { min-height: 34px; padding: 7px 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; color: #9fb2aa; background: var(--surface-strong); border-top: 1px solid #294139; font-size: .59rem; }

@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; } }
@media (max-width: 1050px) {
  .shell-body { grid-template-columns: 190px minmax(0, 1fr); }
  .split-workspace { grid-template-columns: 1fr; }
  .inspector { position: static; }
  .detail-grid--operation { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .topbar { align-items: flex-start; }
  .topbar__context > div { display: none; }
  .shell-body { display: block; }
  .module-nav { position: sticky; z-index: 10; top: 0; padding: 7px; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .module-nav__heading, .boundary-note { display: none; }
  .module-link { min-width: 145px; min-height: 48px; padding: 7px 9px; }
  .module-link small, .module-link kbd { display: none; }
  main { padding: 12px; }
  .two-column { grid-template-columns: 1fr; }
  .metric-grid--compact { grid-template-columns: 1fr; }
  .tenant-hero { align-items: flex-start; }
  .tenant-hero__status { justify-items: start; }
  .workspace-heading { align-items: flex-start; }
  .workspace-heading__meta > span:last-child { display: none; }
  .app-footer { display: none; }
}
@media (max-width: 520px) {
  .brand small { display: none; }
  .tenant-hero { display: grid; }
  .detail-grid, .detail-grid--operation { grid-template-columns: 1fr; }
  .search-form > div { display: grid; }
  .state-panel { grid-template-columns: auto 1fr; }
  .state-panel .button { grid-column: 1 / -1; }
  .control-card { align-items: stretch; flex-direction: column; }
}

/* Staff portal follows the neutral NorthTMS v6.3 direction. */
:root { --surface:#fff; --surface-subtle:#f6f6f7; --surface-strong:#191a1d; --line:#e2e2e6; --line-strong:#bfc0c5; --text:#242529; --text-muted:#71727a; --accent:#202125; --accent-strong:#101114; --accent-soft:#ededf0; --radius:16px; --shadow:0 4px 16px rgba(18,18,24,.035); color:#242529; background:#f6f6f7; }
html,body {background:var(--surface-subtle);}
.topbar {background:#fff;color:var(--text);border-bottom:1px solid var(--line);min-height:72px;}
.brand__mark {border-radius:13px;background:#191a1d;color:#fff;}
.brand strong {letter-spacing:-.04em;font-size:1.35rem;}
.brand small {color:var(--text-muted);}
.topbar__context {color:var(--text-muted);}
.topbar__context strong {color:var(--text);}
.shell-body {gap:16px;padding:16px;}
.module-nav {background:rgba(255,255,255,.86);border:1px solid var(--line);border-radius:22px;box-shadow:var(--shadow);padding:16px 10px;}
.module-link {border-radius:12px;padding:12px;}
.module-link.is-active {background:#eeeef1;color:#202125;}
.boundary-note {background:#f4f4f6;border-color:var(--line);border-radius:12px;color:var(--text-muted);}
main {padding:12px 8px;}
.workspace-heading h1 {font-size:1.8rem;letter-spacing:-.04em;}
.button {border-radius:999px;min-height:40px;padding:9px 16px;font-weight:650;}
.staff-form {display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:16px;margin-top:18px;align-items:end;}
.staff-form label {display:grid;gap:7px;font-size:.8rem;font-weight:600;}
.staff-form input,.staff-form select,.staff-form textarea {width:100%;min-height:42px;border:1px solid var(--line-strong);border-radius:10px;padding:10px 12px;background:#fff;color:var(--text);font:inherit;}
.staff-form small,.staff-help {color:var(--text-muted);font-size:.78rem;font-weight:400;line-height:1.5;}
.staff-form textarea {resize:vertical;}
.staff-form label:has(textarea) {grid-column:1/-1;}
.staff-actions,.ticket-meta {display:flex;gap:12px;align-items:center;flex-wrap:wrap;margin:14px 0;}
.staff-notice {border:1px solid var(--line);background:#fff;padding:14px 18px;border-radius:14px;overflow-wrap:anywhere;}
.staff-summary {margin-top:14px;}
.staff-workspace table td {font-size:.8rem;padding:14px;}
.staff-workspace table td small {display:block;color:var(--text-muted);margin-top:5px;}
.staff-workspace blockquote {border-left:3px solid var(--line-strong);margin:16px 0;padding:8px 16px;background:var(--surface-subtle);border-radius:0 12px 12px 0;}
@media(max-width:760px){.shell-body{padding:8px;display:block;}.module-nav{margin-bottom:14px;}.module-nav__heading,.boundary-note{display:none;}.module-link{display:inline-flex;}.module-link small,.module-link kbd{display:none;}.staff-form{grid-template-columns:1fr;}.topbar__context>div{display:none;}.workspace-heading{padding:0 8px;}}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{scroll-behavior:auto;transition:none!important;animation:none!important;}}
