:root {
  color-scheme: light;
  --bg: #eef2ff;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --soft: #f8fafc;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --green: #0f766e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--bg) 0%, #ffffff 80%);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 1.15rem 1.5rem;
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

.brand {
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0;
}

.nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.user-pill {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: capitalize;
}

.nav a {
  color: #334155;
  font-weight: 600;
}

.nav a.button,
.button,
.query-link,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
}

.nav a.button {
  padding: 0.65rem 1.1rem;
}

.query-link {
  padding: 0.65rem 1rem;
  border-radius: 0.7rem;
  flex-shrink: 0;
}

.query-link.secondary {
  background: #e2e8f0;
  color: #334155;
}

button {
  width: 100%;
  padding: 0.95rem 1rem;
  font-size: 1rem;
}

.nav a.button:hover,
.button:hover,
.query-link:hover,
button:hover {
  background: var(--accent-dark);
  text-decoration: none;
}

.query-link.secondary:hover {
  background: #cbd5e1;
}

.main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.shell {
  width: min(100%, 540px);
  padding: 2.2rem;
  background: var(--panel);
  border-radius: 28px;
  box-shadow: 0 30px 60px rgba(15, 23, 42, 0.12);
}

.shell.wide {
  width: min(98vw, 1500px);
}

.shell.login-shell {
  width: min(100%, 1500px);
  min-height: min(720px, calc(100vh - 9rem));
  padding: clamp(2rem, 3.5vw, 4rem);
}

.login-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 414px;
  gap: clamp(2rem, 6vw, 6rem);
  align-items: start;
}

.login-intro {
  max-width: 860px;
}

.login-intro h1 {
  margin: 0 0 0.35rem;
  font-size: clamp(2.6rem, 4vw, 3.3rem);
  line-height: 1;
}

.login-intro p {
  margin: 0.25rem 0;
  color: var(--text);
  font-size: 1rem;
}

.login-intro h2 {
  margin: 1.65rem 0 0.6rem;
  font-size: 1.15rem;
}

.objective-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid #d6dbe3;
}

.objective-list li {
  padding: 1rem 0;
  border-bottom: 1px solid #d6dbe3;
  font-size: 1.05rem;
}

.login-card {
  margin-top: 4.1rem;
  padding: 1.45rem 1.35rem 1.55rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.9rem;
  background: var(--soft);
}

.hero.compact {
  margin-bottom: 1.25rem;
}

.hero.compact h1 {
  font-size: 1.5rem;
  line-height: 1.15;
}

.hero.compact p {
  margin: 0;
}

.hero {
  margin-bottom: 1.5rem;
}

.hero h1,
.page-heading h1 {
  margin: 0 0 0.55rem;
  font-size: clamp(2rem, 4vw, 2.75rem);
  line-height: 1.05;
}

.hero p,
.page-heading p,
.muted {
  color: var(--muted);
}

.form-group {
  margin-bottom: 1rem;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  color: #334155;
  font-size: 0.95rem;
  font-weight: 600;
}

input,
select {
  width: 100%;
  padding: 0.95rem 1rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.95rem;
  background: var(--soft);
  color: var(--text);
  font: inherit;
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 4.7rem;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 0.55rem;
  width: auto;
  min-width: 3.6rem;
  padding: 0.45rem 0.75rem;
  transform: translateY(-50%);
  background: #e2e8f0;
  color: var(--text);
  font-size: 0.85rem;
}

.password-toggle:hover {
  background: #cbd5e1;
  color: var(--text);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.small-link {
  display: block;
  margin: 1rem 0 0;
  color: var(--muted);
}

.alert {
  margin-bottom: 1.25rem;
  padding: 1rem 1.25rem;
  background: #e0f2fe;
  color: #075985;
  border: 1px solid #bae6fd;
  border-radius: 1rem;
}

.footer {
  padding: 1rem 1.5rem;
  color: var(--muted);
  font-size: 0.95rem;
  text-align: center;
}

.layout {
  display: flex;
  align-items: flex-start;
  gap: clamp(1.5rem, 3vw, 3rem);
}

.sidebar {
  width: 230px;
  flex-shrink: 0;
}

.sidebar h3 {
  margin: 0 0 1rem;
  color: #94a3b8;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sidebar a {
  display: block;
  padding: 0.78rem 1rem;
  border-radius: 0.7rem;
  color: #334155;
  font-weight: 600;
}

.sidebar a:hover {
  background: #eff6ff;
  color: var(--accent);
  text-decoration: none;
}

.content {
  flex: 1;
  min-width: 0;
}

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.action-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.page-heading p {
  margin: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.stats-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-top: 1.25rem;
}

.stat-card,
.panel,
.species-summary {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 1rem;
}

.stat-card {
  padding: 1.1rem 1.25rem;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
}

.stat-card strong {
  display: block;
  margin-top: 0.35rem;
  font-size: 2rem;
}

.panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.8fr);
  gap: 1rem;
}

.panel {
  overflow: hidden;
}

.panel h2 {
  margin: 0;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--line);
  font-size: 1.1rem;
}

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

th,
td {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 0.92rem;
}

th {
  background: #f1f5f9;
  color: #334155;
  font-size: 0.84rem;
}

td .muted {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.84rem;
}

.empty {
  margin: 0;
  padding: 2rem;
  color: var(--muted);
  text-align: center;
}

.filter-bar {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 140px;
  align-items: end;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.query-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) minmax(180px, 0.8fr) 130px;
  gap: 1rem;
  align-items: end;
  margin-bottom: 1.25rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--soft);
}

.reserve-filter-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(160px, 0.8fr) minmax(180px, 0.9fr) minmax(150px, 0.7fr) 120px;
  gap: 1rem;
  align-items: end;
  margin-bottom: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--soft);
}

.summary-filter-panel {
  display: grid;
  grid-template-columns: minmax(220px, 360px) 120px auto;
  gap: 1rem;
  align-items: end;
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--soft);
}

.summary-panel {
  max-height: min(70vh, 720px);
  overflow: auto;
}

.summary-panel th {
  position: sticky;
  top: 0;
  z-index: 2;
  box-shadow: inset 0 -1px 0 var(--line);
}

.help-strip {
  margin-bottom: 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid #bfdbfe;
  border-radius: 0.85rem;
  background: #eff6ff;
  color: #1e3a8a;
}

.tag {
  display: inline-flex;
  align-items: center;
  max-width: 220px;
  padding: 0.35rem 0.55rem;
  border-radius: 999px;
  background: #ecfdf5;
  color: #065f46;
  font-size: 0.82rem;
  font-weight: 700;
}

.table-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.7rem;
  border-radius: 0.65rem;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 0.84rem;
  font-weight: 800;
}

.table-action:hover {
  background: #dbeafe;
  text-decoration: none;
}

.reserve-species-summary {
  margin-bottom: 1.25rem;
  padding: 1.15rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--panel);
}

.summary-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.summary-heading h2 {
  margin: 0 0 0.25rem;
  font-size: 1.35rem;
}

.summary-heading p,
.reserve-summary-copy {
  margin: 0;
  color: var(--muted);
}

.reserve-summary-copy {
  max-width: 1050px;
  line-height: 1.55;
}

.reserve-summary-copy strong {
  color: var(--text);
}

.reserve-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.reserve-summary-grid article {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  background: #f8fafc;
}

.reserve-summary-grid h3 {
  margin: 0;
  padding: 0.8rem 0.95rem;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  font-size: 1rem;
}

.species-list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.species-list li {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--line);
}

.species-list li:last-child {
  border-bottom: 0;
}

.species-list strong,
.species-list small {
  display: block;
}

.species-list small {
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.species-list em {
  color: var(--text);
  font-style: normal;
  font-weight: 800;
}

.risk-status-detail,
.risk-status-heading,
.risk-species-list,
.risk-species-list span {
  display: block;
  width: 100%;
}

.risk-status-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.risk-species-list {
  margin-top: 0.75rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--line);
}

.risk-species-list span + span {
  margin-top: 0.55rem;
}

.compact-empty {
  padding: 1rem;
  text-align: left;
}

.admin-panel {
  margin-bottom: 1rem;
}

.admin-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 1rem;
  padding: 1rem;
  align-items: end;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-weight: 600;
}

.checkbox-label input {
  width: auto;
}

.filter-bar label {
  margin-bottom: 0;
  padding-bottom: 0.95rem;
}

.species-summary {
  margin-bottom: 1rem;
  padding: 1.25rem;
}

.species-summary h2 {
  margin: 0 0 0.3rem;
}

.species-summary p {
  margin: 0 0 0.9rem;
  color: var(--muted);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.6rem;
  color: var(--muted);
}

.summary-grid strong {
  color: var(--text);
}

#map {
  width: 100%;
  height: min(68vh, 680px);
  min-height: 480px;
  border: 1px solid var(--line);
  border-radius: 1rem;
  z-index: 0;
}

.legend {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.legend-dot,
.map-dot {
  width: 14px;
  height: 14px;
  border: 2px solid white;
  border-radius: 50%;
  background: #dc2626;
  box-shadow: 0 0 0 2px #dc2626;
}

.analysis-panel {
  margin-top: 1rem;
}

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

.mini-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0.85rem;
}

.mini-panel h3 {
  margin: 0;
  padding: 0.8rem 0.95rem;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
  font-size: 1rem;
}

.fire-note {
  margin: 0 1rem 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid #fed7aa;
  border-radius: 0.85rem;
  background: #fff7ed;
  color: #9a3412;
}

@media (max-width: 900px) {
  .layout,
  .page-heading {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
  }

  .sidebar a {
    display: inline-block;
  }

  .panel-grid {
    grid-template-columns: 1fr;
  }

  .filter-bar {
    grid-template-columns: 1fr;
  }

  .query-panel {
    grid-template-columns: 1fr;
  }

  .reserve-filter-panel {
    grid-template-columns: 1fr;
  }

  .summary-filter-panel {
    grid-template-columns: 1fr;
  }

  .summary-heading {
    flex-direction: column;
  }

  .reserve-summary-grid {
    grid-template-columns: 1fr;
  }

  .admin-form {
    grid-template-columns: 1fr;
  }

  .shell.login-shell {
    min-height: auto;
  }

  .login-layout {
    grid-template-columns: 1fr;
  }

  .login-card {
    margin-top: 0;
  }

  .filter-bar label {
    padding-bottom: 0;
  }
}

@media (max-width: 640px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .shell {
    padding: 1.35rem;
    border-radius: 18px;
  }

  th,
  td {
    min-width: 140px;
  }

  .panel {
    overflow-x: auto;
  }
}
