:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-subtle: #f8fafc;
  --text: #0f172a;
  --text-muted: #475569;
  --text-light: #64748b;
  --link: #0066cc;
  --link-hover: #004999;
  --accent-bg: #eef5ff;
  --good-bg: #ecfdf5;
  --good-text: #065f46;
  --warn-bg: #fffbeb;
  --warn-text: #92400e;
  --bad-bg: #fef2f2;
  --bad-text: #991b1b;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 4px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

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

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

.page-shell {
  max-width: 1340px;
  margin: 0 auto;
  padding: 28px 24px 56px;
}

/* Hero */
.hero {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  box-shadow: var(--shadow-md);
  margin-bottom: 20px;
}

.hero-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-light);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--accent-bg);
  color: var(--link);
  font-size: 12px;
  font-weight: 600;
}

.hero h1 {
  margin: 0 0 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(26px, 3vw, 36px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--text);
}

.subtitle {
  margin: 0 0 22px;
  max-width: 880px;
  font-size: 15px;
  color: var(--text-muted);
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.kpi-card {
  background: var(--surface-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-light);
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Controls */
.controls-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.control-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-light);
  margin-bottom: 10px;
}

.preset-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preset-btn {
  appearance: none;
  border: none;
  background: var(--surface-subtle);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.preset-btn:hover {
  background: #e9eff7;
}

.preset-btn.active {
  background: var(--link);
  color: #ffffff;
}

.preset-desc {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 165px;
}

.search-field {
  flex: 1 1 220px;
}

.filter-field span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.filter-field input,
.filter-field select {
  height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--surface-subtle);
  color: var(--text);
  font-size: 14px;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.12);
}

.filter-field input:focus,
.filter-field select:focus {
  outline: 2px solid var(--link);
  outline-offset: 1px;
}

.toggle-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  user-select: none;
}

.toggle-field input {
  width: 16px;
  height: 16px;
  accent-color: var(--link);
}

.btn-secondary,
.btn-ghost {
  height: 38px;
  padding: 0 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-secondary {
  background: var(--surface-subtle);
  color: var(--text-muted);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: #e2e8f0;
  color: var(--text);
}

.btn-ghost {
  background: var(--accent-bg);
  color: var(--link);
}

.btn-ghost:hover {
  background: #dcebff;
}

/* Table Card */
.table-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
  overflow: hidden;
}

.table-header-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px 16px;
}

.table-header-bar h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  font-weight: 700;
}

.table-hint {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.country-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  min-width: 1020px;
}

.country-table thead th {
  background: var(--surface-subtle);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  text-align: left;
  padding: 12px 12px;
  white-space: nowrap;
  user-select: none;
  box-shadow: inset 0 -1px 0 rgba(15, 23, 42, 0.08);
}

.country-table thead th.num,
.country-table tbody td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.country-table thead th.sortable {
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.country-table thead th.sortable:hover {
  color: var(--link);
  background: #eff4fb;
}

.country-table thead th.sorted-asc::after {
  content: " ▲";
  color: var(--link);
  font-size: 10px;
}

.country-table thead th.sorted-desc::after {
  content: " ▼";
  color: var(--link);
  font-size: 10px;
}

.country-table tbody tr.data-row {
  cursor: pointer;
  transition: background 0.12s ease;
  box-shadow: inset 0 -1px 0 rgba(15, 23, 42, 0.06);
}

.country-table tbody tr.data-row:hover {
  background: #f8fbff;
}

.country-table tbody tr.data-row.expanded {
  background: #f1f7ff;
}

.country-table tbody td {
  padding: 13px 12px;
  vertical-align: middle;
}

.rank-num {
  font-weight: 700;
  color: var(--text-light);
  font-variant-numeric: tabular-nums;
}

.country-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.country-name-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  color: var(--text);
  font-size: 14.5px;
}

.iso-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 18px;
  border-radius: 4px;
  background: #e2e8f0;
  color: #334155;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

.country-region {
  font-size: 12px;
  color: var(--text-light);
}

.floor-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--good-bg);
  color: var(--good-text);
  margin-left: 2px;
  white-space: nowrap;
  flex-shrink: 0;
}

.score-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.score-pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}

.score-high {
  background: var(--good-bg);
  color: var(--good-text);
}

.score-mid {
  background: var(--accent-bg);
  color: var(--link);
}

.score-low {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.score-bar {
  width: 68px;
  height: 5px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--link);
}

.cell-main {
  font-weight: 600;
  color: var(--text);
}

.cell-sub {
  display: block;
  font-size: 11.5px;
  color: var(--text-light);
  margin-top: 2px;
}

.metric-good {
  color: var(--good-text);
}

.metric-warn {
  color: var(--warn-text);
}

.metric-bad {
  color: var(--bad-text);
}

.details-btn {
  appearance: none;
  border: none;
  background: var(--accent-bg);
  color: var(--link);
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.details-btn:hover {
  background: #d8e8ff;
}

/* Expandable Detail Drawer Row */
.detail-row td {
  padding: 0;
  background: #f8fafc;
  box-shadow: inset 0 -1px 0 rgba(15, 23, 42, 0.08);
}

.detail-panel {
  padding: 20px 24px 24px;
}

.mobile-scroll-hint {
  display: none;
  padding: 6px 16px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--link);
}

.detail-verdict {
  margin: 0 0 16px;
  padding: 12px 16px;
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  font-size: 14px;
  color: var(--text);
}

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

.detail-box {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

.detail-box h4 {
  margin: 0 0 8px;
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-light);
}

.detail-box ul {
  margin: 0;
  padding-left: 18px;
  font-size: 13.5px;
  color: var(--text-muted);
}

.detail-box li {
  margin-bottom: 6px;
}

.detail-box p {
  margin: 0 0 8px;
  font-size: 13.5px;
  color: var(--text-muted);
}

.detail-box p:last-child {
  margin-bottom: 0;
}

.subscore-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.subscore-chip {
  background: var(--surface);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  color: var(--text-muted);
  box-shadow: var(--shadow-sm);
  font-variant-numeric: tabular-nums;
}

.subscore-chip strong {
  color: var(--text);
}

.ref-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  font-size: 12.5px;
}

.ref-label {
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 11px;
}

.ref-link {
  color: var(--link);
  font-weight: 600;
}

/* Secondary Grid: Excluded & Blind Spots */
.secondary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.info-card,
.sources-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.section-head h2,
.sources-card h2 {
  margin: 0 0 6px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  font-weight: 700;
}

.section-head p,
.sources-intro {
  margin: 0 0 18px;
  font-size: 13.5px;
  color: var(--text-muted);
}

.excluded-list,
.blindspot-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.excluded-item,
.blindspot-item {
  background: var(--surface-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.excluded-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 4px;
}

.excluded-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}

.excluded-fail {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--bad-text);
  background: var(--bad-bg);
  padding: 2px 8px;
  border-radius: 999px;
}

.excluded-item p,
.blindspot-item p {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.blindspot-title {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--text);
  margin-bottom: 4px;
}

.sources-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.source-tile {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: var(--surface-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 13px;
  box-shadow: var(--shadow-sm);
}

.source-tile a {
  font-weight: 600;
  color: var(--link);
}

.source-date {
  font-size: 11.5px;
  color: var(--text-light);
}

.site-footer {
  margin-top: 28px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-light);
}

.empty-state {
  padding: 36px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* Inline City Hyperlinks on Main Country Table */
.row-city-links {
  margin-top: 3px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text-light);
}

.inline-city-link {
  color: var(--link);
  font-weight: 600;
  white-space: nowrap;
}

.city-links-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 12px;
}

.city-pill-link {
  display: inline-flex;
  align-items: center;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--accent-bg);
  color: var(--link);
  font-size: 12px;
  font-weight: 600;
}

.city-pill-link:hover {
  background: #d8e8ff;
  text-decoration: none;
}

/* City Profile Page */
.city-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--link);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.back-link:hover {
  background: var(--accent-bg);
  text-decoration: none;
}

.city-nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.city-jump-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.city-switcher {
  height: 36px;
  padding: 0 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.sibling-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.sibling-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-light);
}

.sibling-pill {
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--link);
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.sibling-pill.active {
  background: var(--link);
  color: #ffffff;
}

.sibling-pill:hover {
  text-decoration: none;
  background: var(--accent-bg);
}

.sibling-pill.active:hover {
  background: var(--link);
}

.city-hero-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
}

.city-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
  margin-bottom: 24px;
}

.city-hero-copy h1 {
  margin: 0 0 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(28px, 3.2vw, 40px);
  line-height: 1.15;
}

.city-verdict-box {
  background: var(--surface-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 14px;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.city-photo-stack {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.85fr);
  gap: 12px;
}

.city-photo-main,
.city-photo-sub {
  margin: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface-subtle);
  box-shadow: var(--shadow-sm);
}

.city-photo-main img,
.city-photo-sub img {
  display: block;
  width: 100%;
  height: 220px;
  object-fit: cover;
}

.city-photo-main figcaption,
.city-photo-sub figcaption {
  padding: 8px 10px;
  font-size: 11.5px;
  color: var(--text-light);
  font-weight: 600;
}

.img-fallback img {
  display: none;
}

.img-fallback {
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eef5ff, #f8fafc);
}

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

.area-row {
  box-shadow: inset 0 -1px 0 rgba(15, 23, 42, 0.06);
}

.area-name {
  font-weight: 700;
  color: var(--text);
  margin-bottom: 3px;
}

.area-tag {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-bg);
  color: var(--link);
  white-space: nowrap;
}

.area-notes {
  color: var(--text-muted);
  font-size: 12.5px;
}

.city-content-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.stack-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stack-item {
  background: var(--surface-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.stack-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 4px;
}

.stack-item strong {
  font-size: 13.5px;
  color: var(--text);
}

.stack-item p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.mini-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-bg);
  color: var(--link);
  white-space: nowrap;
}

.sub-heading {
  margin: 16px 0 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-light);
}

.clean-bullets {
  margin: 0;
  padding-left: 18px;
  font-size: 13.5px;
  color: var(--text-muted);
}

.clean-bullets li {
  margin-bottom: 10px;
}

.logistics-card {
  margin-bottom: 24px;
}

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

/* Responsive */
@media (max-width: 1024px) {
  .kpi-strip,
  .city-kpi-grid,
  .logistics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .secondary-grid,
  .detail-grid,
  .city-hero-grid,
  .city-content-grid {
    grid-template-columns: 1fr;
  }
  .sources-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .mobile-scroll-hint {
    display: block;
  }
  .detail-panel {
    position: sticky;
    left: 0;
    width: calc(100vw - 48px);
    max-width: 100%;
    padding: 16px;
  }
}

@media (max-width: 640px) {
  .page-shell {
    padding: 14px 12px 40px;
  }
  .detail-panel {
    width: calc(100vw - 24px);
  }
  .hero {
    padding: 20px 16px;
  }
  .controls-card {
    padding: 16px;
  }
  .kpi-strip,
  .city-kpi-grid,
  .city-photo-stack,
  .logistics-grid {
    grid-template-columns: 1fr;
  }
  .city-hero-card {
    padding: 18px 16px;
  }
  .filter-field,
  .search-field {
    min-width: 100%;
  }
  .table-header-bar {
    padding: 16px;
  }
  .info-card,
  .sources-card {
    padding: 16px;
  }
  .sources-grid {
    grid-template-columns: 1fr;
  }
}
