:root {
  --ink: #151b19;
  --ink-soft: #24302c;
  --paper: #f3f0e8;
  --surface: #fffdf7;
  --teal: #146b60;
  --teal-dark: #0b4c45;
  --amber: #d89a27;
  --red: #b83b32;
  --green: #3b7654;
  --steel: #68736f;
  --rule: #d6d4cb;
  --rule-dark: #b9b9b2;
  --info: #315f78;
  --sidebar-width: 266px;
  --display: Georgia, 'Times New Roman', ui-serif, serif;
  --body: Arial, Helvetica, ui-sans-serif, sans-serif;
  --mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
}

* { box-sizing: border-box; }
html { background: var(--paper); color: var(--ink); font-family: var(--body); }
body { margin: 0; min-width: 320px; background: var(--paper); font-size: 14px; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea, summary { outline: none; }
:focus-visible { box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--teal); border-radius: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 100; left: 16px; top: -80px; background: var(--surface); padding: 10px 14px; color: var(--ink); }
.skip-link:focus { top: 14px; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-width); display: flex; flex-direction: column; background: var(--ink); color: #eef1eb; z-index: 30; }
.brand-block { padding: 25px 22px 18px; border-bottom: 1px solid #34413c; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; background: var(--amber); color: var(--ink); font: 700 21px/1 var(--display); border-radius: 50% 50% 50% 4px; }
.brand strong { display: block; letter-spacing: .14em; font-size: 14px; }
.brand small { display: block; margin-top: 3px; color: #a8b3ae; font: 9px/1.3 var(--mono); letter-spacing: .12em; }
.environment-chip { display: inline-flex; margin: 17px 0 0 46px; color: #aab7b1; border: 1px solid #42504b; border-radius: 99px; padding: 4px 8px; font: 10px/1 var(--mono); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 11px 22px; scrollbar-width: thin; }
.nav-group { margin-top: 18px; }
.nav-group h2 { margin: 0 11px 6px; color: #74817c; font-size: 9px; letter-spacing: .17em; text-transform: uppercase; }
.nav-link { min-height: 36px; display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 5px; padding: 7px 10px; color: #cbd2cf; text-decoration: none; border-left: 2px solid transparent; }
.nav-link:hover { color: #fff; background: #1d2925; }
.nav-link.active { color: #fff; background: #22332e; border-left-color: var(--amber); }
.nav-index { color: #687873; font: 9px/1 var(--mono); }
.nav-link.active .nav-index { color: var(--amber); }
.nav-count { min-width: 21px; padding: 3px 6px; text-align: center; background: var(--red); color: #fff; border-radius: 99px; font: 10px/1 var(--mono); }
.sidebar-foot { padding: 16px 18px 20px; border-top: 1px solid #34413c; }
.operator-badge { display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 10px; }
.operator-avatar { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid #5c6a65; border-radius: 50%; color: var(--amber); font-family: var(--display); }
.operator-badge strong { display: block; font-size: 12px; }
.operator-badge small { display: block; margin-top: 3px; color: #86938e; font-size: 10px; }
.system-line { margin-top: 14px; color: #89958f; font-size: 10px; }
.live-dot { display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: #72b68b; box-shadow: 0 0 0 3px rgb(114 182 139 / .12); }

.workspace { min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar { height: 66px; display: flex; align-items: center; gap: 24px; padding: 0 34px; background: rgb(255 253 247 / .92); border-bottom: 1px solid var(--rule); position: sticky; top: 0; z-index: 20; }
.global-search { width: min(560px, 55vw); height: 38px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 9px; padding: 0 12px; background: var(--paper); border: 1px solid var(--rule); }
.global-search input { min-width: 0; border: 0; background: transparent; color: var(--ink); }
.global-search input::placeholder { color: #89918e; }
kbd { border: 1px solid var(--rule-dark); background: var(--surface); padding: 2px 6px; color: var(--steel); font: 10px/1 var(--mono); }
.topbar-meta { margin-left: auto; display: flex; align-items: center; gap: 20px; color: var(--steel); font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
.alert-counter { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.alert-counter strong { display: grid; min-width: 25px; height: 25px; place-items: center; background: var(--red); color: #fff; border-radius: 50%; font: 11px/1 var(--mono); }
.mobile-menu { display: none; width: 38px; height: 38px; border: 1px solid var(--rule); background: transparent; padding: 9px; }
.mobile-menu span:not(.sr-only) { display: block; height: 1px; background: var(--ink); margin: 4px 0; }
.nav-scrim { display: none; }

.page-frame { padding: 34px clamp(20px, 3vw, 48px) 70px; max-width: 1640px; margin: 0 auto; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; min-height: 74px; margin-bottom: 28px; }
.eyebrow { margin: 0 0 8px; color: var(--teal); font-size: 10px; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; }
.page-header h1, .login-panel h1 { margin: 0; font: 500 clamp(28px, 3vw, 42px)/1.02 var(--display); letter-spacing: -.025em; }
.page-actions { display: flex; align-items: center; gap: 8px; }

.message-stack { position: fixed; z-index: 50; right: 22px; top: 82px; width: min(430px, calc(100vw - 44px)); }
.message { display: flex; justify-content: space-between; gap: 12px; padding: 13px 15px; margin-bottom: 8px; border: 1px solid var(--rule-dark); background: var(--surface); box-shadow: 0 12px 35px rgb(21 27 25 / .12); }
.message.success { border-left: 4px solid var(--green); }.message.error { border-left: 4px solid var(--red); }.message.info { border-left: 4px solid var(--info); }
.message button { border: 0; background: none; color: var(--steel); cursor: pointer; }

.button { display: inline-flex; min-height: 36px; align-items: center; justify-content: center; gap: 7px; padding: 8px 13px; border: 1px solid var(--rule-dark); background: var(--surface); color: var(--ink); text-decoration: none; cursor: pointer; font-weight: 700; }
.button:hover { border-color: var(--ink); }.button.primary { background: var(--teal); color: #fff; border-color: var(--teal); }.button.primary:hover { background: var(--teal-dark); }.button.danger { color: var(--red); border-color: #d9a5a1; }.button.small { min-height: 30px; padding: 5px 9px; font-size: 12px; }
.button:disabled { opacity: .65; cursor: wait; }

.filter-bar { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 10px; padding: 14px; margin-bottom: 18px; background: var(--surface); border: 1px solid var(--rule); }
.field { display: grid; gap: 5px; min-width: 140px; }
.field.grow { flex: 1; min-width: 220px; }
.field label { color: var(--steel); font-size: 10px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
input, select, textarea { width: 100%; border: 1px solid var(--rule-dark); background: #fff; color: var(--ink); padding: 9px 10px; border-radius: 2px; }
textarea { resize: vertical; line-height: 1.45; }

.metric-strip { display: grid; grid-template-columns: repeat(6, 1fr); margin-bottom: 24px; background: var(--surface); border: 1px solid var(--rule); }
.metric { min-width: 0; padding: 17px 16px 15px; border-right: 1px solid var(--rule); }
.metric:last-child { border-right: 0; }
.metric-label { min-height: 24px; color: var(--steel); font-size: 9px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.metric-value { margin-top: 9px; font: 500 clamp(20px, 2vw, 29px)/1 var(--display); font-variant-numeric: tabular-nums; }
.metric-note { margin-top: 8px; color: var(--steel); font-size: 11px; }
.metric.critical .metric-value { color: var(--red); }.metric.warning .metric-value { color: #8b5a18; }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, .75fr); gap: 22px; margin-bottom: 22px; }
.panel { background: var(--surface); border: 1px solid var(--rule); min-width: 0; }
.panel-header { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 16px; border-bottom: 1px solid var(--rule); }
.panel-header h2 { margin: 0; font: 600 17px/1.2 var(--display); }
.panel-header p { margin: 3px 0 0; color: var(--steel); font-size: 11px; }
.panel-body { padding: 16px; }
.panel.flush .panel-body { padding: 0; }

.chart { height: 260px; display: grid; grid-template-columns: repeat(7, 1fr); align-items: end; gap: clamp(8px, 2vw, 28px); padding: 30px 24px 24px; border-top: 1px solid var(--rule); }
.chart-link { display: contents; color: inherit; }
.chart-bar { display: grid; grid-template-rows: 1fr auto; height: 100%; align-items: end; gap: 9px; text-align: center; color: var(--steel); font: 10px/1 var(--mono); }
.chart-bar span { width: min(28px, 70%); min-height: 4px; justify-self: center; background: var(--teal); border-radius: 1px 1px 0 0; }
.chart-bar:nth-last-child(-n+2) span { background: var(--amber); }
.chart-legend { display: flex; gap: 16px; color: var(--steel); font-size: 11px; }.legend-key { display: inline-block; width: 9px; height: 9px; margin-right: 5px; background: var(--teal); }.legend-key.warning { background: var(--amber); }

.ranking { list-style: none; margin: 0; padding: 0; }
.ranking li { padding: 13px 0; border-bottom: 1px solid var(--rule); }.ranking li:last-child { border-bottom: 0; }
.ranking-top { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; }.ranking-top strong { font-family: var(--mono); }
.rank-track { height: 3px; margin-top: 9px; background: #e4e2da; }.rank-track span { display: block; height: 100%; background: var(--red); }

.table-wrap { max-width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th { padding: 10px 13px; color: var(--steel); background: #f7f5ef; border-bottom: 1px solid var(--rule); text-align: left; font-size: 9px; letter-spacing: .1em; text-transform: uppercase; white-space: nowrap; }
.data-table td { padding: 12px 13px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #f8f4e9; }
.data-table a { text-decoration-color: #a5aaa5; text-underline-offset: 3px; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }.mono { font-family: var(--mono); font-size: .94em; }.muted { color: var(--steel); }.negative { color: var(--red); }.positive-text { color: var(--green); }
.status { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-size: 10px; font-weight: 700; letter-spacing: .045em; text-transform: uppercase; }
.status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--info); }.status.critical::before { background: var(--red); border-radius: 1px; }.status.warning::before { background: var(--amber); }.status.positive::before { background: var(--green); }.status.neutral::before { background: var(--steel); }
.score { display: inline-grid; min-width: 37px; height: 27px; place-items: center; border: 1px solid var(--rule-dark); font: 700 12px/1 var(--mono); }.score.critical { color: var(--red); border-color: #dca7a2; }.score.warning { color: #85520f; border-color: #dfbe83; }.score.positive { color: var(--green); }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, .75fr); gap: 22px; }
.detail-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; }
.detail-list > div { padding: 14px 0; border-bottom: 1px solid var(--rule); }.detail-list > div:nth-child(odd) { padding-right: 20px; }.detail-list > div:nth-child(even) { padding-left: 20px; border-left: 1px solid var(--rule); }
.detail-list dt { color: var(--steel); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; }.detail-list dd { margin: 6px 0 0; font-weight: 700; }
.risk-total { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 18px; padding: 18px; background: var(--ink); color: #fff; }
.risk-number { font: 500 58px/1 var(--display); color: #f0b44a; }.risk-copy strong { display: block; font-size: 13px; text-transform: uppercase; }.risk-copy span { display: block; margin-top: 5px; color: #aeb8b4; font-size: 11px; }
.risk-ledger { list-style: none; margin: 0; padding: 0; }.risk-ledger li { display: grid; grid-template-columns: 1fr auto; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--rule); }.risk-ledger li:last-child { border-bottom: 0; }.risk-ledger strong { font-family: var(--mono); color: var(--red); }.risk-ledger small { display: block; margin-top: 4px; color: var(--steel); }

.timeline { list-style: none; margin: 0; padding: 0; }.timeline li { position: relative; display: grid; grid-template-columns: 84px 14px 1fr; gap: 10px; min-height: 66px; }.timeline li:not(:last-child)::after { content: ''; position: absolute; left: 90px; top: 18px; bottom: -2px; width: 1px; background: var(--rule-dark); }.timeline time { color: var(--steel); font: 10px/1.4 var(--mono); text-align: right; }.timeline-mark { position: relative; z-index: 1; width: 9px; height: 9px; margin-top: 2px; border-radius: 50%; background: var(--teal); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--teal); }.timeline strong { display: block; font-size: 12px; }.timeline p { margin: 4px 0 0; color: var(--steel); line-height: 1.45; }

.case-hero { display: grid; grid-template-columns: 1.4fr .6fr; border: 1px solid var(--rule); background: var(--surface); margin-bottom: 22px; }.case-summary { padding: 24px; }.case-summary p { max-width: 70ch; color: var(--steel); line-height: 1.55; }.case-score { display: grid; place-items: center; text-align: center; background: var(--ink); color: #fff; padding: 24px; }.case-score strong { font: 500 62px/1 var(--display); color: #f0b44a; }.case-score span { margin-top: 6px; color: #aeb8b4; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; }
.evidence-row { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--rule); }.evidence-row:last-child { border-bottom: 0; }.file-type { display: grid; place-items: center; height: 32px; border: 1px solid var(--rule-dark); font: 9px/1 var(--mono); }.hash { max-width: 190px; overflow: hidden; text-overflow: ellipsis; color: var(--steel); font: 9px/1.4 var(--mono); }
.stack { display: grid; gap: 14px; }.split-actions { display: flex; flex-wrap: wrap; gap: 8px; }.form-errors { color: var(--red); margin: 5px 0 0; font-size: 11px; }
.empty-state { padding: 52px 24px; text-align: center; }.empty-state strong { display: block; font: 500 24px/1.1 var(--display); }.empty-state p { color: var(--steel); }
.stat-list { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--rule); background: var(--surface); margin-bottom: 22px; }.stat-list > div { padding: 15px; border-right: 1px solid var(--rule); }.stat-list > div:last-child { border: 0; }.stat-list small { display: block; color: var(--steel); text-transform: uppercase; letter-spacing: .08em; font-size: 9px; }.stat-list strong { display: block; margin-top: 7px; font: 500 22px/1 var(--display); font-variant-numeric: tabular-nums; }
.variance-list { display: flex; align-items: flex-end; gap: 8px; height: 130px; padding-top: 18px; }.variance-bar { flex: 1; min-width: 14px; display: grid; align-items: end; height: 100%; }.variance-bar span { min-height: 3px; background: var(--red); }.variance-bar small { margin-top: 6px; text-align: center; color: var(--steel); font: 8px/1 var(--mono); }
.pattern-alert { padding: 14px 16px; border-left: 4px solid var(--red); background: #fbede8; color: #612621; }.pattern-alert strong { display: block; }.pattern-alert p { margin: 5px 0 0; font-size: 12px; }
.rule-list { display: grid; gap: 1px; background: var(--rule); border: 1px solid var(--rule); }.rule-row { display: grid; grid-template-columns: minmax(220px, 1.5fr) repeat(4, minmax(90px, .5fr)) auto; align-items: center; gap: 12px; background: var(--surface); padding: 14px 15px; }.rule-row h3 { margin: 0; font-size: 13px; }.rule-row p { margin: 4px 0 0; color: var(--steel); font-size: 11px; }.rule-cell small { display: block; color: var(--steel); font-size: 9px; text-transform: uppercase; }.rule-cell strong { display: block; margin-top: 4px; font-family: var(--mono); }
.rule-editor { margin-top: 20px; border: 2px solid var(--ink); background: var(--surface); padding: 20px; }.rule-editor[hidden] { display: none; }.rule-editor-header { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 17px; }.rule-editor-header h2 { margin: 0; font: 500 23px/1 var(--display); }.rule-form-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }.checkbox-field { display: flex; align-items: center; gap: 8px; }.checkbox-field input { width: auto; }
.audit-diff { margin: 0; padding: 9px; background: #f4f2eb; font: 10px/1.5 var(--mono); white-space: pre-wrap; }.disclosure summary { cursor: pointer; color: var(--teal); font-weight: 700; }
.field-error { display: block; color: var(--red); font-size: 12px; font-weight: 700; }
.receipt-stage { display: grid; place-items: start center; overflow: auto; max-height: 680px; background: #e7e3d9; }
.receipt-preview { display: block; width: min(100%, 360px); height: auto; border: 1px solid var(--rule-dark); background: var(--surface); }

.login-page { min-height: 100vh; display: grid; place-items: center; background: var(--ink); padding: 24px; }.login-panel { width: min(460px, 100%); padding: 38px; background: var(--surface); border-top: 5px solid var(--amber); }.login-panel .brand-mark { margin-bottom: 30px; }.login-panel p { color: var(--steel); }.login-panel form { display: grid; gap: 10px; margin: 26px 0 18px; }.login-panel form p { margin: 0; }.login-panel label { display: block; color: var(--ink); margin-bottom: 5px; font-size: 11px; font-weight: 700; }.login-panel small { color: var(--steel); font-family: var(--mono); }

@media (max-width: 1180px) {
  .metric-strip { grid-template-columns: repeat(3, 1fr); }.metric:nth-child(3) { border-right: 0; }.metric:nth-child(-n+3) { border-bottom: 1px solid var(--rule); }
  .stat-list { grid-template-columns: repeat(2, 1fr); }.stat-list > div:nth-child(2) { border-right: 0; }.stat-list > div:nth-child(-n+2) { border-bottom: 1px solid var(--rule); }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform 220ms cubic-bezier(.16,1,.3,1); box-shadow: 20px 0 45px rgb(0 0 0 / .2); }.nav-open .sidebar { transform: translateX(0); }.nav-open .nav-scrim { display: block; position: fixed; inset: 0; z-index: 25; border: 0; background: rgb(10 17 14 / .55); }
  .workspace { margin-left: 0; }.mobile-menu { display: block; }.topbar { padding: 0 18px; }.global-search { width: auto; flex: 1; }.topbar-meta time, .alert-counter span { display: none; }
  .content-grid, .detail-grid { grid-template-columns: 1fr; }.case-hero { grid-template-columns: 1fr; }.case-score { min-height: 160px; }
  .rule-row { grid-template-columns: 1fr 1fr 1fr; }.rule-row > div:first-child { grid-column: 1 / -1; }.rule-form-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .page-frame { padding: 24px 14px 48px; }.page-header { align-items: flex-start; flex-direction: column; margin-bottom: 20px; }.page-actions { width: 100%; }
  .global-search kbd { display: none; }.topbar { gap: 10px; }.topbar-meta { gap: 8px; }
  .metric-strip { grid-template-columns: repeat(2, 1fr); }.metric { border-bottom: 1px solid var(--rule); }.metric:nth-child(2n) { border-right: 0; }.metric:nth-last-child(-n+2) { border-bottom: 0; }
  .filter-bar { align-items: stretch; }.field, .field.grow { min-width: 100%; }.filter-bar .button { flex: 1; }
  .detail-list { grid-template-columns: 1fr; }.detail-list > div:nth-child(odd), .detail-list > div:nth-child(even) { padding: 13px 0; border-left: 0; }
  .chart { gap: 8px; padding-inline: 10px; }.chart-bar { font-size: 8px; }
  .stat-list { grid-template-columns: 1fr 1fr; }.rule-row { grid-template-columns: 1fr 1fr; }.rule-form-grid { grid-template-columns: 1fr; }
  .timeline li { grid-template-columns: 62px 14px 1fr; }.timeline li:not(:last-child)::after { left: 68px; }
  .evidence-row { grid-template-columns: 34px 1fr; }.evidence-row .status { grid-column: 2; }.hash { max-width: 230px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; } }
