:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #607086;
  --line: #d9e0e8;
  --paper: #f4f6f8;
  --panel: #ffffff;
  --brand: #c74634;
  --brand-hover: #a83a2b;
  --teal: #287a7e;
  --gold: #b47a15;
  --danger: #b42318;
  --topbar: #20252d;
  --input-bg: #ffffff;
  --input-hover: #f8fafc;
  --soft-bg: #eef2f6;
  --soft-hover: #e2e8f0;
  --table-grid: #dfe7f0;
  --table-head-bg: #f4f8fc;
  --table-filter-bg: #f8fafc;
  --meter-track: #d9e0e8;
  --row-base: #ffffff;
  --tooltip-bg: #172033;
  --tooltip-ink: #ffffff;
  --disabled-bg: #94a3b8;
  --disabled-ink: #eef2f6;
  --shadow: rgb(23 32 51 / 0.18);
  --footer-bg: #ffffff;
  --controls-gradient: linear-gradient(135deg, #ffffff 0%, #d9f0f2 44%, #ffd4c2 100%);
  --dropdown-gradient: linear-gradient(135deg, #ffffff 0%, #eef7fb 52%, #fff1dc 100%);
  --summary-gradient-1: linear-gradient(135deg, #f2f9ff 0%, #c6e5ff 48%, #b8edd1 100%);
  --summary-gradient-2: linear-gradient(135deg, #f3f5ff 0%, #cbd6ff 45%, #b8efff 100%);
  --summary-gradient-3: linear-gradient(135deg, #f4fbe8 0%, #c8efaf 45%, #ffe391 100%);
  --summary-gradient-4: linear-gradient(135deg, #fff8df 0%, #ffe098 45%, #ffc4aa 100%);
  --summary-gradient-5: linear-gradient(135deg, #fff0ee 0%, #ffc8c4 45%, #ffb4ca 100%);
  --summary-gradient-6: linear-gradient(135deg, #f1f7ff 0%, #c7dcff 45%, #d0c3ff 100%);
  --region-gradient: linear-gradient(135deg, #ffffff 0%, #e4f5f0 42%, #dcecff 100%);
  --limits-gradient: linear-gradient(135deg, #ffffff 0%, #eaf7de 44%, #d9efff 100%);
  --errors-gradient: linear-gradient(135deg, #ffffff 0%, #ffe8df 42%, #ffdfe6 100%);
}

body[data-theme="light"] {
  --ink: #111827;
  --muted: #5f6f83;
  --line: #d7dee8;
  --paper: #f6f8fb;
  --panel: #ffffff;
  --brand: #2563eb;
  --brand-hover: #1d4ed8;
  --teal: #0f766e;
  --gold: #b7791f;
  --danger: #b42318;
  --topbar: #263241;
  --controls-gradient: linear-gradient(135deg, #ffffff 0%, #e5efff 44%, #eaf7ef 100%);
  --dropdown-gradient: linear-gradient(135deg, #ffffff 0%, #eef5ff 52%, #f2f7fb 100%);
  --summary-gradient-1: linear-gradient(135deg, #ffffff 0%, #dbeafe 48%, #d9f7e7 100%);
  --summary-gradient-2: linear-gradient(135deg, #f8fbff 0%, #cfe0ff 45%, #e0e7ff 100%);
  --summary-gradient-3: linear-gradient(135deg, #f8fffb 0%, #c9f0d8 45%, #d7eafe 100%);
  --summary-gradient-4: linear-gradient(135deg, #fffdf4 0%, #fde7a4 45%, #dbeafe 100%);
  --summary-gradient-5: linear-gradient(135deg, #fff7f7 0%, #ffd1d1 45%, #e2e8f0 100%);
  --summary-gradient-6: linear-gradient(135deg, #f8fbff 0%, #d5e3ff 45%, #d7f0ff 100%);
  --region-gradient: linear-gradient(135deg, #ffffff 0%, #edf5ff 42%, #ecfdf3 100%);
  --limits-gradient: linear-gradient(135deg, #ffffff 0%, #eff6ff 44%, #f0fdf4 100%);
  --errors-gradient: linear-gradient(135deg, #ffffff 0%, #fff1f2 42%, #fee2e2 100%);
}

body[data-theme="ocean"] {
  --ink: #12313d;
  --muted: #517084;
  --line: #c9dce4;
  --paper: #eef6f8;
  --brand: #0f766e;
  --brand-hover: #115e59;
  --teal: #0e7490;
  --gold: #b7791f;
  --danger: #b42318;
  --topbar: #0f2733;
  --controls-gradient: linear-gradient(135deg, #ffffff 0%, #cbeff3 44%, #d2f5df 100%);
  --dropdown-gradient: linear-gradient(135deg, #ffffff 0%, #e8f7fb 52%, #e4f8ef 100%);
  --summary-gradient-1: linear-gradient(135deg, #f4fbff 0%, #bfe7f2 48%, #c3f0dc 100%);
  --summary-gradient-2: linear-gradient(135deg, #eff9ff 0%, #9edeee 45%, #aae7f5 100%);
  --summary-gradient-3: linear-gradient(135deg, #f0fff8 0%, #a6ead2 45%, #bfead4 100%);
  --summary-gradient-4: linear-gradient(135deg, #f5fbff 0%, #afd6ff 45%, #9fc9f5 100%);
  --summary-gradient-5: linear-gradient(135deg, #fff5f1 0%, #ffc6b0 45%, #ffb2c0 100%);
  --summary-gradient-6: linear-gradient(135deg, #f0fbff 0%, #a9ddea 45%, #b6d6ff 100%);
  --region-gradient: linear-gradient(135deg, #ffffff 0%, #d9f4ef 42%, #cbe7ff 100%);
  --limits-gradient: linear-gradient(135deg, #ffffff 0%, #daf4df 44%, #c7ecff 100%);
  --errors-gradient: linear-gradient(135deg, #ffffff 0%, #ffe6d9 42%, #ffd9df 100%);
}

body[data-theme="forest"] {
  --ink: #1f2f24;
  --muted: #5b6f60;
  --line: #d4dfd2;
  --paper: #f2f6ef;
  --brand: #2f7d32;
  --brand-hover: #27642b;
  --teal: #3d7c5c;
  --gold: #a36f16;
  --danger: #a83226;
  --topbar: #1e2d24;
  --controls-gradient: linear-gradient(135deg, #ffffff 0%, #dff1d5 44%, #f4dfb9 100%);
  --dropdown-gradient: linear-gradient(135deg, #ffffff 0%, #edf8e8 52%, #fff2db 100%);
  --summary-gradient-1: linear-gradient(135deg, #fbfff7 0%, #cfeaba 48%, #f1df9c 100%);
  --summary-gradient-2: linear-gradient(135deg, #f2fff0 0%, #b6df9f 45%, #b9e2b8 100%);
  --summary-gradient-3: linear-gradient(135deg, #fff9e9 0%, #f2d287 45%, #b8df8f 100%);
  --summary-gradient-4: linear-gradient(135deg, #f5fff2 0%, #c3e6a8 45%, #f0c978 100%);
  --summary-gradient-5: linear-gradient(135deg, #fff2ea 0%, #f5c09a 45%, #e4a792 100%);
  --summary-gradient-6: linear-gradient(135deg, #f0fff4 0%, #b8dfb8 45%, #cfdc91 100%);
  --region-gradient: linear-gradient(135deg, #ffffff 0%, #e1f3d8 42%, #d6eadc 100%);
  --limits-gradient: linear-gradient(135deg, #ffffff 0%, #e4f5ce 44%, #d8eedc 100%);
  --errors-gradient: linear-gradient(135deg, #ffffff 0%, #ffe8d1 42%, #ffd9cf 100%);
}

body[data-theme="sunset"] {
  --ink: #33221c;
  --muted: #806356;
  --line: #ead2c7;
  --paper: #fbf4ef;
  --brand: #c74634;
  --brand-hover: #a83a2b;
  --teal: #b65f4c;
  --gold: #b7791f;
  --danger: #a83226;
  --topbar: #35201c;
  --controls-gradient: linear-gradient(135deg, #ffffff 0%, #ffe3be 44%, #ffc0ad 100%);
  --dropdown-gradient: linear-gradient(135deg, #ffffff 0%, #fff0df 52%, #ffe1d9 100%);
  --summary-gradient-1: linear-gradient(135deg, #fff8ee 0%, #ffd7a8 48%, #ffb9aa 100%);
  --summary-gradient-2: linear-gradient(135deg, #fff4e7 0%, #ffc979 45%, #ffa98e 100%);
  --summary-gradient-3: linear-gradient(135deg, #fff6df 0%, #ffe08c 45%, #ffb66f 100%);
  --summary-gradient-4: linear-gradient(135deg, #fff0e6 0%, #ffbf91 45%, #ff8f84 100%);
  --summary-gradient-5: linear-gradient(135deg, #fff0f1 0%, #ffaaa9 45%, #ff9ec1 100%);
  --summary-gradient-6: linear-gradient(135deg, #fff2e8 0%, #ffc08b 45%, #f4a9d4 100%);
  --region-gradient: linear-gradient(135deg, #ffffff 0%, #ffe9cf 42%, #ffd6c7 100%);
  --limits-gradient: linear-gradient(135deg, #ffffff 0%, #fff0ca 44%, #ffd4ba 100%);
  --errors-gradient: linear-gradient(135deg, #ffffff 0%, #ffd7c8 42%, #ffc0d0 100%);
}

body[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e8edf5;
  --muted: #a9b6c7;
  --line: #334155;
  --paper: #0b1120;
  --panel: #111827;
  --brand: #f26a55;
  --brand-hover: #d95744;
  --teal: #2dd4bf;
  --gold: #f2b84b;
  --danger: #fb7185;
  --topbar: #060a12;
  --input-bg: #111827;
  --input-hover: #172033;
  --soft-bg: #1e293b;
  --soft-hover: #27364a;
  --table-grid: rgb(226 232 240 / 0.24);
  --table-head-bg: rgb(226 232 240 / 0.08);
  --table-filter-bg: #111827;
  --meter-track: #334155;
  --row-base: #111827;
  --tooltip-bg: #e8edf5;
  --tooltip-ink: #0b1120;
  --disabled-bg: #475569;
  --disabled-ink: #cbd5e1;
  --shadow: rgb(0 0 0 / 0.42);
  --footer-bg: #0f172a;
  --controls-gradient: linear-gradient(135deg, #111827 0%, #173040 44%, #3a1d2a 100%);
  --dropdown-gradient: linear-gradient(135deg, #111827 0%, #17283b 52%, #241f38 100%);
  --summary-gradient-1: linear-gradient(135deg, #101827 0%, #173b52 48%, #164838 100%);
  --summary-gradient-2: linear-gradient(135deg, #111827 0%, #25345d 45%, #17465b 100%);
  --summary-gradient-3: linear-gradient(135deg, #101827 0%, #1e4d32 45%, #4d4320 100%);
  --summary-gradient-4: linear-gradient(135deg, #151827 0%, #58431e 45%, #552b25 100%);
  --summary-gradient-5: linear-gradient(135deg, #1d1420 0%, #5b242d 45%, #4c223d 100%);
  --summary-gradient-6: linear-gradient(135deg, #101827 0%, #263b63 45%, #3d315f 100%);
  --region-gradient: linear-gradient(135deg, #111827 0%, #102f2b 42%, #122640 100%);
  --limits-gradient: linear-gradient(135deg, #111827 0%, #1b3125 44%, #122940 100%);
  --errors-gradient: linear-gradient(135deg, #111827 0%, #3a1d1a 42%, #3b1d2b 100%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.topbar {
  min-height: 116px;
  background: var(--topbar);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(20px, 4vw, 48px);
  border-bottom: 5px solid var(--brand);
}

.brand-eyebrow {
  align-items: center;
  display: flex;
  gap: 10px;
  margin-bottom: 6px;
}

.brand-logo {
  display: block;
  height: 22px;
  width: auto;
}

.eyebrow {
  margin: 0;
  color: #c8d1dc;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  font-size: clamp(2rem, 4vw, 3.3rem);
  line-height: 1;
}

h2 {
  font-size: 1rem;
}

.download,
button {
  border: 0;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  min-height: 40px;
  padding: 10px 16px;
  text-decoration: none;
  cursor: pointer;
}

.download:hover,
button:hover {
  background: var(--brand-hover);
}

.download[aria-disabled="true"],
.download.download-disabled,
.download[aria-disabled="true"]:hover,
.download.download-disabled:hover {
  background: var(--disabled-bg);
  color: var(--disabled-ink);
  cursor: not-allowed;
  opacity: 0.75;
  pointer-events: none;
}

.downloads {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.theme-control {
  align-items: center;
  color: #c8d1dc;
  display: flex;
  font-size: 0.72rem;
  font-weight: 800;
  gap: 8px;
  min-width: 150px;
  min-height: 40px;
  text-transform: uppercase;
}

.theme-control select {
  background: var(--input-bg);
  border: 1px solid rgb(255 255 255 / 0.28);
  min-height: 40px;
  min-width: 132px;
  padding: 8px 10px;
  width: auto;
}

.layout {
  width: min(1500px, calc(100% - 32px));
  margin: 24px auto 48px;
}

.controls {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(200px, 1fr) minmax(220px, 1fr) minmax(150px, 0.75fr) minmax(220px, 1.2fr) auto auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
  background: var(--controls-gradient);
  border: 1px solid var(--line);
  border-radius: 8px;
}

body.scan-active .controls {
  border-color: color-mix(in srgb, var(--brand) 34%, var(--line));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 10%, transparent);
}

.scan-banner {
  align-items: center;
  background: color-mix(in srgb, var(--brand) 10%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--brand) 36%, var(--line));
  border-left: 6px solid var(--brand);
  border-radius: 8px;
  box-shadow: 0 14px 34px color-mix(in srgb, var(--brand) 14%, transparent);
  display: flex;
  gap: 12px;
  margin-top: 12px;
  padding: 14px 16px;
}

.scan-banner > div {
  flex: 1;
  min-width: 0;
}

.scan-banner[hidden] {
  display: none;
}

.scan-banner strong {
  color: var(--ink);
  display: block;
  font-size: 1rem;
  line-height: 1.2;
}

.scan-banner > div > span {
  color: var(--muted);
  display: block;
  font-size: 0.9rem;
  margin-top: 2px;
}

.restored-notice {
  align-items: center;
  background: linear-gradient(135deg, color-mix(in srgb, var(--teal) 16%, var(--panel)) 0%, color-mix(in srgb, var(--gold) 12%, var(--panel)) 100%);
  border: 1px solid color-mix(in srgb, var(--teal) 38%, var(--line));
  border-left: 6px solid var(--teal);
  border-radius: 8px;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  margin-top: 12px;
  padding: 12px 14px;
}

.restored-notice[hidden] {
  display: none;
}

.restored-notice span {
  color: var(--ink);
  font-size: 0.94rem;
  font-weight: 800;
}

.restored-notice button {
  white-space: nowrap;
}

.scan-progress {
  background: color-mix(in srgb, var(--brand) 12%, var(--input-bg));
  border: 1px solid color-mix(in srgb, var(--brand) 28%, var(--line));
  border-radius: 999px;
  height: 12px;
  margin-top: 10px;
  overflow: hidden;
}

.scan-progress span {
  background: linear-gradient(90deg, var(--brand), color-mix(in srgb, var(--brand) 62%, var(--gold)));
  border-radius: inherit;
  display: block;
  height: 100%;
  transition: width 220ms ease;
  width: 0%;
}

.scan-spinner {
  animation: scan-spin 900ms linear infinite;
  border: 3px solid color-mix(in srgb, var(--brand) 20%, transparent);
  border-top-color: var(--brand);
  border-radius: 999px;
  flex: 0 0 auto;
  height: 30px;
  width: 30px;
}

button:disabled {
  cursor: progress;
  opacity: 0.72;
}

label {
  color: var(--muted);
  display: grid;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.field {
  display: grid;
  gap: 6px;
}

.field-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--ink);
  min-height: 40px;
  padding: 9px 10px;
}

.checkbox-label {
  align-items: center;
  color: var(--ink);
  display: flex;
  gap: 8px;
  min-height: 40px;
  text-transform: none;
}

.checkbox-label input {
  width: 18px;
  min-height: 18px;
}

.tooltip {
  align-items: center;
  background: var(--soft-bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 0.75rem;
  font-weight: 800;
  height: 20px;
  justify-content: center;
  position: relative;
  width: 20px;
}

.tooltip::after {
  background: var(--tooltip-bg);
  border-radius: 6px;
  bottom: calc(100% + 8px);
  color: var(--tooltip-ink);
  content: attr(aria-label);
  font-size: 0.78rem;
  font-weight: 500;
  left: 50%;
  line-height: 1.35;
  opacity: 0;
  padding: 8px 10px;
  pointer-events: none;
  position: absolute;
  text-transform: none;
  transform: translateX(-50%);
  transition: opacity 120ms ease;
  visibility: hidden;
  width: 280px;
  z-index: 30;
}

.tooltip:hover::after,
.tooltip:focus::after {
  opacity: 1;
  visibility: visible;
}

.multi-select {
  position: relative;
}

.multi-trigger {
  align-items: center;
  background: var(--input-bg);
  border: 1px solid var(--line);
  color: var(--ink);
  display: flex;
  gap: 10px;
  justify-content: space-between;
  min-height: 40px;
  padding: 9px 10px;
  width: 100%;
}

.multi-trigger:hover {
  background: var(--input-hover);
}

.chevron {
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--muted);
  flex: 0 0 auto;
}

.multi-menu {
  background: var(--dropdown-gradient);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 42px var(--shadow);
  left: 0;
  max-height: 360px;
  min-width: 100%;
  overflow: hidden;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
}

.multi-actions {
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 8px;
  padding: 8px;
}

.multi-actions button {
  background: var(--soft-bg);
  color: var(--ink);
  min-height: 32px;
  padding: 6px 10px;
}

.multi-actions button:hover {
  background: var(--soft-hover);
}

.multi-search-wrap {
  border-bottom: 1px solid var(--line);
  padding: 8px;
}

.multi-search {
  background: var(--input-bg);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 0.88rem;
  min-height: 34px;
  padding: 7px 9px;
  width: 100%;
}

.multi-search:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgb(37 99 235 / 0.15);
  outline: none;
}

.multi-search:disabled {
  background: var(--table-filter-bg);
  color: var(--muted);
}

.multi-options {
  max-height: 250px;
  overflow-y: auto;
  padding: 6px;
}

.multi-option {
  align-items: flex-start;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  gap: 10px;
  padding: 8px;
  text-transform: none;
}

.multi-option:hover {
  background: var(--input-hover);
}

.multi-option input {
  flex: 0 0 auto;
  margin-top: 2px;
  min-height: 16px;
  width: 16px;
}

.multi-option-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.multi-option-text strong,
.multi-option-text small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multi-option-text strong {
  font-size: 0.9rem;
  font-weight: 700;
}

.multi-option-text small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.multi-empty {
  color: var(--muted);
  padding: 12px;
}

.controls [data-multi-select="regions"] .multi-menu {
  max-width: calc(100vw - 40px);
  right: auto;
  width: min(520px, calc(100vw - 40px));
}

.controls [data-multi-select="services"] .multi-menu,
.controls [data-multi-select="limits"] .multi-menu {
  max-width: calc(100vw - 40px);
  right: auto;
  width: min(720px, calc(100vw - 40px));
}

.controls [data-multi-select="regions"] .multi-option-text strong {
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
}

.controls [data-multi-select="services"] .multi-option-text strong,
.controls [data-multi-select="limits"] .multi-option-text strong,
.controls [data-multi-select="limits"] .multi-option-text small {
  line-height: 1.35;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

.summary {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 16px;
  margin: 16px 0;
}

.summary article,
.metrics-section,
.region-section,
.limits-section,
.errors-section {
  border: 1px solid var(--line);
  border-radius: 8px;
}

.summary article {
  background: var(--summary-gradient-1);
  padding: 18px;
}

.summary article:nth-child(2) {
  background: var(--summary-gradient-2);
}

.summary article:nth-child(3) {
  background: var(--summary-gradient-3);
}

.summary article:nth-child(4) {
  background: var(--summary-gradient-4);
}

.summary article:nth-child(5) {
  background: var(--summary-gradient-5);
}

.summary article:nth-child(6) {
  background: var(--summary-gradient-6);
}

.region-section {
  background: var(--region-gradient);
}

.limits-section {
  background: var(--limits-gradient);
}

.errors-section {
  background: var(--errors-gradient);
}

.summary span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.summary strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  line-height: 1;
}

.metrics-section {
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--panel) 86%, var(--brand)) 0%, color-mix(in srgb, var(--panel) 82%, var(--teal)) 52%, color-mix(in srgb, var(--panel) 86%, var(--gold)) 100%);
  margin: 16px 0;
  overflow: hidden;
}

.metrics-section[hidden] {
  display: none;
}

.metrics-section .section-head {
  padding: 14px 18px;
}

#metricsNote {
  color: var(--muted);
  font-size: 0.85rem;
}

.metrics-board {
  display: grid;
  gap: 12px;
  grid-template-columns: 1.1fr 2fr;
  padding: 14px 18px 18px;
}

.metrics-board[hidden] {
  display: none;
}

.metric-lead,
.metric-card,
.metric-slowest,
.metric-operations {
  background: color-mix(in srgb, var(--panel) 78%, transparent);
  border: 1px solid color-mix(in srgb, var(--line) 76%, transparent);
  border-radius: 8px;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.24);
  min-width: 0;
  padding: 12px;
}

.metric-lead {
  display: flex;
  flex-direction: column;
  grid-row: span 2;
  min-height: 206px;
  position: relative;
}

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

.metric-card[data-tone="retrieved"] {
  border-color: color-mix(in srgb, var(--teal) 44%, var(--line));
}

.metric-card[data-tone="sent"] {
  border-color: color-mix(in srgb, var(--brand) 42%, var(--line));
}

.metric-card[data-tone="latency"] {
  border-color: color-mix(in srgb, var(--gold) 48%, var(--line));
}

.metric-card[data-tone="cache"] {
  border-color: color-mix(in srgb, var(--teal) 34%, var(--line));
}

.metric-card[data-tone="usage"] {
  border-color: color-mix(in srgb, var(--brand) 34%, var(--line));
}

.metric-card[data-tone="errors"] {
  border-color: color-mix(in srgb, var(--danger) 38%, var(--line));
}

.metric-lead span,
.metric-card span,
.metric-slowest span,
.metric-operations span,
.metric-lead small,
.metric-card small,
.metric-slowest small,
.metric-operations small {
  color: var(--muted);
  display: block;
}

.metric-lead span,
.metric-card span,
.metric-slowest span,
.metric-operations span {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-lead strong,
.metric-card strong,
.metric-slowest strong {
  color: var(--ink);
  display: block;
  font-size: 1.35rem;
  line-height: 1.1;
  margin-top: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metrics-section .metric-lead strong {
  font-size: clamp(3.4rem, 8vw, 5rem);
  margin-top: 24px;
}

.metrics-section .metric-lead small {
  font-size: 0.82rem;
}

.metric-lead small,
.metric-card small,
.metric-slowest small,
.metric-operations small {
  font-size: 0.76rem;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-slowest {
  align-items: flex-start;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.metric-operations {
  display: grid;
  gap: 10px;
  grid-column: 1 / -1;
  grid-template-columns: minmax(150px, 0.35fr) 1fr;
}

.metric-operation-list {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.metric-operation-row {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.metric-operation-row > span,
.metric-operation-row > small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-operation-row > span {
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: none;
}

.metric-operation-track {
  background: color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: 999px;
  height: 6px;
  overflow: hidden;
}

.metric-operation-track span {
  background: linear-gradient(90deg, var(--brand), var(--teal));
  border-radius: inherit;
  display: block;
  height: 100%;
}

.metric-operation-empty {
  color: var(--muted);
  font-size: 0.84rem;
}

.limits-section,
.errors-section {
  margin-top: 16px;
}

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

.section-actions {
  align-items: center;
  display: flex;
  gap: 12px;
}

.secondary-button {
  background: var(--soft-bg);
  color: var(--ink);
  min-height: 34px;
  padding: 7px 12px;
}

.secondary-button:hover {
  background: var(--soft-hover);
}

.table-tools {
  align-items: flex-start;
}

.table-filter {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-end;
}

.table-tools .table-filter {
  flex: 1;
  justify-content: flex-start;
  padding-left: 24px;
}

.alert-controls {
  align-items: end;
  background: color-mix(in srgb, var(--brand) 8%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--brand) 28%, var(--line));
  border-left: 5px solid var(--brand);
  border-radius: 8px;
  box-shadow: 0 8px 18px color-mix(in srgb, var(--brand) 10%, transparent);
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  padding: 10px 12px;
}

.policy-control,
.threshold-control {
  color: var(--muted);
  display: grid;
  font-size: 0.72rem;
  font-weight: 800;
  gap: 4px;
  text-transform: uppercase;
}

.policy-control {
  color: var(--ink);
  font-size: 0.78rem;
}

.policy-control select {
  border-color: color-mix(in srgb, var(--brand) 34%, var(--line));
  font-weight: 800;
  min-height: 40px;
  min-width: 178px;
  padding: 8px 10px;
}

.policy-control select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
  outline: none;
}

.threshold-control {
  opacity: 0.9;
}

.threshold-input {
  align-items: center;
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex;
  gap: 6px;
  min-height: 34px;
  padding: 0 8px 0 0;
}

.threshold-input input {
  border: 0;
  min-height: 32px;
  padding: 6px 8px;
  width: 68px;
}

.threshold-input input:focus {
  outline: none;
}

.threshold-input:focus-within {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgb(37 99 235 / 0.15);
}

.threshold-input span {
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
}

.severity-chips {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}

.severity-chip {
  background: var(--soft-bg);
  border: 1px solid transparent;
  color: var(--ink);
  display: inline-flex;
  gap: 6px;
  min-height: 34px;
  padding: 7px 10px;
}

.severity-chip.critical {
  background: color-mix(in srgb, var(--danger) 10%, var(--panel));
  border-color: color-mix(in srgb, var(--danger) 42%, var(--line));
  color: var(--danger);
  font-weight: 900;
}

.severity-chip.warning {
  background: color-mix(in srgb, var(--gold) 14%, var(--panel));
  border-color: color-mix(in srgb, var(--gold) 46%, var(--line));
  color: color-mix(in srgb, var(--gold) 78%, var(--ink));
  font-weight: 900;
}

.severity-chip:hover {
  background: var(--soft-hover);
}

.severity-chip.active {
  background: var(--teal);
  color: #fff;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 18%, transparent);
}

.severity-chip.critical.active {
  background: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 22%, transparent);
}

.severity-chip.warning.active {
  background: var(--gold);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 24%, transparent);
}

.severity-chip.healthy.active {
  background: #237b4b;
}

.severity-chip.no-data.active {
  background: #64748b;
}

.severity-chip span {
  color: inherit;
  font-size: 0.76rem;
  font-weight: 800;
}

.table-filter > span {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

#statusText {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: right;
}

.source-badge {
  background: color-mix(in srgb, var(--soft-bg) 88%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  padding: 6px 10px;
  white-space: nowrap;
}

.source-badge[data-source="persistence"] {
  background: color-mix(in srgb, var(--teal) 18%, var(--panel));
  border-color: color-mix(in srgb, var(--teal) 44%, var(--line));
  color: var(--teal);
}

.source-badge[data-source="cache"],
.source-badge[data-source="restored"] {
  background: color-mix(in srgb, var(--gold) 18%, var(--panel));
  border-color: color-mix(in srgb, var(--gold) 44%, var(--line));
  color: color-mix(in srgb, var(--gold) 76%, var(--ink));
}

.source-badge[data-source="scanning"] {
  background: color-mix(in srgb, var(--brand) 14%, var(--panel));
  border-color: color-mix(in srgb, var(--brand) 36%, var(--line));
  color: var(--brand);
}

.source-badge[data-source="error"] {
  background: color-mix(in srgb, var(--danger) 14%, var(--panel));
  border-color: color-mix(in srgb, var(--danger) 38%, var(--line));
  color: var(--danger);
}

#statusText.status-scanning {
  color: var(--brand);
  font-weight: 900;
}

body.scan-active .summary article {
  animation: scan-card-pulse 1400ms ease-in-out infinite;
}

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

.region-section .table-wrap,
.limits-section .table-wrap {
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  box-shadow: inset 0 0 0 1px var(--table-grid);
}

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

.region-section table,
.limits-section table {
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  position: relative;
  text-transform: uppercase;
}

.region-section th,
.region-section td,
.limits-section th,
.limits-section td {
  border-bottom: 1px solid var(--table-grid);
  border-right: 1px solid var(--table-grid);
}

.region-section thead th,
.limits-section thead tr:first-child th {
  background: var(--table-head-bg);
}

.region-section th:last-child,
.region-section td:last-child,
.limits-section th:last-child,
.limits-section td:last-child {
  border-right: 0;
}

.filter-row th {
  background: var(--table-filter-bg);
  padding: 8px;
}

.limits-section .filter-row th {
  background: var(--table-filter-bg);
}

.column-resizer {
  bottom: 0;
  cursor: col-resize;
  position: absolute;
  right: -3px;
  top: 0;
  touch-action: none;
  width: 7px;
  z-index: 4;
}

.column-resizer::after {
  background: color-mix(in srgb, var(--table-grid) 72%, var(--muted));
  bottom: 7px;
  content: "";
  opacity: 0.55;
  position: absolute;
  right: 3px;
  top: 7px;
  width: 1px;
}

.column-resizer:hover::after,
.column-resizer:focus-visible::after,
body.column-resize-active .column-resizer::after {
  background: var(--brand);
  opacity: 0.9;
  width: 2px;
}

body.column-resize-active {
  cursor: col-resize;
  user-select: none;
}

.filter-row .multi-select {
  min-width: 130px;
}

.filter-row .multi-trigger {
  font-size: 0.8rem;
  min-height: 32px;
  padding: 6px 8px;
}

.filter-row .multi-menu {
  min-width: 240px;
}

.filter-row [data-column-filter="regionName"] .multi-menu,
.filter-row [data-column-filter="regionStatus"] .multi-menu {
  min-width: 320px;
}

.filter-row [data-column-filter="regionName"] .multi-option-text strong,
.filter-row [data-column-filter="regionStatus"] .multi-option-text strong {
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
}

.filter-row .multi-actions button {
  font-size: 0.72rem;
  min-height: 28px;
  padding: 5px 8px;
}

.filter-row .multi-search {
  font-size: 0.76rem;
  min-height: 30px;
  padding: 5px 7px;
}

.filter-row .multi-options {
  max-height: 210px;
}

.sort-button {
  align-items: center;
  background: transparent;
  border: 0;
  color: inherit;
  display: inline-flex;
  gap: 6px;
  justify-content: inherit;
  min-height: auto;
  padding: 0;
  text-align: inherit;
  text-transform: inherit;
}

.sort-button:hover {
  background: transparent;
  color: var(--ink);
}

.sort-button::after {
  color: #94a3b8;
  content: "↕";
  font-size: 0.72rem;
}

.sort-button[data-direction="asc"]::after {
  color: var(--brand);
  content: "↑";
}

.sort-button[data-direction="desc"]::after {
  color: var(--brand);
  content: "↓";
}

.region-coded {
  background: color-mix(in srgb, var(--region-color) 8%, var(--row-base));
}

.region-coded:hover {
  background: color-mix(in srgb, var(--region-color) 14%, var(--row-base));
}

.region-coded td:first-child {
  border-left: 5px solid var(--region-color);
}

.limits-section tr.limit-alert-warning td {
  background: color-mix(in srgb, var(--gold) 11%, var(--row-base));
}

.limits-section tr.limit-alert-critical td {
  background: color-mix(in srgb, var(--danger) 11%, var(--row-base));
}

.limits-section tr.limit-alert-warning:hover td {
  background: color-mix(in srgb, var(--gold) 17%, var(--row-base));
}

.limits-section tr.limit-alert-critical:hover td {
  background: color-mix(in srgb, var(--danger) 17%, var(--row-base));
}

.limits-section tr.limit-alert-warning td:first-child {
  border-left-color: var(--gold);
}

.limits-section tr.limit-alert-critical td:first-child {
  border-left-color: var(--danger);
}

.numeric {
  text-align: right;
}

.description-cell {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.usage-cell {
  min-width: 150px;
}

.usage-meter {
  align-items: center;
  border-radius: 7px;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(78px, 1fr) auto;
  min-width: 132px;
  padding: 4px 6px;
}

.usage-meter.usage-warning {
  background: color-mix(in srgb, var(--gold) 16%, var(--panel));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gold) 46%, var(--line));
}

.usage-meter.usage-critical {
  background: color-mix(in srgb, var(--danger) 14%, var(--panel));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 48%, var(--line));
}

.usage-meter-track {
  background: var(--meter-track);
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: 999px;
  height: 12px;
  overflow: hidden;
}

.usage-meter-fill {
  background: #237b4b;
  border-radius: inherit;
  display: block;
  height: 100%;
  width: var(--usage-pct, 0%);
}

.usage-warning .usage-meter-fill {
  background: var(--gold);
}

.usage-critical .usage-meter-fill {
  background: var(--danger);
}

.usage-no_data {
  display: block;
  min-width: 0;
}

.usage-meter-value {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.usage-warning .usage-meter-value {
  color: color-mix(in srgb, var(--gold) 72%, var(--ink));
  font-weight: 900;
}

.usage-critical .usage-meter-value {
  color: var(--danger);
  font-weight: 900;
}

.usage-no_data .usage-meter-value {
  color: var(--muted);
  font-weight: 700;
}

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

.usage-warn {
  color: var(--gold);
  font-weight: 800;
}

.usage-critical {
  color: var(--danger);
  font-weight: 800;
}

.danger {
  color: var(--danger);
  font-weight: 800;
}

.empty {
  color: var(--muted);
  text-align: center;
}

.app-footer {
  align-items: center;
  background: var(--footer-bg);
  border-top: 1px solid var(--line);
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.82rem;
  gap: 8px 14px;
  justify-content: center;
  margin-top: 32px;
  padding: 14px clamp(20px, 4vw, 48px);
}

.app-footer span {
  white-space: nowrap;
}

.app-footer strong {
  color: var(--ink);
}

.app-footer > span:not(:last-child)::after {
  color: var(--line);
  content: "|";
  margin-left: 14px;
}

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

@keyframes scan-card-pulse {
  0%,
  100% {
    filter: saturate(1);
  }

  50% {
    filter: saturate(1.2) brightness(1.03);
  }
}

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

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

  .metrics-board {
    grid-template-columns: 1fr;
  }

  .metric-lead {
    min-height: 180px;
  }

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

@media (max-width: 640px) {
  .topbar,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .controls,
  .summary,
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .metric-operations {
    grid-template-columns: 1fr;
  }

  .controls [data-multi-select="regions"] .multi-menu,
  .controls [data-multi-select="services"] .multi-menu,
  .controls [data-multi-select="limits"] .multi-menu {
    right: 0;
    width: 100%;
  }

  .table-filter {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  .restored-notice {
    align-items: stretch;
    flex-direction: column;
  }

  .alert-controls,
  .severity-chips {
    align-items: stretch;
    flex-direction: column;
  }

  .threshold-control,
  .policy-control,
  .policy-control select,
  .threshold-input,
  .severity-chip {
    width: 100%;
  }

  .app-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .app-footer span {
    white-space: normal;
  }

  .app-footer > span:not(:last-child)::after {
    content: "";
    margin-left: 0;
  }
}
