/* Geodetic Design System — foundation tokens + core components.
   Dark-first, neutral/cool, one blue accent. Borders over shadows. */

:root {
  /* Surfaces (darkest -> lightest) */
  --canvas: #0c0e11;
  --base:   #14171b;
  --panel:  #1b1f24;
  --raised: #23282e;
  --hover:  #2a2f36;

  /* Text */
  --text-hi:       #e6e9ed;
  --text-mid:      #9ba3ad;
  --text-lo:       #6b727c;
  --text-disabled: #4a515a;

  /* Borders */
  --border:    #2a2f36;
  --border-hi: #333940;
  --divider:   #171b21;

  /* Accent & semantic */
  --accent:       rgb(139, 149, 163);
  --accent-hover: rgb(166, 176, 189);
  --success:      #4cc38a;
  --warning:      #e0a34e;
  --danger:       #ff6b6b;

  /* Radii */
  --r-sm:   2px;
  --r-md:   3px;
  --r-lg:   4px;
  --r-pill: 10px;

  /* Type */
  --font-ui:   'Geist', system-ui, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, monospace;
}

/* ---- Base ---- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--canvas);
  color: var(--text-hi);
  font-family: var(--font-ui);
  font-size: 13px;
  color-scheme: dark;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
::selection { background: rgba(139, 149, 163, 0.28); }

/* ============================================================
   01 · Button
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  color: var(--text-hi);
  background: var(--panel);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-md);
  padding: 8px 15px;
  cursor: pointer;
  text-decoration: none;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, transform 120ms ease;
}
.btn:active { transform: scale(0.96); }
.btn:hover { background: var(--raised); border-color: #3d4550; }
.btn__icon { font-family: var(--font-mono); font-size: 15px; line-height: 1; }
.btn--icon { padding-left: 12px; }

.btn--primary {
  color: var(--canvas);
  background: var(--accent);
  border-color: var(--accent);
}
.btn--primary:hover {
  color: var(--canvas);
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn--secondary {
  color: var(--text-hi);
  background: var(--panel);
  border-color: var(--border-hi);
}
.btn--secondary:hover {
  background: var(--raised);
  border-color: #3d4550;
}

.btn--ghost {
  color: var(--text-mid);
  background: transparent;
  border-color: transparent;
}
.btn--ghost:hover {
  background: var(--divider);
  color: var(--text-hi);
}

.btn--destructive {
  color: var(--danger);
  background: transparent;
  border-color: #3a2a2c;
}
.btn--destructive:hover { background: #241a1c; }

/* quiet: borderless, for dense table/row actions */
.btn--quiet {
  color: var(--text-mid);
  background: transparent;
  border-color: transparent;
}
.btn--quiet:hover { color: var(--text-hi); background: var(--hover); border-color: transparent; }

/* danger: layers on any variant (used as `btn--quiet btn--danger`) */
.btn--danger { color: var(--danger); }
.btn--danger:hover { color: var(--danger); background: #241a1c; border-color: transparent; }

.btn--sm { font-size: 11.5px; padding: 5px 10px; }
.btn--lg { font-size: 14px; padding: 11px 20px; }

.btn:disabled,
.btn[disabled] {
  color: var(--text-disabled);
  background: var(--base);
  border-color: var(--raised);
  cursor: not-allowed;
}
.btn:disabled:hover,
.btn[disabled]:hover {
  color: var(--text-disabled);
  background: var(--base);
  border-color: var(--raised);
}
.btn:disabled:active,
.btn[disabled]:active { transform: none; }

/* ============================================================
   02 · Text input / select
   ============================================================ */
.input {
  font-family: inherit;
  font-size: 13px;
  color: var(--text-hi);
  background: var(--base);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 8px 11px;
  outline: none;
  transition: border-color 120ms ease;
}
.input:focus { border-color: var(--accent); }
.input--mono { font-family: var(--font-mono); }

/* input with a unit suffix behind a hairline divider */
.input-unit {
  display: inline-flex;
  align-items: center;
  background: var(--base);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 0 11px;
  transition: border-color 120ms ease;
}
.input-unit:focus-within { border-color: var(--accent); }
.input-unit > input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-hi);
  background: transparent;
  border: none;
  padding: 8px 0;
  outline: none;
}
.input-unit__suffix {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-lo);
  padding-left: 8px;
  border-left: 1px solid var(--raised);
}

/* error */
.input--error { border-color: #4a3234; }
.field__error { font-size: 11px; color: var(--danger); margin-top: 5px; }

/* disabled */
.input:disabled,
.input[disabled] {
  color: var(--text-disabled);
  background: #101318;
  border-color: #1e232a;
  cursor: not-allowed;
}

/* select */
.select-wrap { position: relative; display: inline-block; }
.select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  padding-right: 30px;
}
.select__chevron {
  position: absolute;
  right: 11px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--text-lo);
  border-bottom: 1.5px solid var(--text-lo);
  margin-top: -6px;
  transform: rotate(45deg);
  pointer-events: none;
}

/* ============================================================
   03 · Tabs
   ============================================================ */
.tabs {
  display: flex;
  width: 100%;
  border-bottom: 1px solid #1e232a;
}
.tab {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-lo);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 11px 16px;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease;
}
.tab:hover { color: var(--text-mid); }
.tab.is-active {
  color: var(--text-hi);
  border-bottom-color: var(--accent);
}
.tab.is-active:hover { color: var(--text-hi); }

/* ============================================================
   04 · Segmented control
   ============================================================ */
.segmented {
  display: inline-flex;
  background: var(--base);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 2px;
}
.seg {
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-mid);
  background: transparent;
  border: none;
  border-radius: var(--r-sm);
  padding: 6px 14px;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}
.seg.is-active { background: var(--hover); color: var(--text-hi); }

/* ============================================================
   Stepper
   ============================================================ */
.stepper {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 20px;
  counter-reset: stepper-step;
}
.stepper__dot {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-lo);
  border-bottom: 2px solid transparent;
  padding-bottom: 6px;
  counter-increment: stepper-step;
  transition: color 120ms ease, border-color 120ms ease;
}
.stepper__dot::before { content: counter(stepper-step) "."; }
.stepper__dot.is-active {
  color: var(--text-hi);
  border-bottom-color: var(--accent);
}

.wizard-step[hidden] { display: none; }

/* ============================================================
   05 · Toggle (native checkbox, CSS-driven)
   ============================================================ */
.toggle {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle__track {
  width: 34px;
  height: 19px;
  border-radius: var(--r-pill);
  padding: 2px;
  background: var(--hover);
  transition: background 160ms ease;
}
.toggle__knob {
  display: block;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  transition: transform 160ms ease;
  transform: translateX(0);
}
.toggle input:checked + .toggle__track { background: var(--accent); }
.toggle input:checked + .toggle__track .toggle__knob { transform: translateX(15px); }

/* ============================================================
   06 · Checkbox (native checkbox, CSS-driven)
   ============================================================ */
.check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.check input { position: absolute; opacity: 0; width: 0; height: 0; }
.check__box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: var(--r-md);
  border: 1.5px solid #3d4550;
  background: transparent;
  transition: background 120ms ease, border-color 120ms ease;
}
.check__tick {
  width: 8px;
  height: 5px;
  border-left: 1.5px solid var(--canvas);
  border-bottom: 1.5px solid var(--canvas);
  transform: rotate(-45deg) translateY(-1px);
  opacity: 0;
}
.check input:checked + .check__box { background: var(--accent); border-color: var(--accent); }
.check input:checked + .check__box .check__tick { opacity: 1; }
.check__label { font-size: 13px; color: var(--text-hi); }

/* ============================================================
   07 · Slider (native range, --pct drives fill)
   ============================================================ */
.range-field { width: 260px; }
.range-field__head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}
.range-field__label { font-size: 12px; color: var(--text-mid); }
.range-field__value { font-family: var(--font-mono); font-size: 12px; color: var(--accent); }

.range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 14px;
  background: transparent;
  cursor: pointer;
  --pct: 0%;
}
.range::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(to right,
    var(--accent) 0 var(--pct), var(--raised) var(--pct) 100%);
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -5.5px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
.range::-moz-range-track { height: 3px; border-radius: 2px; background: var(--raised); }
.range::-moz-range-progress { height: 3px; border-radius: 2px; background: var(--accent); }
.range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* ============================================================
   App shell — topbar + account menu
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 52px;
  padding: 0 24px;
  background: var(--canvas);
  border-bottom: 1px solid #1e232a;
}
.topbar__brand { display: flex; align-items: center; }
.topbar__logo { display: block; height: 20px; width: auto; }
.topbar__spacer { flex: 1; }
.topbar__right { display: flex; align-items: center; gap: 8px; }
.topbar__screen { font-size: 13px; color: var(--text-lo); }

.av {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: var(--r-md);
  background: var(--raised);
  color: var(--text-hi);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
}
.av--accent { background: var(--accent); color: var(--canvas); }
.av--lg { width: 38px; height: 38px; font-size: 13px; border-radius: var(--r-lg); }

.acct { position: relative; }
.acct__btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 8px;
  font-family: inherit;
  color: var(--text-hi);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.acct__btn:hover,
.acct.is-open .acct__btn { background: var(--panel); border-color: var(--border); }
.acct__meta { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.25; }
.acct__name { font-size: 12.5px; font-weight: 500; color: var(--text-hi); }
.acct__sub { font-size: 11px; color: var(--text-lo); }
.acct__email { font-size: 11px; color: var(--text-lo); }
.acct__chev { color: var(--text-lo); }
.acct__badge,
.menu__badge {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px;
  color: var(--base); background: var(--accent-hover); border-radius: var(--r-pill);
  font-family: var(--font-mono); font-size: 10px; font-weight: 600; line-height: 1;
}
.acct__badge { position: absolute; top: 0; left: 28px; border: 2px solid var(--base); }
.menu__badge { margin-left: auto; }

.acct__pop {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 244px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-lg);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 140ms ease, transform 140ms ease, visibility 140ms;
  z-index: 40;
}
.acct.is-open .acct__pop { opacity: 1; visibility: visible; transform: translateY(0); }
.acct__id { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }

.menu__sep { height: 1px; margin: 6px 0; background: var(--divider); }
.menu__form { margin: 0; }
.menu__item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.25;
  text-align: left;
  text-decoration: none;
  color: var(--text-mid);
  background: transparent;
  border: 0;
  border-radius: var(--r-md);
  appearance: none;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.menu__item:hover { background: var(--hover); color: var(--text-hi); }
.menu__item svg { color: var(--text-lo); }
.menu__item:hover svg { color: var(--text-hi); }
.menu__item--danger { color: var(--danger); }
.menu__item--danger svg { color: var(--danger); }
.menu__item--danger:hover { background: #241a1c; color: var(--danger); }
.menu__item--danger:hover svg { color: var(--danger); }

.app-main {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 24px 80px;
  flex: 1 0 auto;
}

/* ============================================================
   Page header
   ============================================================ */
.pagehead { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.main__eyebrow { font-family: var(--font-mono); font-size: 11px; color: var(--text-lo); letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 10px; }
.main__title { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; margin: 0; }
.main__lede { font-size: 13px; color: var(--text-mid); line-height: 1.55; margin: 8px 0 0; max-width: 620px; }

/* ============================================================
   Layout helpers
   ============================================================ */
.page-narrow { max-width: 820px; }
.settings-layout { display: grid; grid-template-columns: 190px minmax(0, 1fr); align-items: start; gap: 28px; }
.settings-sidebar { position: sticky; top: 76px; }
.settings-nav { display: flex; flex-direction: column; gap: 3px; }
.settings-nav__item { padding: 9px 11px; color: var(--text-mid); font-size: 13px; border-radius: var(--r-md); }
.settings-nav__item:hover { color: var(--text-hi); background: var(--hover); }
.settings-nav__item.is-active { color: var(--text-hi); background: var(--raised); box-shadow: inset 2px 0 0 var(--accent); }
.settings-content { min-width: 0; }
.settings-card + .settings-card { margin-top: 16px; }
.settings-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.settings-summary > div { padding: 16px; border-right: 1px solid var(--divider); }
.settings-summary > div:last-child { border-right: 0; }
.settings-summary dt { margin-bottom: 6px; color: var(--text-lo); font-family: var(--font-mono); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }
.settings-summary dd { margin: 0; color: var(--text-hi); font-size: 13px; overflow-wrap: anywhere; }
.settings-form-card .card__body { padding: 18px; }
.settings-form-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 18px; }
.settings-form-actions p { margin: 0; color: var(--text-lo); font-size: 12px; line-height: 1.5; }
.settings-readonly { color: var(--text-mid); font-size: 13px; line-height: 1.6; }
.form-col { max-width: 720px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.col-span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.form-section-label { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-lo); margin: 20px 0 12px; padding-top: 16px; border-top: 1px solid var(--divider); }

/* ============================================================
   Card
   ============================================================ */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-lg); }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--divider); }
.card__title { font-size: 13px; font-weight: 600; color: var(--text-hi); }
.card__body { padding: 16px; }
.list-card .card__body { padding: 0; }

/* ============================================================
   Table
   ============================================================ */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--divider); }
.tbl thead th { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-lo); font-weight: 500; border-bottom-color: var(--border); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover td { background: rgba(255, 255, 255, 0.015); }
.tbl .mono, .mono { font-family: var(--font-mono); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.tbl-foot { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--divider); }
.tbl-foot__count { font-family: var(--font-mono); font-size: 11px; color: var(--text-lo); }
.view-link { color: var(--text-hi); font-weight: 500; }
.view-link:hover { color: var(--accent-hover); }

/* ============================================================
   Chip / status
   ============================================================ */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; font-size: 11px; font-weight: 500; line-height: 1.5; color: var(--text-mid); background: var(--raised); border: 1px solid var(--border); border-radius: var(--r-pill); white-space: nowrap; }
.chip--soft { background: var(--base); border-color: var(--border); color: var(--text-lo); font-weight: 400; }
.chip--info { background: rgba(139, 149, 163, 0.14); border-color: rgba(139, 149, 163, 0.4); color: var(--accent-hover); }
.chip--success { background: rgba(76, 195, 138, 0.12); border-color: rgba(76, 195, 138, 0.35); color: var(--success); }
.chip--warning { background: rgba(224, 163, 78, 0.12); border-color: rgba(224, 163, 78, 0.35); color: var(--warning); }
.chip--danger { background: rgba(255, 107, 107, 0.1); border-color: rgba(255, 107, 107, 0.35); color: var(--danger); }

/* ============================================================
   Modal
   ============================================================ */
.modal-backdrop { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-start; justify-content: center; padding: 64px 20px; background: rgba(0, 0, 0, 0.55); overflow-y: auto; }
.modal { width: 100%; max-width: 440px; background: var(--panel); border: 1px solid var(--border-hi); border-radius: var(--r-lg); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5); }
.modal--wide { max-width: 620px; }
.modal__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--divider); }
.modal__title { font-size: 14px; font-weight: 600; color: var(--text-hi); }
.modal__close { display: inline-grid; place-items: center; width: 26px; height: 26px; background: transparent; border: none; border-radius: var(--r-md); color: var(--text-lo); font-size: 18px; line-height: 1; cursor: pointer; transition: background 120ms ease, color 120ms ease; }
.modal__close:hover { background: var(--hover); color: var(--text-hi); }
.modal__body { padding: 18px; }
.modal__foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--divider); }

/* ============================================================
   Alert / messages
   ============================================================ */
.messages { position: fixed; top: 64px; right: 24px; z-index: 80; display: flex; flex-direction: column; gap: 8px; max-width: 360px; }
.alert { position: relative; display: flex; align-items: flex-start; gap: 10px; padding: 10px 34px 10px 12px; font-size: 12.5px; line-height: 1.45; color: var(--text-hi); background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-md); }
.alert--success { color: var(--success); background: rgba(76, 195, 138, 0.1); border-color: rgba(76, 195, 138, 0.3); }
.alert--danger { color: var(--danger); background: #241a1c; border-color: #3a2a2c; }
.alert--warning { color: var(--warning); background: rgba(224, 163, 78, 0.1); border-color: rgba(224, 163, 78, 0.3); }
.alert--info { color: var(--accent-hover); background: rgba(139, 149, 163, 0.12); border-color: rgba(139, 149, 163, 0.35); }
.dismiss { position: absolute; top: 6px; right: 8px; display: inline-grid; place-items: center; width: 22px; height: 22px; padding: 0; background: transparent; border: none; border-radius: var(--r-sm); color: inherit; font-size: 16px; line-height: 1; opacity: 0.6; cursor: pointer; }
.dismiss:hover { opacity: 1; }

/* ============================================================
   Form field (rendered via components/_field.html)
   ============================================================ */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-lo); }
.field-hint { font-size: 11px; color: var(--text-lo); line-height: 1.5; }
.field-error { font-size: 11px; color: var(--danger); }
.field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.field select,
.field textarea {
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-hi);
  background: var(--base);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 8px 11px;
  outline: none;
  transition: border-color 120ms ease;
}
.field textarea { min-height: 76px; line-height: 1.5; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field input::placeholder, .field textarea::placeholder { color: var(--text-lo); }
.field input[type="date"], .field input[type="number"] { font-family: var(--font-mono); }
.field input[type="date"]::-webkit-calendar-picker-indicator { opacity: 0.5; cursor: pointer; transition: opacity 120ms ease; }
.field input[type="date"]::-webkit-calendar-picker-indicator:hover { opacity: 0.85; }
.field input[type="file"] { font-size: 12px; color: var(--text-mid); }
.field input[type="file"]::file-selector-button,
.filefield input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 6px 12px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-hi);
  background: var(--panel);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.field input[type="file"]::file-selector-button:hover,
.filefield input[type="file"]::file-selector-button:hover {
  background: var(--raised);
  border-color: #3d4550;
}
.field select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 30px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='M2 4 L5 7 L8 4' fill='none' stroke='%236b727c' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}
.field[data-field="error"] input,
.field[data-field="error"] select,
.field[data-field="error"] textarea { border-color: #4a3234; }
.field[data-field="error"] .field-label { color: var(--danger); }

.checkfield { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; }
.checkfield input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.checkfield__text { font-size: 13px; color: var(--text-hi); }

/* ============================================================
   File field (image widget)
   ============================================================ */
.filefield { display: flex; flex-direction: column; gap: 8px; }
.filefield__current { display: flex; align-items: center; gap: 12px; }
.filefield__thumb { display: block; width: 46px; height: 46px; flex: none; overflow: hidden; background: var(--base); border: 1px solid var(--border); border-radius: var(--r-md); }
.filefield__thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.filefield__info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.filefield__name { font-size: 12px; color: var(--accent-hover); word-break: break-all; }
.filefield__clear { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-mid); cursor: pointer; }

/* Project dashboard — search, card grid, pagination. */
.dash-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.dash-search { display: flex; gap: 8px; max-width: 420px; flex: 1; }
.dash-search .input { flex: 1; }

.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

.project-card {
  display: flex; gap: 14px; padding: 14px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-lg);
  color: inherit; transition: border-color 120ms ease;
}
.project-card:hover { border-color: var(--border-hi); }
.project-card__preview {
  flex: 0 0 92px; width: 92px; height: 92px;
  background: var(--divider); border: 1px solid var(--border); border-radius: var(--r-lg);
  overflow: hidden;
}
.project-card__preview--topography {
  display: grid;
  place-items: center;
  color: var(--success);
  font-family: var(--font-mono);
  font-size: 28px;
}
.project-card__body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.project-card__title { font-size: 14px; font-weight: 600; color: var(--text-hi); }
.project-card__meta { font-size: 12px; color: var(--text-mid); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-card__meta--muted { color: var(--text-lo); }

.pagination { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 24px; }
.pagination__status { font-size: 12px; color: var(--text-mid); }

.empty-state {
  padding: 48px 24px; text-align: center; color: var(--text-lo);
  border: 1px dashed var(--border); border-radius: var(--r-lg);
}

/* Projects page enhancements. */
.projects-page { --project-card-height: 166px; }
.projects-hero {
  position: relative; display: flex; align-items: flex-end; justify-content: space-between;
  gap: 32px; margin-bottom: 36px; padding: 10px 0 32px; border-bottom: 1px solid var(--border);
}
.projects-hero::after {
  content: ""; position: absolute; right: 0; bottom: -1px; width: min(28%, 260px); height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent)); opacity: .65;
}
.projects-hero__copy { min-width: 0; }
.projects-hero .main__eyebrow { margin-bottom: 8px; }
.projects-hero__title {
  margin: 0; color: var(--text-hi); font-size: clamp(28px, 4vw, 38px); font-weight: 600;
  line-height: 1.05; letter-spacing: -.035em;
}
.projects-hero__lede {
  max-width: 500px; margin: 10px 0 0; color: var(--text-mid); font-size: 13.5px; line-height: 1.55;
}
.projects-hero__actions { display: flex; flex: none; gap: 8px; }

.projects-list-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 16px;
}
.projects-list-head__title { margin: 0; color: var(--text-hi); font-size: 15px; font-weight: 600; }
.projects-list-head__count {
  margin: 4px 0 0; color: var(--text-lo); font-family: var(--font-mono); font-size: 10px;
  letter-spacing: .05em; text-transform: uppercase;
}
.dash-search { position: relative; display: flex; align-items: center; width: min(100%, 390px); max-width: none; }
.dash-search__icon { position: absolute; left: 12px; z-index: 1; color: var(--text-lo); pointer-events: none; }
.dash-search .dash-search__input {
  width: 100%; min-height: 38px; padding-left: 38px; padding-right: 78px;
  background: var(--base); border-color: var(--border-hi); border-radius: var(--r-lg);
}
.dash-search .dash-search__input--clearable { padding-right: 120px; }
.dash-search .dash-search__input--clearable:placeholder-shown { padding-right: 78px; }
.dash-search__input::placeholder { color: var(--text-lo); }
.dash-search__clear { position: absolute; right: 80px; padding: 5px; color: var(--text-lo); font-size: 11px; }
.dash-search__input:placeholder-shown + .dash-search__clear { display: none; }
.dash-search__clear:hover { color: var(--text-hi); }
.dash-search__submit {
  position: absolute; right: 4px; min-height: 30px; padding: 6px 11px; border: 0; background: var(--raised);
}
.drawing-grid-region { transition: opacity 140ms ease; }
.drawing-grid-region.htmx-request { opacity: .45; }
.project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.project-card {
  position: relative; display: grid; grid-template-columns: 142px minmax(0, 1fr); gap: 0; padding: 0;
  min-height: var(--project-card-height); overflow: hidden; color: inherit; background: var(--panel);
  border: 1px solid var(--border); border-radius: 6px;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}
.project-card:hover {
  color: inherit; background: #1d2228; border-color: #3a424c; transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(0, 0, 0, .18);
}
.project-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.project-card__preview {
  position: relative; flex: none; width: 100%; height: 100%; min-height: var(--project-card-height);
  overflow: hidden; border: 0; border-right: 1px solid var(--border); border-radius: 0;
  background: linear-gradient(rgba(139, 149, 163, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(139, 149, 163, .035) 1px, transparent 1px), var(--base);
  background-size: 18px 18px;
}
.project-card__preview--topography {
  display: grid; place-items: center; color: var(--success); font-size: inherit;
  background: radial-gradient(circle at 52% 45%, rgba(76, 195, 138, .13), transparent 55%), var(--base);
}
.project-card__preview--topography svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.project-card__preview--topography path {
  stroke: rgba(76, 195, 138, .34); stroke-width: 1.15; vector-effect: non-scaling-stroke;
}
.project-card__terrain-mark {
  display: grid; place-items: center; width: 36px; height: 36px; color: var(--success);
  background: rgba(12, 14, 17, .82); border: 1px solid rgba(76, 195, 138, .3); border-radius: 50%;
  font-family: var(--font-mono); font-size: 13px; font-weight: 500;
}
.project-card__body { display: flex; flex-direction: column; gap: 0; min-width: 0; padding: 16px 17px 15px; }
.project-card__topline {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px;
}
.project-card__kind {
  color: var(--accent-hover); font-family: var(--font-mono); font-size: 9px; font-weight: 500;
  letter-spacing: .075em; text-transform: uppercase;
}
.project-card__kind--terrain { color: var(--success); }
.project-card__arrow { flex: none; color: var(--text-disabled); transition: color 160ms ease, transform 160ms ease; }
.project-card:hover .project-card__arrow { color: var(--text-hi); transform: translateX(2px); }
.project-card__title {
  overflow: hidden; margin: 0; color: var(--text-hi); font-size: 15px; font-weight: 600;
  line-height: 1.3; text-overflow: ellipsis; white-space: nowrap;
}
.project-card__description {
  overflow: hidden; margin: 5px 0 12px; color: var(--text-mid); font-size: 12px;
  line-height: 1.4; text-overflow: ellipsis; white-space: nowrap;
}
.project-card__details {
  display: flex; flex-direction: column; gap: 4px; margin-top: auto; color: var(--text-lo);
  font-size: 10.5px; line-height: 1.35;
}
.project-card__details span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-card__status {
  position: absolute; left: 9px; bottom: 9px; padding: 3px 6px; color: var(--success);
  background: rgba(12, 14, 17, .84); border: 1px solid rgba(76, 195, 138, .28);
  border-radius: var(--r-sm); font-family: var(--font-mono); font-size: 8px;
  letter-spacing: .04em; text-transform: uppercase;
}
.pagination { margin-top: 28px; }
.pagination__status {
  color: var(--text-lo); font-family: var(--font-mono); font-size: 10px; text-transform: uppercase;
}
.projects-page .empty-state {
  padding: 64px 24px; color: var(--text-lo); text-align: center;
  background: linear-gradient(180deg, rgba(27, 31, 36, .62), rgba(20, 23, 27, .42));
  border: 1px dashed var(--border-hi); border-radius: 6px;
}
.projects-page .empty-state__icon {
  display: grid; place-items: center; width: 50px; height: 50px; margin: 0 auto 16px;
  color: var(--text-mid); background: var(--panel); border: 1px solid var(--border-hi); border-radius: 50%;
}
.projects-page .empty-state__title { margin: 0; color: var(--text-hi); font-size: 16px; font-weight: 600; }
.projects-page .empty-state__copy {
  max-width: 360px; margin: 7px auto 18px; color: var(--text-lo); font-size: 12.5px; line-height: 1.55;
}

/* ============================================================
   Auth — sign in / sign up (layouts/auth.html)
   ============================================================ */
.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 48px 20px; }
.auth-col { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 24px; }
.auth-brand { display: flex; justify-content: center; }
.auth-brand img { height: 26px; }
.auth-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 28px 26px; }
.auth-card__head { margin-bottom: 22px; }
.auth-card__title { font-size: 21px; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 6px; }
.auth-card__sub { font-size: 13px; color: var(--text-mid); margin: 0; }
.auth-card__sub a { color: var(--accent-hover); }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-form .btn { width: 100%; justify-content: center; }
.auth-form__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.auth-form__link { font-size: 12px; color: var(--text-mid); }
.auth-form__link:hover { color: var(--accent-hover); }
.auth-sep { display: flex; align-items: center; gap: 12px; margin: 20px 0; font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-lo); }
.auth-sep::before, .auth-sep::after { content: ""; flex: 1; height: 1px; background: var(--divider); }
.auth-social { display: flex; flex-direction: column; gap: 10px; }
.auth-social .btn { width: 100%; justify-content: center; }
.btn--google { color: #202124; background: #fff; border-color: #dadce0; }
.btn--google:hover { color: #202124; background: #f8faff; border-color: #c6cbd1; }
.auth-provider-missing {
  margin: 0;
  padding: 10px 12px;
  color: var(--warning);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
  background: rgba(224, 163, 78, .08);
  border: 1px solid rgba(224, 163, 78, .24);
  border-radius: var(--r-md);
}
.oauth-confirm { text-align: center; }
.oauth-confirm__mark {
  width: 48px;
  height: 48px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  background: #fff;
  border: 1px solid #dadce0;
  border-radius: 50%;
}
.oauth-confirm__mark svg { width: 22px; height: 22px; }
.oauth-confirm__head { margin-bottom: 18px; }
.oauth-confirm__eyebrow {
  margin: 0 0 8px;
  color: var(--text-lo);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.oauth-confirm__notice {
  margin-bottom: 20px;
  padding: 13px 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--text-mid);
  text-align: left;
  background: var(--base);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.oauth-confirm__notice > span {
  flex: 0 0 auto;
  color: var(--accent-hover);
  font-family: var(--font-mono);
}
.oauth-confirm__notice p { margin: 0; font-size: 11.5px; line-height: 1.55; }
.oauth-confirm .auth-form { gap: 10px; }
.oauth-confirm .auth-foot { line-height: 1.6; }
.signout-confirm { text-align: center; }
.signout-confirm__mark {
  width: 48px;
  height: 48px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  color: var(--danger);
  background: rgba(255, 107, 107, .08);
  border: 1px solid rgba(255, 107, 107, .22);
  border-radius: 50%;
}
.signout-confirm__head { margin-bottom: 18px; }
.signout-confirm__eyebrow {
  margin: 0 0 8px;
  color: var(--text-lo);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.signout-confirm__account {
  margin-bottom: 20px;
  padding: 13px 14px;
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--text-mid);
  text-align: left;
  background: var(--base);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.signout-confirm__account > span:last-child {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.signout-confirm__account small {
  color: var(--text-lo);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.signout-confirm__account strong {
  overflow: hidden;
  color: var(--text-hi);
  font-size: 12px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.signout-confirm .auth-form { gap: 10px; }
.auth-card > .btn { width: 100%; }
.auth-foot { text-align: center; font-size: 12.5px; color: var(--text-lo); margin: 18px 0 0; }
.auth-foot a { color: var(--text-mid); }
.auth-foot a:hover { color: var(--accent-hover); }
.terms-field { display: flex; flex-direction: column; gap: 7px; }
.terms-field .checkfield { align-items: flex-start; }
.terms-field .checkfield input { flex: 0 0 auto; margin-top: 2px; }
.terms-field .checkfield__text { color: var(--text-mid); font-size: 12px; line-height: 1.55; }
.terms-field .checkfield__text a { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 2px; }
.terms-field[data-field="error"] .checkfield__text { color: var(--danger); }
.auth-legal {
  display: flex;
  justify-content: center;
  gap: 18px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.auth-legal a { color: var(--text-lo); }
.auth-legal a:hover { color: var(--text-mid); }
.app-legal {
  min-height: 58px;
  margin: 24px;
  padding-top: 18px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  color: var(--text-disabled);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: .06em;
  text-transform: uppercase;
  border-top: 1px solid var(--divider);
}
.app-legal nav { display: flex; gap: 15px; }
.app-legal a { color: var(--text-lo); }
.app-legal a:hover { color: var(--text-mid); }

/* ============================================================
   Responsive app shell + projects
   ============================================================ */
@media (max-width: 720px) {
  .topbar { height: 50px; gap: 10px; padding: 0 14px; }
  .topbar__logo { height: 18px; }
  .topbar__screen { display: none; }
  .acct__btn { padding: 4px; }
  .acct__btn > .acct__meta, .acct__chev { display: none; }
  .acct__pop { position: fixed; top: 56px; right: 10px; left: 10px; min-width: 0; }
  .app-main { padding: 24px 14px 52px; }
  .settings-page__head { margin-bottom: 18px; }
  .settings-layout { display: block; }
  .settings-sidebar { position: static; margin: 0 -14px 22px; overflow-x: auto; padding: 0 14px 8px; }
  .settings-nav { width: max-content; flex-direction: row; }
  .settings-nav__item { white-space: nowrap; }
  .settings-nav__item.is-active { box-shadow: inset 0 -2px 0 var(--accent); }
  .settings-summary { grid-template-columns: 1fr; }
  .settings-summary > div { border-right: 0; border-bottom: 1px solid var(--divider); }
  .settings-summary > div:last-child { border-bottom: 0; }
  .settings-form-actions { align-items: stretch; flex-direction: column; }
  .settings-form-actions .btn { justify-content: center; }
  .messages { top: 58px; right: 12px; left: 12px; max-width: none; }

  .projects-page { --project-card-height: 148px; }
  .projects-hero { align-items: stretch; flex-direction: column; gap: 22px; margin-bottom: 28px; padding: 2px 0 26px; }
  .projects-hero::after { width: 38%; }
  .projects-hero__title { font-size: 30px; }
  .projects-hero__lede { margin-top: 8px; font-size: 13px; }
  .projects-hero__actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .projects-hero__actions .btn { min-height: 40px; padding-right: 10px; padding-left: 10px; }

  .projects-list-head { align-items: stretch; flex-direction: column; gap: 14px; }
  .dash-search { width: 100%; }
  .dash-search .dash-search__input { min-height: 42px; }
  .dash-search__submit { min-height: 34px; }
  .project-grid { grid-template-columns: minmax(0, 1fr); gap: 11px; }
  .project-card { grid-template-columns: 122px minmax(0, 1fr); }
  .project-card:hover { transform: none; box-shadow: none; }
  .project-card__body { padding: 14px 15px 13px; }
  .project-card__topline { margin-bottom: 8px; }
  .project-card__description { margin-bottom: 10px; }
  .projects-page .empty-state { padding: 48px 18px; }
  .pagination { justify-content: space-between; gap: 8px; }

  .app-legal { margin: 16px 14px; padding-top: 16px; }
}

@media (max-width: 390px) {
  .projects-hero__actions { grid-template-columns: 1fr; }
  .project-card { grid-template-columns: 108px minmax(0, 1fr); }
  .project-card__body { padding-right: 12px; padding-left: 12px; }
  .project-card__title { font-size: 14px; }
  .project-card__details { font-size: 10px; }
  .app-legal { align-items: flex-start; flex-direction: column; gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .project-card, .project-card__arrow, .drawing-grid-region { transition: none; }
}

/* ============================================================
   Reference (settings CRUD) + audit + permissions matrix
   ============================================================ */
.ref-tabs { margin-bottom: 22px; overflow-x: auto; }
.ref-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.ref-toolbar__title { font-size: 15px; font-weight: 600; margin: 0; }
.ref-toolbar__count { font-family: var(--font-mono); font-size: 11px; color: var(--text-lo); text-transform: uppercase; letter-spacing: 0.06em; }

.filterbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.filterbar .select-wrap { display: inline-block; }
.filterbar .select { min-width: 160px; }

.matrix__role, .matrix__cell { text-align: center; }
.matrix__group td { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-lo); background: var(--base); }
.matrix__yes { color: var(--success); font-weight: 600; }
.matrix__no { color: var(--text-disabled); }
