:root {
  color-scheme: dark;
  --bg: #060b13;
  --shell: #08111f;
  --panel: #0d1828;
  --panel-strong: #111f32;
  --panel-soft: #0a1422;
  --line: #203148;
  --line-soft: rgba(123, 151, 185, 0.18);
  --text: #f3f7fb;
  --muted: #9aabc0;
  --dim: #70839a;
  --blue: #6fb7ff;
  --cyan: #62d9d2;
  --green: #6fd0a1;
  --amber: #f0bd65;
  --orange: #ef8e60;
  --red: #ff727d;
  --violet: #a997ff;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.28);
  --radius: 16px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--bg); scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 84% 8%, rgba(48, 109, 165, 0.14), transparent 27rem),
    linear-gradient(145deg, #050a11 0%, #07101b 52%, #050a11 100%);
  color: var(--text);
}

button, select { font: inherit; }
button, select, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid rgba(111, 183, 255, 0.7);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  left: 1rem;
  top: 1rem;
  z-index: 100;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: white;
  color: #06101c;
  transform: translateY(-200%);
}
.skip-link:focus { transform: translateY(0); }

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  padding: 1.5rem 1rem;
  border-right: 1px solid var(--line-soft);
  background: rgba(7, 15, 26, 0.94);
  backdrop-filter: blur(20px);
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0 0.65rem;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(111, 183, 255, 0.55);
  border-radius: 11px;
  background: linear-gradient(145deg, rgba(111, 183, 255, 0.2), rgba(98, 217, 210, 0.06));
  color: white;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.brand strong, .brand span { display: block; }
.brand strong { font-size: 0.95rem; letter-spacing: 0.16em; }
.brand span { margin-top: 0.2rem; color: var(--muted); font-size: 0.76rem; }

.nav-list { display: grid; gap: 0.35rem; }
.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-height: 46px;
  padding: 0.65rem 0.8rem;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
}
.nav-item:hover { background: rgba(111, 183, 255, 0.06); color: var(--text); }
.nav-item.is-active {
  border-color: rgba(111, 183, 255, 0.22);
  background: linear-gradient(90deg, rgba(111, 183, 255, 0.14), rgba(111, 183, 255, 0.03));
  color: white;
}
.nav-icon {
  width: 2rem;
  color: var(--dim);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.08em;
}
.nav-item.is-active .nav-icon { color: var(--blue); }

.sidebar-foot {
  margin-top: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 1rem 0.75rem;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 0.77rem;
}
.sidebar-foot strong, .sidebar-foot span { display: block; }
.sidebar-foot strong { color: #c9d6e4; font-size: 0.78rem; }
.sidebar-foot span:last-child { margin-top: 0.2rem; }
.environment-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  margin-top: 0.35rem;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(240, 189, 101, 0.09);
}

.workspace { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  min-height: 96px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 1.5rem;
  padding: 1.25rem clamp(1rem, 3vw, 2.5rem);
  border-bottom: 1px solid var(--line-soft);
  background: rgba(6, 12, 21, 0.86);
  backdrop-filter: blur(18px);
}
.topbar-copy p {
  margin: 0 0 0.3rem;
  color: var(--blue);
  font-size: 0.73rem;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.topbar-copy h1 { margin: 0; font-size: clamp(1.35rem, 2.5vw, 2rem); line-height: 1.14; }
.topbar-controls {
  display: grid;
  grid-template-columns: auto minmax(180px, 240px) auto;
  align-items: center;
  gap: 0.65rem;
}
.field-label { color: var(--muted); font-size: 0.76rem; font-weight: 650; }
select, .quiet-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #0c1726;
  color: var(--text);
}
select { padding: 0 2.2rem 0 0.8rem; }
.quiet-button { padding: 0 0.9rem; cursor: pointer; }
.quiet-button:hover { border-color: #3a5778; background: #112036; }
.menu-toggle { display: none; }

.status-strip {
  min-height: 42px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem clamp(1rem, 3vw, 2.5rem);
  border-bottom: 1px solid var(--line-soft);
  background: rgba(12, 23, 38, 0.68);
  color: var(--muted);
  font-size: 0.78rem;
}
.status-strip > div { display: flex; align-items: center; gap: 0.55rem; }
.status-strip strong { color: #d6e1ec; font-weight: 650; }
.status-indicator { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.status-indicator.is-live { background: var(--green); box-shadow: 0 0 0 4px rgba(111, 208, 161, 0.09); }
.status-indicator.is-error { background: var(--red); box-shadow: 0 0 0 4px rgba(255, 114, 125, 0.09); }

.content { padding: clamp(1rem, 3vw, 2.5rem); }
.content-grid { display: grid; gap: 1rem; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.section-gap { margin-top: 1rem; }

.panel {
  min-width: 0;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: linear-gradient(150deg, rgba(16, 29, 47, 0.96), rgba(10, 20, 34, 0.94));
  box-shadow: var(--shadow);
}
.panel-pad { padding: 1.15rem; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}
.panel-head h2, .panel-head h3 { margin: 0; font-size: 1rem; }
.panel-head p { margin: 0.35rem 0 0; color: var(--muted); font-size: 0.8rem; line-height: 1.45; }
.panel-meta { color: var(--dim); font-size: 0.75rem; white-space: nowrap; }

.kpi-card { padding: 1rem 1.05rem; }
.kpi-label { display: block; color: var(--muted); font-size: 0.78rem; line-height: 1.35; }
.kpi-line { display: flex; align-items: baseline; gap: 0.6rem; margin-top: 0.55rem; }
.kpi-value { font-size: clamp(1.6rem, 3.5vw, 2.2rem); font-weight: 760; letter-spacing: -0.04em; }
.kpi-delta { font-size: 0.76rem; font-weight: 720; }
.positive { color: var(--green); }
.negative { color: var(--red); }
.neutral { color: var(--amber); }
.kpi-foot { display: flex; justify-content: space-between; gap: 0.75rem; margin-top: 0.7rem; color: var(--dim); font-size: 0.7rem; }

.progress-track {
  height: 7px;
  overflow: hidden;
  border-radius: 100px;
  background: rgba(115, 143, 175, 0.14);
}
.progress-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--cyan)); }

.alert-banner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
  border: 1px solid rgba(255, 114, 125, 0.42);
  border-radius: 14px;
  background: linear-gradient(90deg, rgba(255, 114, 125, 0.14), rgba(255, 114, 125, 0.04));
}
.alert-banner h2 { margin: 0; font-size: 0.95rem; }
.alert-banner p { margin: 0.3rem 0 0; color: #d1dae5; font-size: 0.82rem; line-height: 1.45; }
.alert-code { color: var(--red); font-size: 0.73rem; font-weight: 800; letter-spacing: 0.1em; }

.signal-list, .action-list, .source-list, .decision-list { display: grid; gap: 0.65rem; }
.signal-row, .action-row, .source-row, .decision-row {
  display: grid;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--line-soft);
}
.signal-row:last-child, .action-row:last-child, .source-row:last-child, .decision-row:last-child { border-bottom: 0; }
.signal-row { grid-template-columns: 11px minmax(0, 1fr) auto; }
.action-row { grid-template-columns: minmax(0, 1fr) auto auto; }
.source-row { grid-template-columns: minmax(0, 1fr) 100px 70px; }
.decision-row { grid-template-columns: minmax(0, 1fr) auto; }
.row-title { margin: 0; color: #e9f0f7; font-size: 0.86rem; font-weight: 680; }
.row-copy { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.76rem; line-height: 1.45; }
.row-meta { color: var(--dim); font-size: 0.7rem; white-space: nowrap; }
.severity-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--blue); }
.severity-low { background: var(--blue); }
.severity-medium { background: var(--amber); }
.severity-high { background: var(--orange); }
.severity-critical { background: var(--red); box-shadow: 0 0 0 4px rgba(255, 114, 125, 0.08); }

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 100px;
  color: #cbd7e5;
  background: rgba(111, 183, 255, 0.06);
  font-size: 0.68rem;
  font-weight: 680;
  text-transform: capitalize;
}
.status-pill.critical { border-color: rgba(255, 114, 125, 0.4); color: #ffb5bb; background: rgba(255, 114, 125, 0.08); }
.status-pill.high { border-color: rgba(239, 142, 96, 0.4); color: #ffc0a4; background: rgba(239, 142, 96, 0.08); }
.status-pill.medium, .status-pill.attention { border-color: rgba(240, 189, 101, 0.35); color: #f7d89f; background: rgba(240, 189, 101, 0.08); }
.status-pill.healthy, .status-pill.approved { border-color: rgba(111, 208, 161, 0.35); color: #a8e9c8; background: rgba(111, 208, 161, 0.08); }

.domain-list { display: grid; gap: 0.8rem; }
.domain-row { display: grid; grid-template-columns: 112px minmax(0, 1fr) 42px; align-items: center; gap: 0.75rem; }
.domain-name { color: #c9d6e4; font-size: 0.76rem; }
.domain-value { color: var(--muted); font-size: 0.72rem; text-align: right; }

.trend-chart { width: 100%; height: auto; overflow: visible; }
.trend-chart .grid-line { stroke: rgba(140, 162, 190, 0.13); stroke-width: 1; }
.trend-chart .trend-area { fill: url(#areaGradient); }
.trend-chart .trend-line { fill: none; stroke: var(--blue); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.trend-chart .trend-dot { fill: #08111f; stroke: var(--cyan); stroke-width: 3; }
.trend-chart text { fill: var(--dim); font-size: 11px; }

.comparison-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.comparison-table th, .comparison-table td { padding: 0.8rem 0.65rem; border-bottom: 1px solid var(--line-soft); text-align: left; }
.comparison-table th { color: var(--dim); font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; }
.comparison-table td { color: #d6e1ec; }
.comparison-table td:nth-child(n+2), .comparison-table th:nth-child(n+2) { text-align: right; }

.score-hero { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 1.25rem; align-items: center; }
.score-ring {
  width: 118px;
  height: 118px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--cyan) calc(var(--score) * 1%), rgba(111, 183, 255, 0.1) 0);
  position: relative;
}
.score-ring::after { content: ""; position: absolute; inset: 10px; border-radius: 50%; background: var(--panel); }
.score-ring strong { position: relative; z-index: 1; font-size: 2rem; }
.score-summary h2 { margin: 0; font-size: 1.15rem; }
.score-summary p { margin: 0.45rem 0 0; color: var(--muted); font-size: 0.82rem; line-height: 1.5; }

.filter-row { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-bottom: 1rem; }
.filter-button {
  min-height: 34px;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 100px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.72rem;
}
.filter-button.is-active { color: white; border-color: rgba(111, 183, 255, 0.5); background: rgba(111, 183, 255, 0.12); }

.recommendation-list { counter-reset: recommendation; display: grid; gap: 0.8rem; }
.recommendation {
  counter-increment: recommendation;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0.85rem;
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  background: rgba(5, 11, 19, 0.25);
}
.recommendation::before { content: counter(recommendation, decimal-leading-zero); color: var(--blue); font-size: 0.7rem; font-weight: 800; padding-top: 0.15rem; }
.recommendation h3 { margin: 0; font-size: 0.85rem; }
.recommendation p { margin: 0.3rem 0 0; color: var(--muted); font-size: 0.76rem; line-height: 1.45; }

.empty-state, .error-state, .loading-state {
  min-height: 280px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0.7rem;
  text-align: center;
  color: var(--muted);
}
.loading-mark { width: 28px; height: 28px; border: 2px solid var(--line); border-top-color: var(--blue); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.mobile-overlay { position: fixed; inset: 0; z-index: 18; background: rgba(0, 0, 0, 0.58); }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-3 { grid-column: span 2; }
  .topbar { grid-template-columns: minmax(0, 1fr); }
  .topbar-controls { grid-template-columns: auto minmax(180px, 1fr) auto; }
}

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0;
    transform: translateX(-105%);
    width: min(82vw, 290px);
    transition: transform 180ms ease;
  }
  .sidebar.is-open { transform: translateX(0); }
  .menu-toggle {
    display: inline-flex;
    width: max-content;
    min-height: 38px;
    align-items: center;
    padding: 0 0.8rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--text);
  }
  .topbar { position: relative; grid-template-columns: auto minmax(0, 1fr); gap: 0.8rem; }
  .topbar-controls { grid-column: 1 / -1; grid-template-columns: 1fr auto; }
  .field-label { grid-column: 1 / -1; }
  .status-strip { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 620px) {
  .content { padding: 0.8rem; }
  .topbar { padding: 1rem; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .span-2, .span-3 { grid-column: span 1; }
  .alert-banner { grid-template-columns: 1fr; }
  .alert-banner .status-pill { width: max-content; }
  .action-row, .source-row, .decision-row { grid-template-columns: minmax(0, 1fr); align-items: flex-start; }
  .score-hero { grid-template-columns: 1fr; justify-items: start; }
  .domain-row { grid-template-columns: 88px minmax(0, 1fr) 38px; }
  .comparison-table { min-width: 570px; }
  .table-scroll { overflow-x: auto; }
}

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