@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,600;9..144,700&family=Manrope:wght@400;500;600;700&display=swap');

:root {
  --bg-card: #ffffff;
  --bg-soft: #eef4f8;
  --text-main: #14293a;
  --text-soft: #4a6274;
  --brand: #005e8d;
  --brand-deep: #004d74;
  --brand-dark: #003a5c;
  --accent: #09b8c1;
  --border: #d8e4ec;
  --border-input: #c3d5e0;
  --shadow-card: 0 10px 24px rgba(4, 40, 61, 0.08);
  --shadow-raised: 0 16px 34px rgba(4, 40, 61, 0.16);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --gap: 12px;
  --serif: "Fraunces", Georgia, serif;
  --sans: "Manrope", "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--text-main);
  background:
    radial-gradient(circle at 12% 8%, rgba(0, 94, 141, 0.1), transparent 36%),
    radial-gradient(circle at 88% 28%, rgba(9, 184, 193, 0.12), transparent 40%),
    linear-gradient(165deg, #f4f8fb 0%, #e9f1f7 55%, #ddebf3 100%);
  background-attachment: fixed;
}

h1,
h2 {
  font-family: var(--serif);
  letter-spacing: 0.01em;
}

.hidden {
  display: none;
}

.skip-link {
  position: fixed;
  left: 12px;
  top: -60px;
  z-index: 2000;
  padding: 10px 14px;
  border: 2px solid var(--brand);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--brand-dark);
  text-decoration: none;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 12px;
}

.shell {
  width: min(1500px, 100% - 24px);
  margin: 16px auto 24px;
  display: grid;

  grid-template-columns: minmax(0, 1fr);
  gap: var(--gap);
}

.hero {
  position: relative;
  overflow: hidden;
  padding: 20px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand) 46%, #0aa2b2 112%);
  color: #fff;
  box-shadow: var(--shadow-raised);
}

.hero::before {
  content: "";
  position: absolute;
  right: -120px;
  top: -90px;
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.25) 0%, transparent 70%);
}

.hero-top {
  position: relative;
  display: flex;
  gap: 14px;
  align-items: start;
  justify-content: space-between;
  flex-wrap: wrap;
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.4rem, 4.2vw, 2rem);
}

.hero p {
  margin: 8px 0 0;
  max-width: 70ch;
  line-height: 1.45;
}

.lang-switch {
  display: inline-flex;
  gap: 6px;
  padding: 5px;
  border-radius: 12px;
  background: rgba(2, 32, 48, 0.3);
}

.lang-switch button {
  padding: 7px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.lang-switch button[aria-pressed="true"] {
  background: #fff;
  color: var(--brand-dark);
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  box-shadow: var(--shadow-card);
}

.panel {
  padding: 14px;
}

.panel-title {
  margin: 0 0 10px;
  color: var(--brand-dark);
  font-size: 1.05rem;
}

.panel-title + .legend,
.stat-row + .panel-title {
  margin-top: 0;
}

.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.field {
  margin-bottom: 11px;
}

.field label {
  display: block;
  margin-bottom: 4px;
  color: var(--text-soft);
  font-size: 0.9rem;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  background: #fbfdfe;
  color: var(--text-main);
  font: inherit;
}

:focus-visible {
  outline: 3px solid rgba(9, 184, 193, 0.75);
  outline-offset: 2px;
}

.neutral-btn {
  padding: 10px 12px;
  border: 1px solid #bcd6e6;
  border-radius: var(--radius-sm);
  background: #e8f2f8;
  color: var(--brand-deep);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.neutral-btn:hover {
  background: #dcebf4;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--brand-dark);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-card);
}

.toolbar-btn-icon {
  position: relative;
  display: block;
  width: 16px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: background-color 0.2s ease;
}

.toolbar-btn-icon::before,
.toolbar-btn-icon::after {
  content: "";
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform 0.2s ease;
}

.toolbar-btn-icon::before {
  top: -5px;
}

.toolbar-btn-icon::after {
  top: 5px;
}

.toolbar-btn[aria-expanded="true"] .toolbar-btn-icon {
  background: transparent;
}

.toolbar-btn[aria-expanded="true"] .toolbar-btn-icon::before {
  transform: translateY(5px) rotate(45deg);
}

.toolbar-btn[aria-expanded="true"] .toolbar-btn-icon::after {
  transform: translateY(-5px) rotate(-45deg);
}

.toolbar-count {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.92rem;
}

.toolbar-count strong {
  color: var(--brand-dark);
  font-family: var(--serif);
  font-size: 1.15rem;
}

.workspace {
  display: grid;
  gap: var(--gap);
  min-height: 0;
}

.map-shell {
  overflow: hidden;
  padding: 0;
}

.map {
  width: 100%;
  height: 100%;
  background: var(--bg-soft);
}

.marker-dot {
  display: block;
  width: 14px;
  height: 14px;
  border: 2px solid #fff;
  border-radius: 999px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.24);
}

.leaflet-control-attribution {
  font-size: 0.7rem;
}

.leaflet-control-zoom a {
  color: var(--brand-deep);
}

.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background-color: rgba(9, 184, 193, 0.32);
}

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background-color: var(--brand);
  color: #fff;
  font-family: var(--sans);
  font-weight: 700;
}

.detail .empty {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.95rem;
}

.detail h3 {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.3;
}

.sheet-close {
  flex: none;
  width: 34px;
  height: 34px;
  margin: -4px -4px 0 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-soft);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.kv {
  display: grid;
  gap: 7px;
  font-size: 0.94rem;
}

.kv div {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
}

.kv strong {
  display: block;
  color: #3c5568;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

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

.stat {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  text-align: center;
}

.stat strong {
  display: block;
  color: var(--brand-dark);
  font-family: var(--serif);
  font-size: 1.2rem;
}

.stat span {
  font-size: 0.82rem;
}

.legend {
  display: grid;
  gap: 6px;
  font-size: 0.88rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.swatch {
  width: 14px;
  height: 14px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 999px;
}

.table-wrap {
  padding: 14px;
}

.table-scroll {
  margin-top: 10px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;

  font-size: clamp(0.69rem, 0.42rem + 1.1vw, 0.92rem);
}

caption {
  padding: 10px;
  font-weight: 700;
  text-align: left;
}

th,
td {
  padding: 0.6em 0.7em;
  border-bottom: 1px solid #e2ecf2;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  padding: 0;
  background: #eaf2f7;
  color: #2c4657;
}

.th-sort {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  padding: 0.6em 0.7em;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.th-sort:hover {
  background: #ddedf5;
}

.th-sort::after {
  content: "↕";
  margin-left: auto;
  opacity: 0.4;
  font-size: 0.85em;
}

th[aria-sort="ascending"] .th-sort::after {
  content: "↑";
  opacity: 1;
}

th[aria-sort="descending"] .th-sort::after {
  content: "↓";
  opacity: 1;
}

.th-short {
  display: none;
}

th[aria-sort]:not([aria-sort="none"]) {
  background: #d9ecf4;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: #f0f7fb;
}

@media (max-width: 700px) {
  table {
    table-layout: fixed;
  }

  th,
  td {
    padding: 0.5em 0.35em;

    overflow-wrap: break-word;
  }

  .th-long {
    display: none;
  }

  .th-short {
    display: inline;
  }

  .th-sort {
    display: block;
    padding: 0.5em 0.35em;
  }

  .th-sort::after {
    content: none;
    margin-left: 4px;
  }

  tbody td:nth-child(3),
  tbody td:nth-child(5) {
    white-space: nowrap;
  }

  col.col-name { width: 26%; }
  col.col-type { width: 12%; }
  col.col-year { width: 11%; }
  col.col-fund { width: 15%; }
  col.col-budget { width: 18%; }
  col.col-entities { width: 18%; }
}

.fade-in {
  opacity: 0;
  transform: translateY(8px);
  animation: fadeInUp 0.5s ease forwards;
}

.fade-in.delay-1 {
  animation-delay: 0.1s;
}

@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fade-in {
    opacity: 1;
    transform: none;
    animation: none;
  }

  .detail,
  .skip-link,
  .toolbar-btn-icon,
  .toolbar-btn-icon::before,
  .toolbar-btn-icon::after {
    transition: none;
  }
}

@media (max-width: 1199.98px) {
  .filters {
    display: none;
  }

  .filters.is-open {
    display: block;
  }

  .filters .panel-title:first-child {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .map-shell {
    height: 58dvh;
    min-height: 320px;
    max-height: 620px;
  }

  .detail {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1100;
    max-height: 72dvh;
    overflow-y: auto;
    border-width: 1px 0 0;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -14px 34px rgba(4, 40, 61, 0.25);
    transform: translateY(101%);

    visibility: hidden;
    transition: transform 0.28s ease, visibility 0s linear 0.28s;
  }

  .detail.is-open {
    transform: none;
    visibility: visible;
    transition: transform 0.28s ease, visibility 0s;
  }

  .detail .panel-head {
    position: sticky;
    top: -14px;
    z-index: 1;
    margin: -14px -14px 8px;
    padding: 14px;
    background: var(--bg-card);
  }
}

@media (min-width: 1200px) {
  .toolbar {
    display: none;
  }

  .workspace {
    grid-template-columns: 290px minmax(0, 1fr) 320px;
    height: clamp(520px, calc(100vh - 250px), 860px);
  }

  .filters,
  .detail {
    overflow-y: auto;
  }

  .sheet-close {
    display: none;
  }
}

@media (min-width: 1400px) {
  .workspace {
    grid-template-columns: 320px minmax(0, 1fr) 360px;
  }
}
