:root {
  color-scheme: light;
  --ink: #182026;
  --muted: #65727c;
  --line: #dbe2e8;
  --panel: #ffffff;
  --surface: #f4f7f9;
  --brand: #194d5f;
  --brand-strong: #123642;
  --gold: #c69a3a;
  --good: #167052;
  --warn: #9b5b0b;
  --danger: #a43737;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--surface);
}

button, input { font: inherit; }

.is-hidden { display: none !important; }

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #11191d 0%, #183842 52%, #f4f7f9 52%);
}

.login-panel {
  width: min(460px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 28px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 20px 70px rgba(17, 25, 29, 0.22);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  font-weight: 750;
}

.brand-login { margin-bottom: 24px; }

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  color: #11191d;
  background: var(--gold);
}

.brand-text { overflow-wrap: anywhere; }

.login-panel h1 {
  margin: 0 0 22px;
  font-size: 1.7rem;
  line-height: 1.2;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.login-form input {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  color: var(--ink);
  background: #ffffff;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px 18px;
  color: #f6f8f9;
  background: #11191d;
}

.nav-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
}

.nav-search input {
  min-width: 0;
  min-height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 7px;
  padding: 0 10px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.nav-search input::placeholder { color: #8da0aa; }

.nav-search button {
  min-height: 36px;
  border: 0;
  border-radius: 7px;
  padding: 0 10px;
  color: #11191d;
  background: var(--gold);
  font-size: 0.78rem;
  font-weight: 850;
  cursor: pointer;
}

.nav-list {
  display: grid;
  gap: 18px;
}

.nav-section {
  display: grid;
  gap: 7px;
}

.nav-section-toggle {
  display: flex;
  width: 100%;
  min-height: 32px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 0;
  border-radius: 7px;
  padding: 0 10px 0 12px;
  color: #8da0aa;
  background: transparent;
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0;
  text-align: left;
  text-transform: uppercase;
  cursor: pointer;
}

.nav-section-toggle:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
}

.nav-chevron {
  color: var(--gold);
  font-size: 0.82rem;
  font-weight: 900;
}

.nav-section-items {
  display: grid;
  gap: 7px;
}

.nav-item {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: #d8e2e7;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
}

.main-panel {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
}

.topbar-title {
  min-width: 0;
  margin-right: auto;
}

.menu-toggle {
  display: none;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--brand);
  background: #ffffff;
  cursor: pointer;
}

.menu-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1, h2, h3 { margin: 0; letter-spacing: 0; }

h1 {
  font-size: 2rem;
  line-height: 1.15;
}

h2 { font-size: 1.1rem; }

.status-bar {
  min-height: 34px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 12px;
  color: #34444e;
  background: #e6edf1;
  font-size: 0.86rem;
  font-weight: 700;
}

.status-bar.error {
  color: var(--danger);
  background: #ffe3e3;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-grid-four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 18px;
}

.content-grid-three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stats-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(17, 25, 29, 0.06);
}

.stats-hero h2 { font-size: 1.45rem; }

.stats-hero-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(110px, 1fr));
  gap: 10px;
}

.stats-hero-kpis span,
.source-kpis span {
  display: grid;
  gap: 4px;
  min-height: 58px;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  color: var(--muted);
  background: #f8fafb;
  font-size: 0.78rem;
  font-weight: 800;
}

.stats-hero-kpis strong,
.source-kpis strong {
  color: var(--ink);
  font-size: 1.1rem;
  line-height: 1;
  overflow-wrap: anywhere;
}

.source-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.source-card {
  display: grid;
  gap: 14px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(17, 25, 29, 0.06);
}

.source-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.source-card h3 {
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.source-card small {
  color: var(--muted);
  font-weight: 700;
}

.source-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.source-kpis span { min-height: 54px; }

.source-kpis small {
  font-size: 0.72rem;
  text-transform: uppercase;
}

.category-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.category-chips span {
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 8px;
  color: #34444e;
  background: #f8fafb;
  font-size: 0.74rem;
  font-weight: 800;
}

.compact-action {
  min-height: 30px;
  padding: 0 10px;
  font-size: 0.78rem;
  white-space: nowrap;
}

.trend-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
}

.segmented-control {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.segmented-control button {
  min-height: 38px;
  border: 0;
  border-right: 1px solid var(--line);
  padding: 0 12px;
  color: var(--brand);
  background: #ffffff;
  font-weight: 800;
  cursor: pointer;
}

.segmented-control button:last-child { border-right: 0; }

.segmented-control button.active {
  color: #ffffff;
  background: var(--brand);
}

.trend-toolbar select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  color: var(--ink);
  background: #ffffff;
  font-weight: 700;
}

.risk-period-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(17, 25, 29, 0.06);
}

.period-actions,
.period-slicers {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.period-slicers label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 850;
  text-transform: uppercase;
}

.period-slicers select {
  min-width: 118px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  color: var(--ink);
  background: #ffffff;
  font-weight: 750;
  text-transform: none;
}

.secondary-action:disabled {
  color: #9ba8af;
  background: #eef2f4;
  cursor: not-allowed;
}

.trend-chart-wrap {
  display: grid;
  position: relative;
  gap: 12px;
  padding: 16px;
}

.trend-chart {
  width: 100%;
  min-height: 320px;
}

.trend-chart line {
  stroke: var(--line);
  stroke-width: 1;
}

.trend-chart text {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.trend-hit-point {
  fill: transparent;
  stroke: transparent;
  cursor: crosshair;
  pointer-events: all;
}

.trend-hit-point:focus {
  outline: none;
  stroke: var(--gold);
  stroke-width: 2;
}

.trend-tooltip {
  position: fixed;
  z-index: 2147483647;
  max-width: min(260px, calc(100% - 28px));
  border: 1px solid rgba(17, 25, 29, 0.16);
  border-radius: 7px;
  padding: 9px 10px;
  color: #ffffff;
  background: rgba(17, 25, 29, 0.94);
  box-shadow: 0 12px 28px rgba(17, 25, 29, 0.22);
  font-size: 0.78rem;
  font-weight: 750;
  line-height: 1.45;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.trend-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.trend-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.trend-legend button {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  color: #34444e;
  background: #ffffff;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}

.trend-legend span {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.trend-list {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.trend-list button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px;
  color: var(--ink);
  background: #ffffff;
  text-align: left;
  cursor: pointer;
}

.trend-list button.active {
  border-color: var(--brand);
  background: #eef5f7;
}

.trend-list button.trend-clear {
  border-color: rgba(198, 154, 58, 0.45);
  background: #fff9ec;
}

.trend-list span,
.trend-list small {
  overflow-wrap: anywhere;
}

.trend-list small {
  color: var(--muted);
}

.trend-list strong {
  grid-row: 1 / span 2;
  grid-column: 2;
  align-self: center;
  color: var(--brand);
}

.metric-card,
.workspace {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 30px rgba(17, 25, 29, 0.06);
}

.metric-card {
  min-height: 120px;
  padding: 18px;
}

.metric-label,
.metric-card small {
  color: var(--muted);
}

.metric-card strong {
  display: block;
  margin: 12px 0 8px;
  font-size: 1.8rem;
  line-height: 1;
  overflow-wrap: anywhere;
}

.workspace {
  overflow: hidden;
}

.loading-panel {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 10px;
  min-height: 260px;
  padding: 36px 18px;
  text-align: center;
}

.loading-panel strong {
  color: var(--ink);
}

.loading-panel small {
  color: var(--muted);
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #d9e2e6;
  border-top-color: var(--brand);
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.primary-action,
.secondary-action {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 7px;
  cursor: pointer;
}

.primary-action {
  border: 0;
  color: #ffffff;
  background: var(--brand);
}

.secondary-action {
  border: 1px solid var(--line);
  color: var(--brand);
  background: #ffffff;
}

.primary-action:hover { background: var(--brand-strong); }

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
}

th, td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

tbody tr:last-child td { border-bottom: 0; }

.status {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 800;
}

.status.review { color: var(--warn); background: #fff1db; }
.status.clear { color: var(--good); background: #ddf3eb; }
.status.blocked { color: var(--danger); background: #ffe3e3; }

.text-link {
  border: 0;
  padding: 0;
  color: var(--brand);
  background: transparent;
  font-weight: 800;
  cursor: pointer;
}

.text-link.selected { color: var(--gold); }

.insight-list {
  display: grid;
  gap: 10px;
  max-height: 680px;
  overflow: auto;
  padding-right: 4px;
}

.insight-panel {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.insight-panel h3 {
  margin: 0;
  font-size: 0.96rem;
}

.insight-panel small {
  color: #75838b;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.insight-panel p {
  margin: 0;
  color: #34444e;
  line-height: 1.55;
}

.warning-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.warning-list span {
  min-height: 28px;
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--warn);
  background: #fff1db;
  font-size: 0.76rem;
  font-weight: 800;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 18px;
}

.tag-list span {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 11px;
  color: #34444e;
  background: #f8fafb;
  font-size: 0.82rem;
  font-weight: 800;
}

.empty-state {
  padding: 24px;
  color: var(--muted);
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .app-shell.nav-open::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 20;
    background: rgba(17, 25, 29, 0.46);
  }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: min(84vw, 320px);
    gap: 14px;
    padding: 14px;
    overflow: auto;
    transform: translateX(-100%);
    transition: transform 180ms ease;
  }
  .app-shell.nav-open .sidebar { transform: translateX(0); }
  .menu-toggle { display: inline-flex; }
  .topbar { align-items: center; }
  .nav-list { grid-template-columns: 1fr; }
  .nav-item, .nav-section-toggle { text-align: left; }
  .content-grid, .content-grid-three { grid-template-columns: 1fr; }
  .risk-period-toolbar { align-items: stretch; flex-direction: column; }
  .stats-hero { align-items: stretch; flex-direction: column; }
  .source-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-grid, .metric-grid-four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 580px) {
  .main-panel { padding: 16px 12px; }
  .topbar { align-items: flex-start; flex-wrap: wrap; }
  .topbar-title { flex: 1 1 calc(100% - 56px); }
  .top-actions { justify-content: flex-start; }
  .nav-list { grid-template-columns: 1fr; }
  .period-actions,
  .period-slicers { width: 100%; }
  .period-slicers label { flex: 1 1 120px; }
  .stats-hero-kpis,
  .source-grid,
  .source-kpis { grid-template-columns: 1fr; }
  .metric-grid, .metric-grid-four { grid-template-columns: 1fr; }
  h1 { font-size: 1.5rem; }
}
