:root {
  --color-bg: #f7f7f8;
  --color-surface: #ffffff;
  --color-surface-alt: #fafafa;
  --color-text: #1f2329;
  --color-text-muted: #6b7280;
  --color-text-faint: #9ca3af;
  --color-border-subtle: #ececef;
  --color-border: #e1e3e7;
  --color-border-strong: #d1d5db;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-soft: #eef4ff;
  --color-primary-faint: #f8fafc;
  --color-accent-orange: #ea580c;
  --color-error: #b91c1c;
  --color-error-soft: #fef2f2;
  --color-success: #047857;
  --color-success-soft: #ecfdf5;
  --color-warn-soft: #fff7ed;
  --color-warn: #b45309;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 10px 32px rgba(15, 23, 42, 0.10);
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --header-h: 52px;
  --sidebar-w: 380px;
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --transition: 140ms cubic-bezier(0.2, 0.0, 0.2, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font);
  color: var(--color-text);
  background: var(--color-bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  letter-spacing: -0.005em;
}

input, select, textarea {
  font-family: inherit;
  font-size: 13.5px;
  color: var(--color-text);
}

::placeholder { color: var(--color-text-faint); }

/* ---------- LOGIN PAGE ---------- */

.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1rem;
  background: radial-gradient(ellipse at top, #eef4ff 0%, var(--color-bg) 50%);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2.25rem 2rem 1.75rem;
}

.login-brand {
  text-align: center;
  margin-bottom: 1.75rem;
}

.login-brand h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.login-brand p {
  margin: 0.3rem 0 0;
  color: var(--color-text-muted);
  font-size: 13px;
}

/* ---------- FORM PRIMITIVES ---------- */

.field {
  display: block;
  margin-bottom: 0.85rem;
}

.field > span,
.field > label > span:first-child {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--color-text-muted);
  margin-bottom: 0.3rem;
}

.field input[type="text"],
.field input[type="password"],
.field input[type="number"],
.field select,
.field textarea {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.field textarea {
  resize: vertical;
  min-height: 120px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.55;
}

/* ---------- BUTTONS ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 0.85rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--color-primary);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
  box-shadow: var(--shadow-xs);
}

.btn:hover { background: var(--color-primary-hover); }
.btn:active { transform: translateY(0.5px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }

.btn-block {
  width: 100%;
  padding: 0.65rem 1rem;
  font-size: 13.5px;
}

.btn-ghost {
  background: transparent;
  color: var(--color-text);
  border-color: var(--color-border);
  box-shadow: none;
}

.btn-ghost:hover {
  background: var(--color-surface-alt);
  border-color: var(--color-border-strong);
}

.btn-sm {
  padding: 0.25rem 0.55rem;
  font-size: 12px;
  font-weight: 500;
}

/* ---------- ALERTS ---------- */

.alert {
  margin-top: 0.75rem;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  display: none;
  border: 1px solid transparent;
}

.alert.alert-error {
  background: var(--color-error-soft);
  color: var(--color-error);
  border-color: #fecaca;
}

.alert.alert-success {
  background: var(--color-success-soft);
  color: var(--color-success);
  border-color: #a7f3d0;
}

.alert.alert-info {
  background: var(--color-primary-soft);
  color: var(--color-primary);
  border-color: #bfdbfe;
}

.alert.is-visible { display: block; }

/* ---------- APP SHELL ---------- */

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.app-header {
  flex: 0 0 var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border-subtle);
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 600;
  font-size: 14.5px;
  letter-spacing: -0.015em;
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--color-primary) 0%, #4f46e5 100%);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-mark-img {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
  display: block;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.user-chip {
  color: var(--color-text-muted);
  font-size: 12.5px;
}

.app-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: row-reverse;
  min-height: 0;
}

.map-wrap {
  flex: 1 1 auto;
  position: relative;
  min-width: 0;
}

#map {
  width: 100%;
  height: 100%;
}

.map-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--color-text-muted);
  background: #eef0f3;
  pointer-events: none;
  font-size: 13px;
}

.sidebar {
  flex: 0 0 var(--sidebar-w);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border-subtle);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-tabs {
  display: flex;
  padding: 0.5rem 0.5rem 0;
  gap: 0.15rem;
  border-bottom: 1px solid var(--color-border-subtle);
}

.sidebar-tab {
  flex: 1;
  padding: 0.55rem 0.5rem;
  background: none;
  border: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  color: var(--color-text-muted);
  font-weight: 500;
  font-size: 12.5px;
  letter-spacing: 0;
  position: relative;
  transition: color var(--transition), background var(--transition);
}

.sidebar-tab:hover { color: var(--color-text); background: var(--color-surface-alt); }

.sidebar-tab.is-active {
  color: var(--color-primary);
  font-weight: 600;
}

.sidebar-tab.is-active::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0.4rem;
  right: 0.4rem;
  height: 2px;
  background: var(--color-primary);
  border-radius: 2px 2px 0 0;
}

.sidebar-panel {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1rem 1rem 1.5rem;
  display: none;
}

.sidebar-panel.is-active { display: block; }

.panel-empty {
  text-align: center;
  color: var(--color-text-muted);
  padding: 1.75rem 1rem;
  font-size: 12.5px;
}

.panel-empty h3 {
  margin: 0 0 0.3rem;
  color: var(--color-text);
  font-size: 13px;
  font-weight: 600;
}

/* ---------- PANEL HEADINGS ---------- */

h3.panel-title,
.import-form h3,
.trip-form h3,
.sets-header h3 {
  margin: 0 0 0.5rem;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
}

.section-hint {
  margin: 0 0 0.85rem;
  color: var(--color-text-muted);
  font-size: 12px;
  line-height: 1.55;
}

.section-hint code {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border-subtle);
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
  font-size: 11px;
  font-family: var(--font-mono);
}

/* ---------- IMPORT FORM ---------- */

.import-mode-tabs {
  display: inline-flex;
  padding: 2px;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}

.import-mode-tab {
  background: transparent;
  border: none;
  padding: 0.3rem 0.7rem;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-muted);
  border-radius: 4px;
  transition: background var(--transition), color var(--transition);
}

.import-mode-tab.is-active {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-xs);
}

.file-drop {
  display: block;
  margin-bottom: 0.75rem;
  padding: 1.5rem 1rem;
  border: 1.5px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface-alt);
  text-align: center;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
}

.file-drop:hover,
.file-drop.is-dragover {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.file-drop.has-file {
  border-style: solid;
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.file-drop-text {
  font-size: 12.5px;
  font-weight: 500;
}

.panel-divider {
  border: none;
  border-top: 1px solid var(--color-border-subtle);
  margin: 1.25rem 0;
}

/* ---------- MAPPING UI ---------- */

.mapping-section {
  margin: 0.25rem 0 1rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  background: var(--color-surface-alt);
}

.mapping-summary {
  font-size: 11.5px;
  color: var(--color-text-muted);
  margin-bottom: 0.6rem;
}

.mapping-summary strong { color: var(--color-text); font-weight: 600; }

.mapping-table {
  width: 100%;
  border-collapse: collapse;
}

.mapping-table tr + tr { border-top: 1px solid var(--color-border-subtle); }

.mapping-table td {
  padding: 0.4rem 0.15rem;
  vertical-align: middle;
}

.mapping-table td:first-child {
  width: 42%;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--color-text-muted);
}

.mapping-table .required::after {
  content: " *";
  color: var(--color-error);
}

.mapping-table select {
  width: 100%;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  font-size: 12.5px;
}

.sample-details { margin-top: 0.75rem; }

.sample-details summary {
  cursor: pointer;
  font-size: 11.5px;
  color: var(--color-primary);
  font-weight: 500;
}

.sample-scroll {
  margin-top: 0.5rem;
  max-height: 180px;
  overflow: auto;
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}

.sample-table {
  border-collapse: collapse;
  font-size: 10.5px;
  white-space: nowrap;
  font-family: var(--font-mono);
}

.sample-table th, .sample-table td {
  padding: 0.3rem 0.5rem;
  border-right: 1px solid var(--color-border-subtle);
  border-bottom: 1px solid var(--color-border-subtle);
  text-align: left;
}

.sample-table th {
  background: var(--color-surface-alt);
  position: sticky;
  top: 0;
  font-weight: 600;
  font-family: var(--font);
}

/* ---------- SETS / TRIPS LIST ---------- */

.sets-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.5rem;
}

.muted-count {
  color: var(--color-text-faint);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.sets-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.set-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  margin-bottom: 0.35rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.set-item:hover {
  border-color: var(--color-border);
  box-shadow: var(--shadow-xs);
}

.set-item-info { min-width: 0; flex: 1; }

.set-item-name {
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--color-text);
}

.set-item-meta {
  color: var(--color-text-muted);
  font-size: 11.5px;
  margin-top: 0.1rem;
  font-variant-numeric: tabular-nums;
}

.set-item-actions {
  display: flex;
  gap: 0.2rem;
  flex-shrink: 0;
  align-items: center;
}

.set-color-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,0.1);
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
}

.set-row-with-dot {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}

.set-item.is-hidden { opacity: 0.5; }
.set-item.is-hidden .set-color-dot { opacity: 0.3; }

.color-palette {
  position: absolute;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 0.45rem;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.3rem;
  z-index: 50;
}

.color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,0.08);
  cursor: pointer;
  transition: transform var(--transition);
}

.color-swatch:hover { transform: scale(1.15); }
.color-swatch.is-current { box-shadow: 0 0 0 2px var(--color-primary), 0 0 0 4px var(--color-primary-soft); }

.icon-btn.is-toggled {
  background: var(--color-primary-soft);
  color: var(--color-primary);
  border-color: #bfdbfe;
}

.inline-rename {
  width: 100%;
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--color-primary);
  border-radius: 4px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--color-surface);
}

.info-edit-form {
  font-family: var(--font);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 240px;
}

.info-edit-form input,
.info-edit-form textarea {
  width: 100%;
  padding: 0.3rem 0.45rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 12.5px;
  font-family: inherit;
}

.info-edit-form textarea { resize: vertical; min-height: 50px; }

.info-edit-form label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.info-edit-actions {
  display: flex;
  gap: 0.35rem;
  justify-content: flex-end;
  margin-top: 0.2rem;
}

.info-edit-actions button {
  padding: 0.25rem 0.6rem;
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid var(--color-border);
  background: var(--color-surface-alt);
}

.info-edit-actions button.primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm);
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  color: var(--color-text-muted);
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  font-size: 13px;
  text-decoration: none;
  padding: 0;
}

.icon-btn:hover {
  background: var(--color-surface-alt);
  color: var(--color-text);
  border-color: var(--color-border);
  text-decoration: none;
}

.icon-btn.danger:hover {
  background: var(--color-error-soft);
  color: var(--color-error);
  border-color: #fecaca;
}

/* ---------- TRIP FORM ---------- */

.mode-toggle {
  display: inline-flex;
  padding: 2px;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm);
  width: 100%;
}

.mode-toggle label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  font-size: 12.5px;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.mode-toggle input { display: none; }

.mode-toggle label:has(input:checked) {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-xs);
  font-weight: 600;
}

.stops-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.4rem;
}

.stops-list {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm);
  background: var(--color-surface-alt);
  padding: 0.2rem;
}

.stops-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.45rem;
  border-radius: var(--radius-xs);
  font-size: 12.5px;
  background: transparent;
  transition: background var(--transition);
}

.stops-row:hover { background: var(--color-surface); }
.stops-row input { margin: 0; }

.stops-row span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stops-row.draggable {
  cursor: grab;
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  margin-bottom: 2px;
}

.stops-row.draggable::before {
  content: "⠿";
  color: var(--color-text-faint);
  font-size: 14px;
  line-height: 1;
}

.stops-row.dragging { opacity: 0.5; }

.stops-row.drop-target-above {
  box-shadow: inset 0 2px 0 var(--color-primary);
}

.stops-row.drop-target-below {
  box-shadow: inset 0 -2px 0 var(--color-primary);
}

.stops-empty {
  padding: 0.6rem;
  color: var(--color-text-faint);
  font-size: 12px;
  text-align: center;
}

/* ---------- ACTIVE TRIP PANEL ---------- */

.active-trip-panel {
  margin-bottom: 1rem;
  padding: 0.7rem 0.85rem;
  background: linear-gradient(135deg, var(--color-primary-soft) 0%, #fafbff 100%);
  border: 1px solid #c7d7fe;
  border-radius: var(--radius-md);
}

.active-trip-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.active-trip-name {
  font-weight: 600;
  font-size: 13.5px;
  letter-spacing: -0.005em;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.active-trip-meta {
  font-size: 11.5px;
  color: var(--color-primary);
  margin-top: 0.2rem;
  font-variant-numeric: tabular-nums;
}

.active-trip-actions {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.55rem;
}

.active-trip-actions .btn-ghost {
  background: var(--color-surface);
}

.via-hint {
  margin-top: 0.55rem;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-sm);
  background: var(--color-warn-soft);
  color: var(--color-warn);
  font-size: 11.5px;
  line-height: 1.5;
  border: 1px solid #fed7aa;
}

.via-place-input {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.4rem 0.55rem;
  font-size: 12.5px;
  border: 1px solid #fed7aa;
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--color-text);
  font-family: inherit;
}

.via-place-input:focus {
  outline: none;
  border-color: var(--color-warn);
  box-shadow: 0 0 0 3px #fed7aa;
}

.pac-container { z-index: 9999; }

.via-active #map { cursor: crosshair !important; }

.rally-pill {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.05rem 0.4rem;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: var(--color-warn-soft);
  color: var(--color-warn);
  border: 1px solid #fed7aa;
  border-radius: 999px;
  vertical-align: 1px;
}

.numbered-marker-label {
  background: var(--color-primary);
  color: #fff;
  border-radius: 50%;
  font-weight: 700;
  font-size: 12px;
  padding: 2px 6px;
}

/* ---------- SEARCH MODE ---------- */

.search-results {
  margin-top: 0.85rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--color-border-subtle);
}

.search-results-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.4rem;
  gap: 0.4rem;
}

.search-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}

.search-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--color-border-subtle);
  cursor: pointer;
  transition: background var(--transition);
}

.search-row:hover { background: var(--color-surface-alt); }
.search-row:last-child { border-bottom: none; }

.search-row input { margin-top: 0.2rem; flex-shrink: 0; }

.search-row-body { min-width: 0; flex: 1; }

.search-row-name {
  font-weight: 600;
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--color-text);
}

.search-row-meta {
  color: var(--color-text-muted);
  font-size: 11.5px;
  margin-top: 0.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rating-pill {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0 0.35rem;
  font-size: 10.5px;
  color: var(--color-warn);
  background: var(--color-warn-soft);
  border-radius: 999px;
  vertical-align: 1px;
}

/* ---------- SHARE MODAL ---------- */

.share-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  place-items: center;
  padding: 1rem;
}

.share-modal.is-open { display: grid; }

.share-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
}

.share-modal-body {
  position: relative;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.5rem 1.25rem;
  max-width: 360px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow-y: auto;
}

.share-modal-body h3 {
  margin: 0 0 0.3rem;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.share-modal-help {
  margin: 0 0 1rem;
  color: var(--color-text-muted);
  font-size: 12.5px;
  line-height: 1.5;
}

.share-modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  font-size: 20px;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.share-modal-close:hover { background: var(--color-surface-alt); color: var(--color-text); }

.share-url-row {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.share-url-row input {
  flex: 1;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--color-surface-alt);
  color: var(--color-text);
  min-width: 0;
}

.share-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.share-qr {
  display: grid;
  place-items: center;
  margin: 0.75rem 0 0.3rem;
  padding: 0.65rem;
  background: #fff;
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
}

.share-qr svg, .share-qr img { display: block; max-width: 220px; height: auto; }

.share-qr-help {
  margin: 0;
  text-align: center;
  font-size: 11.5px;
  color: var(--color-text-muted);
}

.pushpin-label-overlay {
  position: absolute;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--color-border-strong);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  pointer-events: none;
  transform: translate(0, -50%);
  z-index: 100;
  letter-spacing: -0.005em;
}

/* ---------- SETTINGS ---------- */

.settings-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--color-border-subtle);
}

.settings-section:last-of-type { border-bottom: none; }

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.4rem 0;
  font-size: 12.5px;
}

.settings-label {
  color: var(--color-text-muted);
  font-weight: 500;
}

.seg-toggle {
  display: inline-flex;
  padding: 2px;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm);
}

.seg-toggle label {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.55rem;
  border-radius: 4px;
  font-size: 12px;
  color: var(--color-text-muted);
  cursor: pointer;
}

.seg-toggle input { display: none; }

.seg-toggle label:has(input:checked) {
  background: var(--color-surface);
  color: var(--color-text);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

.settings-select {
  padding: 0.25rem 0.55rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  font-size: 12.5px;
  min-width: 120px;
}

.inline-form {
  display: flex;
  gap: 0.35rem;
  flex: 1;
  max-width: 60%;
}

.inline-form input {
  flex: 1;
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
}

.settings-collapse {
  margin-top: 0.75rem;
  border-top: 1px solid var(--color-border-subtle);
  padding-top: 0.5rem;
}

.settings-collapse summary {
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--color-primary);
  padding: 0.25rem 0;
  list-style: none;
}

.settings-collapse summary::before {
  content: "›";
  display: inline-block;
  width: 1em;
  transition: transform var(--transition);
  color: var(--color-text-muted);
}

.settings-collapse[open] summary::before { transform: rotate(90deg); }

.settings-stack { margin-top: 0.5rem; }

.settings-subtitle {
  margin: 0.75rem 0 0.4rem;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--color-text-muted);
  text-transform: uppercase;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.stat-card {
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm);
  background: var(--color-surface-alt);
}

.stat-card-value {
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.stat-card-label {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 0.1rem;
}

.users-list {
  margin: 0.5rem 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.users-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  font-size: 12.5px;
}

.users-list-row .uname { font-weight: 600; }
.users-list-row .udis { color: var(--color-text-muted); margin-left: 0.4rem; font-weight: 400; }

.admin-pill {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.05rem 0.4rem;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  border-radius: 999px;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 12.5px;
  margin-bottom: 0.75rem;
}

.settings-help {
  display: block;
  margin-top: 0.15rem;
  font-size: 11px;
  font-weight: 400;
  color: var(--color-text-faint);
  line-height: 1.4;
  max-width: 200px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  inset: 0;
  background: #d1d5db;
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--transition);
}

.switch-slider::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  bottom: 2px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: var(--shadow-xs);
}

.switch input:checked + .switch-slider {
  background: var(--color-primary);
}

.switch input:checked + .switch-slider::before {
  transform: translateX(16px);
}
