/* ═══════════════════════════════════════════════════════════════
   Prep & Landing — Main Stylesheet
   Theme-aware design system. Google Fonts loaded in base.html.
   Themes set via data-theme attribute on <body>.
   ═══════════════════════════════════════════════════════════════ */


/* ─────────────────────────────────────────────────────────────────
   THEME VARIABLES
   Each theme defines the full set of CSS custom properties.
   All components reference these variables — never raw colors.
───────────────────────────────────────────────────────────────── */

/* Default / Theme A: Midnight Navy + Warm Gold */
body, body[data-theme="a"] {
  --bg-page:        #080d14;
  --bg-surface:     #0f1923;
  --bg-elevated:    #192433;
  --bg-subtle:      #253448;
  --text-primary:   #e8eef5;
  --text-secondary: #7a9ab8;
  --text-dim:       #4a6580;
  --accent-1:       #f0a420;
  --accent-1-dim:   #b87e18;
  --btn-primary-text: #0a0a0a;
  --accent-2:       #e05252;
  --accent-ok:      #3dba6f;
  --accent-warn:    #d29030;
  --accent-info:    #4090e0;
  --accent-purple:  #a06cd5;
  --navbar-bg:      #060c13;
  --focus-ring:     rgba(240, 164, 32, 0.2);
  --shadow-sm:      0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:      0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg:      0 8px 28px rgba(0,0,0,0.65);
}

/* Theme B: Deep Forest + Christmas Red */
body[data-theme="b"] {
  --bg-page:        #09100a;
  --bg-surface:     #0f1a10;
  --bg-elevated:    #192b1a;
  --bg-subtle:      #253d26;
  --text-primary:   #e5ede5;
  --text-secondary: #7aaa7e;
  --text-dim:       #4a7050;
  --accent-1:       #cc2020;
  --accent-1-dim:   #a01818;
  --btn-primary-text: #ffffff;
  --accent-2:       #f0c020;
  --accent-ok:      #40c060;
  --accent-warn:    #d09030;
  --accent-info:    #4090e0;
  --accent-purple:  #a06cd5;
  --navbar-bg:      #060d06;
  --focus-ring:     rgba(224, 48, 48, 0.2);
  --shadow-sm:      0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:      0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg:      0 8px 28px rgba(0,0,0,0.65);
}

/* Theme C: Velvet Burgundy + Warm Amber */
body[data-theme="c"] {
  --bg-page:        #120608;
  --bg-surface:     #1e0c10;
  --bg-elevated:    #2d1218;
  --bg-subtle:      #40202a;
  --text-primary:   #f2e8e8;
  --text-secondary: #b08088;
  --text-dim:       #704050;
  --accent-1:       #e8a840;
  --accent-1-dim:   #b88030;
  --btn-primary-text: #0a0a0a;
  --accent-2:       #c83048;
  --accent-ok:      #50b870;
  --accent-warn:    #d09030;
  --accent-info:    #5090d8;
  --accent-purple:  #a06cd5;
  --navbar-bg:      #0c0408;
  --focus-ring:     rgba(232, 168, 64, 0.2);
  --shadow-sm:      0 1px 3px rgba(0,0,0,0.5);
  --shadow-md:      0 4px 12px rgba(0,0,0,0.6);
  --shadow-lg:      0 8px 28px rgba(0,0,0,0.75);
}

/* Theme D: Arctic White + Santa Red (light mode) */
body[data-theme="d"] {
  --bg-page:        #f0f4f8;
  --bg-surface:     #ffffff;
  --bg-elevated:    #eef2f7;
  --bg-subtle:      #d8e2ed;
  --text-primary:   #1a2535;
  --text-secondary: #5a7090;
  --text-dim:       #9ab0c8;
  --accent-1:       #c0281e;
  --accent-1-dim:   #961e16;
  --btn-primary-text: #ffffff;
  --accent-2:       #1a5c28;
  --accent-ok:      #1a7a40;
  --accent-warn:    #b06010;
  --accent-info:    #1860c0;
  --accent-purple:  #6030a0;
  --navbar-bg:      #c0281e;
  --focus-ring:     rgba(192, 40, 30, 0.2);
  --shadow-sm:      0 1px 3px rgba(0,0,0,0.1);
  --shadow-md:      0 4px 12px rgba(0,0,0,0.15);
  --shadow-lg:      0 8px 24px rgba(0,0,0,0.2);
}


/* ─────────────────────────────────────────────────────────────────
   RESET & BASE
───────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-page);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

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

select { appearance: auto; }


/* ─────────────────────────────────────────────────────────────────
   NAVBAR
───────────────────────────────────────────────────────────────── */

.navbar {
  display: flex;
  align-items: center;
  padding: 0 24px;
  height: 60px;
  background: var(--navbar-bg);
  border-bottom: 1px solid var(--bg-subtle);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 19px;
  font-weight: normal;
  color: var(--text-primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}
body[data-theme="d"] .nav-brand { color: rgba(255,255,255,0.96); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 32px;
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 400;
  padding: 6px 11px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}
.nav-link:hover { color: var(--text-primary); background: var(--bg-elevated); text-decoration: none; }
.nav-link.active { color: var(--text-primary); background: var(--bg-elevated); }

body[data-theme="d"] .nav-link               { color: rgba(255,255,255,0.82); }
body[data-theme="d"] .nav-link:hover         { color: #fff; background: rgba(255,255,255,0.18); }
body[data-theme="d"] .nav-link.active        { color: #fff; background: rgba(255,255,255,0.22); }

/* Legacy nav-links a (for any unredesigned includes) */
.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.nav-links a:hover { color: var(--text-primary); background: var(--bg-elevated); text-decoration: none; }
body[data-theme="d"] .nav-links a { color: rgba(255,255,255,0.82); }
body[data-theme="d"] .nav-links a:hover { color: #fff; background: rgba(255,255,255,0.18); }

.nav-user {
  font-size: 12px;
  color: var(--text-dim);
}
body[data-theme="d"] .nav-user { color: rgba(255,255,255,0.65); }

.nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-user-email {
  font-size: 12px;
  color: var(--text-dim);
}
body[data-theme="d"] .nav-user-email { color: rgba(255,255,255,0.65); }

.nav-logout {
  font-size: 12px;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 5px 10px;
  border-radius: 5px;
  border: 1px solid var(--bg-subtle);
  transition: all 0.15s;
}
.nav-logout:hover { color: var(--text-primary); border-color: var(--text-dim); text-decoration: none; }
body[data-theme="d"] .nav-logout             { color: rgba(255,255,255,0.82); border-color: rgba(255,255,255,0.35); }
body[data-theme="d"] .nav-logout:hover       { color: #fff; border-color: rgba(255,255,255,0.75); background: rgba(255,255,255,0.12); }


/* ─────────────────────────────────────────────────────────────────
   THEME SWITCHER
───────────────────────────────────────────────────────────────── */

.theme-switcher { position: relative; }

.theme-switcher-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid var(--bg-subtle);
  cursor: pointer;
  transition: all 0.15s;
  padding: 0;
}
.theme-switcher-btn:hover { background: var(--bg-elevated); border-color: var(--text-dim); }
body[data-theme="d"] .theme-switcher-btn             { border-color: rgba(255,255,255,0.35); }
body[data-theme="d"] .theme-switcher-btn:hover       { background: rgba(255,255,255,0.15); border-color: rgba(255,255,255,0.65); }

.theme-dot-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: block;
}
body[data-theme="a"] .theme-dot-indicator { background: #f0a420; }
body[data-theme="b"] .theme-dot-indicator { background: #e03030; }
body[data-theme="c"] .theme-dot-indicator { background: #e8a840; }
body[data-theme="d"] .theme-dot-indicator { background: rgba(255,255,255,0.9); }

.theme-picker {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--bg-subtle);
  border-radius: 10px;
  padding: 8px;
  display: none;
  flex-direction: column;
  gap: 2px;
  box-shadow: var(--shadow-md);
  min-width: 168px;
  z-index: 200;
}
.theme-switcher.open .theme-picker { display: flex; }

.theme-option {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: background 0.12s;
  text-align: left;
  width: 100%;
}
.theme-option:hover { background: var(--bg-elevated); }
.theme-option.current { border-color: var(--bg-subtle); background: var(--bg-elevated); }

.theme-option-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  flex-shrink: 0;
}
.theme-option[data-theme="a"] .theme-option-dot { background: #f0a420; }
.theme-option[data-theme="b"] .theme-option-dot { background: #e03030; }
.theme-option[data-theme="c"] .theme-option-dot { background: #e8a840; }
.theme-option[data-theme="d"] .theme-option-dot { background: #c0281e; }

.theme-option-label {
  font-size: 12.5px;
  color: var(--text-secondary);
  font-family: 'DM Sans', sans-serif;
}
.theme-option.current .theme-option-label { color: var(--text-primary); }


/* ─────────────────────────────────────────────────────────────────
   LAYOUT
───────────────────────────────────────────────────────────────── */

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px;
}


/* ─────────────────────────────────────────────────────────────────
   PAGE HEADER
───────────────────────────────────────────────────────────────── */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}

/* Legacy h1 support */
.page-header h1 {
  margin: 0;
  font-size: 24px;
  font-family: 'DM Serif Display', Georgia, serif;
  font-weight: normal;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.page-header .subtitle { margin: 4px 0 0; color: var(--text-secondary); font-size: 13px; }

/* New-style header components */
.page-title-group {}

.page-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-1);
  margin-bottom: 4px;
}

.page-title {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 30px;
  font-weight: normal;
  color: var(--text-primary);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 5px;
}

.page-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
  padding-top: 4px;
  flex-wrap: wrap;
}


/* ─────────────────────────────────────────────────────────────────
   ALERTS / FLASH MESSAGES
───────────────────────────────────────────────────────────────── */

.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 16px;
  border-radius: 8px;
  border-left: 3px solid;
  font-size: 13px;
  margin-bottom: 16px;
  line-height: 1.45;
}
.alert-success { background: rgba(61,186,111,0.08);  border-color: var(--accent-ok);   color: var(--text-primary); }
.alert-error   { background: rgba(224,82,82,0.08);   border-color: var(--accent-2);    color: var(--text-primary); }
.alert-warning { background: rgba(210,144,48,0.08);  border-color: var(--accent-warn); color: var(--text-primary); }
.alert-info    { background: rgba(64,144,224,0.08);  border-color: var(--accent-info); color: var(--text-primary); }


/* ─────────────────────────────────────────────────────────────────
   BUTTONS
───────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 15px;
  border-radius: 7px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
  line-height: 1;
  vertical-align: middle;
}
.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--accent-1);
  color: var(--btn-primary-text);
  border-color: var(--accent-1);
}
.btn-primary:hover { background: var(--accent-1-dim); border-color: var(--accent-1-dim); }

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--bg-subtle);
}
.btn-secondary:hover { background: var(--bg-elevated); border-color: var(--text-dim); }

.btn-danger {
  background: transparent;
  color: var(--accent-2);
  border-color: var(--bg-subtle);
}
.btn-danger:hover { background: rgba(200,40,40,0.1); border-color: var(--accent-2); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-elevated); }

.btn-link {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-size: 13px;
  color: var(--accent-info);
  text-decoration: underline;
  font-family: inherit;
}
.btn-link:hover { color: var(--text-primary); }

.btn-danger-link {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-size: 13px;
  color: var(--accent-2);
  text-decoration: underline;
  font-family: inherit;
}

.btn-sm  { padding: 5px 11px; font-size: 13px; border-radius: 6px; }
.btn-block { display: flex; width: 100%; justify-content: center; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

.btn-copy {
  font-size: 12px;
  padding: 3px 9px;
  background: var(--bg-elevated);
  border: 1px solid var(--bg-subtle);
  border-radius: 5px;
  cursor: pointer;
  color: var(--text-secondary);
  margin-left: 6px;
  font-family: inherit;
  transition: all 0.15s;
}
.btn-copy:hover { background: var(--bg-subtle); color: var(--text-primary); }


/* ─────────────────────────────────────────────────────────────────
   CARDS / PANELS
───────────────────────────────────────────────────────────────── */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-subtle);
  border-radius: 10px;
  padding: 22px 24px;
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.form-card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-subtle);
  padding: 28px;
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  max-width: 640px;
}


/* ─────────────────────────────────────────────────────────────────
   SETTINGS PANEL (collapsible)
───────────────────────────────────────────────────────────────── */

.settings-panel {
  background: var(--bg-surface);
  border: 1px solid var(--bg-subtle);
  border-radius: 10px;
  margin-bottom: 16px;
  overflow: hidden;
}

.settings-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.15s;
}
.settings-toggle:hover { color: var(--text-primary); }
.settings-toggle .toggle-arrow { transition: transform 0.2s; font-size: 10px; }
.settings-toggle.open .toggle-arrow { transform: rotate(180deg); }

.settings-body {
  border-top: 1px solid var(--bg-subtle);
  padding: 20px 24px;
  display: none;
}
.settings-body.open { display: block; }

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 24px;
}


/* ─────────────────────────────────────────────────────────────────
   TABLES
───────────────────────────────────────────────────────────────── */

/* Wrapped table container (new style) */
.table-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--bg-subtle);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 16px;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 20px;
  border-bottom: 1px solid var(--bg-subtle);
}

.table-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.table-count {
  font-size: 12px;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
}

/* Base table styling — works for both .table and table inside .table-wrap */
.table, .table-wrap table {
  width: 100%;
  border-collapse: collapse;
}

.table {
  background: var(--bg-surface);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--bg-subtle);
}

.table th,
.table-wrap table th {
  background: var(--bg-elevated);
  text-align: left;
  padding: 9px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--bg-subtle);
}

.table td,
.table-wrap table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--bg-subtle);
  vertical-align: middle;
  color: var(--text-primary);
  font-size: 13px;
}

.table tbody tr:last-child td,
.table-wrap table tbody tr:last-child td { border-bottom: none; }

.table tbody tr:hover,
.table-wrap table tbody tr:hover { background: var(--bg-elevated); }

.table a,
.table-wrap table a { color: var(--accent-info); }

.table a:hover,
.table-wrap table a:hover { text-decoration: underline; }

/* Drag and drop */
.drag-handle-col { width: 28px; }
.drag-handle {
  cursor: grab;
  color: var(--text-dim);
  font-size: 16px;
  text-align: center;
  user-select: none;
  letter-spacing: -3px;
}
.drag-handle:active { cursor: grabbing; }
tr.dragging { opacity: 0.5; background: var(--bg-elevated) !important; }
tr.row-inactive { opacity: 0.4; }
tr.row-inactive td.active-cell { opacity: 1; }
.active-cell { text-align: center; width: 52px; }

/* td helpers */
.td-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-dim);
  width: 36px;
  text-align: center;
}
.td-drag {
  color: var(--text-dim);
  cursor: grab;
  font-size: 16px;
  width: 28px;
  text-align: center;
  letter-spacing: -3px;
}
.td-actions { text-align: right; white-space: nowrap; }

.table-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}


/* ─────────────────────────────────────────────────────────────────
   STATUS CHIPS
───────────────────────────────────────────────────────────────── */

.status-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid transparent;
}

.chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.chip-ok   { background: rgba(61,186,111,0.1);  border-color: rgba(61,186,111,0.25);  color: var(--accent-ok); }
.chip-warn { background: rgba(210,144,48,0.1);  border-color: rgba(210,144,48,0.25);  color: var(--accent-warn); }
.chip-err  { background: rgba(224,82,82,0.1);   border-color: rgba(224,82,82,0.25);   color: var(--accent-2); }
.chip-dim  { background: var(--bg-elevated);    border-color: var(--bg-subtle);        color: var(--text-secondary); }

.chip-ok .chip-dot   { background: var(--accent-ok); }
.chip-warn .chip-dot { background: var(--accent-warn); }
.chip-err .chip-dot  { background: var(--accent-2); }
.chip-dim .chip-dot  { background: var(--text-dim); }


/* ─────────────────────────────────────────────────────────────────
   BADGES
───────────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

/* New named badges */
.badge-ok     { background: rgba(61,186,111,0.12);  color: var(--accent-ok); }
.badge-warn   { background: rgba(210,144,48,0.12);  color: var(--accent-warn); }
.badge-err    { background: rgba(224,82,82,0.12);   color: var(--accent-2); }
.badge-info   { background: rgba(64,144,224,0.12);  color: var(--accent-info); }
.badge-dim    { background: var(--bg-elevated);     color: var(--text-secondary); }
.badge-accent { background: rgba(240,164,32,0.12);  color: var(--accent-1); }
.badge-purple { background: rgba(160,108,213,0.12); color: var(--accent-purple); }

/* Legacy aliases for unredesigned templates */
.badge-success { background: rgba(61,186,111,0.12);  color: var(--accent-ok); }
.badge-warning { background: rgba(210,144,48,0.12);  color: var(--accent-warn); }
.badge-error   { background: rgba(224,82,82,0.12);   color: var(--accent-2); }
.badge-auto    { background: rgba(64,144,224,0.12);  color: var(--accent-info); }
.badge-manual  { background: rgba(160,108,213,0.12); color: var(--accent-purple); }


/* ─────────────────────────────────────────────────────────────────
   ACTION BAR
───────────────────────────────────────────────────────────────── */

.action-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 20px;
  background: var(--bg-surface);
  border: 1px solid var(--bg-subtle);
  border-radius: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.action-bar-label {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
  flex: 1;
  min-width: 80px;
}

.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--text-dim);
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 700;
  cursor: help;
  font-style: normal;
  flex-shrink: 0;
  transition: all 0.15s;
}
.info-icon:hover { border-color: var(--accent-1); color: var(--accent-1); }

/* ─────────────────────────────────────────────────────────────────
   HELP MODAL
───────────────────────────────────────────────────────────────── */

.help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--bg-subtle);
  border-radius: 6px;
  color: var(--text-secondary);
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}
.help-btn:hover { border-color: var(--accent-1); color: var(--accent-1); }
.help-btn-icon { font-size: 14px; font-weight: 700; }

.help-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 600;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 16px 24px;
  overflow-y: auto;
}
.help-modal-overlay.open { display: flex; }

.help-modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--bg-subtle);
  border-radius: 14px;
  padding: 28px 32px;
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow-lg);
  position: relative;
}

.help-modal-title {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 22px;
  font-weight: normal;
  color: var(--text-primary);
  margin: 0 0 16px;
  padding-right: 32px;
}

.help-modal-body {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.65;
}
.help-modal-body p  { margin: 0 0 12px; }
.help-modal-body p:last-child { margin-bottom: 0; }
.help-modal-body strong { color: var(--text-primary); }
.help-modal-body ol, .help-modal-body ul { padding-left: 20px; margin: 0 0 12px; }
.help-modal-body li { margin-bottom: 6px; }
.help-modal-body code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--accent-1);
  background: var(--bg-elevated);
  padding: 1px 5px;
  border-radius: 4px;
}

.help-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: none;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.15s;
}
.help-modal-close:hover { background: var(--bg-subtle); color: var(--text-primary); }

/* ── Onboarding info panel ─────────────────────────────────────── */

.onboarding-panel {
  background: linear-gradient(135deg, rgba(240,164,32,0.07) 0%, rgba(240,164,32,0.03) 100%);
  border: 1px solid rgba(240,164,32,0.25);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  margin-bottom: 28px;
}
.onboarding-panel-title {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 17px;
  font-weight: normal;
  color: var(--text-primary);
  margin: 0 0 8px;
}
.onboarding-panel-body {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0;
}

/* ── Device ping / connection status ──────────────────────────── */

.ping-section {
  background: var(--bg-elevated);
  border: 1px solid var(--bg-subtle);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  margin-top: 24px;
}

.ping-status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 8px;
  border: 1px solid var(--bg-subtle);
  background: var(--bg-surface);
  margin: 12px 0;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s;
}
.ping-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-dim);
  transition: background 0.3s;
}
.ping-status.live   { border-color: var(--accent-ok);   background: rgba(61,186,111,0.06); }
.ping-status.live .ping-dot   { background: var(--accent-ok); animation: pulse-green 1.5s infinite; }
.ping-status.recent { border-color: var(--accent-ok);   background: rgba(61,186,111,0.04); }
.ping-status.recent .ping-dot { background: var(--accent-ok); }
.ping-status.stale  { border-color: var(--accent-warn); background: rgba(210,144,48,0.06); }
.ping-status.stale .ping-dot  { background: var(--accent-warn); }
.ping-status.never  { border-color: var(--bg-subtle);   }
.ping-status.error  { border-color: var(--accent-2);    background: rgba(224,82,82,0.05); }
.ping-status.error .ping-dot  { background: var(--accent-2); }

@keyframes pulse-green {
  0%, 100% { box-shadow: 0 0 0 0 rgba(61,186,111, 0.5); }
  50%       { box-shadow: 0 0 0 5px rgba(61,186,111, 0); }
}

/* ─────────────────────────────────────────────────────────────────
   EXPORT STRIP
───────────────────────────────────────────────────────────────── */

.export-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  margin-top: -8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.export-strip-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-right: 2px;
}


/* ─────────────────────────────────────────────────────────────────
   FORMS
───────────────────────────────────────────────────────────────── */

.form-group { margin-bottom: 18px; }

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--bg-subtle);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent-1);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* New field components */
.field-group { display: flex; flex-direction: column; gap: 5px; }

.field-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.field-input {
  background: var(--bg-elevated);
  border: 1px solid var(--bg-subtle);
  border-radius: 6px;
  padding: 9px 13px;
  color: var(--text-primary);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
.field-input:focus {
  border-color: var(--accent-1);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.field-hint { font-size: 11px; color: var(--text-dim); line-height: 1.4; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
  flex-wrap: wrap;
}

.required { color: var(--accent-2); }

.hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.4;
}
.hint code {
  background: var(--bg-elevated);
  color: var(--accent-1);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  border: 1px solid var(--bg-subtle);
}

/* Toggle switch */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-top: 1px solid var(--bg-subtle);
  margin-top: 12px;
}

.toggle-label { font-size: 13px; color: var(--text-primary); font-weight: 500; }
.toggle-hint  { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

.toggle-switch {
  position: relative;
  width: 38px;
  height: 22px;
  cursor: pointer;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--bg-subtle);
  border-radius: 11px;
  transition: background 0.2s;
}
.toggle-switch input:checked ~ .toggle-track { background: var(--accent-1); }
.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.toggle-switch input:checked ~ .toggle-track .toggle-thumb { transform: translateX(16px); }

/* Native checkbox */
input[type="checkbox"] {
  accent-color: var(--accent-1);
  width: 15px;
  height: 15px;
  cursor: pointer;
}


/* ─────────────────────────────────────────────────────────────────
   LOGIN PAGE
───────────────────────────────────────────────────────────────── */

.login-box {
  max-width: 400px;
  width: 100%;
  margin: 40px auto 0;
  background: var(--bg-surface);
  padding: 40px 40px 36px;
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--bg-subtle);
  text-align: center;
}

.login-box h1 {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 26px;
  font-weight: normal;
  margin: 0 0 4px;
  color: var(--text-primary);
}

.login-box h2 {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 28px;
  font-weight: 400;
}

.login-box .form-group { text-align: left; }

.login-box .form-group label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 5px;
}


/* ─────────────────────────────────────────────────────────────────
   TRACCAR STATUS BAR (used in zones/detail — hidden in Phase 2)
───────────────────────────────────────────────────────────────── */

.traccar-status {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  background: var(--bg-surface);
  border: 1px solid var(--bg-subtle);
  border-radius: 8px;
  padding: 10px 16px;
  margin-bottom: 20px;
  font-size: 13px;
}

.traccar-status-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}

.traccar-status-label {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}


/* ─────────────────────────────────────────────────────────────────
   EMPTY STATE
───────────────────────────────────────────────────────────────── */

.empty-state {
  color: var(--text-secondary);
  padding: 56px 24px;
  text-align: center;
  line-height: 1.6;
}

.empty-state h2 {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 22px;
  font-weight: normal;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-state p { margin-bottom: 20px; color: var(--text-secondary); }


/* ─────────────────────────────────────────────────────────────────
   DEVICE IDENTIFIER & CODE
───────────────────────────────────────────────────────────────── */

.device-identifier {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  letter-spacing: 0.05em;
  color: var(--accent-1);
}

code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  background: var(--bg-elevated);
  color: var(--accent-1);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--bg-subtle);
}


/* ─────────────────────────────────────────────────────────────────
   ZONE / ROUTE STATS (legacy, zones/detail.html)
───────────────────────────────────────────────────────────────── */

.zone-stats { margin-bottom: 20px; font-size: 13px; color: var(--text-secondary); }
.zone-stats .sep { margin: 0 6px; color: var(--bg-subtle); }


/* ─────────────────────────────────────────────────────────────────
   UTILITIES
───────────────────────────────────────────────────────────────── */

.text-muted { color: var(--text-secondary); }
.text-dim   { color: var(--text-dim); }
.sep        { margin: 0 4px; }


/* ─────────────────────────────────────────────────────────────────
   SCROLLBAR
───────────────────────────────────────────────────────────────── */

::-webkit-scrollbar          { width: 8px; height: 8px; }
::-webkit-scrollbar-track    { background: var(--bg-page); }
::-webkit-scrollbar-thumb    { background: var(--bg-subtle); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }


/* ─────────────────────────────────────────────────────────────────
   ADDRESS UPLOAD — TABS, DROP ZONE, QUICK ADD
───────────────────────────────────────────────────────────────── */

/* Tab bar */
.upload-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--bg-subtle);
  margin-bottom: 0;
}

.upload-tab {
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.upload-tab:hover { color: var(--text-primary); }

.upload-tab.active {
  color: var(--accent-1);
  border-bottom-color: var(--accent-1);
}

/* Tab panels */
.upload-panel {
  display: none;
  padding: 24px 0 0;
}

.upload-panel.active { display: block; }

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--bg-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--accent-1);
  background: color-mix(in srgb, var(--accent-1) 5%, var(--bg-surface));
}

.drop-zone-icon   { font-size: 36px; margin-bottom: 12px; line-height: 1; }
.drop-zone-text   { font-size: 14px; color: var(--text-primary); margin-bottom: 6px; }
.drop-zone-hint   { font-size: 12px; color: var(--text-dim); }
.drop-zone-filename {
  margin-top: 14px;
  font-size: 13px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent-1);
  padding: 6px 14px;
  background: color-mix(in srgb, var(--accent-1) 10%, transparent);
  border-radius: var(--radius-sm);
  display: inline-block;
}

.drop-zone-browse {
  background: none;
  border: none;
  color: var(--accent-1);
  cursor: pointer;
  font-size: inherit;
  font-family: inherit;
  padding: 0;
  text-decoration: underline;
}

/* Quick Add */
.quick-add-form   { background: var(--bg-surface); border: 1px solid var(--bg-subtle); border-radius: var(--radius-md); padding: 20px; }
.quick-add-fields { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.quick-add-fields .field-group { min-width: 0; }

/* ─────────────────────────────────────────────────────────────────
   ONBOARDING WIZARD
───────────────────────────────────────────────────────────────── */

.wizard-shell {
  max-width: 580px;
  margin: 40px auto;
  padding: 0 16px;
}

/* Step progress indicator */
.wizard-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 36px;
}

.wizard-step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.wizard-step-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  border: 2px solid var(--bg-subtle);
  background: var(--bg-surface);
  color: var(--text-dim);
  transition: all 0.2s ease;
}

.wizard-step-label {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.wizard-step-active .wizard-step-circle {
  border-color: var(--accent-1);
  background: color-mix(in srgb, var(--accent-1) 15%, transparent);
  color: var(--accent-1);
}

.wizard-step-active .wizard-step-label { color: var(--accent-1); }

.wizard-step-done .wizard-step-circle {
  border-color: var(--accent-ok);
  background: color-mix(in srgb, var(--accent-ok) 15%, transparent);
  color: var(--accent-ok);
}

.wizard-step-done .wizard-step-label { color: var(--accent-ok); }

.wizard-step-connector {
  flex: 1;
  height: 2px;
  background: var(--bg-subtle);
  min-width: 40px;
  max-width: 80px;
  margin-bottom: 18px;   /* aligns with circle center */
  transition: background 0.2s ease;
}

.wizard-connector-done { background: var(--accent-ok); }

/* Card */
.wizard-card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-subtle);
  border-radius: var(--radius-lg);
  padding: 36px 40px;
  box-shadow: var(--shadow-md);
}

.wizard-card-complete {
  text-align: center;
  padding: 52px 40px;
}

.wizard-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-1);
  margin-bottom: 10px;
}

.wizard-title {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 28px;
  font-weight: normal;
  color: var(--text-primary);
  margin: 0 0 12px;
  line-height: 1.2;
}

.wizard-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0 0 28px;
}

.wizard-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 28px;
  flex-wrap: wrap;
}

.wizard-complete-icon {
  font-size: 52px;
  margin-bottom: 16px;
  line-height: 1;
}

/* ─────────────────────────────────────────────────────────────────
   EXPORT STRIP  (zone detail page)
───────────────────────────────────────────────────────────────── */

.export-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--bg-subtle);
  border-radius: 8px;
  margin-bottom: 20px;
}

.export-strip-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-secondary);
  margin-right: 4px;
}

/* ─────────────────────────────────────────────────────────────────
   HELP MODAL
───────────────────────────────────────────────────────────────── */

.help-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--bg-subtle);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.help-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}
.help-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: var(--accent-1);
  color: var(--bg-base);
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.help-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.72);
  z-index: 800;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.help-modal-overlay.open {
  display: flex;
}

.help-modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--bg-subtle);
  border-radius: 14px;
  padding: 32px 36px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  position: relative;
}

.help-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--bg-elevated);
  border: none;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.help-modal-close:hover { background: var(--bg-subtle); color: var(--text-primary); }

.help-modal-title {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 22px;
  font-weight: normal;
  color: var(--text-primary);
  margin-bottom: 16px;
  padding-right: 32px;
}

.help-modal-body {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
}
.help-modal-body p { margin: 0 0 12px; }
.help-modal-body p:last-child { margin-bottom: 0; }
.help-modal-body ul { margin: 0 0 12px; padding-left: 20px; }
.help-modal-body li { margin-bottom: 6px; }
.help-modal-body strong { color: var(--text-primary); }

/* ─────────────────────────────────────────────────────────────────
   ONBOARDING PANEL  (stepped setup flow)
───────────────────────────────────────────────────────────────── */

.onboarding-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--bg-subtle);
  border-radius: 12px;
  padding: 24px 28px;
  margin-bottom: 28px;
}

.onboarding-panel-step {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--accent-1);
  margin-bottom: 6px;
}

.onboarding-panel-title {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 20px;
  font-weight: normal;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.onboarding-panel-body {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-secondary);
  margin-bottom: 20px;
}
.onboarding-panel-body p { margin: 0 0 8px; }
.onboarding-panel-body p:last-child { margin-bottom: 0; }
.onboarding-panel-body strong { color: var(--text-primary); }

.onboarding-panel-steps {
  display: flex;
  gap: 0;
  flex-wrap: wrap;
}

.onboarding-step {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 4px 12px 4px 0;
}
.onboarding-step + .onboarding-step {
  padding-left: 12px;
  border-left: 1px solid var(--bg-subtle);
}
.onboarding-step-done  { color: #4ade80; font-weight: 600; }
.onboarding-step-active { color: var(--text-primary); font-weight: 600; }

/* ─────────────────────────────────────────────────────────────────
   SETUP STEPS  (device setup page)
───────────────────────────────────────────────────────────────── */

.setup-steps {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.setup-step {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--bg-subtle);
}
.setup-step:last-child { border-bottom: none; padding-bottom: 0; }
.setup-step:first-child { padding-top: 0; }

.setup-step-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  background: var(--accent-1);
  color: var(--bg-base);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  margin-top: 1px;
}

.setup-step-body { flex: 1; }

.setup-step-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.setup-step-desc {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
}
.setup-step-desc strong { color: var(--text-primary); }

/* ─────────────────────────────────────────────────────────────────
   PING / CONNECTION TEST
───────────────────────────────────────────────────────────────── */

.ping-section {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.ping-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
}

.ping-message { color: var(--text-primary); }

.ping-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.ping-checking  { background: var(--bg-elevated); border-color: var(--bg-subtle); }
.ping-checking  .ping-dot { background: var(--text-secondary); animation: pulse-dim 1s ease-in-out infinite; }

.ping-live      { background: rgba(74,222,128,.08); border-color: rgba(74,222,128,.35); }
.ping-live      .ping-dot { background: #4ade80; animation: pulse-green 1.2s ease-in-out infinite; }
.ping-live      .ping-message { color: #4ade80; }

.ping-recent    { background: rgba(250,204,21,.08); border-color: rgba(250,204,21,.3); }
.ping-recent    .ping-dot { background: #facc15; }
.ping-recent    .ping-message { color: #facc15; }

.ping-stale     { background: rgba(251,146,60,.08); border-color: rgba(251,146,60,.3); }
.ping-stale     .ping-dot { background: #fb923c; }
.ping-stale     .ping-message { color: #fb923c; }

.ping-never,
.ping-not_synced,
.ping-idle      { background: var(--bg-elevated); border-color: var(--bg-subtle); }
.ping-never     .ping-dot,
.ping-not_synced .ping-dot,
.ping-idle      .ping-dot { background: var(--text-secondary); }

.ping-error     { background: rgba(239,68,68,.08); border-color: rgba(239,68,68,.3); }
.ping-error     .ping-dot { background: #ef4444; }
.ping-error     .ping-message { color: #ef4444; }

@keyframes pulse-green {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .5; transform: scale(.8); }
}
@keyframes pulse-dim {
  0%, 100% { opacity: .8; }
  50%       { opacity: .3; }
}

/* ─────────────────────────────────────────────────────────────────
   DASHBOARD
───────────────────────────────────────────────────────────────── */

.dash-section { }

.dash-filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 2rem;
}
.dash-filter-input {
  flex: 1;
  min-width: 0;
}
.dash-filter-select {
  width: 210px;
  flex-shrink: 0;
}
.dash-filter-empty {
  padding: 0.75rem 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.share-btn-inactive {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}

.dash-dept-group {
  margin-bottom: 1.5rem;
}

.dash-dept-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 0;
  padding: 6px 0;
}

.dash-dept-name {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

/* ─────────────────────────────────────────────────────────────────
   RESPONSIVE
───────────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .container        { padding: 20px 16px; }
  .form-row         { grid-template-columns: 1fr; }
  .settings-grid    { grid-template-columns: 1fr; }
  .navbar           { padding: 0 16px; }
  .nav-links        { gap: 0; margin-left: 12px; }
  .nav-link         { padding: 6px 8px; font-size: 12.5px; }
  .page-title       { font-size: 24px; }
  .action-bar       { gap: 8px; }
  .nav-user-email   { display: none; }
}

/* ── Driver manual ─────────────────────────────────────────────────────────── */

.dm-sheet {
  background: var(--bg-surface);
  border: 1px solid var(--bg-subtle);
  border-radius: 10px;
  padding: 8px 0;
}

.dm-block { padding: 10px 20px; }
.dm-block + .dm-block { border-top: 1px solid var(--bg-subtle); }

.dm-do {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 4px;
}

.dm-do-label {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
}

.dm-street {
  font-size: 12px;
  color: var(--text-dim);
}

.dm-stops {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
}

.dm-stops li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 2px 0 2px 16px;
  font-size: 14px;
  color: var(--text-primary);
}

.dm-seq {
  min-width: 30px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  font-size: 12px;
}

.dm-num { font-weight: 500; font-variant-numeric: tabular-nums; }
.dm-note { font-size: 12px; color: var(--text-secondary); }

.dm-unlocated {
  font-size: 11px;
  color: var(--accent-warn);
  border: 1px solid var(--accent-warn);
  border-radius: 10px;
  padding: 0 6px;
}

/* Navigation line between two "Do:" blocks */
.dm-inst {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 2px;
  padding: 7px 12px;
  background: var(--bg-elevated);
  border-left: 3px solid var(--bg-subtle);
  border-radius: 0 6px 6px 0;
}

.dm-inst-text {
  flex: 1;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
  cursor: text;
  border-radius: 4px;
  padding: 1px 3px;
  margin: -1px -3px;
}

.dm-inst-text:hover,
.dm-inst-text:focus {
  background: var(--bg-subtle);
  color: var(--text-primary);
  outline: none;
}

.dm-inst-input {
  flex: 1;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-page);
  border: 1px solid var(--accent-1);
  border-radius: 4px;
  padding: 5px 8px;
  resize: vertical;
  min-height: 34px;
}

.dm-inst-input:focus { outline: none; box-shadow: 0 0 0 3px var(--focus-ring); }

.dm-inst-edited { border-left-color: var(--accent-1); }
.dm-inst-attention { border-left-color: var(--accent-warn); }

.dm-inst-tags { display: flex; gap: 6px; flex-shrink: 0; }

.dm-tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 10px;
  padding: 1px 7px;
  white-space: nowrap;
}

.dm-tag-edited { color: var(--accent-1); border: 1px solid var(--accent-1-dim); }
.dm-tag-attention { color: var(--accent-warn); border: 1px solid var(--accent-warn); }

.dm-inst-hint {
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .dm-inst { flex-wrap: wrap; }
  .dm-inst-tags { width: 100%; }
}

.dm-revert {
  font-size: 13px;
  line-height: 1;
  color: var(--text-dim);
  background: none;
  border: 1px solid var(--bg-subtle);
  border-radius: 10px;
  padding: 2px 7px;
  cursor: pointer;
}

.dm-revert:hover { color: var(--accent-1); border-color: var(--accent-1-dim); }

/* Rename affordance beside the route title. Sits on the title baseline and
   stays quiet until hovered, so it never competes with the route name. */
.title-edit-btn {
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  vertical-align: middle;
  margin-left: 10px;
  padding: 3px 10px;
  color: var(--text-dim);
  background: none;
  border: 1px solid var(--bg-subtle);
  border-radius: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.title-edit-btn:hover {
  color: var(--accent-1);
  border-color: var(--accent-1-dim);
}

.title-edit-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* ── Geocode failure reasons (route detail) ───────────────────────────────── */
.geocode-reason {
  margin-top: 4px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text-secondary);
  border-left: 2px solid var(--accent-2);
  padding-left: 8px;
  max-width: 520px;
}
.geocode-reason strong { color: var(--accent-2); font-weight: 600; }
.geocode-reason-detail {
  margin-top: 2px;
  color: var(--text-dim);
  white-space: pre-line;
  word-break: break-word;
}
.geocode-matched {
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-dim);
  font-style: italic;
}

/* ── Dashboard: unlocated stops notice ────────────────────────────────────── */
.dash-notfound-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--bg-subtle);
  border-left: 3px solid var(--accent-warn);
  border-radius: 8px;
}
.dash-notfound-bar strong { color: var(--text-primary); }

/* ── Upload: add vs replace ───────────────────────────────────────────────── */
.upload-mode {
  border: 1px solid var(--bg-subtle);
  border-radius: 8px;
  padding: 10px 14px 12px;
  margin: 0 0 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.upload-mode legend {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 0 6px;
}
.upload-mode-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-primary);
}
.upload-mode-option input { margin-top: 3px; }
.upload-mode-hint {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 1px;
}
.upload-mode-danger:has(input:checked) strong { color: var(--accent-2); }

/* ── Route detail: lat/lon link column ────────────────────────────────────── */
.td-latlon {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  white-space: nowrap;
}
.td-latlon a {
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
}
.td-latlon a:hover { color: var(--accent-info); }
.td-latlon-none { color: var(--text-dim); }

/* ── Stop numbers (labels) ────────────────────────────────────────────────── */
.stop-label { font-variant-numeric: tabular-nums; }
.stop-label-new { font-style: italic; color: var(--accent-info); }
.stop-label-none { color: var(--text-dim); }
.numbering-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 9px 20px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--bg-subtle);
}
.numbering-bar strong { color: var(--text-primary); }
.numbering-prompt { border-left: 3px solid var(--accent-warn); }
.numbering-locked { border-left: 3px solid var(--accent-ok); }

/* ── Rough-guess locations needing review ─────────────────────────────────── */
.geocode-review {
  margin-top: 4px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text-secondary);
  border-left: 2px solid var(--accent-warn);
  padding-left: 8px;
  max-width: 520px;
}
.geocode-review strong { color: var(--accent-warn); font-weight: 600; }
.geocode-review-how { display: block; color: var(--text-dim); margin-top: 1px; }
