/* MeshMate web frontend — visual system per plan/redesign.md §2/§3.
   Light theme: warm green-tinted off-white, forest green primary, navy brand,
   cyan->lime "signal" gradient accent. Hanken Grotesk UI + JetBrains Mono detail. */
@import url('https://fonts.googleapis.com/css2?family=Hanken+Grotesk:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg: #EAEFE8;
  --surface: #FFFFFF;
  --surface-2: #F4F7F2;
  --nav: #0E2238;
  --line: rgba(16, 27, 46, 0.08);

  --text-hi: #102036;
  --text-mid: #51627A;
  --text-low: #8496A8;

  --primary: #2E7D32;
  --primary-d: #245F28;
  --on-primary: #FFFFFF;
  --primary-c: #CFE9D3;
  --on-primary-c: #14431A;
  --accent: #2E7D32;          /* links, focus, active states */
  --icon-chip: #E7EFE6;
  --chip-muted: #EAEEF3;

  --secondary: #0E8C9A;
  --secondary-bg: rgba(31, 208, 224, 0.14);

  --warn-bg: #FBEEDC;
  --warn-border: rgba(180, 120, 30, 0.25);
  --warn-text: #7A5410;
  --danger: #C1392B;
  --danger-bg: #FDECEA;

  --sig: linear-gradient(90deg, #1FD0E0 0%, #7FDB8C 55%, #C6F24E 100%);

  --radius: 20px;
  --radius-field: 15px;
  --shadow: 0 8px 24px -16px rgba(40, 60, 45, 0.5);
  --ui: 'Hanken Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* legacy aliases so older rules keep resolving */
  --muted: var(--text-mid);
  --ink: var(--text-hi);
  --card: var(--surface);
  --green: var(--primary);
  --green-d: var(--primary-d);
}

/* Dark theme (redesign §2). A head script sets [data-theme] from the saved
   choice or the OS preference before paint, so CSS only needs these overrides.
   Dark uses borders, not shadows. */
[data-theme="dark"] {
  --bg: #0A1320;
  --surface: #16243A;
  --surface-2: #1E3048;
  --nav: #0C1626;
  --line: rgba(255, 255, 255, 0.07);

  --text-hi: #EAF1F8;
  --text-mid: #94A7BD;
  --text-low: #7D8EA1;

  --primary: #A7E0AC;          /* filled button bg */
  --primary-d: #BDEFC2;        /* hover */
  --on-primary: #0B3D14;       /* filled button label */
  --primary-c: rgba(127, 219, 140, 0.16);
  --on-primary-c: #BDEFC2;
  --accent: #7FDB8C;
  --icon-chip: #1E3048;
  --chip-muted: rgba(255, 255, 255, 0.07);

  --secondary: #5BE0EC;
  --secondary-bg: rgba(31, 208, 224, 0.16);

  --warn-bg: rgba(224, 182, 91, 0.14);
  --warn-border: rgba(224, 182, 91, 0.30);
  --warn-text: #E0B65B;
  --danger: #E0563B;
  --danger-bg: rgba(224, 86, 59, 0.15);

  --shadow: none;
}
[data-theme="dark"] select.input {
  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='%2394A7BD' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}
/* Dark map tiles get a hairline so the panel edge stays visible. */
[data-theme="dark"] #map { border-color: rgba(255, 255, 255, 0.10); }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--ui);
  color: var(--text-hi);
  background: var(--bg);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: var(--mono); font-feature-settings: "tnum"; }

/* Top bar */
.topbar {
  position: relative;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--nav); color: #EAF1F8; padding: 13px 22px;
}
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0;
  height: 3px; background: var(--sig);
}
.brand {
  display: flex; align-items: center; gap: 11px; color: #EAF1F8;
  font-weight: 800; font-size: 19px; letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }
.brand img { width: 34px; height: 34px; border-radius: 9px; }
.brand .wm-accent { color: #7FDB8C; }
.brand-sub {
  font-weight: 700; color: #8aa0b8; font-size: 11px; margin-left: 4px;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.topnav { display: flex; align-items: center; gap: 12px; }
.topnav .user { color: #c7d3e2; font-size: 14px; }
.toplink { color: #c7d3e2; font-size: 14px; font-weight: 600; }
.toplink:hover { color: #EAF1F8; text-decoration: none; }
@media (max-width: 620px) { .toplink { display: none; } }
.reg-table th { width: auto; }
.reg-table td .badge { margin: 0 4px 4px 0; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filter-bar .input { width: auto; flex: 1 1 220px; }
.filter-bar select.input { flex: 0 0 auto; min-width: 150px; }
.filter-bar .check-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--text-mid); }
.filter-count { color: var(--text-mid); font-size: 13px; margin: 12px 0 0; }
.theme-toggle {
  width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid rgba(255,255,255,0.28); border-radius: 50%;
  color: #EAF1F8; cursor: pointer; font-size: 15px; line-height: 1; padding: 0;
}
.theme-toggle:hover { background: rgba(255,255,255,0.1); }
.theme-toggle::before { content: "\263E"; }            /* moon — offer dark */
[data-theme="dark"] .theme-toggle::before { content: "\2600"; } /* sun — offer light */

.container { max-width: 1040px; margin: 0 auto; padding: 30px 22px 64px; }

/* Headings */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 16px; }
.page-head h1 { font-size: 27px; font-weight: 800; letter-spacing: -0.01em; margin: 0; }
.sub { color: var(--text-mid); font-size: 14px; margin: 3px 0 0; }

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px;
}
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.cols { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 20px; align-items: start; }
@media (max-width: 820px) { .cols { grid-template-columns: 1fr; } }

.region-card { transition: border-color .12s, transform .12s; }
.region-card:hover { border-color: var(--primary-c); text-decoration: none; }
.region-card h3 { margin: 0 0 4px; font-size: 17px; font-weight: 700; }
.region-card .slug { color: var(--text-mid); font-family: var(--mono); font-size: 12.5px; }
.region-card .meta { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }

/* Badges (pill, uppercase) */
.badge {
  display: inline-block; padding: 3px 11px; border-radius: 20px;
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
}
.badge.ok { background: var(--primary-c); color: var(--on-primary-c); }
.badge.muted { background: var(--chip-muted); color: var(--text-low); }
.badge.warn { background: var(--warn-bg); color: var(--warn-text); }
.badge.secondary { background: var(--secondary-bg); color: var(--secondary); }

/* Forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.form-section {
  margin: 24px 0 12px; padding-bottom: 7px; border-bottom: 1px solid var(--line);
  font-size: 13px; font-weight: 700; color: var(--text-low);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.form-section:first-child { margin-top: 0; }
.form-section .hint {
  display: block; font-weight: 500; font-size: 12px; color: var(--text-mid);
  margin-top: 3px; text-transform: none; letter-spacing: 0;
}
.pending-list { list-style: none; margin: 12px 0 0; padding: 0; }
.pending-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-top: 1px solid var(--line);
}

.field label {
  display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-hi);
}
.field .help { color: var(--text-mid); font-size: 12px; margin-top: 4px; }
.field .err { color: var(--danger); font-size: 12px; margin-top: 4px; }
.input {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--radius-field);
  font-family: var(--ui); font-size: 14.5px; font-weight: 500; background: var(--surface); color: var(--text-hi);
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
select.input { 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='%2351627A' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
.check-row { display: flex; align-items: center; gap: 8px; }
.check { width: 18px; height: 18px; accent-color: var(--primary); }

/* Buttons (pill) */
.btn {
  display: inline-flex; align-items: center; gap: 8px; background: var(--primary);
  color: var(--on-primary); border: none; border-radius: 30px; padding: 11px 22px;
  font-family: var(--ui); font-size: 14.5px; font-weight: 700; cursor: pointer;
}
.btn:hover { background: var(--primary-d); text-decoration: none; }
.btn-ghost {
  background: transparent; color: #EAF1F8; border: 1px solid rgba(255,255,255,0.28);
  border-radius: 30px; padding: 8px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-ghost:hover { background: rgba(255,255,255,0.1); text-decoration: none; }
.btn-outline {
  background: var(--surface); color: var(--primary-d); border: 1px solid var(--line);
  border-radius: 30px; padding: 10px 18px; font-weight: 700;
}
.btn-outline:hover { border-color: var(--primary); text-decoration: none; }

/* Toasts */
.toast { border-radius: 14px; padding: 11px 15px; margin-bottom: 14px; font-size: 14px; font-weight: 600; }
.toast.ok { background: var(--primary-c); color: var(--on-primary-c); }
.toast.err { background: var(--danger-bg); color: var(--danger); }

/* Tables / lists */
.vlist { list-style: none; margin: 0; padding: 0; }
.vlist li { display: flex; justify-content: space-between; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.vlist li:last-child { border-bottom: none; }
.vlist .when { color: var(--text-mid); font-size: 12px; font-family: var(--mono); }
.section-title {
  font-size: 13px; font-weight: 700; margin: 0 0 12px; color: var(--text-low);
  text-transform: uppercase; letter-spacing: 0.06em;
}

/* Map */
#map { height: 420px; border-radius: 16px; border: 1px solid var(--line); }
.map-hint { color: var(--text-mid); font-size: 13px; margin: 0 0 10px; }

/* Boundary editor — country/subregion chips */
.bd-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.bd-label { font-size: 13px; font-weight: 600; color: var(--text-mid); }
.chip-wrap { display: inline-flex; align-items: center; gap: 4px; }
.chip {
  background: var(--surface-2); color: var(--text-hi); border: 1px solid var(--line);
  border-radius: 30px; padding: 6px 14px; font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.chip:hover { border-color: var(--primary); }
.chip.on { background: var(--primary-c); color: var(--on-primary-c); border-color: transparent; }
.chip-mini {
  background: transparent; color: var(--accent); border: 1px solid var(--line);
  border-radius: 30px; padding: 5px 10px; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
}
.chip-mini:hover { border-color: var(--primary); }
.bd-summary { color: var(--text-mid); font-size: 13px; margin: 12px 0 0; font-weight: 600; }

/* Public region discovery */
.discover { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
.discover #map { height: 560px; border-radius: 18px; }
.region-list { display: flex; flex-direction: column; gap: 12px; max-height: 560px; overflow: auto; }
.region-list .region-card { display: block; }
@media (max-width: 760px) {
  .discover { grid-template-columns: 1fr; }
  .discover #map { height: 320px; }
  .region-list { max-height: none; }
}
.region-card { cursor: pointer; }
.region-card.sel { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-c); }
.detail-panel { margin-top: 16px; }
.detail-panel h3 { margin: 0 0 12px; }
.settings-block { margin-bottom: 12px; }
.settings-block h3 { margin: 0 0 12px; font-size: 13px; font-weight: 700; color: var(--text-low); text-transform: uppercase; letter-spacing: 0.06em; }
.settings-table { width: 100%; border-collapse: collapse; }
.settings-table th {
  text-align: left; vertical-align: top; width: 210px; padding: 11px 14px 11px 0;
  font-weight: 600; color: var(--text-hi); border-top: 1px solid var(--line);
}
.settings-table td { padding: 11px 0; border-top: 1px solid var(--line); }
.settings-table tr:first-child th, .settings-table tr:first-child td { border-top: 0; }
.settings-table .val { font-family: var(--mono); font-weight: 500; color: var(--text-hi); }
.settings-table .note { display: block; font-family: var(--ui); color: var(--text-mid); font-size: 12.5px; font-weight: 500; margin-top: 3px; }

/* Login / register */
.login-wrap { min-height: 80vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 380px; max-width: 92vw; text-align: center; }
.login-card img { width: 66px; height: 66px; border-radius: 18px; margin-bottom: 14px; }
.login-card h1 { font-size: 22px; font-weight: 800; letter-spacing: -0.01em; margin: 0 0 4px; }
.login-card form { margin-top: 18px; text-align: left; display: grid; gap: 12px; }
.login-card .btn { justify-content: center; }

.empty { text-align: center; color: var(--text-mid); padding: 48px 16px; }

/* Landing page */
.grad {
  background: var(--sig); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.hero { text-align: center; padding: 30px 0 12px; }
.hero-logo { width: 76px; height: 76px; border-radius: 20px; }
.hero h1 { font-size: 44px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.08; margin: 18px 0 0; }
.hero-sub { max-width: 640px; margin: 16px auto 0; color: var(--text-mid); font-size: 16.5px; line-height: 1.5; }
.hero-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 26px; }
.hero-cta .btn, .hero-cta .btn-outline { padding: 13px 26px; font-size: 15px; }
@media (max-width: 560px) { .hero h1 { font-size: 33px; } }

.stat-row {
  display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; margin: 34px 0 8px;
}
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 16px 26px; min-width: 130px; box-shadow: var(--shadow);
}
.stat .n { font-size: 28px; font-weight: 800; letter-spacing: -0.01em; }
.stat .l { color: var(--text-mid); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; margin-top: 2px; }

.land-section { margin: 56px 0; }
.land-section > h2 { font-size: 26px; font-weight: 800; letter-spacing: -0.01em; margin: 0 0 6px; text-align: center; }
.land-section > .lead { text-align: center; color: var(--text-mid); max-width: 680px; margin: 0 auto 26px; font-size: 15.5px; line-height: 1.5; }

.story {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 30px 32px; position: relative; overflow: hidden;
}
.story::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--sig); }
.story h2 { margin: 0 0 10px; font-size: 22px; font-weight: 800; }
.story p { margin: 0; color: var(--text-mid); font-size: 15.5px; line-height: 1.6; max-width: 760px; }

.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.feature { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 20px; box-shadow: var(--shadow); }
.feature .chip {
  width: 40px; height: 40px; border-radius: 12px; background: var(--icon-chip);
  display: flex; align-items: center; justify-content: center; font-size: 20px; margin-bottom: 12px;
}
.feature h3 { margin: 0 0 5px; font-size: 16.5px; font-weight: 700; }
.feature p { margin: 0; color: var(--text-mid); font-size: 13.5px; line-height: 1.45; }
.feature.link-card { display: block; transition: border-color .12s; }
.feature.link-card:hover { border-color: var(--primary); text-decoration: none; }
.feature .more { color: var(--accent); font-size: 13.5px; font-weight: 700; margin-top: 10px; display: inline-block; }

.admin-band {
  background: var(--nav); color: #EAF1F8; border-radius: var(--radius); padding: 34px 32px; text-align: center;
}
.admin-band h2 { color: #EAF1F8; margin: 0 0 8px; font-size: 24px; font-weight: 800; }
.admin-band p { color: #B7C6D8; max-width: 620px; margin: 0 auto 22px; font-size: 15px; line-height: 1.55; }
.admin-band .btn-outline { background: transparent; color: #EAF1F8; border-color: rgba(255,255,255,0.3); }
.admin-band .btn-outline:hover { background: rgba(255,255,255,0.08); }

.land-footer { text-align: center; color: var(--text-mid); font-size: 13.5px; padding: 30px 0 8px; font-weight: 600; }

/* Get-started steps */
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.step {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 22px; box-shadow: var(--shadow);
}
.step-n {
  width: 40px; height: 40px; border-radius: 50%; background: var(--sig);
  color: #0B3D14; font-weight: 800; font-size: 18px;
  display: flex; align-items: center; justify-content: center; margin-bottom: 13px;
}
.step h3 { margin: 0 0 6px; font-size: 16.5px; font-weight: 700; }
.step p { margin: 0 0 10px; color: var(--text-mid); font-size: 13.5px; line-height: 1.45; }
.step .more { color: var(--accent); font-size: 13.5px; font-weight: 700; }

/* App screenshot showcase — one accurate device, switchable screens */
.device-stage { position: relative; padding: 26px 0 6px; display: flex; justify-content: center; }
.device-stage::before {
  content: ""; position: absolute; top: 36px; left: 50%; transform: translateX(-50%);
  width: 360px; height: 360px; max-width: 80vw; background: var(--sig);
  filter: blur(72px); opacity: 0.20; border-radius: 50%; z-index: 0;
}
.device {
  position: relative; z-index: 1; width: 280px; max-width: 78vw; padding: 13px;
  background: #0E2238; border-radius: 40px;
  box-shadow: 0 34px 70px -34px rgba(15,30,22,0.65), inset 0 0 0 1.5px rgba(255,255,255,0.06);
  animation: floaty 6.5s ease-in-out infinite;
}
.device::before {
  content: ""; position: absolute; top: 13px; left: 50%; transform: translateX(-50%);
  width: 104px; height: 19px; background: #0E2238; border-radius: 0 0 16px 16px; z-index: 2;
}
.device .screen {
  position: relative; border-radius: 28px; overflow: hidden; aspect-ratio: 480 / 956;
  background: #dfe7dd;
}
.device .screen img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity 0.45s ease;
}
.device .screen img.active { opacity: 1; }
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
@media (prefers-reduced-motion: reduce) { .device { animation: none; } }

.shot-tabs { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 24px; }
.shot-tab {
  background: var(--surface); color: var(--text-mid); border: 1px solid var(--line);
  border-radius: 30px; padding: 8px 18px; font: inherit; font-size: 13.5px; font-weight: 700; cursor: pointer;
}
.shot-tab:hover { border-color: var(--primary); }
.shot-tab.on { background: var(--primary-c); color: var(--on-primary-c); border-color: transparent; }
.shot-cap { text-align: center; color: var(--text-mid); font-size: 14px; font-weight: 600; margin: 14px 0 0; }
