:root {
  color-scheme: dark;
  --bg: #070708;
  --panel: #121213;
  --panel-2: #171719;
  --line: #28282c;
  --text: #f4f1ea;
  --muted: #9b9aa0;
  --gold: #d3b46b;
  --gold-2: #f0cf7a;
  --red: #ff4b55;
  --orange: #f58a24;
  --blue: #279cf5;
  --green: #37d67a;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: radial-gradient(circle at 64% 18%, rgba(158, 36, 29, .16), transparent 28%), var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button, .gold-button { border: 1px solid var(--line); background: #19191b; color: var(--text); border-radius: 7px; padding: 10px 14px; cursor: pointer; text-decoration: none; }
button:hover, a:hover { border-color: var(--gold); }
button:disabled { opacity: .62; cursor: wait; }
.gold-button { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: #0c0b08; font-weight: 700; box-shadow: 0 10px 30px rgba(211, 180, 107, .2); border: 0; }
.danger { color: var(--red); border-color: rgba(255,75,85,.4); background: rgba(255,75,85,.08); }
.is-hidden { display: none !important; }

.login-screen { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(420px, 520px); background: radial-gradient(circle at 28% 18%, rgba(211, 180, 107, .16), transparent 26%), radial-gradient(circle at 70% 72%, rgba(255, 75, 85, .12), transparent 30%), #070708; }
.login-brand-panel { border-right: 1px solid var(--line); padding: 34px; display: flex; flex-direction: column; justify-content: space-between; min-height: 100vh; }
.login-brand { display: flex; align-items: center; gap: 12px; font-size: 20px; }
.login-brand span { width: 34px; height: 34px; display: grid; place-items: center; background: var(--gold); color: #090806; border-radius: 6px; font-weight: 900; }
.login-hero { max-width: 720px; }
.login-hero h1 { margin: 12px 0 18px; font-size: clamp(40px, 6vw, 76px); line-height: .98; letter-spacing: 0; max-width: 900px; }
.login-hero p:not(.eyebrow) { color: #bbb9b2; font-size: 18px; line-height: 1.6; max-width: 660px; }
.login-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; max-width: 720px; }
.login-metrics div { border: 1px solid var(--line); background: rgba(18,18,19,.72); border-radius: 8px; padding: 18px; }
.login-metrics strong { display: block; font-size: 22px; color: var(--gold); margin-bottom: 4px; }
.login-metrics span { color: var(--muted); }
.login-card { align-self: center; justify-self: center; width: min(440px, calc(100% - 40px)); background: linear-gradient(180deg, rgba(255,255,255,.045), rgba(255,255,255,.018)); border: 1px solid var(--line); border-radius: 8px; padding: 26px; box-shadow: 0 28px 80px rgba(0,0,0,.42); }
.login-card-head { display: flex; justify-content: space-between; gap: 18px; align-items: start; margin-bottom: 12px; }
.login-card h2 { margin: 0; font-size: 27px; }
.login-subtitle, .login-footnote { color: var(--muted); line-height: 1.5; }
.demo-login-grid { display: grid; gap: 10px; margin: 20px 0; max-height: 420px; overflow: auto; padding-right: 4px; }
.demo-login-card { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; align-items: center; border: 1px solid var(--line); background: #111113; border-radius: 8px; padding: 13px; cursor: pointer; }
.demo-login-card input { width: auto; grid-row: 1 / 4; accent-color: var(--gold); }
.demo-login-card span { color: var(--gold); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.demo-login-card strong { font-size: 16px; }
.demo-login-card small { color: var(--muted); line-height: 1.35; }
.demo-login-card.is-selected { border-color: rgba(211,180,107,.62); background: rgba(211,180,107,.09); }

.app-shell { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; }
.sidebar { border-right: 1px solid var(--line); background: #111112; padding: 24px 16px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 24px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; font-size: 20px; }
.brand span { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 6px; background: var(--gold); color: #090806; font-weight: 900; }
nav { display: grid; gap: 8px; }
nav a { color: var(--muted); text-decoration: none; padding: 12px 14px; border: 1px solid transparent; border-radius: 7px; display: flex; align-items: center; gap: 12px; }
nav a.active { color: var(--gold); background: rgba(211,180,107,.1); border-color: rgba(211,180,107,.28); }
.nav-icon { width: 22px; color: #a6a6aa; text-align: center; font-weight: 800; line-height: 1; }
nav a.active .nav-icon { color: var(--gold); }
.role-panel { margin-top: auto; border-top: 1px solid var(--line); padding-top: 20px; display: grid; gap: 8px; color: var(--muted); }

.workspace { min-width: 0; }
.topbar { height: 88px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 32px; background: rgba(18,18,19,.88); backdrop-filter: blur(18px); position: sticky; top: 0; z-index: 5; }
.topbar h1, .section-head h2, .panel h2 { margin: 0; }
.eyebrow, .muted { color: var(--muted); letter-spacing: .08em; text-transform: uppercase; font-size: 12px; margin: 0 0 4px; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.topbar-language { width: 76px; min-width: 76px; }
.user-chip { display: flex; align-items: center; gap: 10px; border-left: 1px solid var(--line); padding-left: 14px; min-width: 190px; }
.user-chip span { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: rgba(211,180,107,.18); border: 1px solid rgba(211,180,107,.45); color: var(--gold); font-weight: 800; }
.user-chip strong { display: block; font-size: 14px; }
.user-chip small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 4px rgba(255,75,85,.12); }
#view { padding: 32px; }

.panel, .filter-panel, .preview-panel, .chat-panel, .evidence-panel { background: linear-gradient(180deg, rgba(255,255,255,.025), rgba(255,255,255,.01)); border: 1px solid var(--line); border-radius: 8px; padding: 24px; box-shadow: 0 20px 50px rgba(0,0,0,.22); }
.section-head { display: flex; justify-content: space-between; gap: 18px; align-items: center; margin-bottom: 24px; }
.section-head p { color: var(--muted); margin: 6px 0 0; }
.compact { margin-bottom: 16px; }

.rule-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 24px; }
.filter-panel { display: grid; align-content: start; gap: 16px; }
.filter-panel h3 { margin: 8px 0 0; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .09em; }
input, select, textarea { width: 100%; color: var(--text); background: #111217; border: 1px solid var(--line); border-radius: 7px; padding: 11px 12px; }
textarea { min-height: 210px; resize: vertical; line-height: 1.5; }
.stack { display: grid; gap: 8px; }
.stack button { text-align: left; display: flex; justify-content: space-between; }

.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.rule-card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 20px; display: grid; gap: 14px; min-height: 250px; }
.rule-card h3 { margin: 0; font-size: 18px; }
.rule-card p { color: var(--muted); margin: 0; line-height: 1.45; }
.meta-row, .button-row, .tag-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pill, .tag-row span { border: 1px solid var(--line); background: #1a1a1c; color: var(--muted); border-radius: 6px; padding: 5px 8px; font-size: 12px; }
.Critical, .High { color: var(--red); border-color: rgba(255,75,85,.35); background: rgba(255,75,85,.1); }
.Medium { color: var(--gold); border-color: rgba(211,180,107,.35); background: rgba(211,180,107,.1); }
.Low { color: var(--blue); border-color: rgba(39,156,245,.35); background: rgba(39,156,245,.1); }
.Active, .Normal { color: var(--green); }
.PendingApproval, .Testing { color: var(--gold); border-color: rgba(211,180,107,.35); background: rgba(211,180,107,.1); }
.Rejected, .Disabled { color: var(--muted); border-color: rgba(155,154,160,.35); background: rgba(155,154,160,.08); }

.split-view { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(400px, .75fr); gap: 24px; }
.chat-panel { min-height: calc(100vh - 152px); display: grid; grid-template-rows: auto 1fr auto auto; gap: 18px; }
.assistant-bubble { background: #131721; border: 1px solid #273247; border-radius: 8px; padding: 18px; color: #c9ced8; line-height: 1.5; }
.preview-panel { position: sticky; top: 120px; align-self: start; }
pre { background: #050506; border: 1px solid var(--line); border-radius: 7px; padding: 18px; overflow: auto; color: #d8c894; line-height: 1.5; max-height: 54vh; }
.definition-grid { display: grid; grid-template-columns: 150px 1fr; gap: 10px; }
.definition-grid dt { color: var(--muted); }
.definition-grid dd { margin: 0; }
.wide { width: 100%; margin-top: 10px; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 430px; gap: 24px; }
.detail-list { display: grid; gap: 18px; }
.detail-list h3 { color: var(--muted); text-transform: uppercase; font-size: 12px; letter-spacing: .08em; margin-bottom: 8px; }

.simulation-layout { display: grid; grid-template-columns: 288px minmax(0, 1fr) 360px; gap: 18px; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin-bottom: 24px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 22px; min-height: 130px; }
.kpi span { color: var(--muted); }
.kpi strong { display: block; font-size: 34px; margin-top: 16px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-size: 12px; }
td { color: #ddd; }
td small { display: block; color: var(--muted); margin-top: 5px; line-height: 1.35; }
.table-wrap { width: 100%; overflow-x: auto; }
.evidence-panel { position: sticky; top: 120px; align-self: start; }

.approval-filter-bar { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; margin: -6px 0 20px; padding: 14px; border: 1px solid var(--line); background: #101012; border-radius: 8px; }
.approval-filter-bar label { display: grid; gap: 6px; min-width: 190px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.filter-tags { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-height: 40px; }
.filter-tags button { display: inline-flex; align-items: center; gap: 8px; color: var(--gold); border-color: rgba(211,180,107,.32); background: rgba(211,180,107,.08); padding: 8px 10px; }
.filter-tags span { color: var(--muted); font-size: 16px; line-height: 1; }

.config-layout { display: block; max-width: 100%; }
.config-layout .panel { padding: 22px; }
.config-layout table { min-width: 980px; }
.config-layout td:nth-child(1) { min-width: 260px; }
.threshold-input { min-width: 230px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
.severity-select { min-width: 130px; }
.impact-note { display: block; color: var(--muted); line-height: 1.4; max-width: 260px; }
.switch { display: inline-flex; align-items: center; cursor: pointer; }
.switch input { width: auto; position: absolute; opacity: 0; pointer-events: none; }
.switch span { width: 44px; height: 24px; border-radius: 999px; background: #2a2a2d; border: 1px solid var(--line); position: relative; transition: .18s ease; }
.switch span::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; background: #777; left: 3px; top: 2px; transition: .18s ease; }
.switch input:checked + span { background: rgba(55,214,122,.18); border-color: rgba(55,214,122,.45); }
.switch input:checked + span::after { left: 21px; background: var(--green); }
.switch input:disabled + span { opacity: .5; cursor: not-allowed; }

.audit-dashboard-page { display: grid; gap: 30px; }
.dashboard-kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; }
.dashboard-kpi { min-height: 180px; border: 1px solid var(--line); border-radius: 8px; background: linear-gradient(180deg, rgba(255,255,255,.025), rgba(255,255,255,.006)); padding: 26px 24px; box-shadow: 0 22px 58px rgba(0,0,0,.34); }
.dashboard-kpi.red { border-color: rgba(255,75,85,.36); background: linear-gradient(180deg, rgba(255,75,85,.08), rgba(255,255,255,.006)); }
.dashboard-kpi.gold { border-color: rgba(211,180,107,.22); }
.dashboard-kpi strong { display: block; font-size: 38px; margin: 20px 0 8px; line-height: 1; }
.dashboard-kpi.red strong { color: var(--red); text-transform: uppercase; font-size: 28px; letter-spacing: .03em; }
.dashboard-kpi small { color: var(--muted); font-size: 15px; font-weight: 500; margin-left: 6px; }
.dashboard-kpi p { color: var(--muted); margin: 10px 0 0; font-size: 12px; }
.kpi-label { display: flex; align-items: center; justify-content: space-between; gap: 14px; color: var(--muted); }
.kpi-label i { font-style: normal; color: var(--gold); opacity: .9; }
.dashboard-kpi.red .kpi-label i { color: var(--red); }
.dashboard-kpi.blue .kpi-label i { color: var(--blue); }
.mini-progress { height: 5px; border-radius: 999px; background: #2a2a2c; overflow: hidden; margin-top: 18px; }
.mini-progress span { display: block; height: 100%; border-radius: inherit; background: var(--gold); }
.dashboard-kpi.red .mini-progress span { background: linear-gradient(90deg, var(--red) 0 52%, #37373a 52% 72%, #37373a 72%); }
.dashboard-kpi.blue .mini-progress span { background: var(--blue); }
.mini-chip-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.mini-chip-row span { border: 1px solid var(--line); border-radius: 5px; color: var(--muted); padding: 5px 9px; font-size: 12px; }
.mini-chip-row span:first-child { color: var(--red); border-color: rgba(255,75,85,.42); background: rgba(255,75,85,.08); }
.mini-chip-row span:nth-child(2) { color: var(--gold); border-color: rgba(211,180,107,.38); background: rgba(211,180,107,.07); }
.dashboard-main-grid { display: grid; grid-template-columns: minmax(0, 1fr) 352px; gap: 32px; align-items: start; }
.dashboard-section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.dashboard-section-head h2 { margin: 0; font-size: 20px; }
.dashboard-section-head a { color: var(--gold); text-decoration: none; font-size: 13px; }
.signal-grid.executive { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.signal-card, .alert-item { border: 1px solid var(--line); border-radius: 8px; padding: 18px; background: #111113; }
.executive-card { min-height: 146px; display: grid; gap: 10px; transition: border-color .18s ease, transform .18s ease; }
.executive-card:hover { transform: translateY(-2px); border-color: rgba(211,180,107,.34); }
.executive-card.high { border-color: rgba(255,75,85,.34); background: linear-gradient(180deg, rgba(255,75,85,.055), rgba(255,255,255,.006)); }
.signal-card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.signal-icon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 7px; background: #29292c; color: #efeee9; font-weight: 800; }
.executive-card.high .signal-icon { background: rgba(255,75,85,.2); color: var(--red); }
.status-badge { border: 1px solid var(--line); border-radius: 5px; padding: 5px 9px; font-size: 12px; color: var(--muted); }
.status-badge.normal { color: var(--green); border-color: rgba(55,214,122,.35); background: rgba(55,214,122,.08); }
.status-badge.high { color: var(--red); border-color: rgba(255,75,85,.42); background: rgba(255,75,85,.1); }
.status-badge.review { color: var(--gold); border-color: rgba(211,180,107,.36); background: rgba(211,180,107,.08); }
.signal-card h3 { margin: 0; font-size: 17px; }
.signal-card p { color: var(--muted); margin: 0; line-height: 1.38; font-size: 13px; }
.priority-section { border: 1px solid var(--line); border-radius: 8px; background: #101011; overflow: hidden; }
.priority-section .dashboard-section-head { margin: 0; padding: 20px 20px 14px; }
.priority-alert-list { display: grid; }
.priority-alert { display: grid; grid-template-columns: 12px 1fr; gap: 12px; padding: 18px 20px; border-top: 1px solid var(--line); color: var(--text); text-decoration: none; }
.priority-alert:hover { background: rgba(211,180,107,.04); border-color: var(--line); }
.priority-alert h3 { margin: 0 0 6px; font-size: 15px; }
.priority-alert p { color: var(--muted); margin: 0; line-height: 1.35; font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.priority-alert small { color: #77777d; display: block; margin-top: 12px; }
.alert-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; background: var(--gold); }
.alert-dot.Critical, .alert-dot.High { background: var(--red); }
.alert-dot.Medium { background: var(--gold); }
.trend-section { display: grid; gap: 0; }
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.chart-card { border: 1px solid var(--line); border-radius: 8px; background: #101011; padding: 24px; min-height: 386px; }
.chart-card h3 { margin: 0 0 18px; color: var(--muted); font-size: 15px; font-weight: 600; }
.svg-chart svg { width: 100%; height: 260px; display: block; }
.svg-chart text { fill: #85858a; font-size: 11px; text-anchor: middle; }
.grid-line { stroke: #27272a; stroke-width: 1; }
.line-gold, .line-red { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.line-gold { stroke: var(--gold); }
.line-red { stroke: var(--red); }
.area-red { fill: rgba(255,75,85,.12); stroke: none; }
.chart-point { cursor: pointer; stroke: #101011; stroke-width: 2; }
.gold-point { fill: var(--gold); }
.red-point { fill: var(--red); }
.bar-standard { fill: #2b2b2d; }
.bar-anomaly { fill: var(--blue); }
.chart-bar { cursor: pointer; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 12px; color: #8f8f95; font-size: 12px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 8px; }
.chart-legend b { font-weight: 500; }
.chart-legend i { width: 12px; height: 12px; display: inline-block; }
.legend-gold { background: var(--gold); }
.legend-red { background: var(--red); }
.legend-blue { background: var(--blue); }
.legend-gray { background: #2b2b2d; }
.chart-tooltip { position: fixed; z-index: 20; pointer-events: none; background: #080809; color: var(--text); border: 1px solid rgba(211,180,107,.42); border-radius: 6px; padding: 8px 10px; box-shadow: 0 14px 34px rgba(0,0,0,.46); font-size: 12px; white-space: nowrap; }
.alert-list { display: grid; gap: 12px; }
.alert-item { text-decoration: none; color: var(--text); display: block; }
.alert-item p { color: var(--muted); margin: 6px 0; }

.alert-detail { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; }
.hero-alert { grid-column: 1 / -1; border-color: rgba(255,75,85,.35); background: linear-gradient(110deg, rgba(255,75,85,.13), rgba(211,180,107,.06)); }
.hero-alert h2 { font-size: 34px; margin: 12px 0 6px; }
.wide-panel { grid-column: 1 / -1; }
.note-composer { display: grid; gap: 10px; margin: 12px 0; }
.note-composer[hidden] { display: none; }
.note-composer textarea { min-height: 96px; }
.note-list { display: grid; gap: 10px; margin: 14px 0; }
.note-list article { border: 1px solid var(--line); background: #101012; border-radius: 8px; padding: 12px; }
.note-list article p { margin: 8px 0; color: #dedbd2; line-height: 1.45; }
.note-list article small { color: var(--muted); }

@media (max-width: 1100px) {
  .login-screen { grid-template-columns: 1fr; }
  .login-brand-panel { min-height: auto; gap: 48px; border-right: 0; border-bottom: 1px solid var(--line); }
  .login-card { margin: 32px 0; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rule-layout, .split-view, .detail-grid, .simulation-layout, .dashboard-grid, .dashboard-main-grid, .chart-grid, .alert-detail { grid-template-columns: 1fr; }
  .card-grid, .kpi-grid, .dashboard-kpi-grid, .signal-grid.executive { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .login-brand-panel { padding: 22px; }
  .login-hero h1 { font-size: 40px; }
  .login-metrics { grid-template-columns: 1fr; }
  #view { padding: 18px; }
  .topbar { height: auto; padding: 18px; align-items: flex-start; gap: 12px; flex-direction: column; }
  .topbar-actions { width: 100%; flex-wrap: wrap; }
  .user-chip { border-left: 0; padding-left: 0; }
  .card-grid, .kpi-grid, .dashboard-kpi-grid, .signal-grid, .signal-grid.executive { grid-template-columns: 1fr; }
  nav { grid-template-columns: 1fr; }
}
