:root {
  --sdaia-teal: #00ae8d;
  --sdaia-navy: #1c355e;
  --sdaia-coral: #e96852;
  --sdaia-green: #6abf4b;
  --sdaia-cyan: #00c1de;
  --sdaia-amber: #ffb548;
  --sdaia-purple: #625d9c;
  --sdaia-black: #101820;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #d9e0ea;
  --line-strong: #b8c2d1;
  --text: #172033;
  --muted: #5c687a;
  --muted-2: #7b8594;
  --danger: #9e3224;
  --shadow: 0 10px 22px rgba(16, 24, 32, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

a {
  color: var(--sdaia-navy);
  text-decoration: none;
}

a:hover {
  color: var(--sdaia-teal);
  text-decoration: underline;
}

button,
input,
select {
  font: inherit;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  color: var(--sdaia-black);
  font-size: 26px;
  font-weight: 760;
  line-height: 1.15;
}

h2 {
  color: var(--sdaia-black);
  font-size: 17px;
  font-weight: 720;
  line-height: 1.2;
}

.eyebrow,
.metric-label,
.section-label,
.filter-bar span,
.inline-label {
  color: var(--sdaia-navy);
  font-size: 11px;
  font-weight: 780;
  letter-spacing: 0;
  text-transform: uppercase;
}

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 18px 28px 12px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-main {
  align-items: center;
  display: flex;
  gap: 20px;
  justify-content: space-between;
}

.header-actions,
.filter-actions,
.inline-controls {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.app-message {
  color: var(--muted);
  min-height: 18px;
  padding-top: 8px;
}

.app-message.error {
  color: var(--danger);
  font-weight: 650;
}

.dashboard-shell {
  display: grid;
  gap: 16px;
  padding: 18px 28px 32px;
}

.button {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  font-weight: 720;
  justify-content: center;
  min-height: 34px;
  padding: 7px 12px;
}

.button.primary {
  background: var(--sdaia-teal);
  color: #ffffff;
}

.button.primary:hover {
  background: #058f77;
  text-decoration: none;
}

.button.secondary {
  background: #eef3f7;
  border-color: var(--line);
  color: var(--sdaia-navy);
}

.button.secondary:hover {
  background: #e2eaf2;
  text-decoration: none;
}

.chip {
  align-items: center;
  background: #eef3f7;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--sdaia-navy);
  display: inline-flex;
  font-size: 12px;
  font-weight: 760;
  min-height: 26px;
  padding: 4px 9px;
  white-space: nowrap;
}

.chip-live {
  background: #e3f7f2;
  border-color: rgba(0, 174, 141, 0.28);
  color: #00745f;
}

.chip-static {
  background: #f2effb;
  border-color: rgba(98, 93, 156, 0.28);
  color: #46417f;
}

.chip-warning,
.chip-blocked {
  background: #fff1de;
  border-color: rgba(255, 181, 72, 0.45);
  color: #8a5700;
}

.chip-error {
  background: #fde9e6;
  border-color: rgba(233, 104, 82, 0.35);
  color: var(--danger);
}

.metric-strip {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
}

.metric-tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--sdaia-cyan);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(16, 24, 32, 0.04);
  min-height: 88px;
  padding: 12px 14px;
}

.metric-tile:nth-child(2) {
  border-left-color: var(--sdaia-green);
}

.metric-tile:nth-child(3) {
  border-left-color: var(--sdaia-purple);
}

.metric-tile:nth-child(4) {
  border-left-color: var(--sdaia-teal);
}

.metric-tile:nth-child(5) {
  border-left-color: var(--sdaia-amber);
}

.metric-tile:nth-child(6) {
  border-left-color: var(--sdaia-coral);
}

.metric-tile strong {
  color: var(--sdaia-black);
  display: block;
  font-size: 27px;
  font-weight: 800;
  line-height: 1.05;
  margin: 6px 0 3px;
}

.metric-tile span:last-child,
.record-detail dd,
.empty-note {
  color: var(--muted);
  font-size: 12px;
}

.filter-bar {
  align-items: end;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(8, minmax(120px, 1fr));
  padding: 12px;
}

.filter-bar label {
  display: grid;
  gap: 5px;
}

.wide-filter {
  grid-column: span 2;
}

input,
select {
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--text);
  min-height: 34px;
  padding: 7px 9px;
  width: 100%;
}

input:focus,
select:focus,
button:focus-visible {
  border-color: var(--sdaia-teal);
  outline: 2px solid rgba(0, 174, 141, 0.18);
  outline-offset: 1px;
}

.check-control {
  align-items: center;
  display: flex;
  gap: 7px;
  min-height: 34px;
  white-space: nowrap;
}

.check-control input {
  height: 16px;
  min-height: 16px;
  width: 16px;
}

.quick-actions {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  overflow: hidden;
}

.quick-action {
  background: var(--surface);
  border: 0;
  border-right: 1px solid var(--line);
  color: var(--sdaia-navy);
  cursor: pointer;
  font-weight: 760;
  min-height: 38px;
  padding: 8px 14px;
}

.quick-action:last-child {
  border-right: 0;
}

.quick-action.active {
  background: var(--sdaia-navy);
  color: #ffffff;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.panel-header {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  min-height: 66px;
  padding: 12px 14px;
}

.compact-header {
  min-height: 60px;
}

.panel-toolbar {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
}

.workspace-grid {
  align-items: start;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(260px, 0.75fr) minmax(0, 1.75fr) minmax(280px, 0.9fr);
}

.source-panel,
.detail-panel {
  position: sticky;
  top: 94px;
}

.coverage-grid {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  padding: 12px 14px;
}

.section-label {
  color: var(--muted);
  margin-bottom: 7px;
}

.mini-chart {
  display: grid;
  gap: 7px;
  min-height: 44px;
}

.mini-row {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(92px, 0.45fr) minmax(70px, 1fr) 54px;
  min-height: 22px;
}

.mini-label {
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-track {
  background: #edf2f6;
  border-radius: 999px;
  height: 9px;
  overflow: hidden;
}

.mini-fill {
  background: var(--sdaia-teal);
  height: 100%;
  min-width: 2px;
}

.mini-row:nth-child(2n) .mini-fill {
  background: var(--sdaia-cyan);
}

.mini-row:nth-child(3n) .mini-fill {
  background: var(--sdaia-green);
}

.mini-row:nth-child(5n) .mini-fill {
  background: var(--sdaia-amber);
}

.mini-value {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.table-wrap {
  max-width: 100%;
  overflow: auto;
}

.table-wrap.tall {
  max-height: 560px;
}

.source-list-wrap {
  max-height: 428px;
}

.records-table-wrap {
  max-height: 590px;
}

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

.source-list-wrap table {
  min-width: 430px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  position: sticky;
  text-transform: uppercase;
  top: 0;
  z-index: 1;
}

td {
  color: var(--text);
  font-size: 12px;
  line-height: 1.35;
}

tbody tr:hover,
.click-row:focus {
  background: #f2fbf8;
}

.click-row {
  cursor: pointer;
}

.click-row.active,
.click-row.selected {
  background: #eaf8f5;
  box-shadow: inset 3px 0 0 var(--sdaia-teal);
}

.numeric {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.muted {
  color: var(--muted);
}

.strong {
  color: var(--sdaia-black);
  font-weight: 760;
}

.source-cell,
.metric-cell {
  max-width: 260px;
  overflow-wrap: anywhere;
}

.record-detail {
  padding: 12px 14px;
}

.detail-grid {
  display: grid;
  gap: 7px 12px;
  grid-template-columns: minmax(92px, 0.42fr) minmax(0, 1fr);
  margin: 0;
}

.detail-grid dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-grid dd {
  color: var(--text);
  margin: 0;
  overflow-wrap: anywhere;
}

.detail-link {
  border-top: 1px solid var(--line);
  margin-top: 12px;
  padding-top: 10px;
}

.raw-json {
  background: #111827;
  border: 0;
  border-radius: 0 0 6px 6px;
  color: #dbeafe;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  line-height: 1.45;
  margin: 0;
  max-height: 360px;
  overflow: auto;
  padding: 12px 14px;
  white-space: pre-wrap;
}

.inline-controls input {
  min-width: 180px;
  width: 240px;
}

.warning-panel {
  border-left: 4px solid var(--sdaia-coral);
}

.warning-list {
  display: grid;
  gap: 8px;
  max-height: 300px;
  overflow: auto;
  padding: 12px 14px;
}

.warning-item {
  align-items: start;
  border: 1px solid #f3c4ba;
  border-radius: 6px;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(170px, 0.22fr) minmax(0, 1fr) auto;
  padding: 10px;
}

.warning-source {
  color: var(--sdaia-black);
  font-weight: 760;
  margin-top: 5px;
  overflow-wrap: anywhere;
}

.warning-reason {
  color: var(--muted);
  line-height: 1.35;
}

.empty-row td,
.empty-note {
  color: var(--muted-2);
  font-style: italic;
  padding: 14px;
}

@media (max-width: 1380px) {
  .metric-strip {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

  .filter-bar {
    grid-template-columns: repeat(4, minmax(130px, 1fr));
  }

  .workspace-grid {
    grid-template-columns: minmax(250px, 0.85fr) minmax(0, 1.6fr);
  }

  .detail-panel {
    grid-column: 1 / -1;
    position: static;
  }

  .source-panel {
    top: 94px;
  }
}

@media (max-width: 980px) {
  .workspace-grid,
  .coverage-grid {
    grid-template-columns: 1fr;
  }

  .source-panel {
    position: static;
  }

  .filter-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .wide-filter,
  .filter-actions {
    grid-column: span 2;
  }
}

@media (max-width: 720px) {
  .app-header,
  .dashboard-shell {
    padding-left: 14px;
    padding-right: 14px;
  }

  .header-main,
  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions,
  .inline-controls,
  .filter-actions {
    align-items: stretch;
  }

  .metric-strip,
  .filter-bar {
    grid-template-columns: 1fr;
  }

  .wide-filter,
  .filter-actions {
    grid-column: auto;
  }

  .quick-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-action {
    border-bottom: 1px solid var(--line);
  }

  .mini-row {
    grid-template-columns: minmax(96px, 0.45fr) minmax(80px, 1fr) 58px;
  }

  .inline-controls input {
    min-width: 0;
    width: 100%;
  }

  .warning-item {
    grid-template-columns: 1fr;
  }
}
