body.country-page {
  line-height: 1.45;
}

.shell {
  width: min(1160px, calc(100% - 24px));
  margin: 20px auto 36px;
}

.hero {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 12px 28px rgba(20, 35, 50, 0.08);
}

h1 {
  margin: 0;
  font-size: clamp(26px, 3.8vw, 44px);
  line-height: 1.1;
}

.controls {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: 10px;
}

.energy-mix-teaser {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  white-space: normal;
}

.energy-mix-teaser[hidden] {
  display: none;
}

.energy-mix-teaser-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border: 1px solid #dbe4f3;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 4px 14px rgba(20, 35, 50, 0.06);
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
}

.energy-mix-teaser-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6a7890;
}

.energy-mix-teaser-icon {
  font-size: 12px;
  line-height: 1;
}

.energy-mix-teaser-value {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid currentColor;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  background: rgba(255,255,255,0.84);
}

.energy-mix-teaser-item.is-green {
  color: #166534;
  background: #ecfdf5;
  border-color: #86efac;
}

.energy-mix-teaser-item.is-green .energy-mix-teaser-label {
  color: #166534;
}

.energy-mix-teaser-item.is-green .energy-mix-teaser-value {
  background: #dcfce7;
}

.energy-mix-teaser-item.is-blue {
  color: #1d4ed8;
  background: #eff6ff;
  border-color: #93c5fd;
}

.energy-mix-teaser-item.is-blue .energy-mix-teaser-label {
  color: #1d4ed8;
}

.energy-mix-teaser-item.is-blue .energy-mix-teaser-value {
  background: #dbeafe;
}

.energy-mix-teaser-item.is-yellow {
  color: #854d0e;
  background: #fefce8;
  border-color: #fde047;
}

.energy-mix-teaser-item.is-yellow .energy-mix-teaser-label {
  color: #854d0e;
}

.energy-mix-teaser-item.is-yellow .energy-mix-teaser-value {
  background: #fef3c7;
}

.energy-mix-teaser-item.is-orange {
  color: #9a3412;
  background: #fff7ed;
  border-color: #fdba74;
}

.energy-mix-teaser-item.is-orange .energy-mix-teaser-label {
  color: #9a3412;
}

.energy-mix-teaser-item.is-orange .energy-mix-teaser-value {
  background: #fed7aa;
}

.energy-mix-teaser-item.is-black {
  color: #f9fafb;
  background: linear-gradient(180deg, rgba(31,41,55,0.98), rgba(17,24,39,0.98));
  border-color: #111827;
}

.energy-mix-teaser-item.is-black .energy-mix-teaser-label {
  color: #d1d5db;
}

.energy-mix-teaser-item.is-black .energy-mix-teaser-value {
  background: #1f2937;
  color: #f9fafb;
}

.energy-mix-teaser-item.is-red {
  color: #b91c1c;
  background: #fef2f2;
  border-color: #fca5a5;
}

.energy-mix-teaser-item.is-red .energy-mix-teaser-label {
  color: #b91c1c;
}

.energy-mix-teaser-item.is-red .energy-mix-teaser-value {
  background: #fee2e2;
}

.energy-mix-teaser-item.is-clean-firm-jenks .energy-mix-teaser-label,
.energy-mix-teaser-item.is-clean-firm-jenks .energy-mix-teaser-value {
  color: inherit;
}

.energy-mix-teaser-item.is-clean-firm-soft {
  color: #334155;
  background: #e2e8f0;
  border-color: #cbd5e1;
}

.energy-mix-teaser-item.is-clean-firm-soft .energy-mix-teaser-label {
  color: #334155;
}

.energy-mix-teaser-item.is-clean-firm-soft .energy-mix-teaser-value {
  background: #f8fafc;
}

.energy-mix-teaser-item.is-clean-firm-mid {
  color: #0f172a;
  background: #94a3b8;
  border-color: #64748b;
}

.energy-mix-teaser-item.is-clean-firm-mid .energy-mix-teaser-label {
  color: #0f172a;
}

.energy-mix-teaser-item.is-clean-firm-mid .energy-mix-teaser-value {
  background: #cbd5e1;
}

.energy-mix-teaser-item.is-clean-firm-strong {
  color: #f8fafc;
  background: #475569;
  border-color: #334155;
}

.energy-mix-teaser-item.is-clean-firm-strong .energy-mix-teaser-label {
  color: #e2e8f0;
}

.energy-mix-teaser-item.is-clean-firm-strong .energy-mix-teaser-value {
  background: #334155;
}

.energy-mix-teaser-item.is-clean-firm-max {
  color: #f8fafc;
  background: #1e293b;
  border-color: #0f172a;
}

.energy-mix-teaser-item.is-clean-firm-max .energy-mix-teaser-label {
  color: #cbd5e1;
}

.energy-mix-teaser-item.is-clean-firm-max .energy-mix-teaser-value {
  background: #0f172a;
}

select,
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  padding: 12px;
  color: var(--ink);
  font: inherit;
}

select:focus,
input:focus {
  outline: 2px solid #9bb8f6;
  border-color: #9bb8f6;
}

.stats {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.map-wrap {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #eef3f9;
  position: relative;
}

#countryMap {
  width: 100%;
  height: 270px;
  background: #d8e4f3;
}

.map-hint {
  position: absolute;
  inset: auto 10px 10px 10px;
  font-size: 11px;
  color: #516178;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid #d3dbe7;
  border-radius: 999px;
  padding: 5px 10px;
  text-align: center;
  pointer-events: none;
}

.leaflet-container {
  font-family: var(--fm);
}

.country-pin {
  background: #1d4ed8;
  border: 2px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(29, 78, 216, 0.45);
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.86);
}

.chip strong {
  margin-right: 4px;
}

main {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}

.list-wrap {
  max-height: 58vh;
  overflow-y: auto;
  border: 1px solid rgba(221, 227, 236, 0.94);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  padding: 10px;
}

.list-wrap::-webkit-scrollbar {
  width: 8px;
}

.list-wrap::-webkit-scrollbar-thumb {
  background: #d5deea;
  border-radius: 999px;
}

.empty {
  border: 1px dashed #cbd5e1;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.7);
  padding: 26px;
  color: var(--muted);
  text-align: center;
}

.list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(540px, 1fr));
  gap: 12px;
}

.card {
  border: 1px solid rgba(221, 227, 236, 0.94);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 26px rgba(22, 31, 44, 0.08);
  padding: 14px;
  position: relative;
  opacity: 0;
  transform: translateY(16px) scale(0.985);
  animation: reveal 0.55s cubic-bezier(.2, .7, .2, 1) forwards;
  animation-delay: var(--delay, 0ms);
}

.card.is-expanded {
  z-index: 20;
}

.card.is-focused {
  outline: 2px solid #2563eb;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.2), 0 12px 26px rgba(22, 31, 44, 0.08);
}

@keyframes reveal {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.card-head-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.name {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
}

.id {
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.badge {
  border-radius: 999px;
  padding: 4px 9px;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.facts {
  margin-top: 10px;
  display: grid;
  gap: 6px;
}

.fact {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px dashed #d8e2ef;
  padding-bottom: 4px;
  font-size: 13px;
}

.fact:last-child {
  border-bottom: none;
}

.key {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 10px;
}

.val {
  font-weight: 600;
  text-align: right;
  word-break: break-word;
}

.card-actions {
  margin-top: 11px;
  display: flex;
  gap: 8px;
}

.card-actions-manual-only {
  margin-top: 10px;
}

.card-actions a {
  flex: 1;
  text-align: center;
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 12px;
  border: 1px solid #bfd2fb;
  background: var(--accent-soft);
  color: #143f9f;
}

.card-actions a:hover {
  background: #bfdbfe;
}

.card-action-manual {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.card-action-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
  flex-shrink: 0;
}

.details-toggle {
  width: 22px;
  height: 22px;
  border: 1px solid #bfd2fb;
  border-radius: 50%;
  background: var(--accent-soft);
  color: #143f9f;
  font: inherit;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s ease, background 0.12s ease, border-color 0.12s ease;
}

.details-toggle:hover {
  background: #bfdbfe;
}

.details-toggle.is-open {
  transform: rotate(90deg);
  border-color: #8fb1f4;
  background: #dbeafe;
}

.note {
  margin-top: 10px;
  padding: 8px 10px;
  border-left: 3px solid #c7d2fe;
  background: #f8faff;
  border-radius: 8px;
  color: #475569;
  font-size: 12px;
}

.detail-units {
  margin-top: 0;
  border: 1px solid #d8e1f1;
  border-radius: 12px;
  background: #ffffff;
  padding: 10px;
  position: absolute;
  top: 50px;
  left: 12px;
  right: 12px;
  z-index: 15;
  box-shadow: 0 10px 24px rgba(20, 34, 58, 0.2);
}

.detail-units[hidden] {
  display: none;
}

.detail-units-title {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #4b5f7f;
  margin-bottom: 8px;
}

.detail-units-wrap {
  overflow-x: auto;
}

.detail-units-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  font-size: 12px;
}

.detail-units-table th,
.detail-units-table td {
  border-bottom: 1px dashed #dbe6f8;
  padding: 7px 8px;
  text-align: left;
  white-space: nowrap;
}

.detail-units-table th {
  color: #475569;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.detail-units-table td:last-child,
.detail-units-table th:last-child {
  border-right: none;
}

.country-resource-section {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  padding: 18px;
  box-shadow: 0 12px 26px rgba(22, 31, 44, 0.06);
}

.country-resource-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.country-resource-head h2 {
  margin: 4px 0 8px;
  font-size: 22px;
  line-height: 1.2;
}

.country-resource-copy {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  max-width: 720px;
}

.country-resource-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid #bfd2fb;
  background: #eff6ff;
  color: #143f9f;
  text-decoration: none;
  white-space: nowrap;
}

.country-resource-link:hover {
  background: #dbeafe;
}

footer {
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}

@media (max-width: 760px) {
  .shell {
    width: min(1160px, calc(100% - 14px));
    margin-top: 10px;
  }

  .hero {
    padding: 14px;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .energy-mix-teaser {
    width: 100%;
  }

  .energy-mix-teaser-item {
    width: 100%;
    justify-content: space-between;
  }

  .list {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 12px;
  }

  .detail-units {
    position: static;
    margin-top: 10px;
    box-shadow: none;
  }
}

:root[data-map-theme="dark"] body.country-page {
  background: var(--page-bg);
  color: var(--txt);
}

:root[data-map-theme="dark"] .hero,
:root[data-map-theme="dark"] .card,
:root[data-map-theme="dark"] .country-resource-section,
:root[data-map-theme="dark"] .list-wrap {
  background: rgba(17, 24, 39, 0.94);
  border-color: var(--brd);
  box-shadow: var(--shadow-panel);
}

:root[data-map-theme="dark"] .hero {
  backdrop-filter: blur(8px);
}

:root[data-map-theme="dark"] .energy-mix-teaser-item,
:root[data-map-theme="dark"] .chip,
:root[data-map-theme="dark"] .empty {
  background: var(--surf2);
  border-color: var(--brd);
  color: var(--txt);
}

:root[data-map-theme="dark"] .energy-mix-teaser-label,
:root[data-map-theme="dark"] .country-resource-copy,
:root[data-map-theme="dark"] .map-hint {
  color: var(--mut);
}

:root[data-map-theme="dark"] .energy-mix-teaser-value {
  background: rgba(255, 255, 255, 0.10);
}

:root[data-map-theme="dark"] .map-wrap,
:root[data-map-theme="dark"] #countryMap {
  background: #0b1120;
  border-color: var(--brd);
}

:root[data-map-theme="dark"] .map-hint {
  background: rgba(17, 24, 39, 0.86);
  border-color: var(--brd);
}

:root[data-map-theme="dark"] .list-wrap::-webkit-scrollbar-thumb {
  background: #475569;
}

:root[data-map-theme="dark"] .fact {
  border-bottom-color: var(--brd);
}

:root[data-map-theme="dark"] .card-actions a,
:root[data-map-theme="dark"] .details-toggle,
:root[data-map-theme="dark"] .country-resource-link {
  background: rgba(96, 165, 250, 0.16);
  border-color: rgba(147, 197, 253, 0.42);
  color: #bfdbfe;
}

:root[data-map-theme="dark"] .card-actions a:hover,
:root[data-map-theme="dark"] .details-toggle:hover,
:root[data-map-theme="dark"] .country-resource-link:hover {
  background: rgba(96, 165, 250, 0.24);
  border-color: rgba(147, 197, 253, 0.62);
}

:root[data-map-theme="dark"] .details-toggle.is-open {
  background: rgba(96, 165, 250, 0.28);
  border-color: #60a5fa;
}

:root[data-map-theme="dark"] .note {
  background: rgba(96, 165, 250, 0.10);
  border-left-color: #60a5fa;
  color: var(--txt);
}

:root[data-map-theme="dark"] .detail-units {
  background: var(--surf);
  border-color: var(--brd);
  box-shadow: var(--shadow-panel);
}

:root[data-map-theme="dark"] .detail-units-title,
:root[data-map-theme="dark"] .detail-units-table th {
  color: var(--mut);
}

:root[data-map-theme="dark"] .detail-units-table th,
:root[data-map-theme="dark"] .detail-units-table td {
  border-bottom-color: var(--brd);
}
