@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --primary: #154360;
  --accent: #1abc9c;
  --muted: #6c7a89;
  --border: #e1e6ef;
  --shadow: 0 15px 35px rgba(21, 67, 96, 0.08);
}

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

body {
  margin: 0;
  font-family: "Inter", sans-serif;
  background: var(--bg);
  color: #202b32;
  line-height: 1.6;
  min-height: 100vh;
}

a {
  text-decoration: none;
  color: inherit;
}

header {
  background: var(--surface);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 20;
}

.shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 0;
  gap: 1rem;
}

.brand {
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.04em;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  font-weight: 500;
  flex-wrap: wrap;
}

.nav-links a {
  color: var(--muted);
  transition: color 0.2s ease;
}

.nav-links a.active,
.nav-links a:hover {
  color: var(--primary);
}

.language-switcher {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  flex-wrap: wrap;
}

.language-switcher button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.2rem;
  transition: all 0.2s ease;
}

.language-switcher button .flag {
  font-size: 1rem;
}

.language-switcher button.is-active {
  color: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 8px 16px rgba(21, 67, 96, 0.15);
}

main {
  padding: 3rem 0 4rem;
}

.hero {
  background: linear-gradient(120deg, #e3f9ff, #f1f4ff);
  border-radius: 28px;
  padding: 3rem;
  box-shadow: var(--shadow);
  margin-bottom: 2.5rem;
}

.hero h1 {
  font-size: 2rem;
  margin: 0 0 1rem;
  color: var(--primary);
}

.hero p {
  margin: 0;
  max-width: 700px;
  color: #415160;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.card {
  background: var(--surface);
  border-radius: 20px;
  padding: 1.75rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.card h2 {
  margin-top: 0;
  font-size: 1.15rem;
  color: var(--primary);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0.4rem 0 0;
}

.tabs {
  margin-top: 2rem;
}

.tab-buttons {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.tab-buttons button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  padding: 0.65rem 1.1rem;
  border-radius: 30px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-buttons button.is-active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 10px 20px rgba(21, 67, 96, 0.2);
}

.tab-panel {
  display: none;
  margin-top: 1.5rem;
}

.tab-panel.is-active {
  display: block;
}

.table-card {
  padding: 0;
  overflow: hidden;
}

.table-card header {
  position: static;
  box-shadow: none;
  padding: 1.5rem 1.75rem 0;
}

.table-card header h3 {
  margin: 0;
}

.datatable-container {
  padding: 1.5rem 1.75rem 1.75rem;
}

table.dataTable {
  width: 100% !important;
  border-collapse: collapse;
}

table.dataTable thead {
  background: #f7f9fb;
}

table.dataTable thead th {
  color: var(--primary);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

table.dataTable tbody td {
  border-bottom: 1px solid #f1f2f6;
}

footer {
  margin-top: 3rem;
  padding: 2rem 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.forest-card header h3 {
  margin-bottom: 0.75rem;
}

.table-card + .forest-card {
  margin-top: 2rem;
}

.forest-plot {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: 1rem;
}

.forest-row {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.forest-label {
  min-width: 160px;
  font-weight: 500;
  color: var(--primary);
}

.forest-axis {
  flex: 1;
  position: relative;
  height: 38px;
  border-radius: 8px;
  background: linear-gradient(90deg, #f5f7fb, #edf1f8);
  border: 1px solid var(--border);
  overflow: hidden;
}

.forest-axis::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: #cfd8e3;
  transform: translateY(-50%);
}

.forest-ci {
  position: absolute;
  top: 50%;
  height: 4px;
  background: var(--accent);
  transform: translateY(-50%);
  border-radius: 4px;
}

.forest-ci::before,
.forest-ci::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 8px;
  height: 14px;
  border: 2px solid var(--accent);
  border-top: none;
  border-bottom: none;
  transform: translateY(-50%);
}

.forest-ci::before {
  left: -4px;
}

.forest-ci::after {
  right: -4px;
}

.forest-effect {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  background: var(--primary);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 4px 10px rgba(21, 67, 96, 0.25);
}

.forest-value {
  min-width: 150px;
  font-variant-numeric: tabular-nums;
  color: #415160;
  text-align: right;
}

.forest-scale {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.5rem;
}

.d3-forest-wrapper {
  margin-top: 1.5rem;
}

.d3-forest-wrapper svg {
  width: 100%;
  height: auto;
}

.d3-forest-meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.75rem;
}

.data-table-wrapper {
  margin-top: 1.25rem;
}

.filter-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.filter-inputs input,
.filter-inputs select {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.6rem 0.8rem;
  font-family: inherit;
  font-size: 0.95rem;
  background: #fff;
}

.filter-inputs label {
  font-size: 0.85rem;
  color: var(--muted);
  display: block;
  margin-bottom: 0.3rem;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.auth-overlay.is-visible {
  opacity: 1;
  visibility: visible;
}

.auth-card {
  background: #000;
  border-radius: 20px;
  padding: 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: none;
  border: 1px solid #1c1c1c;
  color: #fff;
}

.auth-card h1 {
  margin-top: 0;
  margin-bottom: 0.5rem;
  color: #fff;
}

.auth-card p {
  margin-top: 0;
  color: #c9d1d9;
}

.auth-card label {
  display: block;
  font-weight: 600;
  color: #fff;
  margin-top: 1rem;
  margin-bottom: 0.3rem;
}

.auth-card input {
  width: 100%;
  border: 1px solid #333;
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  font-family: inherit;
  font-size: 1rem;
  background: #0d1117;
  color: #fff;
}

.auth-card button {
  width: 100%;
  margin-top: 1.5rem;
  padding: 0.85rem 1rem;
  border: none;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.auth-card button:hover {
  transform: translateY(-1px);
}

.auth-error {
  margin-top: 0.75rem;
  color: #f16a6f;
  font-size: 0.9rem;
  min-height: 1em;
}

body.auth-locked {
  overflow: hidden;
  background: #000;
  color: #fff;
}

body.auth-locked header,
body.auth-locked main,
body.auth-locked footer {
  visibility: hidden;
}

@media (max-width: 640px) {
  .hero {
    padding: 2rem;
  }

  .nav {
    flex-direction: column;
    gap: 0.85rem;
  }

  .tab-buttons {
    flex-direction: column;
  }

  .forest-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .forest-label,
  .forest-value {
    min-width: auto;
    text-align: left;
  }

  .forest-value {
    width: 100%;
  }
}
