:root {
  --bg:          #0f172a;
  --surface:     #1e293b;
  --surface-2:   #334155;
  --primary:     #3b82f6;
  --primary-d:   #2563eb;
  --text:        #f1f5f9;
  --text-muted:  #94a3b8;
  --text-dim:    #64748b;
  --border:      #334155;
  --success:     #10b981;
  --warning:     #f59e0b;
  --error:       #ef4444;
  --radius:      10px;
  --radius-sm:   6px;
  --nav-h:       60px;
  --header-h:    52px;
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
}

/* ─── Views ─────────────────────────────────────────────── */

.view { display: none; }
.view.active { display: flex; flex-direction: column; min-height: 100vh; }

/* ─── Auth / Setup screens ───────────────────────────────── */

.auth-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  gap: 24px;
}

.auth-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.auth-logo svg { width: 64px; height: 64px; }

.auth-logo h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.auth-logo p {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
}

.auth-form {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ─── Main App Layout ────────────────────────────────────── */

#view-app {
  flex-direction: column;
}

.app-header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.app-header h1 {
  font-size: 18px;
  font-weight: 700;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
}

.badge {
  background: var(--primary);
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
}
.badge.admin { background: var(--warning); color: #1a1a1a; }

.app-main {
  flex: 1;
  overflow-y: auto;
  padding-bottom: calc(var(--nav-h) + 16px);
}

/* ─── Bottom Navigation ──────────────────────────────────── */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s;
  padding: 8px 4px;
}

.nav-btn svg { width: 22px; height: 22px; }

.nav-btn.active {
  color: var(--primary);
}

/* ─── Tab content ─────────────────────────────────────────── */

.tab-content { display: none; padding: 16px; }
.tab-content.active { display: block; }

/* ─── Form Elements ──────────────────────────────────────── */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

input, select, textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  padding: 10px 12px;
  width: 100%;
  transition: border-color 0.15s;
  appearance: none;
  -webkit-appearance: none;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
}

input::placeholder, textarea::placeholder {
  color: var(--text-dim);
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 34px;
}

textarea { resize: vertical; min-height: 80px; }

input[type="date"], input[type="time"] {
  color-scheme: dark;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.input-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

/* ─── Buttons ────────────────────────────────────────────── */

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  font-weight: 600;
  padding: 10px 18px;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
  width: 100%;
  padding: 13px;
  font-size: 16px;
  border-radius: var(--radius);
}
.btn-primary:hover { background: var(--primary-d); }
.btn-primary:active { opacity: 0.8; }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
}
.btn-secondary:hover { background: var(--border); }

.btn-danger {
  background: transparent;
  color: var(--error);
  border: 1px solid var(--error);
  padding: 6px 12px;
  font-size: 13px;
}
.btn-danger:hover { background: var(--error); color: white; }

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-icon {
  background: var(--surface-2);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  padding: 0;
  flex-shrink: 0;
}
.btn-icon svg { width: 16px; height: 16px; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 8px;
}
.btn-ghost:hover { color: var(--text); }

/* ─── Cards ──────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.card-title {
  font-weight: 700;
  font-size: 16px;
}

.card-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 2px;
}

.card-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-muted);
}

.card-row svg { width: 14px; height: 14px; flex-shrink: 0; }

/* ─── Section headers ─────────────────────────────────────── */

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

.section-title {
  font-size: 17px;
  font-weight: 700;
}

/* ─── Odometer section ───────────────────────────────────── */

.odo-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.odo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
}

.odo-header span {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
}

.odo-header .odo-total-preview {
  font-size: 13px;
  color: var(--text-dim);
}

.odo-body {
  padding: 0 14px 14px;
  display: none;
}

.odo-section.open .odo-body { display: block; }

.odo-chevron {
  transition: transform 0.2s;
  color: var(--text-dim);
}
.odo-section.open .odo-chevron { transform: rotate(180deg); }

.odo-total-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.odo-total-val {
  font-weight: 700;
  color: var(--success);
}
.odo-total-val.zero { color: var(--text-dim); }

/* ─── Summary bar ─────────────────────────────────────────── */

.summary-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  gap: 24px;
  margin-bottom: 14px;
}

.summary-stat {
  display: flex;
  flex-direction: column;
}

.summary-val {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.summary-lbl {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* ─── Filters ─────────────────────────────────────────────── */

.filter-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.filter-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
}

.filter-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ─── Duration display ───────────────────────────────────── */

.duration-display {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  text-align: center;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.duration-display.error { color: var(--error); font-size: 13px; font-weight: 500; }

/* ─── Form sections / dividers ───────────────────────────── */

.form-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.form-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  margin-bottom: 2px;
}

/* ─── Empty state ────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-dim);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  opacity: 0.4;
}

.empty-state p { font-size: 15px; }
.empty-state small { font-size: 13px; }

/* ─── Modal ──────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 20px 16px;
  transform: translateY(100%);
  transition: transform 0.25s ease;
}

.modal-overlay.open .modal {
  transform: translateY(0);
}

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

.modal-title {
  font-size: 18px;
  font-weight: 700;
}

/* ─── Toast notifications ────────────────────────────────── */

.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-2);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  z-index: 300;
  opacity: 0;
  transition: all 0.25s;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.toast-success { background: var(--success); color: white; }
.toast.toast-error   { background: var(--error);   color: white; }
.toast.toast-warning { background: var(--warning);  color: #1a1a1a; }

/* ─── Staff list items ────────────────────────────────────── */

.staff-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
}

.staff-info { flex: 1; }
.staff-name { font-weight: 600; font-size: 15px; }
.staff-meta { font-size: 13px; color: var(--text-muted); }
.staff-actions { display: flex; gap: 6px; }

/* ─── Client list ─────────────────────────────────────────── */

.client-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
}

.client-name { font-weight: 600; font-size: 15px; }
.client-meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

/* ─── Export actions ─────────────────────────────────────── */

.export-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.export-actions button {
  flex: 1;
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--radius);
  padding: 10px 8px;
  font-size: 13px;
  flex-direction: column;
  gap: 4px;
  height: 60px;
}

.export-actions button svg { width: 18px; height: 18px; }

/* ─── Inline toggle ──────────────────────────────────────── */

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
}

.toggle-switch {
  width: 44px;
  height: 24px;
  background: var(--border);
  border-radius: 12px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: transform 0.2s;
}

.toggle-switch.on {
  background: var(--success);
}

.toggle-switch.on::after {
  transform: translateX(20px);
}

/* ─── Scrollbars ─────────────────────────────────────────── */

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 2px; }

/* ─── Utility ────────────────────────────────────────────── */

.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.text-muted { color: var(--text-muted); font-size: 13px; }
.text-error { color: var(--error); font-size: 13px; }
.hidden { display: none !important; }
.full-width { width: 100%; }
.text-center { text-align: center; }
.flex-row { display: flex; gap: 8px; align-items: center; }

/* ─── Shift card collapsible odo ─────────────────────────── */

.shift-odo { display: none; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.shift-odo.open { display: block; }

.odo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
  font-size: 12px;
}
.odo-grid-header { color: var(--text-dim); font-weight: 600; }
.odo-grid-val { color: var(--text-muted); }

.notes-text {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 4px;
  white-space: pre-wrap;
}

.expand-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  padding: 4px 0;
  cursor: pointer;
  text-decoration: underline;
}

/* ─── Provider list ──────────────────────────────────────── */

.provider-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  gap: 10px;
}

.provider-name { font-weight: 600; font-size: 15px; }
.provider-meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

/* ─── Pill tags (e.g. provider names on client rows) ─────── */

.tag {
  display: inline-block;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  margin-right: 4px;
  margin-top: 2px;
}

.tag-provider {
  background: rgba(59, 130, 246, 0.15);
  color: var(--primary);
}

/* ─── Section divider (between providers & clients) ─────── */

.section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* ─── Assign-providers modal checkboxes ─────────────────── */

.cp-checkbox-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}

.cp-checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  flex-shrink: 0;
  cursor: pointer;
}

.cp-checkbox-label { font-size: 15px; font-weight: 500; }
.cp-checkbox-meta  { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

/* ─── Responsive: slightly bigger on tablets ─────────────── */
@media (min-width: 400px) {
  .auth-form { padding: 0 8px; }
}
