:root {
  --bg-0: #06100f;
  --bg-1: #091816;
  --bg-2: #10201d;
  --surface: #121f1d;
  --surface-soft: #162825;
  --surface-muted: #1c2f2b;
  --ink: #e7f4ef;
  --ink-soft: #b7ccc4;
  --line: #26403a;
  --accent: #35c592;
  --accent-strong: #28a579;
  --danger: #ff6e6e;
  --warning: #ffc266;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
  line-height: 1.45;
  background:
    radial-gradient(1400px 900px at 0% -5%, #16342d 0%, transparent 55%),
    radial-gradient(1100px 800px at 100% 0%, #0d2923 0%, transparent 50%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg-1) 52%, var(--bg-0) 100%);
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: url("../img/forest-night.svg") center bottom / cover no-repeat;
  opacity: 0.2;
  pointer-events: none;
  z-index: -1;
}

a {
  color: #8ce8c2;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.9rem;
  padding: 1rem 1.4rem;
  border-bottom: 1px solid #27413b;
  background: rgba(6, 18, 16, 0.74);
  backdrop-filter: blur(10px);
}

.site-header h1 {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: 0.2px;
}

.site-brand-link {
  text-decoration: none;
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: 0.3px;
  line-height: 1;
}

.site-brand-link .eco-logo-blue {
  color: #0ea5e9;
  text-shadow: 0 0 22px rgba(14, 165, 233, 0.65);
}

.site-brand-link .eco-logo-green {
  color: #10b981;
  text-shadow: 0 0 22px rgba(16, 185, 129, 0.45);
}

.site-brand-link:hover {
  opacity: 0.95;
}

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

nav a:not(.btn),
button:not(.btn) {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem 0.8rem;
  font-size: 0.92rem;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.2s ease;
}

nav a:not(.btn) {
  text-decoration: none;
  background: #162724;
  color: var(--ink);
}

button:not(.btn) {
  background: var(--accent);
  color: #042216;
  border-color: #2fb989;
  font-weight: 700;
}

nav a:not(.btn):hover,
button:not(.btn):hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(6, 16, 13, 0.45);
}

button:not(.btn):hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: #eafff6;
}

button:not(.btn):disabled {
  opacity: 0.72;
  cursor: not-allowed;
}

.container {
  max-width: 1560px;
  margin: 1.8rem auto;
  padding: 0 1rem;
}

.card {
  background: linear-gradient(180deg, rgba(23, 39, 35, 0.98), rgba(18, 32, 29, 0.98));
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--ink);
  padding: 1.2rem;
  margin-bottom: 1.2rem;
  box-shadow: 0 18px 40px rgba(4, 11, 9, 0.45);
}

.card h2,
.card h3 {
  margin-top: 0;
  letter-spacing: 0.2px;
}

.messages {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}

.messages li {
  padding: 0.76rem 0.84rem;
  margin-bottom: 0.5rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #132320;
}

.messages li.success {
  border-color: #2f7a62;
  background: #123429;
}

.messages li.error {
  border-color: #7c3d3d;
  background: #381c1c;
}

.inline-form {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
}

.create-user-form {
  display: grid;
  gap: 0.68rem;
  max-width: 820px;
}

.form-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 0.75rem;
  align-items: center;
}

.form-row label {
  font-weight: 700;
  color: #dcf3eb;
}

input[type="text"]:not(.form-control),
input[type="email"]:not(.form-control),
input[type="password"]:not(.form-control),
input[type="file"]:not(.form-control),
select:not(.form-select) {
  width: 100%;
  border: 1px solid #33534b;
  border-radius: 10px;
  padding: 0.56rem 0.65rem;
  background: #10201d;
  color: var(--ink);
}

input::placeholder {
  color: #8cad9f;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.create-user-form button {
  width: fit-content;
}

.button-link:not(.btn) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem 0.8rem;
  font-size: 0.92rem;
  text-decoration: none;
  background: #162724;
  color: var(--ink);
}

.button-link:not(.btn):hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(6, 16, 13, 0.45);
}

code {
  background: #102320;
  border: 1px solid #2d4942;
  border-radius: 8px;
  padding: 0.15rem 0.45rem;
  font-size: 0.84rem;
  color: #b2f7d9;
}

.token-reveal {
  margin-top: 0.8rem;
  padding: 0.9rem;
  border: 1px solid #5f4f2b;
  border-radius: 10px;
  background: linear-gradient(180deg, #3a321f, #2c2517);
  display: grid;
  gap: 0.45rem;
}

.token-secret {
  width: 100%;
  min-height: 74px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.82rem;
  overflow-wrap: anywhere;
  word-break: break-all;
}

.token-actions {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  flex-wrap: wrap;
}

.moderation-table-wrap {
  overflow: auto;
  border: 1px solid #27403a;
  border-radius: 14px;
}

.moderation-filters {
  display: grid;
  gap: 0.7rem;
  margin-bottom: 0.9rem;
}

.moderation-filter-grid {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: 2fr 1fr 1fr 120px;
}

.moderation-filter-grid label {
  display: grid;
  gap: 0.32rem;
  font-size: 0.85rem;
  color: #d6ede5;
  font-weight: 700;
}

.moderation-filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.moderation-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.5rem 0 0.75rem;
}

.meta-chip {
  border: 1px solid #35514a;
  border-radius: 999px;
  background: #132723;
  color: #d1e8e0;
  font-size: 0.78rem;
  padding: 0.2rem 0.55rem;
}

.user-table {
  width: 100%;
  min-width: 980px;
  border-collapse: separate;
  border-spacing: 0;
}

.user-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #12211f;
  border-bottom: 1px solid var(--line);
  color: #d1e8e0;
  font-size: 0.82rem;
  letter-spacing: 0.2px;
}

.user-table th,
.user-table td {
  border-right: 1px solid #26403a;
  border-bottom: 1px solid #223935;
  padding: 0.74rem;
  text-align: left;
  vertical-align: top;
}

.user-table th:last-child,
.user-table td:last-child {
  border-right: none;
}

.user-table tbody tr:nth-child(even) td {
  background: #132420;
}

.user-table tbody tr:nth-child(odd) td {
  background: #10201d;
}

.account-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.account-email {
  color: var(--ink-soft);
  font-size: 0.82rem;
  margin-top: 0.16rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.2rem 0.58rem;
  font-size: 0.74rem;
  font-weight: 700;
  border: 1px solid transparent;
}

.badge-admin {
  background: #44371b;
  color: #ffd78f;
  border-color: #8c6a2e;
}

.badge-moderator {
  background: #103a2f;
  color: #9af7d3;
  border-color: #2f8a6f;
}

.badge-user {
  background: #243330;
  color: #c8d8d3;
  border-color: #3b4f4a;
}

.badge-ok {
  background: #123a2d;
  color: #8cf0ca;
  border-color: #2f8c70;
}

.badge-warn {
  background: #3c2323;
  color: #ffb3b3;
  border-color: #7c4f4f;
}

.badge-muted {
  background: #202f2b;
  color: #a8bdb6;
  border-color: #334742;
}

.meta-line {
  color: var(--ink-soft);
  font-size: 0.8rem;
  margin-top: 0.35rem;
}

.action-stack {
  display: grid;
  gap: 0.45rem;
}

.action-stack button {
  width: 100%;
}

.action-stack-item {
  display: grid;
  gap: 0.45rem;
}

.user-actions {
  border: 1px solid #2f4a43;
  border-radius: 10px;
  background: #132420;
}

.user-actions summary {
  cursor: pointer;
  font-weight: 700;
  padding: 0.45rem 0.6rem;
  color: #d9f3ea;
}

.user-actions[open] summary {
  border-bottom: 1px solid #2f4a43;
}

.user-actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.7rem;
  padding: 0.65rem;
}

.action-block {
  border: 1px solid #29443d;
  border-radius: 10px;
  background: #0f1f1c;
  padding: 0.55rem;
  display: grid;
  gap: 0.45rem;
}

.action-block h4 {
  margin: 0;
  font-size: 0.86rem;
  color: #cfe9df;
}

.action-links {
  display: grid;
  gap: 0.4rem;
}

.dav-token-form input[type="text"] {
  min-width: 200px;
}

.token-list {
  list-style: none;
  margin: 0.62rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.42rem;
}

.token-list li {
  border: 1px solid #2f4a43;
  border-radius: 10px;
  padding: 0.56rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.56rem;
  background: #172925;
}

.token-list small {
  color: var(--ink-soft);
  display: block;
  margin-top: 0.2rem;
}

.pagination {
  margin-top: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.pagination a {
  text-decoration: none;
  border: 1px solid #34564d;
  border-radius: 9px;
  padding: 0.34rem 0.58rem;
  background: #132622;
}

.pagination span {
  color: #cfe7de;
  font-size: 0.88rem;
}

.app-loader {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(4, 12, 10, 0.72);
  backdrop-filter: blur(4px);
  z-index: 2000;
}

.app-loader.is-visible {
  display: flex;
}

.app-loader-card {
  width: min(420px, 92vw);
  border: 1px solid #31554b;
  border-radius: 16px;
  background: #0e1c19;
  padding: 1.2rem;
  text-align: center;
  box-shadow: 0 18px 45px rgba(2, 8, 7, 0.55);
}

.app-loader-card h4 {
  margin: 0.35rem 0 0.3rem;
  font-size: 1.08rem;
}

.app-loader-card p {
  margin: 0;
  color: var(--ink-soft);
}

.spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto;
  border-radius: 50%;
  border: 3px solid #2b4f44;
  border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.login-main {
  max-width: 1200px;
}

.login-shell {
  display: grid;
  grid-template-columns: 1.2fr 0.9fr;
  gap: 1rem;
  align-items: stretch;
}

.login-visual {
  background:
    linear-gradient(140deg, rgba(10, 33, 29, 0.9), rgba(12, 52, 41, 0.72)),
    url("../img/forest-night.svg") center center / cover no-repeat;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 420px;
}

.login-eyebrow {
  margin: 0;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1.1px;
  color: #8de6c3;
}

.login-visual h2 {
  margin: 0.5rem 0 0.6rem;
  font-size: 2rem;
  max-width: 520px;
}

.login-visual p {
  margin: 0;
  color: #c4dfd5;
  max-width: 520px;
}

.login-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-form {
  display: grid;
  gap: 0.8rem;
}

.login-field {
  display: grid;
  gap: 0.35rem;
}

.login-field label {
  font-size: 0.86rem;
  font-weight: 700;
  color: #d6ede5;
}

.login-submit {
  margin-top: 0.35rem;
  width: 100%;
  padding: 0.68rem 0.8rem;
}

.map-view-main {
  max-width: 100%;
  margin-top: 1rem;
}

.map-page-shell {
  padding: 0.7rem;
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(250px, 320px) 1fr;
  gap: 0.8rem;
}

.map-page-head {
  padding: 0.4rem 0.5rem 0.7rem;
}

.map-page-head h2 {
  margin: 0;
}

.map-page-head p {
  margin: 0.25rem 0 0;
  color: var(--ink-soft);
}

.qgis-map-root {
  position: relative;
  width: 100%;
  height: min(74vh, 860px);
  border: 1px solid #29423b;
  border-radius: 14px;
  overflow: hidden;
  background: #0b1816;
}

.qgis-layer-panel {
  border: 1px solid #29423b;
  border-radius: 14px;
  background: #0b1816;
  padding: 0.55rem;
  min-height: 420px;
  max-height: min(74vh, 860px);
  overflow: auto;
}

.layer-panel-loading,
.layer-panel-error {
  color: #cae5db;
  font-size: 0.9rem;
}

.layer-panel-actions {
  display: flex;
  gap: 0.45rem;
  margin-bottom: 0.6rem;
}

.layer-panel-actions button {
  padding: 0.35rem 0.55rem;
  font-size: 0.8rem;
}

.layer-panel-list {
  display: grid;
  gap: 0.35rem;
}

.layer-row {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  gap: 0.4rem;
  align-items: center;
  border: 1px solid #214039;
  border-radius: 8px;
  padding: 0.35rem 0.45rem;
  background: #10201d;
}

.layer-row.has-error {
  border-color: #7c3d3d;
}

.layer-name {
  color: #d4ebe3;
  font-size: 0.88rem;
  line-height: 1.25;
}

.layer-code {
  grid-column: 2 / 4;
  font-size: 0.74rem;
  opacity: 0.85;
}

.layer-meta {
  grid-column: 2 / 3;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.layer-query-toggle {
  grid-column: 3 / 4;
  grid-row: 1 / 3;
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  font-size: 0.72rem;
  color: #bde2d5;
}

.layer-query-toggle input {
  margin: 0;
}

.layer-query-toggle.is-disabled {
  opacity: 0.55;
}

.layer-meta.is-queryable {
  color: #8de4c4;
}

.layer-meta.is-static {
  color: #f2c58a;
}

.qgis-map-root .ol-viewport {
  border-radius: 14px;
}

.qgis-map-loading,
.qgis-map-error {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: #cae5db;
  font-size: 0.95rem;
  text-align: center;
  padding: 1rem;
}

.qgis-map-error {
  color: #ffd5d5;
}

.qgis-map-warning {
  position: absolute;
  z-index: 20;
  left: 12px;
  bottom: 12px;
  background: rgba(56, 28, 28, 0.92);
  border: 1px solid #7c3d3d;
  border-radius: 8px;
  color: #ffd5d5;
  padding: 0.45rem 0.6rem;
  font-size: 0.84rem;
  max-width: min(620px, calc(100% - 24px));
}

.qgis-feature-popup {
  z-index: 30;
  width: min(460px, calc(100vw - 40px));
  max-height: 320px;
  overflow: auto;
  background: rgba(10, 21, 19, 0.95);
  border: 1px solid #2d4942;
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  padding: 0.5rem;
}

.qgis-feature-popup.is-hidden {
  display: none;
}

.qgis-feature-loading,
.qgis-feature-empty,
.qgis-feature-raw {
  color: #cae5db;
  font-size: 0.84rem;
}

.qgis-feature-raw {
  white-space: pre-wrap;
  word-break: break-word;
}

.qgis-feature-list {
  display: grid;
  gap: 0.45rem;
}

.qgis-feature-card {
  border: 1px solid #24413a;
  border-radius: 8px;
  padding: 0.45rem;
  background: #112420;
}

.qgis-feature-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #d8f4e8;
  margin-bottom: 0.35rem;
}

.qgis-feature-grid {
  display: grid;
  grid-template-columns: minmax(120px, 40%) 1fr;
  gap: 0.18rem 0.45rem;
}

.qgis-feature-key {
  font-size: 0.74rem;
  color: #9dc8b9;
  word-break: break-word;
}

.qgis-feature-val {
  font-size: 0.78rem;
  color: #e6f7f0;
  word-break: break-word;
}

@media (max-width: 1100px) {
  .login-shell {
    grid-template-columns: 1fr;
  }

  .login-visual {
    min-height: 260px;
  }
}

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

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

  .form-row {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }

  .card {
    overflow-x: auto;
  }

  .qgis-map-root {
    height: min(68vh, 660px);
  }

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

  .qgis-layer-panel {
    min-height: 220px;
    max-height: 280px;
  }
}
