:root {
  --azure: #0078d4;
  --azure-light: #2b9bf4;
  --azure-bright: #50e6ff;
  --azure-deep: #0a4ea0;

  --bg: #060b16;
  --bg-elev: rgba(20, 30, 51, 0.66);
  --bg-elev-2: rgba(34, 48, 76, 0.58);
  --head-bg: #131f37;
  --border: rgba(120, 165, 230, 0.16);
  --border-strong: rgba(120, 165, 230, 0.30);
  --text: #e9f1fb;
  --text-dim: #94a8c7;
  --accent: #2b9bf4;
  --accent-dim: #1668b8;
  --accent-2: #50e6ff;
  --good: #2bd07a;
  --warn: #f4c531;
  --bad: #ff5d5d;
  --mid: #ff9f43;
  --grad: linear-gradient(135deg, #3aa0ff 0%, #0078d4 55%, #0a4ea0 100%);
  --grad-bright: linear-gradient(135deg, #50e6ff, #2b9bf4);
  --shadow: 0 14px 38px rgba(2, 8, 20, 0.5);
  --shadow-sm: 0 4px 14px rgba(2, 8, 20, 0.4);
  --radius: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(900px 520px at 85% -8%, rgba(0, 120, 212, 0.32), transparent 60%),
    radial-gradient(820px 620px at -5% 110%, rgba(80, 230, 255, 0.14), transparent 55%),
    linear-gradient(180deg, #08111f 0%, var(--bg) 60%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent-2);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Scrollbars */
* {
  scrollbar-color: rgba(120, 165, 230, 0.35) transparent;
  scrollbar-width: thin;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: rgba(120, 165, 230, 0.28);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(120, 165, 230, 0.45);
  background-clip: padding-box;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 26px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(9, 16, 31, 0.86), rgba(9, 16, 31, 0.62));
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-header__brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  display: block;
  box-shadow: 0 6px 20px rgba(0, 120, 212, 0.5);
}

.app-header h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: #fff;
}

.app-header h1 span {
  background: linear-gradient(90deg, #8cccff, #50e6ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.app-header h1 .beta-badge {
  display: inline-block;
  vertical-align: 3px;
  margin-left: 9px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--grad-bright);
  -webkit-background-clip: border-box;
  background-clip: border-box;
  color: #04243a;
  -webkit-text-fill-color: #04243a;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  box-shadow: 0 2px 9px rgba(80, 230, 255, 0.4);
}

.app-header p {
  margin: 3px 0 0;
  color: var(--text-dim);
  font-size: 12.5px;
}

.app-header__status {
  font-size: 12px;
  color: var(--text-dim);
  text-align: right;
  max-width: 360px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  padding: 7px 13px;
  border-radius: 999px;
  backdrop-filter: blur(6px);
}

.app-header__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
  padding: 20px 24px 48px;
  align-items: start;
}

/* Controls */
.controls {
  position: sticky;
  top: 92px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
}

.control-hint {
  margin: 2px 0 0;
  font-size: 11.5px;
  color: var(--text-dim);
}

select,
input[type="range"] {
  width: 100%;
}

select {
  appearance: none;
  background: var(--bg-elev-2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%2394a8c7' stroke-width='1.5' stroke-linecap='round' d='M3 4.5 6 7.5 9 4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 30px 10px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

select:hover {
  border-color: var(--border-strong);
}

select option {
  background: #131f37;
  color: var(--text);
}

select:focus,
.search-input:focus,
.tab:focus-visible,
.collapsible:focus-visible,
.mini-btn:focus-visible,
.segmented button:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(43, 155, 244, 0.32);
}

input[type="range"] {
  accent-color: var(--accent);
  cursor: pointer;
}

.slider-legend {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-dim);
}

.collapsible {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.collapsible:hover {
  border-color: var(--border-strong);
}

.collapsible[aria-expanded="false"] + .collapsible-body {
  display: none;
}

.collapsible-body {
  padding: 10px 2px 2px;
}

.chip {
  background: var(--grad-bright);
  color: #04243a;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 8px;
  min-width: 22px;
  text-align: center;
}

.search-input {
  width: 100%;
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  margin: 6px 0;
}

.search-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 280px;
  overflow: auto;
}

.checkbox-list .empty-mini {
  font-size: 12px;
  color: var(--text-dim);
  padding: 6px 4px;
}

.list-toolbar {
  display: flex;
  gap: 6px;
  margin: 2px 0 6px;
  flex-wrap: wrap;
}

.mini-btn {
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
}

.mini-btn:hover {
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 120, 212, 0.28);
}

.fam-group {
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
  margin-bottom: 4px;
}

.check-fam {
  font-weight: 600;
}

.check-fam input {
  accent-color: var(--accent);
}

.fam-skus {
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.panel-head__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: var(--bg-elev-2);
}

.segmented button {
  background: transparent;
  color: var(--text-dim);
  border: none;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.segmented button.is-active {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 120, 212, 0.35);
}

.check-cat {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin: 8px 0 2px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  padding: 3px 4px;
  border-radius: 6px;
  cursor: pointer;
}

.check-item:hover {
  background: var(--bg-elev-2);
}

.check-item input {
  accent-color: var(--accent);
}

/* Content */
.content {
  min-width: 0;
}

.tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.tab {
  background: var(--bg-elev-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
}

.tab:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.tab.is-active {
  color: #fff;
  border-color: transparent;
  background: var(--grad);
  box-shadow: 0 6px 16px rgba(0, 120, 212, 0.4);
}

.panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
}

.panel.is-hidden {
  display: none;
}

.panel-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(80, 230, 255, 0.05), transparent);
}

.panel-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.panel-sub {
  margin: 4px 0 0;
  color: var(--text-dim);
  font-size: 12.5px;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 240px);
}

.data-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 9px 12px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

.data-table thead th {
  position: sticky;
  top: 0;
  background: var(--head-bg);
  color: var(--text-dim);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  z-index: 5;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--border-strong);
}

.data-table thead th:hover {
  color: var(--text);
}

.data-table thead th.sticky-col,
.data-table tbody td.sticky-col {
  position: sticky;
  left: 0;
  background: var(--head-bg);
  z-index: 4;
}

.data-table thead th.sticky-col {
  z-index: 6;
  background: var(--head-bg);
}

.data-table tbody tr:hover td {
  background: rgba(43, 155, 244, 0.1);
}

.data-table tbody tr:hover td.sticky-col {
  background: #18253f;
}

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

.region-cell {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.region-cell strong {
  font-weight: 600;
}

.region-cell small {
  color: var(--text-dim);
  font-size: 11px;
}

.rank {
  font-weight: 700;
  color: var(--text-dim);
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
}

.badge--ref {
  background: rgba(80, 230, 255, 0.16);
  color: var(--accent-2);
}

.badge--az {
  background: rgba(43, 208, 122, 0.18);
  color: var(--good);
}

.badge--reco {
  background: rgba(244, 197, 49, 0.18);
  color: var(--warn);
}

.badge--legacy {
  background: rgba(148, 168, 199, 0.16);
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-size: 10px;
}

.score-bar {
  position: relative;
  height: 18px;
  width: 92px;
  background: rgba(120, 165, 230, 0.16);
  border-radius: 6px;
  overflow: hidden;
}

.score-bar > span {
  position: absolute;
  inset: 0;
  width: var(--w, 0%);
  background: var(--grad-bright);
  box-shadow: 0 0 12px rgba(80, 230, 255, 0.45);
}

.score-bar > em {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* color coding cells */
.lat-good { color: var(--good); }
.lat-mid { color: var(--warn); }
.lat-high { color: var(--mid); }
.lat-bad { color: var(--bad); }

.delta-cheaper { color: var(--good); font-weight: 600; }
.delta-pricier { color: var(--bad); font-weight: 600; }
.delta-same { color: var(--text-dim); }

.avail-yes { color: var(--good); font-weight: 700; }
.avail-no { color: var(--text-dim); opacity: 0.5; }
.avail-preview { color: var(--warn); font-weight: 700; }
.avail-global { color: var(--accent-2); font-weight: 700; }

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

.about {
  padding: 18px;
  font-size: 13.5px;
  color: var(--text);
}

.about h3 {
  margin: 18px 0 6px;
  font-size: 14px;
}

.about h4 {
  margin: 16px 0 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent-2);
}

.about ul {
  margin: 6px 0;
  padding-left: 18px;
}

.about li {
  margin: 4px 0;
}

.about .note {
  background: var(--bg-elev-2);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text-dim);
  margin: 12px 0;
}

.about .note--wip {
  border-left-color: var(--warn);
  color: var(--text);
}

.about .formula {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  color: var(--text);
}

.about code {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12.5px;
}

.about-table {
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.about-table th,
.about-table td {
  border: 1px solid var(--border);
  padding: 5px 10px;
  text-align: center;
}

.about-table thead th {
  background: var(--bg-elev-2);
  color: var(--text-dim);
  font-weight: 600;
}

.about-table tbody tr:first-child {
  background: rgba(43, 155, 244, 0.12);
}

.empty {
  padding: 28px;
  text-align: center;
  color: var(--text-dim);
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
  margin-right: 6px;
}

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

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bad);
  color: #fff;
  padding: 11px 18px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 50;
  font-size: 13px;
}

.toast.is-hidden {
  display: none;
}

.toast--ok {
  background: linear-gradient(135deg, #16a34a, #0e7a39);
}

@media (max-width: 920px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .controls {
    position: static;
  }
  .app-header__status {
    display: none;
  }
}
