/* Kawoko Parish Management System — design system and components. */

:root {
  --green-950: #071a13;
  --green-900: #0b2a1e;
  --green-800: #113a2a;
  --green-700: #17553d;
  --green-600: #1c6b4c;
  --green-500: #27855f;
  --green-400: #4aa27a;
  --green-100: #e6f2ec;
  --gold-600: #b6893a;
  --gold-500: #c9a24d;
  --gold-400: #ddbd75;
  --gold-100: #fbf3e0;
  --ink: #10201a;
  --ink-soft: #2c4038;
  --muted: #5f7169;
  --muted-2: #7d8d85;
  --line: #e3e9e5;
  --line-strong: #cfd9d3;
  --surface: #ffffff;
  --canvas: #f6f8f6;
  --canvas-2: #eef2ef;
  --danger: #b23b3b;
  --danger-bg: #fbeceb;
  --warning: #a97519;
  --warning-bg: #fdf4e1;
  --ok: #1f7a52;
  --ok-bg: #e8f4ee;
  --shadow-sm: 0 1px 2px rgba(16, 32, 26, 0.06), 0 1px 3px rgba(16, 32, 26, 0.04);
  --shadow-md: 0 8px 24px rgba(16, 32, 26, 0.08), 0 2px 6px rgba(16, 32, 26, 0.05);
  --shadow-lg: 0 24px 60px rgba(16, 32, 26, 0.16);
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --max: 1200px;
}

[data-theme='dark'] {
  --ink: #eef4f0;
  --ink-soft: #cfe0d7;
  --muted: #9db0a7;
  --muted-2: #84978e;
  --line: #23352c;
  --line-strong: #2f463b;
  --surface: #101d17;
  --canvas: #0a1410;
  --canvas-2: #0f1c16;
  --green-100: #163024;
  --gold-100: #2b2313;
  --danger-bg: #2c1616;
  --warning-bg: #2b2313;
  --ok-bg: #12291f;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 30px 70px rgba(0, 0, 0, 0.55);
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--canvas);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img,
svg,
canvas {
  display: block;
  max-width: 100%;
}

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

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 700;
}

p {
  margin: 0;
}

::selection {
  background: var(--gold-400);
  color: var(--green-950);
}

:focus-visible {
  outline: 3px solid var(--gold-500);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ------------------------------------------------------------------ layout */

.wrap {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 24px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.row-wrap {
  flex-wrap: wrap;
}

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

.grow {
  flex: 1 1 auto;
  min-width: 0;
}

.muted {
  color: var(--muted);
}

.text-warn {
  color: var(--warning);
}

.small {
  font-size: 0.82rem;
}

.tiny {
  font-size: 0.74rem;
}

.center {
  text-align: center;
}

.mono {
  font-family: var(--mono);
  font-size: 0.86em;
}

.nowrap {
  white-space: nowrap;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden {
  display: none !important;
}

/* ------------------------------------------------------------------ brand */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(150deg, var(--green-600), var(--green-900));
  display: grid;
  place-items: center;
  color: var(--gold-400);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), var(--shadow-sm);
  flex: 0 0 auto;
}

.brand-mark svg {
  width: 24px;
  height: 24px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-title {
  font-weight: 750;
  font-size: 1.02rem;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

/* ------------------------------------------------------------------ buttons */

.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--ink);
  --btn-border: var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
  text-decoration: none;
}

.btn:hover {
  text-decoration: none;
  border-color: var(--green-400);
  box-shadow: var(--shadow-sm);
}

.btn:active {
  transform: translateY(1px);
}

.btn[disabled],
.btn.is-busy {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  --btn-bg: linear-gradient(160deg, var(--green-600), var(--green-800));
  --btn-fg: #fff;
  --btn-border: transparent;
  box-shadow: 0 6px 18px rgba(23, 85, 61, 0.24);
}

.btn-primary:hover {
  border-color: transparent;
  box-shadow: 0 10px 26px rgba(23, 85, 61, 0.32);
}

.btn-gold {
  --btn-bg: linear-gradient(160deg, var(--gold-500), var(--gold-600));
  --btn-fg: #231a08;
  --btn-border: transparent;
}

.btn-ghost {
  --btn-bg: transparent;
  --btn-border: transparent;
  color: var(--muted);
}

.btn-ghost:hover {
  --btn-bg: var(--canvas-2);
  color: var(--ink);
  border-color: transparent;
}

.btn-outline {
  --btn-bg: transparent;
}

.btn-danger {
  --btn-bg: var(--danger);
  --btn-fg: #fff;
  --btn-border: transparent;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 0.8rem;
  border-radius: 8px;
  gap: 6px;
}

.btn-lg {
  padding: 14px 22px;
  font-size: 1rem;
  border-radius: 12px;
}

.btn-icon {
  padding: 8px;
  width: 36px;
  height: 36px;
  border-radius: 9px;
}

.btn .icon {
  width: 16px;
  height: 16px;
}

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ------------------------------------------------------------------ badges */

.badge {
  text-transform: capitalize;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  background: var(--canvas-2);
  color: var(--ink-soft);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.badge-ok {
  background: var(--ok-bg);
  color: var(--ok);
  border-color: transparent;
}

.badge-warn {
  background: var(--warning-bg);
  color: var(--warning);
  border-color: transparent;
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: transparent;
}

.badge-gold {
  background: var(--gold-100);
  color: var(--gold-600);
  border-color: transparent;
}

.badge-green {
  background: var(--green-100);
  color: var(--green-700);
  border-color: transparent;
}

.badge-outline {
  background: transparent;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}

/* ------------------------------------------------------------------ public site */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  height: 74px;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.site-nav a {
  padding: 8px 12px;
  border-radius: 9px;
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 550;
}

.site-nav a:hover {
  background: var(--canvas-2);
  text-decoration: none;
  color: var(--ink);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hero {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(1100px 520px at 82% -10%, rgba(201, 162, 77, 0.18), transparent 62%),
    radial-gradient(900px 500px at 8% 0%, rgba(39, 133, 95, 0.28), transparent 58%),
    linear-gradient(170deg, var(--green-950) 0%, var(--green-900) 48%, #0e3023 100%);
  color: #f2f7f4;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(760px 460px at 62% 24%, #000 20%, transparent 78%);
  pointer-events: none;
}

.hero-inner {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 56px;
  align-items: center;
  padding: 76px 0 84px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 0.74rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  font-weight: 650;
  color: var(--gold-400);
}

.hero h1 {
  margin-top: 20px;
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  letter-spacing: -0.035em;
  line-height: 1.03;
  font-weight: 780;
}

.hero h1 em {
  font-style: normal;
  color: var(--gold-400);
}

.hero-lead {
  margin-top: 18px;
  font-size: clamp(1rem, 1.4vw, 1.12rem);
  color: rgba(238, 247, 242, 0.78);
  max-width: 54ch;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
}

.hero-meta {
  margin-top: 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  font-size: 0.84rem;
  color: rgba(238, 247, 242, 0.6);
}

.hero-meta span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.hero-map-card {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(6, 22, 16, 0.6);
  box-shadow: 0 40px 90px rgba(0, 0, 0, 0.45);
}

.hero-map-card .map-canvas {
  height: 380px;
}

.hero-map-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(7, 26, 19, 0.9);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.78rem;
  color: rgba(238, 247, 242, 0.75);
}

.stat-strip {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: rgba(255, 255, 255, 0.1);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-strip .stat {
  background: rgba(8, 26, 19, 0.72);
  padding: 22px 24px;
}

.stat-value {
  font-size: clamp(1.5rem, 2.6vw, 2.1rem);
  font-weight: 750;
  letter-spacing: -0.03em;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  margin-top: 2px;
  font-size: 0.76rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(238, 247, 242, 0.55);
  font-weight: 600;
}

.section {
  padding: 84px 0;
}

.section-tight {
  padding: 56px 0;
}

.section-alt {
  background: var(--surface);
  border-block: 1px solid var(--line);
}

.section-head {
  max-width: 62ch;
  margin-bottom: 36px;
}

.section-kicker {
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--green-600);
  margin-bottom: 10px;
}

.section-head h2 {
  font-size: clamp(1.6rem, 3vw, 2.3rem);
}

.section-head p {
  margin-top: 12px;
  color: var(--muted);
  font-size: 1.02rem;
}

.village-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
}

.village-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.village-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--line-strong);
}

.village-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.village-chip {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--green-100);
  color: var(--green-700);
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  flex: 0 0 auto;
}

.village-card h3 {
  font-size: 1rem;
  font-weight: 650;
}

.village-numbers {
  display: flex;
  gap: 18px;
  margin-bottom: 12px;
}

.village-numbers div {
  display: flex;
  flex-direction: column;
}

.village-numbers strong {
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
}

.village-numbers span {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.progress {
  height: 6px;
  border-radius: 999px;
  background: var(--canvas-2);
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--green-500), var(--gold-500));
  transition: width 0.4s ease;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 6px;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.feature {
  padding: 26px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}

.feature-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--green-100);
  color: var(--green-700);
  margin-bottom: 16px;
}

.feature h3 {
  font-size: 1.02rem;
  margin-bottom: 9px;
}

.feature p {
  color: var(--muted);
  font-size: 0.93rem;
}

.role-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 18px;
}

.role-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  position: relative;
}

.role-card.is-founder {
  border-color: var(--gold-400);
  background:
    linear-gradient(180deg, var(--gold-100), transparent 46%),
    var(--surface);
  box-shadow: var(--shadow-sm);
}

.role-card h3 {
  font-size: 1.12rem;
}

.role-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.89rem;
  display: grid;
  gap: 6px;
}

.role-card li::marker {
  color: var(--gold-500);
}

.role-card .role-perms {
  margin-top: auto;
  font-size: 0.76rem;
  color: var(--muted-2);
}

/* ------------------------------------------------------------------ map */

.map-frame {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: var(--canvas-2);
  box-shadow: var(--shadow-sm);
}

.map-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
}

.map-canvas.is-dragging {
  cursor: grabbing;
}

.map-canvas.is-placing {
  cursor: crosshair;
}

.map-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.map-overlay > * {
  pointer-events: auto;
}

.map-toolbar {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 3;
}

.map-toolbar .btn {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-sm);
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 9px;
}

.map-readout {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 11px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  font-size: 0.74rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.map-legend {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 3;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.74rem;
  color: var(--muted);
  display: grid;
  gap: 6px;
  box-shadow: var(--shadow-sm);
}

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

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.map-status {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  font-size: 0.76rem;
  font-weight: 600;
}

.map-status .dot {
  background: var(--green-500);
}

.map-status.is-placing .dot {
  background: var(--gold-500);
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.map-attribution {
  position: absolute;
  right: 8px;
  top: 8px;
  font-size: 0.62rem;
  color: var(--muted-2);
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ------------------------------------------------------------------ admin shell */

.admin-body {
  background: var(--canvas);
}

.admin-shell {
  display: grid;
  grid-template-columns: 258px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px 14px;
  background: var(--green-950);
  color: #dcebe3;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  overflow-y: auto;
}

.sidebar .brand {
  padding: 4px 6px 14px;
  color: #fff;
}

.sidebar .brand-mark {
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.sidebar .brand-sub {
  color: rgba(220, 235, 227, 0.55);
}

.sidebar-section {
  padding: 14px 10px 6px;
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(220, 235, 227, 0.42);
  font-weight: 700;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: 9px;
  color: rgba(220, 235, 227, 0.78);
  font-size: 0.88rem;
  font-weight: 550;
  text-decoration: none;
  border: 1px solid transparent;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  text-decoration: none;
}

.nav-link.is-active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: inset 3px 0 0 var(--gold-500);
}

.nav-link .icon {
  opacity: 0.8;
}

.nav-link .pill {
  margin-left: auto;
  font-size: 0.68rem;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.8rem;
  background: linear-gradient(150deg, var(--green-500), var(--green-700));
  color: #fff;
  flex: 0 0 auto;
}

.user-chip .who {
  min-width: 0;
}

.user-chip .who strong {
  display: block;
  font-size: 0.83rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #fff;
}

.user-chip .who span {
  font-size: 0.7rem;
  color: rgba(220, 235, 227, 0.6);
}

.admin-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 28px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  font-size: 1.16rem;
  font-weight: 700;
}

.topbar .sub {
  font-size: 0.78rem;
  color: var(--muted);
}

.page {
  padding: 26px 28px 60px;
  max-width: 1500px;
  width: 100%;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.page-head h2 {
  font-size: 1.35rem;
}

.page-head p {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

/* ------------------------------------------------------------------ panels & cards */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-head h3 {
  font-size: 0.98rem;
  font-weight: 650;
}

.panel-body {
  padding: 18px;
}

.panel-body.tight {
  padding: 0;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.kpi-grid.four {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.kpi {
  position: relative;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.kpi::after {
  content: '';
  position: absolute;
  right: -24px;
  top: -24px;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--green-100);
  opacity: 0.55;
}

.kpi > * {
  position: relative;
  z-index: 1;
}

.kpi-label {
  font-size: 0.74rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 650;
}

.kpi-value {
  font-size: 1.9rem;
  font-weight: 750;
  letter-spacing: -0.03em;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

.kpi-note {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 4px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 18px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

/* ------------------------------------------------------------------ tables */

.table-wrap {
  overflow-x: auto;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
}

table.data th {
  text-align: left;
  padding: 10px 14px;
  font-size: 0.72rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  background: var(--canvas);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

table.data td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

table.data tbody tr {
  transition: background 0.12s ease;
}

table.data tbody tr:hover {
  background: var(--canvas);
}

table.data tbody tr:last-child td {
  border-bottom: 0;
}

table.data .name-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

table.data .name-cell strong {
  font-weight: 620;
  display: block;
}

table.data .name-cell span {
  font-size: 0.75rem;
  color: var(--muted);
}

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

/* ------------------------------------------------------------------ forms */

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px 16px;
}

.form-grid.cols-3 {
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field.span-2 {
  grid-column: span 2;
}

.field.span-full {
  grid-column: 1 / -1;
}

label.label {
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--ink-soft);
  letter-spacing: 0.01em;
}

label.label .req {
  color: var(--danger);
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.89rem;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--green-500);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--green-500) 18%, transparent);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--muted-2);
}

.textarea {
  min-height: 84px;
  resize: vertical;
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235f7169' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 32px;
}

.field-error {
  font-size: 0.74rem;
  color: var(--danger);
}

.field-hint {
  font-size: 0.74rem;
  color: var(--muted);
}

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 0.86rem;
  cursor: pointer;
  user-select: none;
}

.checkbox input {
  margin: 3px 0 0;
  width: 16px;
  height: 16px;
  accent-color: var(--green-600);
  flex: 0 0 auto;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-size: 0.84rem;
}

.switch input {
  appearance: none;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--line-strong);
  position: relative;
  transition: background 0.16s ease;
  cursor: pointer;
  margin: 0;
}

.switch input::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.16s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.switch input:checked {
  background: var(--green-600);
}

.switch input:checked::after {
  transform: translateX(16px);
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: 10px;
  background: var(--canvas-2);
  border: 1px solid var(--line);
  gap: 2px;
}

.segmented button {
  border: 0;
  background: transparent;
  padding: 6px 12px;
  border-radius: 7px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.segmented button.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.search-field {
  position: relative;
  flex: 1 1 240px;
  max-width: 360px;
}

.search-field .icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-2);
  width: 16px;
  height: 16px;
}

.search-field .input {
  padding-left: 33px;
}

/* ------------------------------------------------------------------ tabs */

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tabs button {
  border: 0;
  background: transparent;
  padding: 11px 14px;
  font: inherit;
  font-size: 0.87rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.tabs button.is-active {
  color: var(--green-700);
  border-bottom-color: var(--green-600);
}

[data-theme='dark'] .tabs button.is-active {
  color: var(--green-400);
}

/* ------------------------------------------------------------------ pagination */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
  color: var(--muted);
  flex-wrap: wrap;
}

.pagination .pages {
  display: flex;
  gap: 4px;
  align-items: center;
}

/* ------------------------------------------------------------------ toast & modal */

.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(380px, calc(100vw - 36px));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 11px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-md);
  font-size: 0.87rem;
  animation: toast-in 0.22s ease;
}

.toast.is-error {
  border-color: color-mix(in srgb, var(--danger) 40%, var(--line));
  background: var(--danger-bg);
  color: var(--danger);
}

.toast.is-ok {
  border-color: color-mix(in srgb, var(--ok) 40%, var(--line));
  background: var(--ok-bg);
  color: var(--ok);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(6, 20, 14, 0.5);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 20px;
  animation: fade-in 0.15s ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  width: min(680px, 100%);
  max-height: min(90vh, 900px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modal-in 0.18s ease;
}

.modal.modal-wide {
  width: min(980px, 100%);
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(14px) scale(0.99); }
  to { opacity: 1; transform: none; }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-head h3 {
  font-size: 1.05rem;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: var(--canvas);
}

/* ------------------------------------------------------------------ misc */

.empty {
  padding: 46px 20px;
  text-align: center;
  color: var(--muted);
}

.empty .icon {
  width: 34px;
  height: 34px;
  margin: 0 auto 12px;
  color: var(--muted-2);
}

.empty h4 {
  font-size: 0.98rem;
  color: var(--ink);
  margin-bottom: 4px;
}

.empty p {
  font-size: 0.86rem;
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 18px 0;
}

.skeleton {
  border-radius: 8px;
  background: linear-gradient(90deg, var(--canvas-2) 25%, var(--line) 37%, var(--canvas-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease infinite;
}

@keyframes shimmer {
  from { background-position: 100% 0; }
  to { background-position: 0 0; }
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--canvas);
}

.login-art {
  position: relative;
  background:
    radial-gradient(900px 480px at 70% -10%, rgba(201, 162, 77, 0.22), transparent 60%),
    linear-gradient(160deg, var(--green-950), var(--green-800));
  color: #eaf4ef;
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

.login-art::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(600px 400px at 40% 60%, #000, transparent 76%);
}

.login-art > * {
  position: relative;
  z-index: 1;
}

.login-art h2 {
  font-size: clamp(1.7rem, 2.6vw, 2.4rem);
  max-width: 16ch;
  line-height: 1.08;
}

.login-art p {
  color: rgba(234, 244, 239, 0.7);
  margin-top: 14px;
  max-width: 42ch;
  font-size: 0.95rem;
}

.login-form-wrap {
  display: grid;
  place-items: center;
  padding: 40px 24px;
}

.login-form {
  width: min(400px, 100%);
}

.login-form h1 {
  font-size: 1.6rem;
  margin-bottom: 6px;
}

.login-form .sub {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 26px;
}

.demo-hint {
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--gold-100);
  border: 1px solid color-mix(in srgb, var(--gold-500) 35%, transparent);
  font-size: 0.8rem;
  color: var(--gold-600);
}

.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid color-mix(in srgb, var(--warning) 24%, transparent);
  margin-bottom: 16px;
}

.banner .icon {
  width: 17px;
  height: 17px;
}

.kv {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 8px 16px;
  font-size: 0.87rem;
}

.kv dt {
  color: var(--muted);
  font-size: 0.8rem;
}

.kv dd {
  margin: 0;
  font-weight: 550;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.sticky-side {
  position: sticky;
  top: 84px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.avatar-sm {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  font-size: 0.72rem;
}

.pin-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
}

.pin-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.84rem;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.pin-item:hover {
  border-color: var(--green-400);
}

.pin-item.is-selected {
  border-color: var(--green-600);
  background: var(--green-100);
}

.map-split {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.map-panel {
  height: calc(100vh - 190px);
  min-height: 480px;
  display: flex;
  flex-direction: column;
}

.map-panel .map-frame {
  flex: 1;
  border-radius: 0;
  border: 0;
}

.gps-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.coord-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.gps-status {
  font-size: 0.78rem;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--canvas-2);
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.gps-status.is-good {
  background: var(--ok-bg);
  color: var(--ok);
}

.gps-status.is-bad {
  background: var(--warning-bg);
  color: var(--warning);
}

.role-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  font-weight: 650;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--canvas-2);
  border: 1px solid var(--line);
  text-transform: capitalize;
}

.role-pill.founder { background: var(--gold-100); color: var(--gold-600); border-color: transparent; }
.role-pill.admin { background: var(--green-100); color: var(--green-700); border-color: transparent; }
.role-pill.field_officer { background: #e9eefb; color: #3a53a5; border-color: transparent; }
.role-pill.viewer { background: var(--canvas-2); color: var(--muted); }

[data-theme='dark'] .role-pill.field_officer { background: #1b2440; color: #9db1ef; }

@media (max-width: 1080px) {
  .hero-inner {
    grid-template-columns: 1fr;
    gap: 36px;
    padding: 56px 0 64px;
  }
  .detail-layout,
  .map-split {
    grid-template-columns: 1fr;
  }
  .sticky-side {
    position: static;
  }
  .map-panel {
    height: 70vh;
  }
}

@media (max-width: 900px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 264px;
    z-index: 60;
    transform: translateX(-102%);
    transition: transform 0.2s ease;
  }
  .sidebar.is-open {
    transform: none;
    box-shadow: var(--shadow-lg);
  }
  .sidebar-scrim {
    position: fixed;
    inset: 0;
    background: rgba(6, 20, 14, 0.45);
    z-index: 55;
  }
  .nav-toggle {
    display: inline-flex !important;
  }
  .page,
  .topbar {
    padding-left: 18px;
    padding-right: 18px;
  }
  .login-shell {
    grid-template-columns: 1fr;
  }
  .login-art {
    display: none;
  }
  .stat-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .site-nav {
    display: none;
  }
}

@media (max-width: 620px) {
  .section {
    padding: 56px 0;
  }
  .wrap {
    padding: 0 16px;
  }
  .page,
  .topbar {
    padding-left: 14px;
    padding-right: 14px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .field.span-2 {
    grid-column: span 1;
  }
  .kv {
    grid-template-columns: 1fr;
    gap: 2px 0;
  }
  .kv dd {
    margin-bottom: 8px;
  }
  .modal-foot {
    flex-wrap: wrap;
  }
  .site-header .wrap {
    height: 64px;
  }
  .brand-title {
    font-size: 0.94rem;
  }
  .nav-toggle {
    display: none !important;
  }
}

@media print {
  .sidebar,
  .topbar,
  .toolbar,
  .pagination,
  .btn {
    display: none !important;
  }
  .admin-shell {
    grid-template-columns: 1fr;
  }
}
