/* Dark theme — deep blue / grey (default) */
:root, :root[data-theme="dark"] {
  --bg: #0e1726; --panel: #172033; --panel-2: #212d44;
  --text: #e6edf7; --muted: #93a3ba; --border: #2c3a52;
  --brand: #38bdf8; --brand-2: #0ea5e9; --accent: #f4a24c;
  --on-brand: #04233a;
  --ok: #22c55e; --warn: #f59e0b; --err: #ef4444;
  --radius: 10px; --hero-overlay: rgba(10,17,30,.58);
}
/* Light theme — warm 'sandy' */
:root[data-theme="light"] {
  --bg: #f3e9d6; --panel: #fffaf0; --panel-2: #efe2c8;
  --text: #3a2f28; --muted: #8a7861; --border: #e3d4b6;
  --brand: #c2622d; --brand-2: #d9772f; --accent: #c2622d;
  --on-brand: #fff7ec;
  --ok: #3f9142; --warn: #c98a1e; --err: #c0392b;
  --radius: 10px; --hero-overlay: rgba(58,47,40,.30);
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  display: flex; flex-direction: column; min-height: 100vh;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--panel-2); padding: 1px 6px; border-radius: 5px; font-size: .9em; }

/* top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 18px; color: var(--text); }
.topbar nav { display: flex; align-items: center; gap: 16px; }
.topbar .who { color: var(--muted); font-size: 13px; }

/* layout */
.container { width: 100%; max-width: 1000px; margin: 0 auto; padding: 28px 20px; flex: 1; }
.full { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.foot {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 16px 20px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--border);
}

/* buttons */
.btn {
  display: inline-block; background: var(--brand-2); color: var(--on-brand); font-weight: 600;
  padding: 9px 16px; border-radius: var(--radius); border: 0; cursor: pointer; font-size: 14px;
}
.btn:hover { background: var(--brand); text-decoration: none; }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--panel-2); }
.btn-danger { background: var(--err); color: #fff; }

/* hero + features */
.hero { text-align: center; padding: 40px 0 24px; }
.hero h1 { font-size: 38px; margin: 0 0 12px; }
.lead { color: var(--muted); font-size: 18px; max-width: 640px; margin: 0 auto 22px; }
.cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin: 34px 0; }
.feature { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.feature h3 { margin: 0 0 8px; font-size: 16px; }
.feature p { margin: 0; color: var(--muted); font-size: 14px; }
.how { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 26px; }
.how ol { margin: 10px 0 0; padding-left: 20px; color: var(--muted); }
.how li { margin: 6px 0; }

/* auth cards + forms */
.auth-card { max-width: 380px; margin: 30px auto; background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 26px; }
.auth-card h1 { margin: 0 0 18px; font-size: 22px; }
label { display: block; margin: 0 0 14px; font-size: 13px; color: var(--muted); }
input, select {
  width: 100%; margin-top: 5px; padding: 10px 12px; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 14px;
}
input:focus, select:focus { outline: 2px solid var(--brand-2); border-color: transparent; }
.muted { color: var(--muted); font-size: 13px; }

/* alerts */
.alert { padding: 10px 12px; border-radius: 8px; font-size: 14px; margin: 0 0 14px; }
.alert-error { background: rgba(239,68,68,.15); color: #fecaca; border: 1px solid rgba(239,68,68,.4); }
.alert-ok { background: rgba(34,197,94,.15); color: #bbf7d0; border: 1px solid rgba(34,197,94,.4); }

/* tables */
table.grid { width: 100%; border-collapse: collapse; background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.grid th, .grid td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
.grid th { background: var(--panel-2); color: var(--muted); font-weight: 600; }
.grid tr:last-child td { border-bottom: 0; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill-ok { background: rgba(34,197,94,.18); color: #86efac; }
.pill-off { background: rgba(148,163,184,.18); color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.small { font-size: 12px; }

/* dashboard list */
.dash-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.dash-head h1 { margin: 0; font-size: 24px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.panel h3 { margin: 0 0 8px; }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.inline-form input { width: auto; flex: 1 1 200px; margin-top: 0; }

/* device page (full-height map layout) */
.full { padding: 0 !important; max-width: none !important; }
.device-bar { display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--border); flex-wrap: wrap; gap: 8px; }
.device-bar h2 { margin: 2px 0 0; font-size: 18px; }
.mode-tabs { display: flex; gap: 6px; }
.tab { background: var(--panel-2); color: var(--muted); border: 1px solid var(--border);
  padding: 7px 16px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.tab.active { background: var(--brand-2); color: var(--on-brand); border-color: transparent; font-weight: 600; }

.device-body { display: flex; flex: 1; min-height: 0; }
#map { flex: 1; min-height: 400px; }
.side { width: 300px; background: var(--panel); border-left: 1px solid var(--border);
  padding: 14px; overflow-y: auto; }
.ctl { margin-bottom: 18px; border-bottom: 1px solid var(--border); padding-bottom: 14px; }
.ctl h4 { margin: 0 0 8px; }
.ctl .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.ctl label.small { display: flex; flex-direction: column; gap: 2px; }
.ctl input, .ctl select { margin-top: 0; }
.switch { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 14px; }
.switch input { width: auto; }
.playback { align-items: center; }
.playback #scrub { flex: 1; }
table.kv { width: 100%; border-collapse: collapse; }
.kv td { padding: 4px 2px; font-size: 13px; border-bottom: 1px solid var(--border); }
.kv td.muted { width: 45%; }

/* trips */
textarea { width: 100%; margin-top: 5px; padding: 10px 12px; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 8px; color: var(--text); font: inherit; font-size: 14px; resize: vertical; }
input[type=color] { width: 100%; height: 34px; padding: 2px; margin-top: 5px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; }
input[type=file] { width: 100%; margin-top: 5px; font-size: 12px; color: var(--muted); }
.sep { border: 0; border-top: 1px solid var(--border); margin: 12px 0; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: middle; }
.tag { display: inline-block; background: var(--panel-2); border-radius: 999px; padding: 1px 8px; font-size: 11px; color: var(--muted); }
.trips-grid th, .trips-grid td { padding: 6px 8px; font-size: 13px; }
.child-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--border); }
.child-row a { flex: 1; }
.media-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 6px; margin-bottom: 10px; }
.media-item { position: relative; }
.media-item img { width: 100%; height: 70px; object-fit: cover; border-radius: 6px; }
.media-del { position: absolute; top: 2px; right: 2px; background: rgba(0,0,0,.6); color: #fff;
  border: 0; border-radius: 4px; cursor: pointer; font-size: 11px; line-height: 1; padding: 2px 5px; }

/* adventure cards + assign */
.adv-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-top: 12px; }
.adv-card { display: block; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; color: var(--text); }
.adv-card:hover { text-decoration: none; background: var(--panel-2); }
.adv-card h3 { margin: 0 0 6px; font-size: 16px; }
.adv-meta { color: var(--muted); font-size: 13px; }
select.assign-adv { margin-top: 0; padding: 5px 8px; font-size: 13px; width: auto; }

/* admin stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin: 18px 0 26px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.stat .num { font-size: 26px; font-weight: 700; color: var(--brand); }
.stat .lbl { font-size: 13px; color: var(--muted); }
h2 { margin-top: 28px; font-size: 20px; }

/* ---- brand + theme toggle ---- */
.brand { display: inline-flex; align-items: center; gap: 9px; }
.brand img.logo { width: 30px; height: 30px; display: block; }
.theme-toggle { background: transparent; border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; cursor: pointer; padding: 5px 10px; font-size: 15px; line-height: 1; }
.theme-toggle:hover { background: var(--panel-2); }

/* ---- public marketing site ---- */
.pub-nav { display: flex; align-items: center; gap: 18px; }
.pub-nav a { color: var(--text); font-weight: 500; }
.pub-nav a:hover { color: var(--brand); text-decoration: none; }
.pub-hero { position: relative; border-radius: 16px; overflow: hidden; margin: 10px 0 36px; border: 1px solid var(--border); }
.pub-hero .hero-img { width: 100%; height: 430px; object-fit: cover; display: block; }
.pub-hero .hero-copy { position: absolute; inset: 0; display: flex; flex-direction: column;
  justify-content: center; align-items: flex-start; padding: 0 clamp(20px, 6vw, 60px);
  background: linear-gradient(90deg, var(--hero-overlay), transparent 85%); }
.pub-hero h1 { font-size: clamp(30px, 5vw, 46px); margin: 0 0 12px; max-width: 620px; color: #fff; text-shadow: 0 2px 14px rgba(0,0,0,.45); }
.pub-hero p { font-size: clamp(15px, 2.2vw, 19px); max-width: 560px; color: #f4f0ea; text-shadow: 0 1px 10px rgba(0,0,0,.45); }
.pub-hero .cta { margin-top: 22px; display: flex; gap: 12px; flex-wrap: wrap; }
.section-title { text-align: center; margin: 40px 0 6px; font-size: 26px; }
.section-sub { text-align: center; color: var(--muted); margin: 0 auto 22px; max-width: 620px; }
.prose { max-width: 780px; margin: 0 auto; }
.prose h2 { margin-top: 28px; } .prose p, .prose li { color: var(--text); }
.riders-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap: 16px; }
.rider-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.foot-links { display: flex; gap: 16px; flex-wrap: wrap; }
.foot-links a { color: var(--muted); }
.foot-brand { display: flex; align-items: center; gap: 8px; }

/* cookie banner */
.cookie-banner { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 999;
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px; box-shadow: 0 6px 24px rgba(0,0,0,.35); font-size: 13px; color: var(--text); }
.cookie-banner span { flex: 1 1 320px; }

/* admin settings form alignment */
.settings-form { align-items: flex-end; }
.settings-form label.small { display: flex; flex-direction: column; gap: 3px; margin: 0; }
.settings-form input[type=number] { width: 130px; margin: 0; }

/* sortable + paginated tables */
.ngt-table-wrap { width: 100%; overflow-x: auto; }
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable::after { content: '\2195'; opacity: .35; margin-left: 5px; font-size: 11px; }
th.sortable[data-dir=asc]::after { content: '\2191'; opacity: .9; }
th.sortable[data-dir=desc]::after { content: '\2193'; opacity: .9; }
.ngt-pager { display: flex; align-items: center; gap: 12px; padding: 10px 2px; flex-wrap: wrap; }
.ngt-pager .btn[disabled] { opacity: .4; cursor: default; }

/* mobile friendliness */
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 14px; }
  .topbar nav, .pub-nav { gap: 10px; flex-wrap: wrap; row-gap: 6px; }
  .topbar .who { display: none; }
  .brand { font-size: 16px; }
  .container { padding: 18px 14px; }
  .device-body { flex-direction: column; }
  #map { min-height: 55vh; }
  .side { width: auto; border-left: 0; border-top: 1px solid var(--border); }
  .device-bar { padding: 10px 14px; }
  .pub-hero .hero-img { height: 260px; }
  .pub-hero .hero-copy { padding: 0 20px 22px; justify-content: flex-end;
    background: linear-gradient(180deg, transparent, var(--hero-overlay)); }
  .dash-head { flex-wrap: wrap; gap: 10px; }
  .inline-form { flex-direction: column; align-items: stretch; }
  .inline-form input, .inline-form .btn { width: 100%; }
  .settings-form { flex-direction: column; align-items: stretch; }
  .settings-form input[type=number] { width: 100%; }
  .grid th, .grid td { padding: 8px 10px; font-size: 13px; }
  .cookie-banner { flex-direction: column; align-items: stretch; text-align: center; }
}
