:root {
  --bg: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --soft: #f9fafb;
  --card: #ffffff;
  --accent: #2563eb;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 14px 18px;
  display: flex;
  gap: 14px;
  align-items: flex-end;
  justify-content: space-between;
}

.brandTitle { font-size: 18px; font-weight: 800; }
.brandSub { color: var(--muted); margin-top: 2px; font-size: 12px; }

.controls { display: flex; gap: 10px; align-items: center; }

.search {
  width: min(520px, 54vw);
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--soft);
  outline: none;
}
.search:focus {
  border-color: rgba(37,99,235,0.5);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.btn {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(37,99,235,0.35);
  background: rgba(37,99,235,0.08);
  color: var(--text);
  cursor: pointer;
}
.btn:hover { border-color: rgba(37,99,235,0.6); }

.page {
  padding: 18px;
  max-width: 1280px;
  margin: 0 auto;
}

.status { color: var(--muted); margin-bottom: 14px; min-height: 18px; }

h1 { margin: 18px 0 6px; font-size: 22px; font-weight: 900; }
h2 { margin: 14px 0 10px; font-size: 16px; font-weight: 850; }

.continentTitle {
  font-size: 26px;
  font-weight: 950;
  letter-spacing: 0.06em;
  margin: 22px 0 10px;
}

.regionBlock {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  padding: 12px;
  margin: 12px 0;
}

.regionHeader {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}

.regionTitle { font-size: 15px; font-weight: 900; margin: 0; }
.regionMeta { color: var(--muted); font-size: 12px; }

.areaGrid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
@media (max-width: 1050px) { .areaGrid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .areaGrid { grid-template-columns: 1fr; } }

.areaBox {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--soft);
  padding: 10px;
}

.areaTitle {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  font-weight: 900;
  margin-bottom: 8px;
}

.pill {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  background: #fff;
}

.countryList {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.countryBtn {
  --swatch: transparent;

  border: 1px solid var(--border);
  border-radius: 999px;

  background:
    linear-gradient(90deg, #fff 0 90%, var(--swatch) 90% 100%);

  padding: 6px 10px;
  cursor: pointer;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.countryBtn:hover { border-color: rgba(37,99,235,0.6); }

.countryTag { font-weight: 900; }
.countryCount {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 7px;
  background: #fff;
}

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

.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  white-space: pre-wrap;
  margin-top: 10px;
}

.error {
  border: 1px solid rgba(220, 38, 38, 0.35);
  background: rgba(220, 38, 38, 0.06);
  border-radius: 12px;
  padding: 12px;
}

/* Modal */
.modalOverlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 999;
}
.modalOverlay.open { display: flex; }

.modal {
  width: min(860px, 96vw);
  max-height: min(96vh, 1080px);
  overflow: auto;
  background: #fff;
  border-radius: 16px;
  border: 1px solid rgba(0,0,0,0.08);
  box-shadow: 0 18px 60px rgba(0,0,0,0.25);
}

.modalHeader {
  position: sticky;
  top: 0;
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.modalHeaderLeft {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.modalTitle {
  font-size: 16px;
  font-weight: 950;
  margin: 0;
}

.modalSub {
  color: var(--muted);
  font-size: 12px;

  /* ✅ left-aligned under the title */
  text-align: left;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.modalSub:empty { display: none; }

.modalClose {
  border: 1px solid var(--border);
  background: var(--soft);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  font-weight: 800;
}
.modalClose:hover { border-color: rgba(37,99,235,0.6); }

.modalBody { padding: 14px; }

.modalH3 {
  margin: 14px 0 8px;
  font-size: 14px;
  font-weight: 950;
}

.statsGrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

@media (max-width: 760px) {
  .statsGrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.stat {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--soft);
  padding: 10px;
}

.statK {
  color: var(--muted);
  font-weight: 900;
  font-size: 11px;
  letter-spacing: 0.06em;
}

.statV {
  font-weight: 950;
  margin-top: 4px;
  word-break: break-word;
}

.miniLine {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.miniPill {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  background: #fff;
  font-weight: 800;
}

.advGroups { display: grid; gap: 12px; }

.ageGroup {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  padding: 10px;
}

.ageHeader {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.ageTitle { font-weight: 950; }

.fileGroup {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--soft);
  padding: 10px;
  margin-top: 10px;
}

.fileHeader {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.fileTitle {
  font-weight: 900;
  color: #111827;
}

.advList { display: grid; gap: 10px; }

.advRow {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  padding: 10px;
}

.advTop {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.advNameLine {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.advName {
  font-weight: 950;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.advMeta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.advEffects {
  margin-top: 8px;
  display: grid;
  gap: 6px;
}

.effRow {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 10px;
  padding-top: 6px;
  border-top: 1px dashed rgba(17,24,39,0.12);
}
.effRow:first-child {
  border-top: none;
  padding-top: 0;
}

.effK { color: var(--muted); font-weight: 850; }
.effV { font-weight: 700; word-break: break-word; }

.infoChip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  font-weight: 950;
  cursor: help;
  user-select: none;
  flex: 0 0 auto;
}

.infoChip:focus {
  outline: none;
  border-color: rgba(37,99,235,0.6);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.infoChipMuted {
  color: var(--muted);
  background: var(--soft);
}

.infoChip::after {
  content: attr(data-tip);
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 50;
  width: min(520px, 70vw);
  max-width: 520px;
  background: #111827;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 650;
  font-size: 12px;
  line-height: 1.35;
  white-space: normal;
  box-shadow: 0 14px 40px rgba(0,0,0,0.35);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 120ms ease, transform 120ms ease, visibility 120ms ease;
}

.infoChip:hover::after,
.infoChip:focus::after {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
