:root {
  --paper: #f2f5f7;
  --ink: #001c50;
  --mute: #5a6368;
  --line: #e0e0e0;
  --card: #ffffff;
  --signal: #164194;
  --gold: #ffc900;
  --bar: #f2f5f7;
  --casp: #164194;
  --casp-bg: #e7eef8;
  --emi: #092d72;
  --emi-bg: #e6ebf4;
  --pi: #8a6a00;
  --pi-bg: #fff6d6;
  --aisp: #3f73d8;
  --aisp-bg: #eaf1fc;
  --bank: #474f54;
  --bank-bg: #f2f5f7;
  --shadow: 0 1px 2px rgba(0, 28, 80, 0.06), 0 8px 24px rgba(0, 28, 80, 0.06);
}

html {
  scroll-behavior: smooth;
  background: #fff;
}

body {
  background: #fff;
  color: #474f54;
  overflow-x: hidden;
}

main {
  min-width: 0;
}

body > header {
  box-shadow: inset 0 3px 0 var(--gold);
}

h1.font-serif,
h2.font-serif,
dd.font-serif {
  color: var(--signal);
  font-weight: 700;
  letter-spacing: -0.02em;
}

header a.font-serif {
  color: var(--signal);
  font-weight: 700;
}

#error,
#analytics-error {
  color: #9b2335;
}

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

.entity-logo {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--paper);
  color: var(--signal);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.entity-logo-sm {
  width: 2rem;
  height: 2rem;
  font-size: 0.7rem;
}

.entity-logo-md {
  width: 2.5rem;
  height: 2.5rem;
  font-size: 0.78rem;
}

.entity-logo-lg {
  width: 5rem;
  height: 5rem;
  font-size: 1.35rem;
}

.entity-logo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0.25rem;
  background: #fff;
  object-fit: contain;
}

.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 2px;
  padding: 0.1rem 0.5rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.4;
}

.chip-casp { background: var(--casp-bg); color: var(--casp); }
.chip-emi { background: var(--emi-bg); color: var(--emi); }
.chip-pi { background: var(--pi-bg); color: var(--pi); }
.chip-aisp { background: var(--aisp-bg); color: var(--aisp); }
.chip-bank { background: var(--bank-bg); color: var(--bank); }
.chip[data-tip] {
  cursor: help;
}

.tip-box {
  position: fixed;
  z-index: 60;
  width: max-content;
  max-width: 18rem;
  border-top: 3px solid var(--gold);
  background: var(--ink);
  color: #fff;
  padding: 0.4rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.35;
  pointer-events: none;
}

.tip-box[hidden] {
  display: none;
}

.chip-quiet {
  background: var(--paper);
  color: var(--mute);
  border: 0;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  font-size: 0.75rem;
}

.field {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%235a6368' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 0.85rem center;
  box-shadow: none;
  padding: 0.55rem 2rem 0.55rem 0.95rem;
  font-size: 0.875rem;
  color: var(--ink);
  outline: none;
}

.field:focus {
  border-color: var(--signal);
  box-shadow: 0 0 0 3px rgba(22, 65, 148, 0.18);
}

input.field {
  background-image: none;
  padding-right: 0.95rem;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border-radius: 2px;
  background: var(--bar);
  padding: 0.55rem 0.7rem 0.55rem 1rem;
}

.seg {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.seg-btn {
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: var(--mute);
  padding: 0.4rem 0.85rem;
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
}

.seg-btn.is-on,
#more.seg-btn {
  background: var(--signal);
  color: white;
  box-shadow: none;
}

#more.seg-btn {
  background: white;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.result-table {
  overflow: hidden;
  border-radius: 2px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.result-table:empty {
  display: none;
}

.result-head,
.row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.35rem;
  width: 100%;
  padding: 0.95rem 1.15rem;
  text-align: left;
}

.result-head {
  display: grid;
  grid-template-columns: 1fr 1.3fr auto;
  align-items: center;
  color: var(--mute);
  background: var(--paper);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sort-col {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  width: fit-content;
  border: 0;
  background: transparent;
  padding: 0;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
}

.sort-col:hover,
.sort-col.is-on {
  color: var(--ink);
}

.sort-mark {
  font-size: 0.75rem;
  letter-spacing: 0;
  line-height: 1;
}

.row {
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
}

.row:hover,
.row.is-on {
  background: #e8eef8;
}

.panel {
  overflow: hidden;
  border-radius: 2px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.pill {
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--card);
  box-shadow: var(--shadow);
  padding: 0.35rem 0.7rem;
  font-size: 0.75rem;
}

.pill.is-on {
  border-color: var(--signal);
  background: var(--signal);
  color: white;
}

.pill.is-on .num {
  color: inherit;
}

@media (min-width: 768px) {
  .result-head,
  .row {
    grid-template-columns: 10rem minmax(0, 1fr) 8.5rem;
    align-items: center;
    gap: 1rem;
  }

  .result-head {
    display: grid;
  }
}

.type-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--mute);
  border-radius: 2px;
  text-decoration: none;
}

.type-btn.is-on {
  background: var(--signal);
  color: #fff;
}

.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35rem;
  border-radius: 2px;
  background: #e7eef8;
  color: var(--signal);
  padding: 0.05rem 0.42rem;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: 0;
}

.type-btn.is-on .count-badge {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.row.is-on {
  background: #e8eef8;
}

#drawer-root {
  pointer-events: none;
}

#drawer-root.is-open {
  pointer-events: auto;
}

#backdrop {
  opacity: 0;
  transition: opacity 0.2s ease;
}

#drawer {
  transform: translateX(100%);
  transition: transform 0.22s ease;
}

#drawer-root.is-open #backdrop {
  opacity: 1;
}

#drawer-root.is-open #drawer {
  transform: translateX(0);
}

.pass {
  background: var(--signal);
  color: #fff;
}

.pass-home {
  box-shadow: inset 0 0 0 1.5px var(--signal);
}

.map-layout {
  display: grid;
  align-items: start;
  gap: 2rem;
}

@media (min-width: 1024px) {
  .map-layout {
    grid-template-columns: minmax(0, 1.15fr) 20rem;
  }
}

.map-stage {
  position: relative;
  height: 34rem;
  background: #e7eef6;
}

.map-layout > ol.panel {
  max-height: 34rem;
  overflow-y: auto;
}

.map-land {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.map-sea { fill: #e7eef6; }
.map-fill { fill: #c5d4ea; }

.map-bubble {
  fill: var(--ink);
}

.map-land a:hover .map-bubble {
  fill: var(--signal);
}

.map-count {
  fill: #fff;
  font-family: "Open Sans", Arial, sans-serif;
  font-size: 12px;
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

.heat {
  min-width: 2.25rem;
  height: 2.25rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.chart-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.chart-scroll svg {
  display: block;
  max-width: none;
  height: auto;
}

@media (max-width: 639px) {
  .toolbar {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .toolbar .seg {
    max-width: 100%;
    overflow-x: auto;
  }

  .result-head {
    grid-template-columns: 1fr;
  }

  .result-head > :first-child,
  .result-head > :last-child {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  #backdrop, #drawer { transition: none; }
}
