/* ==========================================================================
   MMGPS design system
   Light, quiet surfaces; one accent; status colours always paired with an
   icon and a label. Built on Bootstrap 5.3's grid/utilities.
   ========================================================================== */

:root {
  color-scheme: light;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;

  /* surfaces */
  --page: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --surface-sunken: #f1f3f5;
  --hover: #f3f4f6;
  --border: #e6e8eb;
  --border-strong: #d4d8dd;

  /* ink */
  --ink: #111827;
  --ink-2: #4b5563;
  --ink-3: #6b7280;
  --ink-4: #9ca3af;

  /* accent */
  --accent: #0f6fde;
  --accent-hover: #0b5ec0;
  --accent-soft: #ebf3fd;
  --accent-ink: #0a4f9e;
  --focus: 0 0 0 3px rgba(15, 111, 222, 0.22);

  /* status - reserved for outcomes, never decoration */
  --good: #0ca30c;
  --good-soft: #e8f6e8;
  --good-ink: #0a6a0a;
  --warn: #fab219;
  --warn-soft: #fff5de;
  --warn-ink: #7a5200;
  --bad: #d03b3b;
  --bad-soft: #fcebeb;
  --bad-ink: #a12a2a;
  --none: #9a9891;
  --none-soft: #f1f1ef;
  --none-ink: #55534e;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 2px 8px rgba(16, 24, 40, 0.05);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.14), 0 2px 6px rgba(16, 24, 40, 0.06);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --bs-body-font-family: var(--font);
  --bs-body-color: var(--ink);
  --bs-body-bg: var(--page);
  --bs-border-color: var(--border);
  --bs-link-color-rgb: 15, 111, 222;
  --bs-link-hover-color-rgb: 11, 94, 192;
  --bs-emphasis-color: var(--ink);
  --bs-secondary-color: var(--ink-3);
}

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

h1, h2, h3, h4 { color: var(--ink); letter-spacing: -0.01em; }

::selection { background: rgba(15, 111, 222, 0.16); }

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }

.text-muted, .muted { color: var(--ink-3) !important; }
.text-secondary-ink { color: var(--ink-2); }
.mono { font-family: var(--font-mono); font-size: 0.92em; }
.tabular { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.min-w-0 { min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.visually-hidden-focusable:not(:focus):not(:focus-within) { position: absolute !important; }

/* ---------- icons ---------- */
.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.2em;
}
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }
.icon-xl { width: 28px; height: 28px; }
.icon-2xl { width: 40px; height: 40px; stroke-width: 1.6; }

/* ---------- buttons ---------- */
.btn {
  --bs-btn-font-weight: 600;
  --bs-btn-font-size: 14.5px;
  --bs-btn-padding-y: 9px;
  --bs-btn-padding-x: 16px;
  --bs-btn-border-radius: 10px;
  --bs-btn-focus-box-shadow: var(--focus);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .08s;
}
.btn:active { transform: translateY(1px); }
.btn .icon { width: 17px; height: 17px; }

.btn-primary {
  --bs-btn-bg: var(--accent);
  --bs-btn-border-color: var(--accent);
  --bs-btn-hover-bg: var(--accent-hover);
  --bs-btn-hover-border-color: var(--accent-hover);
  --bs-btn-active-bg: var(--accent-hover);
  --bs-btn-active-border-color: var(--accent-hover);
  --bs-btn-disabled-bg: #9fc3ef;
  --bs-btn-disabled-border-color: #9fc3ef;
  box-shadow: 0 1px 2px rgba(15, 111, 222, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.btn-secondary, .btn-light {
  --bs-btn-color: var(--ink);
  --bs-btn-bg: var(--surface);
  --bs-btn-border-color: var(--border-strong);
  --bs-btn-hover-color: var(--ink);
  --bs-btn-hover-bg: var(--hover);
  --bs-btn-hover-border-color: var(--border-strong);
  --bs-btn-active-color: var(--ink);
  --bs-btn-active-bg: var(--surface-sunken);
  --bs-btn-active-border-color: var(--border-strong);
  --bs-btn-disabled-color: var(--ink-4);
  --bs-btn-disabled-bg: var(--surface);
  --bs-btn-disabled-border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.btn-ghost {
  --bs-btn-color: var(--ink-2);
  --bs-btn-bg: transparent;
  --bs-btn-border-color: transparent;
  --bs-btn-hover-color: var(--ink);
  --bs-btn-hover-bg: var(--hover);
  --bs-btn-active-bg: var(--surface-sunken);
  --bs-btn-active-color: var(--ink);
}
.btn-danger-ghost {
  --bs-btn-color: var(--bad-ink);
  --bs-btn-bg: var(--surface);
  --bs-btn-border-color: var(--border-strong);
  --bs-btn-hover-color: var(--bad-ink);
  --bs-btn-hover-bg: var(--bad-soft);
  --bs-btn-hover-border-color: #f1c4c4;
  --bs-btn-active-bg: var(--bad-soft);
  --bs-btn-active-color: var(--bad-ink);
}
.btn-sm { --bs-btn-padding-y: 6px; --bs-btn-padding-x: 11px; --bs-btn-font-size: 13.5px; --bs-btn-border-radius: 8px; gap: 6px; }
.btn-lg { --bs-btn-padding-y: 13px; --bs-btn-padding-x: 20px; --bs-btn-font-size: 16px; --bs-btn-border-radius: 12px; }
.btn-icon { --bs-btn-padding-x: 9px; aspect-ratio: 1; }
.btn-icon.btn-sm { --bs-btn-padding-x: 6px; }

/* ---------- forms ---------- */
.form-label { font-size: 13.5px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.form-label .optional { font-weight: 400; color: var(--ink-3); margin-left: 4px; }
.form-text, .hint { font-size: 13px; color: var(--ink-3); margin-top: 6px; }

.form-control, .form-select {
  font-size: 15px;
  color: var(--ink);
  background-color: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 9px 12px;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
.form-select { padding-right: 36px; }
.form-control::placeholder { color: var(--ink-4); }
.form-control:focus, .form-select:focus { border-color: var(--accent); box-shadow: var(--focus); }
.form-control-sm, .form-select-sm { font-size: 13.5px; padding: 6px 10px; border-radius: 8px; }
.form-select-sm { padding-right: 32px; }
textarea.form-control { min-height: 84px; resize: vertical; }
.form-control.is-invalid, .form-select.is-invalid, .input-validation-error { border-color: var(--bad) !important; }
.form-control.is-invalid:focus, .input-validation-error:focus { box-shadow: 0 0 0 3px rgba(208, 59, 59, 0.18) !important; }
.field-validation-error, .invalid-feedback.d-block, .field-error {
  display: block; font-size: 13px; color: var(--bad-ink); margin-top: 6px; font-weight: 500;
}
.field-validation-valid { display: none; }
.validation-summary-errors ul { margin: 0; padding: 0; list-style: none; }
.form-check-input { width: 1.1em; height: 1.1em; border-color: var(--border-strong); }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-check-input:focus { box-shadow: var(--focus); border-color: var(--accent); }
.form-check-label { font-size: 14px; color: var(--ink-2); }

/* phones: 16px inputs stop iOS from zooming on focus */
@media (max-width: 767.98px) {
  .form-control, .form-select { font-size: 16px; }
}

/* ---------- cards ---------- */
.card-x {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-x + .card-x { margin-top: 16px; }
.grid-2 > .card-x + .card-x { margin-top: 0; }
.card-x-header {
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  padding: 16px 20px 0;
}
.card-x-title { font-size: 15px; font-weight: 650; margin: 0; display: flex; align-items: center; gap: 8px; }
.card-x-title .icon { color: var(--ink-3); }
.card-x-subtitle { font-size: 13px; color: var(--ink-3); margin: 2px 0 0; }
.card-x-body { padding: 16px 20px 20px; }
.card-x-footer { padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.card-x.flush .card-x-body { padding: 0; }

/* ---------- status chip ---------- */
.status {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px 0 8px;
  font-size: 12.5px; font-weight: 600; line-height: 1;
  border-radius: 999px; white-space: nowrap;
}
.status .icon { width: 14px; height: 14px; stroke-width: 2.4; }
.status--resolved { background: var(--good-soft); color: var(--good-ink); }
.status--resolved .icon { color: var(--good); }
.status--partial { background: var(--warn-soft); color: var(--warn-ink); }
.status--partial .icon { color: #d99400; }
.status--unresolved { background: var(--bad-soft); color: var(--bad-ink); }
.status--unresolved .icon { color: var(--bad); }
.status--unknown { background: var(--none-soft); color: var(--none-ink); }
.status--unknown .icon { color: var(--none); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot--resolved { background: var(--good); }
.dot--partial { background: var(--warn); }
.dot--unresolved { background: var(--bad); }
.dot--unknown { background: var(--none); }

.badge-soft {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  background: var(--surface-sunken); color: var(--ink-2); white-space: nowrap;
}
.badge-soft .icon { width: 13px; height: 13px; }
.badge-soft.accent { background: var(--accent-soft); color: var(--accent-ink); }
.badge-soft.warn { background: var(--warn-soft); color: var(--warn-ink); }
.badge-soft.bad { background: var(--bad-soft); color: var(--bad-ink); }
.badge-soft.good { background: var(--good-soft); color: var(--good-ink); }

.role-ADMIN { background: #eef0ff; color: #3b3fa8; }
.role-SUPERVISOR { background: #e9f6f4; color: #11685c; }
.role-TECHNICIAN { background: var(--accent-soft); color: var(--accent-ink); }

/* ---------- avatar ---------- */
.avatar {
  --size: 36px;
  width: var(--size); height: var(--size); flex: none;
  border-radius: 50%;
  display: inline-grid; place-items: center;
  font-size: calc(var(--size) * 0.38); font-weight: 700; letter-spacing: 0.02em;
  color: var(--accent-ink); background: var(--accent-soft);
  border: 1px solid rgba(15, 111, 222, 0.14);
}
.avatar-sm { --size: 28px; }
.avatar-lg { --size: 48px; }

/* ---------- brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; letter-spacing: -0.01em; }
.brand:hover { color: var(--ink); }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-name { font-size: 16px; }
.brand-name small { display: block; font-size: 11.5px; font-weight: 500; color: var(--ink-3); letter-spacing: 0; margin-top: -2px; }

/* ---------- empty state ---------- */
.empty {
  text-align: center; padding: 40px 20px; color: var(--ink-3);
}
.empty .icon-2xl { color: var(--ink-4); margin-bottom: 10px; }
.empty h3 { font-size: 16px; font-weight: 650; margin: 0 0 4px; }
.empty p { margin: 0 auto; max-width: 360px; font-size: 14px; }

/* ---------- toasts ---------- */
.toast-stack {
  position: fixed; z-index: 1090; left: 50%; transform: translateX(-50%);
  bottom: calc(24px + var(--safe-bottom));
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  width: min(92vw, 440px); pointer-events: none;
}
.app-field .toast-stack { bottom: calc(88px + var(--safe-bottom)); }
.toast-x {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 10px;
  width: 100%;
  background: #1f2937; color: #fff;
  border-radius: 12px; padding: 12px 14px;
  font-size: 14px; font-weight: 500; line-height: 1.4;
  box-shadow: var(--shadow-lg);
  animation: toast-in .22s ease-out;
}
.toast-x .icon { margin-top: 1px; color: #86efac; }
.toast-x.error .icon { color: #fca5a5; }
.toast-x.info .icon { color: #93c5fd; }
.toast-x.leaving { animation: toast-out .2s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ---------- alerts ---------- */
.notice {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px; border-radius: 12px; font-size: 14px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--ink-2);
}
.notice .icon { margin-top: 1px; color: var(--ink-3); }
.notice strong { color: var(--ink); }
.notice.warn { background: var(--warn-soft); border-color: #f5dea8; color: var(--warn-ink); }
.notice.warn .icon { color: #c98500; }
.notice.bad { background: var(--bad-soft); border-color: #f2c9c9; color: var(--bad-ink); }
.notice.bad .icon { color: var(--bad); }
.notice.accent { background: var(--accent-soft); border-color: #cfe2fa; color: var(--accent-ink); }
.notice.accent .icon { color: var(--accent); }

/* ---------- definition list ---------- */
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 12px 16px; margin: 0; font-size: 14px; }
.dl dt { color: var(--ink-3); font-weight: 500; }
.dl dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
@media (max-width: 575.98px) {
  .dl { grid-template-columns: 1fr; gap: 2px; }
  .dl dd { margin-bottom: 10px; }
}

/* ---------- photo ---------- */
.photo-frame {
  position: relative; overflow: hidden; border-radius: var(--radius);
  background: #0f1115; aspect-ratio: 4 / 3;
}
.photo-frame img { width: 100%; height: 100%; object-fit: contain; display: block; }
.photo-frame .photo-missing {
  position: absolute; inset: 0; display: grid; place-items: center; color: #9ca3af; font-size: 14px; text-align: center; padding: 16px;
  background: var(--surface-sunken);
}
.thumb {
  width: 52px; height: 52px; border-radius: 10px; object-fit: cover; flex: none;
  background: var(--surface-sunken); border: 1px solid var(--border);
  display: grid; place-items: center; color: var(--ink-4);
}
.thumb-sm { width: 40px; height: 40px; border-radius: 8px; }

/* ==========================================================================
   Sign-in
   ========================================================================== */
.auth {
  min-height: 100vh; min-height: 100dvh;
  display: grid; grid-template-columns: 1fr;
  background: var(--page);
}
.auth-panel {
  display: flex; flex-direction: column; justify-content: center;
  padding: calc(32px + var(--safe-top)) 20px calc(32px + var(--safe-bottom));
}
.auth-card { width: 100%; max-width: 400px; margin: 0 auto; }
.auth-card h1 { font-size: 24px; font-weight: 700; margin: 28px 0 6px; }
.auth-card .lead-text { color: var(--ink-3); font-size: 15px; margin-bottom: 28px; }
.auth-card .form-control { padding: 11px 14px; }
.auth-aside { display: none; }
.auth-foot { color: var(--ink-4); font-size: 12.5px; text-align: center; margin-top: 32px; }

@media (min-width: 992px) {
  .auth { grid-template-columns: minmax(420px, 1fr) minmax(480px, 1.1fr); }
  .auth-aside {
    display: flex; flex-direction: column; justify-content: space-between;
    padding: 40px 48px;
    background: var(--surface);
    border-left: 1px solid var(--border);
    position: relative; overflow: hidden;
  }
  .auth-aside h2 { font-size: 28px; font-weight: 700; line-height: 1.2; max-width: 440px; margin: 0 0 12px; }
  .auth-aside p { color: var(--ink-2); max-width: 440px; font-size: 15px; }
}
.auth-points { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 14px; max-width: 440px; }
.auth-points li { display: flex; gap: 12px; font-size: 14.5px; color: var(--ink-2); }
.auth-points .icon { color: var(--accent); margin-top: 2px; }
.auth-points strong { color: var(--ink); display: block; font-weight: 600; }
.auth-map {
  position: relative; height: 44vh; min-height: 240px; max-height: 420px; margin: 8px -48px -40px;
  border-top: 1px solid var(--border);
  background:
    linear-gradient(var(--surface-2), var(--surface-2)) padding-box;
}
.auth-map svg { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ==========================================================================
   Field app (technicians) - mobile first
   ========================================================================== */
.app-field { background: var(--page); }
.app-header {
  position: sticky; top: 0; z-index: 1020;
  padding-top: var(--safe-top);
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.app-header-inner {
  height: 56px; max-width: 680px; margin: 0 auto; padding: 0 12px 0 16px;
  display: flex; align-items: center; gap: 8px;
}
.app-header .back {
  margin-left: -8px; width: 40px; height: 40px; border-radius: 10px;
  display: inline-grid; place-items: center; color: var(--ink);
}
.app-header .back:hover { background: var(--hover); }
.app-header-title { font-size: 17px; font-weight: 650; margin: 0; flex: 1; min-width: 0; }
.app-header .avatar-btn { border: 0; background: none; padding: 4px; border-radius: 50%; }
.app-header .avatar-btn:focus-visible { box-shadow: var(--focus); }

.sync-pill {
  display: none; align-items: center; gap: 6px; height: 30px; padding: 0 10px;
  border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: var(--warn-soft); color: var(--warn-ink); border: 0;
}
.sync-pill.show { display: inline-flex; }
.sync-pill.offline { background: var(--surface-sunken); color: var(--ink-2); }
.sync-pill .icon { width: 15px; height: 15px; }
.sync-pill.syncing .icon { animation: spin 1s linear infinite; }

.app-main {
  max-width: 680px; margin: 0 auto;
  padding: 16px 16px calc(104px + var(--safe-bottom));
}

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
  background: rgba(255, 255, 255, 0.96);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
}
.tabbar-inner {
  max-width: 680px; margin: 0 auto; height: 64px;
  display: grid; grid-template-columns: 1fr 1fr 1fr; align-items: center;
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  height: 100%; color: var(--ink-3); font-size: 11.5px; font-weight: 600;
}
.tab .icon { width: 22px; height: 22px; }
.tab:hover { color: var(--ink-2); }
.tab.active { color: var(--accent); }
.tab-primary { position: relative; }
.tab-primary .fab {
  width: 56px; height: 56px; margin-top: -22px;
  border-radius: 18px; display: grid; place-items: center;
  background: var(--accent); color: #fff;
  box-shadow: 0 6px 16px rgba(15, 111, 222, 0.35), 0 1px 2px rgba(15, 111, 222, 0.3);
  transition: transform .12s, background-color .15s;
}
.tab-primary .fab .icon { width: 26px; height: 26px; stroke-width: 2.2; }
.tab-primary:active .fab { transform: scale(.96); }
.tab-primary.active .fab { background: var(--accent-hover); }

/* home */
.hello { margin: 4px 0 20px; }
.hello h1 { font-size: 24px; font-weight: 700; margin: 0; }
.hello p { color: var(--ink-3); margin: 2px 0 0; font-size: 14.5px; }

.start-card {
  display: flex; align-items: center; gap: 16px;
  padding: 18px; border-radius: var(--radius-lg);
  background: var(--accent); color: #fff;
  box-shadow: 0 10px 24px rgba(15, 111, 222, 0.25);
  position: relative; overflow: hidden;
}
.start-card:hover { color: #fff; background: var(--accent-hover); }
.start-card .start-icon {
  width: 52px; height: 52px; border-radius: 14px; flex: none;
  display: grid; place-items: center; background: rgba(255, 255, 255, 0.16);
}
.start-card .start-icon .icon { width: 26px; height: 26px; }
.start-card h2 { color: #fff; font-size: 17px; font-weight: 700; margin: 0; }
.start-card p { margin: 2px 0 0; font-size: 13.5px; color: rgba(255, 255, 255, 0.82); }
.start-card .chev { margin-left: auto; opacity: .9; }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0 24px; }
.mini-stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; justify-content: space-between;
}
.mini-stat .label { font-size: 12.5px; color: var(--ink-3); font-weight: 500; }
.mini-stat .value { font-size: 22px; font-weight: 700; line-height: 1.2; margin-top: 2px; }
.mini-stat .value small { font-size: 12.5px; font-weight: 600; color: var(--ink-3); margin-left: 2px; }

.section-title {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  margin: 0 0 10px;
}
.section-title h2 { font-size: 15px; font-weight: 650; margin: 0; }
.section-title a { font-size: 13.5px; font-weight: 600; }

/* visit list (phone) */
.visit-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.visit-item {
  display: flex; gap: 12px; align-items: center;
  padding: 12px 14px; color: var(--ink);
  border-top: 1px solid var(--border);
}
.visit-item:first-child { border-top: 0; }
.visit-item:hover { background: var(--surface-2); color: var(--ink); }
.visit-item .thumb { width: 48px; height: 48px; }
.visit-item-main { flex: 1; min-width: 0; }
.visit-item-title { font-weight: 600; font-size: 14.5px; }
.visit-item-sub { font-size: 13px; color: var(--ink-3); }
.visit-item-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
.visit-item-meta time { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.visit-item.pending { background: var(--warn-soft); }
.visit-group-label { font-size: 12px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; margin: 20px 4px 8px; }

/* install banner */
.install-card {
  display: none; align-items: center; gap: 12px;
  padding: 12px 14px; margin-bottom: 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.install-card.show { display: flex; }
.install-card img { width: 40px; height: 40px; border-radius: 10px; }
.install-card .grow { flex: 1; min-width: 0; font-size: 13.5px; color: var(--ink-2); }
.install-card .grow strong { display: block; color: var(--ink); font-size: 14px; }

/* segmented filter chips */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 4px; margin: 0 -2px 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  height: 34px; padding: 0 14px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600; color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--border-strong);
}
.chip:hover { color: var(--ink); background: var(--hover); }
.chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip .count { font-weight: 700; opacity: .7; }

/* ---------- new visit form ---------- */
.form-step {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 16px; margin-bottom: 14px;
}
.form-step-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.form-step-num {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
  background: var(--surface-sunken); color: var(--ink-2);
}
.form-step.done .form-step-num { background: var(--good); color: #fff; }
.form-step.done .form-step-num span { display: none; }
.form-step.done .form-step-num::after {
  content: ""; width: 10px; height: 6px; margin-top: -3px;
  border-left: 2.4px solid #fff; border-bottom: 2.4px solid #fff; transform: rotate(-45deg);
}
.form-step-title { font-size: 15.5px; font-weight: 650; margin: 0; }
.form-step-sub { font-size: 13px; color: var(--ink-3); margin: 0; }
.form-step.has-error { border-color: #efb4b4; box-shadow: 0 0 0 3px rgba(208, 59, 59, 0.08); }

.capture {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  width: 100%; aspect-ratio: 4 / 3; border-radius: var(--radius);
  border: 1.5px dashed var(--border-strong); background: var(--surface-2);
  color: var(--ink-2); text-align: center; padding: 16px;
}
.capture .capture-icon {
  width: 60px; height: 60px; border-radius: 18px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.capture .capture-icon .icon { width: 28px; height: 28px; }
.capture p { margin: 0; font-size: 13px; color: var(--ink-3); max-width: 280px; }

.shot { position: relative; border-radius: var(--radius); overflow: hidden; background: #0f1115; aspect-ratio: 4 / 3; }
.shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shot-bar {
  position: absolute; left: 10px; right: 10px; bottom: 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.shot-bar .badge-soft { background: rgba(17, 24, 39, 0.72); color: #fff; backdrop-filter: blur(6px); }

.locator { display: flex; align-items: center; gap: 12px; }
.locator-icon {
  width: 44px; height: 44px; border-radius: 12px; flex: none;
  display: grid; place-items: center;
  background: var(--surface-sunken); color: var(--ink-3);
  position: relative;
}
.locator.seeking .locator-icon { color: var(--accent); background: var(--accent-soft); }
.locator.seeking .locator-icon::after {
  content: ""; position: absolute; inset: -4px; border-radius: 14px;
  border: 2px solid rgba(15, 111, 222, 0.35); animation: pulse 1.6s ease-out infinite;
}
.locator.ok .locator-icon { color: var(--good-ink); background: var(--good-soft); }
.locator.weak .locator-icon { color: var(--warn-ink); background: var(--warn-soft); }
.locator.error .locator-icon { color: var(--bad-ink); background: var(--bad-soft); }
.locator-text { flex: 1; min-width: 0; }
.locator-title { font-weight: 600; font-size: 14.5px; }
.locator-sub { font-size: 13px; color: var(--ink-3); }
.accuracy-meter { height: 4px; border-radius: 4px; background: var(--surface-sunken); margin-top: 12px; overflow: hidden; }
.accuracy-meter span { display: block; height: 100%; width: 0; border-radius: 4px; background: var(--good); transition: width .4s ease, background-color .4s; }
@keyframes pulse { 0% { opacity: .9; transform: scale(.9); } 100% { opacity: 0; transform: scale(1.25); } }
@keyframes spin { to { transform: rotate(360deg); } }

.outcomes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.outcome input { position: absolute; opacity: 0; pointer-events: none; }
.outcome label {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 84px; padding: 10px 6px; border-radius: 12px; cursor: pointer; text-align: center;
  border: 1.5px solid var(--border-strong); background: var(--surface);
  font-size: 13px; font-weight: 600; color: var(--ink-2); line-height: 1.25;
  transition: border-color .15s, background-color .15s, color .15s, box-shadow .15s;
}
.outcome label .icon { width: 24px; height: 24px; color: var(--ink-4); }
.outcome input:focus-visible + label { box-shadow: var(--focus); }
.outcome.resolved input:checked + label { border-color: var(--good); background: var(--good-soft); color: var(--good-ink); }
.outcome.resolved input:checked + label .icon { color: var(--good); }
.outcome.partial input:checked + label { border-color: #e7a300; background: var(--warn-soft); color: var(--warn-ink); }
.outcome.partial input:checked + label .icon { color: #d99400; }
.outcome.unresolved input:checked + label { border-color: var(--bad); background: var(--bad-soft); color: var(--bad-ink); }
.outcome.unresolved input:checked + label .icon { color: var(--bad); }

.submit-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1035;
  background: rgba(255, 255, 255, 0.96);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--border);
  padding: 12px 16px calc(12px + var(--safe-bottom));
}
.submit-bar-inner { max-width: 680px; margin: 0 auto; display: flex; flex-direction: column; gap: 6px; }
.submit-bar .hint { margin: 0; text-align: center; min-height: 18px; }
.app-field.has-submit-bar .tabbar { display: none; }

.result {
  text-align: center; padding: 40px 20px 24px;
}
.result-icon {
  width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 16px;
  display: grid; place-items: center; background: var(--good-soft); color: var(--good);
}
.result-icon .icon { width: 36px; height: 36px; stroke-width: 2.4; }
.result.queued .result-icon { background: var(--warn-soft); color: #c98500; }
.result h2 { font-size: 21px; font-weight: 700; margin: 0 0 6px; }
.result p { color: var(--ink-3); max-width: 360px; margin: 0 auto 24px; }

/* ---------- camera overlay ---------- */
.camera {
  position: fixed; inset: 0; z-index: 2000; background: #000; color: #fff;
  display: none; flex-direction: column;
}
.camera.open { display: flex; }
.camera video, .camera canvas.preview {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000;
}
.camera canvas.preview { object-fit: contain; }
.camera-top, .camera-bottom { position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; }
.camera-top { padding-top: calc(12px + var(--safe-top)); background: linear-gradient(rgba(0,0,0,.55), transparent); }
.camera-bottom { margin-top: auto; padding-bottom: calc(24px + var(--safe-bottom)); background: linear-gradient(transparent, rgba(0,0,0,.6)); }
.camera-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 0;
  display: grid; place-items: center; color: #fff; background: rgba(255, 255, 255, 0.14);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.camera-btn:disabled { opacity: .35; }
.camera-btn .icon { width: 22px; height: 22px; }
.shutter {
  width: 76px; height: 76px; border-radius: 50%; border: 4px solid #fff; padding: 4px;
  background: transparent; display: grid; place-items: center;
}
.shutter span { width: 100%; height: 100%; border-radius: 50%; background: #fff; transition: transform .1s; }
.shutter:active span { transform: scale(.9); }
.shutter:disabled { opacity: .4; }
.camera-meta {
  position: relative; z-index: 2; align-self: center; margin-top: 8px;
  display: inline-flex; gap: 8px; align-items: center;
  font-size: 12.5px; font-weight: 600; padding: 6px 12px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.45); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.camera-meta .icon { width: 14px; height: 14px; }
.camera-review { display: none; gap: 12px; width: 100%; }
.camera.reviewing .camera-review { display: flex; }
.camera.reviewing .camera-shoot { display: none; }
.camera-review .btn { flex: 1; }
.camera-shoot { display: flex; width: 100%; align-items: center; justify-content: space-between; }
.camera-message {
  position: absolute; inset: 0; z-index: 1; display: none; align-items: center; justify-content: center;
  padding: 32px; text-align: center; color: #d1d5db; font-size: 15px;
}
.camera.failed .camera-message { display: flex; }
.camera-message h3 { color: #fff; font-size: 18px; margin-bottom: 8px; }

/* ==========================================================================
   Admin panel
   ========================================================================== */
.app-admin { background: var(--page); }
.shell { display: flex; min-height: 100vh; min-height: 100dvh; }
.sidebar {
  width: 252px; flex: none;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; height: 100dvh;
}
.sidebar-brand { padding: 18px 20px 14px; }
.sidebar-nav { padding: 8px 12px; flex: 1; overflow-y: auto; }
.nav-label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-4); padding: 14px 10px 6px; }
.nav-link-x {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; margin-bottom: 2px; border-radius: 9px;
  color: var(--ink-2); font-size: 14px; font-weight: 550;
}
.nav-link-x .icon { color: var(--ink-3); }
.nav-link-x:hover { background: var(--hover); color: var(--ink); }
.nav-link-x.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 650; }
.nav-link-x.active .icon { color: var(--accent); }
.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); }
.user-card {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px; border-radius: 10px; border: 0; background: none; text-align: left; color: var(--ink);
}
.user-card:hover { background: var(--hover); }
.user-card .who { flex: 1; min-width: 0; }
.user-card .who strong { display: block; font-size: 13.5px; font-weight: 650; }
.user-card .who span { display: block; font-size: 12px; color: var(--ink-3); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: none; position: sticky; top: 0; z-index: 1020;
  height: calc(56px + var(--safe-top)); padding: var(--safe-top) 12px 0;
  align-items: center; gap: 8px;
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.content { padding: 28px 32px 48px; width: 100%; max-width: 1480px; }

@media (max-width: 991.98px) {
  .sidebar {
    position: fixed; z-index: 1045; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .sidebar-backdrop {
    position: fixed; inset: 0; z-index: 1040; background: rgba(17, 24, 39, 0.35);
    opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  .sidebar.open + .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  .topbar { display: flex; }
  .content { padding: 20px 16px calc(40px + var(--safe-bottom)); }
}

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-bottom: 20px;
}
.page-head h1 { font-size: 24px; font-weight: 700; margin: 0; }
.page-head .sub { color: var(--ink-3); font-size: 14px; margin: 4px 0 0; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { font-size: 13px; font-weight: 600; color: var(--ink-3); display: inline-flex; align-items: center; gap: 4px; margin-bottom: 8px; }
.crumb:hover { color: var(--ink); }

/* filter row */
.filters {
  display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap;
  padding: 12px; margin-bottom: 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.filters .f { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.filters .f label { font-size: 12px; font-weight: 600; color: var(--ink-3); padding-left: 2px; }
.filters .f-range { min-width: 170px; }
.filters .f-dates { display: none; gap: 6px; align-items: center; }
.filters .f-dates.show { display: flex; }
.filters .f-dates input { width: 150px; }
.filters .f-person { min-width: 190px; }
.filters .f-status { min-width: 160px; }
.filters .f-search { flex: 1; min-width: 200px; }
.filters .f-actions { display: flex; gap: 6px; margin-left: auto; }
.search-input { position: relative; }
.search-input .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--ink-4); width: 16px; height: 16px; }
.search-input .form-control { padding-left: 34px; }
@media (max-width: 767.98px) {
  .filters .f, .filters .f-range, .filters .f-person, .filters .f-status, .filters .f-search { flex: 1 1 100%; min-width: 0; }
  .filters .f-dates input { width: auto; flex: 1; }
  .filters .f-actions { width: 100%; margin-left: 0; }
  .filters .f-actions .btn { flex: 1; }
}

/* stat tiles */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
@media (max-width: 1199.98px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 575.98px) { .stats { gap: 10px; } }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px;
}
.stat-label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink-3); }
.stat-label .icon { width: 16px; height: 16px; }
.stat-value { font-size: 30px; font-weight: 700; line-height: 1.15; margin-top: 8px; letter-spacing: -0.02em; }
.stat-note { font-size: 13px; color: var(--ink-3); margin-top: 4px; }
.stat-note strong { color: var(--ink-2); font-weight: 650; }
@media (max-width: 575.98px) {
  .stat { padding: 14px; }
  .stat-value { font-size: 24px; }
}

.grid-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; margin-bottom: 20px; }
@media (max-width: 1199.98px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

/* chart */
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid-line { stroke: #eceae4; stroke-width: 1; shape-rendering: crispEdges; }
.chart .baseline { stroke: #c9c7bf; stroke-width: 1; shape-rendering: crispEdges; }
.chart .tick { font-size: 11.5px; fill: #898781; font-variant-numeric: tabular-nums; }
.chart .col-hit { fill: transparent; cursor: default; }
.chart .col:hover .seg, .chart .col.focus .seg { filter: brightness(1.08) saturate(1.05); }
.chart .col:hover .col-hover-bg, .chart .col.focus .col-hover-bg { fill: rgba(17, 24, 39, 0.04); }
.chart .col-hover-bg { fill: transparent; }
.chart-tooltip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 170px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg);
  padding: 10px 12px; font-size: 13px; opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s;
}
.chart-tooltip.show { opacity: 1; transform: none; }
.chart-tooltip .tt-title { font-size: 12px; color: var(--ink-3); font-weight: 600; margin-bottom: 6px; }
.chart-tooltip .tt-row { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.chart-tooltip .tt-key { width: 12px; height: 3px; border-radius: 2px; flex: none; }
.chart-tooltip .tt-row strong { font-variant-numeric: tabular-nums; min-width: 28px; }
.chart-tooltip .tt-row span { color: var(--ink-3); }
.chart-tooltip .tt-total { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 6px; display: flex; justify-content: space-between; font-weight: 650; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.seg-toggle { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-sunken); border-radius: 9px; }
.seg-toggle button {
  border: 0; background: none; padding: 4px 10px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: var(--ink-3);
}
.seg-toggle button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* share bars (outcome breakdown) */
.share-bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; gap: 2px; background: var(--surface); }
.share-bar span { display: block; height: 100%; }
.share-bar span:first-child { border-radius: 5px 0 0 5px; }
.share-bar span:last-child { border-radius: 0 5px 5px 0; }
.share-list { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 12px; }
.share-list li { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.share-list .name { flex: 1; color: var(--ink-2); display: inline-flex; align-items: center; gap: 8px; }
.share-list .name .icon { width: 16px; height: 16px; }
.share-list .val { font-weight: 650; font-variant-numeric: tabular-nums; }
.share-list .pct { width: 52px; text-align: right; color: var(--ink-3); font-variant-numeric: tabular-nums; font-size: 13px; }

.meter { height: 6px; border-radius: 3px; background: #e3eefc; overflow: hidden; min-width: 60px; }
.meter span { display: block; height: 100%; border-radius: 3px; background: var(--accent); }

/* tables */
.table-x { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.table-x th {
  font-size: 12px; font-weight: 650; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em;
  padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; text-align: left;
}
.table-x th:first-child { border-top-left-radius: var(--radius); }
.table-x th:last-child { border-top-right-radius: var(--radius); }
.table-x td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table-x tbody tr:last-child td { border-bottom: 0; }
.table-x tbody tr[data-href] { cursor: pointer; }
.table-x tbody tr:hover td { background: var(--surface-2); }
.table-x tr.removed td { opacity: .55; }
.table-x .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-x .primary { font-weight: 600; color: var(--ink); }
.table-x .secondary { font-size: 13px; color: var(--ink-3); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap .table-x { min-width: 720px; }

/* responsive list cards replace wide tables on phones */
.rows-mobile { display: none; }
@media (max-width: 767.98px) {
  .rows-desktop { display: none; }
  .rows-mobile { display: block; }
}

/* pager */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 13.5px; color: var(--ink-3); flex-wrap: wrap; }
.pager .btn-group-x { display: flex; gap: 6px; }

/* ranked list */
.rank-list { list-style: none; margin: 0; padding: 0; }
.rank-list li { display: flex; align-items: center; gap: 12px; padding: 10px 20px; border-top: 1px solid var(--border); font-size: 14px; }
.rank-list li:first-child { border-top: 0; }
.rank-list .name { flex: 1; min-width: 0; }
.rank-list .count { font-weight: 650; font-variant-numeric: tabular-nums; }

/* activity feed */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 14px; padding: 14px 20px; border-top: 1px solid var(--border); }
.feed li:first-child { border-top: 0; }
.feed-icon {
  width: 34px; height: 34px; border-radius: 10px; flex: none; display: grid; place-items: center;
  background: var(--surface-sunken); color: var(--ink-2);
}
.feed-icon .icon { width: 17px; height: 17px; }
.feed-icon.warn { background: var(--warn-soft); color: var(--warn-ink); }
.feed-icon.accent { background: var(--accent-soft); color: var(--accent); }
.feed-body { flex: 1; min-width: 0; }
.feed-title { font-size: 14px; color: var(--ink-2); }
.feed-title strong { color: var(--ink); font-weight: 650; }
.feed-details { font-size: 13.5px; color: var(--ink-2); margin-top: 2px; overflow-wrap: anywhere; }
.feed-meta { font-size: 12.5px; color: var(--ink-3); margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.feed-time { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; text-align: right; }

/* role tabs */
.tabs-x { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs-x a {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 12px; margin-bottom: -1px;
  font-size: 14px; font-weight: 600; color: var(--ink-3); border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs-x a:hover { color: var(--ink); }
.tabs-x a.active { color: var(--ink); border-bottom-color: var(--ink); }
.tabs-x .count { font-size: 12px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--surface-sunken); color: var(--ink-2); }

/* dropdown polish */
.dropdown-menu {
  --bs-dropdown-border-color: var(--border);
  --bs-dropdown-border-radius: 12px;
  --bs-dropdown-link-hover-bg: var(--hover);
  --bs-dropdown-link-active-bg: var(--accent-soft);
  --bs-dropdown-link-active-color: var(--accent-ink);
  --bs-dropdown-font-size: 14px;
  --bs-dropdown-item-padding-y: 8px;
  padding: 6px; box-shadow: var(--shadow-lg);
}
.dropdown-item { border-radius: 8px; display: flex; align-items: center; gap: 10px; color: var(--ink); }
.dropdown-item .icon { color: var(--ink-3); width: 17px; height: 17px; }
.dropdown-item.danger { color: var(--bad-ink); }
.dropdown-item.danger .icon { color: var(--bad); }
.dropdown-header-x { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.dropdown-header-x strong { display: block; font-size: 14px; }
.dropdown-header-x span { font-size: 12.5px; color: var(--ink-3); }
.dropdown-item-form { margin: 0; }
.dropdown-item-form button { width: 100%; border: 0; background: none; text-align: left; }

/* modal polish */
.modal-content { border: 0; border-radius: 16px; box-shadow: var(--shadow-lg); }
.modal-header, .modal-footer { border-color: var(--border); }
.modal-title { font-size: 17px; font-weight: 650; }

/* ==========================================================================
   Maps
   ========================================================================== */
.map { width: 100%; height: 100%; min-height: 280px; background: #eef0f2; border-radius: var(--radius); z-index: 0; }
.map-card .map { height: 380px; border-radius: 0 0 var(--radius) var(--radius); }
.map .leaflet-tile-pane { filter: saturate(0.45) brightness(1.03) contrast(0.96); }
.leaflet-container { font-family: var(--font); font-size: 13px; }
.leaflet-control-attribution { font-size: 10.5px; background: rgba(255, 255, 255, 0.8) !important; }
.leaflet-bar { border: 1px solid var(--border) !important; box-shadow: var(--shadow) !important; border-radius: 10px !important; overflow: hidden; }
.leaflet-bar a { color: var(--ink) !important; width: 32px !important; height: 32px !important; line-height: 32px !important; }

.pin {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2.5px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  transition: transform .12s;
}
.pin--resolved { background: var(--good); }
.pin--partial { background: var(--warn); }
.pin--unresolved { background: var(--bad); }
.pin--unknown { background: var(--none); }
.leaflet-marker-icon:hover .pin, .pin.active { transform: scale(1.35); }
.pin-lg { width: 22px; height: 22px; border-width: 3px; }

.cluster {
  width: 42px; height: 42px; border-radius: 50%; padding: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.cluster b {
  width: 100%; height: 100%; border-radius: 50%; background: #fff;
  display: grid; place-items: center; font-size: 12.5px; font-weight: 700; color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.leaflet-popup-content-wrapper { border-radius: 12px; box-shadow: var(--shadow-lg); padding: 0; overflow: hidden; }
.leaflet-popup-content { margin: 0; width: 260px !important; }
.pop img { width: 100%; height: 150px; object-fit: cover; display: block; background: var(--surface-sunken); }
.pop-body { padding: 12px 14px 14px; }
.pop-title { font-weight: 650; font-size: 14.5px; margin: 0 0 6px; }
.pop-line { font-size: 13px; color: var(--ink-2); margin: 6px 0 0; display: flex; gap: 6px; }
.pop-line .icon { width: 14px; height: 14px; margin-top: 2px; color: var(--ink-4); }
.pop-foot { margin-top: 12px; display: flex; justify-content: space-between; align-items: center; }
.pop-foot a { font-weight: 600; font-size: 13px; }

.map-page { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 16px; height: calc(100vh - 230px); min-height: 520px; }
.map-page .map { height: 100%; box-shadow: var(--shadow); border: 1px solid var(--border); }
.map-side { display: flex; flex-direction: column; min-height: 0; }
.map-side .card-x { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.map-list { overflow-y: auto; flex: 1; }
.map-list button {
  width: 100%; border: 0; background: none; text-align: left;
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-top: 1px solid var(--border);
}
.map-list button:first-child { border-top: 0; }
.map-list button:hover, .map-list button.active { background: var(--surface-2); }
.map-list .dot { margin-top: 7px; }
.map-list .t { font-weight: 600; font-size: 14px; color: var(--ink); }
.map-list .s { font-size: 12.5px; color: var(--ink-3); }
@media (max-width: 991.98px) {
  .map-page { grid-template-columns: 1fr; height: auto; }
  .map-page .map { height: 62vh; min-height: 360px; }
  .map-side { order: 2; }
  .map-list { max-height: 420px; }
}
.map-wrap { position: relative; }
.map-legend {
  position: absolute; z-index: 500; left: 12px; bottom: 12px;
  display: flex; flex-wrap: wrap; gap: 4px; padding: 6px;
  background: rgba(255, 255, 255, 0.96); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
  max-width: calc(100% - 24px);
}
.map-legend label {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px; border-radius: 8px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-2); cursor: pointer; user-select: none;
}
.map-legend label:hover { background: var(--hover); }
.map-legend input { position: absolute; opacity: 0; pointer-events: none; }
.map-legend input:not(:checked) + .dot { background: transparent !important; box-shadow: inset 0 0 0 1.5px var(--ink-4); }
.map-legend input:not(:checked) ~ span { color: var(--ink-4); text-decoration: line-through; }
.map-legend input:focus-visible ~ span { text-decoration: underline; }
.map-legend .n { color: var(--ink-3); font-weight: 600; font-variant-numeric: tabular-nums; }
.map-tools { position: absolute; z-index: 500; right: 12px; top: 12px; display: flex; gap: 6px; }
.map-tools .btn { box-shadow: var(--shadow); }
.map-empty {
  position: absolute; z-index: 500; inset: 0; display: grid; place-items: center; pointer-events: none;
}
.map-empty > div { pointer-events: auto; background: rgba(255,255,255,.96); border: 1px solid var(--border); border-radius: 12px; padding: 14px 18px; box-shadow: var(--shadow); font-size: 14px; color: var(--ink-2); max-width: 300px; text-align: center; }

/* detail page */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px; }
@media (max-width: 1099.98px) { .detail-grid { grid-template-columns: 1fr; } }
.mini-map { height: 260px; border-radius: var(--radius); border: 1px solid var(--border); }
.meta-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media print {
  .sidebar, .topbar, .filters, .page-head .actions, .tabbar, .app-header { display: none !important; }
  .content { padding: 0; }
  body { background: #fff; }
}

/* ---------- misc admin form bits ---------- */
.validation-summary-valid { display: none !important; }
legend.form-label { font-size: 13.5px; float: none; margin-bottom: 8px; }
.role-option {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface);
  transition: border-color .15s, background-color .15s;
}
.role-option:hover { background: var(--surface-2); }
.role-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.role-option strong { font-size: 14.5px; }
.map-tools .btn.active { background: var(--accent-soft); color: var(--accent-ink); border-color: #bcd6f7; }
form.is-loading { opacity: .7; pointer-events: none; }

/* ---------- searchable dropdown (js/combobox.js) ---------- */
.combo { position: relative; }
.combo-native {
  position: absolute !important; width: 1px; height: 1px; opacity: 0; pointer-events: none;
  bottom: 0; left: 12px; margin: 0; padding: 0; border: 0;
}
.combo-trigger {
  display: flex; align-items: center; width: 100%; min-height: 44px;
  text-align: left; cursor: pointer; color: var(--ink);
}
.combo-trigger:focus-visible { border-color: var(--accent); box-shadow: var(--focus); }
.combo-value { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.combo-value-main { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.combo-value-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--ink-3); }
.combo-trigger.is-placeholder .combo-value-main { font-weight: 400; color: var(--ink-4); }
.combo.open .combo-trigger { border-color: var(--accent); box-shadow: var(--focus); }
.combo-native.is-invalid + .combo-trigger,
.combo-native.input-validation-error + .combo-trigger { border-color: var(--bad); }

.combo-panel {
  position: absolute; z-index: 1060; top: calc(100% + 6px); left: 0; right: 0;
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.combo-head { display: none; }
.combo-search { position: relative; padding: 8px; border-bottom: 1px solid var(--border); }
.combo-search .icon { position: absolute; left: 20px; top: 50%; transform: translateY(-50%); color: var(--ink-4); width: 17px; height: 17px; }
.combo-search .form-control { padding-left: 38px; box-shadow: none; }
.combo-list { list-style: none; margin: 0; padding: 6px; max-height: 300px; overflow-y: auto; overscroll-behavior: contain; }
.combo-option {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px; cursor: pointer; min-height: 44px;
}
.combo-option.active { background: var(--hover); }
.combo-option[aria-selected="true"] .combo-option-name { font-weight: 650; }
.combo-option-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.combo-option-name { color: var(--ink); overflow-wrap: anywhere; }
.combo-option-sub { font-size: 13px; color: var(--ink-3); }
.combo-option mark { padding: 0 1px; border-radius: 3px; background: #fff0b3; color: inherit; }
.combo-check { color: var(--accent); flex: none; }
.combo-status { padding: 10px 14px 12px; font-size: 13px; color: var(--ink-3); border-top: 1px solid var(--border); }

/* Phones: the list opens as a full-screen sheet with room for the keyboard. */
html.combo-lock, html.combo-lock body { overflow: hidden; }
.combo.as-sheet .combo-panel {
  position: fixed; inset: 0; z-index: 2100; border: 0; border-radius: 0; box-shadow: none;
  padding-top: var(--safe-top); height: 100vh; height: 100dvh;
  animation: sheet-in .18s ease-out;
}
.combo.as-sheet .combo-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 8px 4px 16px; font-size: 17px;
}
.combo.as-sheet .combo-search { padding: 8px 12px 12px; }
.combo.as-sheet .combo-search .icon { left: 24px; }
.combo.as-sheet .combo-list { order: 3; flex: 1; max-height: none; padding: 4px 8px calc(12px + var(--safe-bottom)); }
.combo.as-sheet .combo-option { min-height: 52px; padding: 10px 12px; }
.combo.as-sheet .combo-status { order: 2; border-top: 0; border-bottom: 1px solid var(--border); padding: 0 16px 10px; }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }
