/* ============================================================
   CSS Custom Properties
   ============================================================ */
:root {
  /* Brand colours */
  --color-shift-leader: #0d9488;   /* teal */
  --color-shift-leader-bg: #f0fdfa;
  --color-colleague: #0284c7;      /* sky blue */
  --color-colleague-bg: #f0f9ff;

  /* Neutral palette */
  --color-bg: #f8f9fa;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-border-strong: #cbd5e1;
  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-text-subtle: #94a3b8;

  /* Accent */
  --color-primary: #6366f1;
  --color-primary-hover: #4f46e5;
  --color-primary-bg: #eef2ff;
  --color-danger: #ef4444;
  --color-danger-hover: #dc2626;

  /* Today highlight */
  --color-today: #fef3c7;
  --color-today-border: #f59e0b;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  /* Typography */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-size-xs: 11px;
  --font-size-sm: 13px;
  --font-size-base: 15px;
  --font-size-lg: 17px;
  --font-size-xl: 20px;
  --font-size-2xl: 24px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Shadow */
  --shadow-sm: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.05);
  --shadow-lg: 0 20px 40px rgba(0,0,0,.12), 0 8px 16px rgba(0,0,0,.06);

  /* Header height */
  --header-height: 60px;

  /* Transition */
  --transition: 150ms ease;
}

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: var(--font-size-base);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100dvh;
  line-height: 1.5;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input, select, textarea {
  font-family: inherit;
  font-size: var(--font-size-base);
}

/* ============================================================
   Scrollbar (subtle)
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border-strong); border-radius: var(--radius-full); }

/* ============================================================
   Header
   ============================================================ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 0 var(--space-5);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-2);
  margin-left: calc(-1 * var(--space-2));
  transition: background var(--transition);
}
.header-left:hover { background: var(--color-bg); }

.app-logo {
  font-size: 22px;
  line-height: 1;
}

.app-title {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--color-text);
  white-space: nowrap;
}

.header-center {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1;
  justify-content: center;
  min-width: 0;
}

.nav-label {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--color-text);
  min-width: 140px;
  text-align: center;
  white-space: nowrap;
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 7px var(--space-4);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  font-weight: 500;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
  white-space: nowrap;
  line-height: 1;
}

.btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}
.btn-primary:hover { background: var(--color-primary-hover); }

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}
.btn-ghost:hover { background: var(--color-bg); }

.btn-danger {
  background: var(--color-danger);
  color: #fff;
}
.btn-danger:hover { background: var(--color-danger-hover); }

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-lg);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}
.btn-icon:hover { background: var(--color-bg); color: var(--color-text); }

.btn-today {
  font-size: var(--font-size-xs);
  padding: 4px var(--space-3);
}

/* View toggle */
.view-toggle {
  display: flex;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  padding: 2px;
  gap: 2px;
}

.btn-toggle {
  padding: 5px var(--space-3);
  border-radius: 4px;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  transition: background var(--transition), color var(--transition);
}
.btn-toggle:hover { color: var(--color-text); }
.btn-toggle.active {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   Page Navigation (tab strip)
   ============================================================ */
.page-nav {
  position: sticky;
  top: var(--header-height);
  z-index: 90;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 var(--space-4);
  gap: var(--space-1);
}
.page-nav::-webkit-scrollbar { display: none; }

.page-nav-btn {
  flex-shrink: 0;
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  border-radius: 0;
  margin-bottom: -1px;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
}
.page-nav-btn:hover { color: var(--color-text); }
.page-nav-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}

/* ============================================================
   Main content area
   ============================================================ */
.app-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-5);
}

/* ============================================================
   Loading / empty states
   ============================================================ */
.loading-state,
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-8) var(--space-6);
  color: var(--color-text-muted);
  text-align: center;
}

.empty-state-icon {
  font-size: 48px;
  line-height: 1;
}

.empty-state h3 {
  font-size: var(--font-size-lg);
  color: var(--color-text);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   List View
   ============================================================ */
.list-view {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.date-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.date-group-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.date-group-label {
  font-size: var(--font-size-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.date-group-today-badge {
  display: inline-block;
  padding: 1px var(--space-2);
  background: var(--color-today);
  color: #92400e;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
}

.date-group-line {
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

/* Shift Card */
.shift-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  border-left-width: 4px;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  transition: box-shadow var(--transition), transform var(--transition);
}

.shift-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.shift-card.role-shift-leader {
  border-left-color: var(--color-shift-leader);
}
.shift-card.role-colleague {
  border-left-color: var(--color-colleague);
}

.shift-card-time {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--color-text);
  white-space: nowrap;
  min-width: 110px;
}

.shift-card-time-sep {
  font-weight: 400;
  color: var(--color-text-muted);
  margin: 0 2px;
}

.shift-card-details {
  flex: 1;
  min-width: 0;
}

.shift-card-role-badge {
  display: inline-block;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
  letter-spacing: 0.03em;
  margin-bottom: 3px;
}

.role-shift-leader .shift-card-role-badge {
  background: #ccfbf1;
  color: #0f766e;
}
.role-colleague .shift-card-role-badge {
  background: #e0f2fe;
  color: #0369a1;
}

.shift-card-location {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shift-card-duration {
  font-size: var(--font-size-xs);
  color: var(--color-text-subtle);
  white-space: nowrap;
}

.shift-card-actions {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* ============================================================
   Calendar View
   ============================================================ */
.calendar-view {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 2px solid var(--color-border);
  margin-bottom: 0;
}

.calendar-weekday {
  padding: var(--space-2) var(--space-1);
  text-align: center;
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-left: 1px solid var(--color-border);
  border-top: 1px solid var(--color-border);
  background: var(--color-border);
  gap: 1px;
}

.calendar-cell {
  background: var(--color-surface);
  min-height: 100px;
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  overflow: hidden;
}

.calendar-cell.outside-month {
  background: var(--color-bg);
}

.calendar-cell.is-today {
  background: var(--color-today);
}

.calendar-cell.has-shifts {
  background: #fafaff;
}
.calendar-cell.is-today.has-shifts {
  background: var(--color-today);
}

.calendar-day-number {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  line-height: 1;
  padding: 1px 0;
}

.calendar-cell.is-today .calendar-day-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: var(--color-today-border);
  color: #fff;
  border-radius: 50%;
  font-weight: 700;
}

.calendar-cell.outside-month .calendar-day-number {
  color: var(--color-text-subtle);
}

/* Shift chips inside calendar cells */
.shift-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 3px var(--space-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  overflow: hidden;
  transition: opacity var(--transition), transform var(--transition);
  border: none;
  text-align: left;
  width: 100%;
}

.shift-chip:hover {
  opacity: 0.85;
  transform: scale(1.02);
}

.shift-chip.role-shift-leader {
  background: #ccfbf1;
  color: #0f766e;
}

.shift-chip.role-colleague {
  background: #e0f2fe;
  color: #0369a1;
}

.chip-time {
  font-size: var(--font-size-xs);
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.chip-label {
  font-size: 10px;
  line-height: 1.2;
  opacity: 0.85;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

.calendar-more {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  padding: 0 var(--space-1);
  font-weight: 500;
}

/* Day Off — cell */
.calendar-cell.is-dayoff {
  background: repeating-linear-gradient(
    -45deg,
    #fff1f2,
    #fff1f2 5px,
    #ffe4e6 5px,
    #ffe4e6 10px
  );
}
.calendar-cell.is-today.is-dayoff {
  background: repeating-linear-gradient(
    -45deg,
    #fef3c7,
    #fef3c7 5px,
    #fde68a 5px,
    #fde68a 10px
  );
}

/* Day Off — chip/banner inside cell */
.dayoff-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px var(--space-2);
  border-radius: var(--radius-sm);
  background: #fecdd3;
  color: #9f1239;
  font-size: var(--font-size-xs);
  font-weight: 700;
  letter-spacing: 0.02em;
  width: 100%;
  cursor: pointer;
  border: none;
  transition: opacity var(--transition);
}
.dayoff-chip:hover { opacity: 0.8; }

/* Day Off — list card */
.shift-card.role-dayoff {
  border-left-color: #e11d48;
  background: #fff1f2;
}
.shift-card.role-dayoff .shift-card-role-badge {
  background: #fecdd3;
  color: #9f1239;
}

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: fadeIn 0.15s ease;
}

.modal-overlay[hidden] {
  display: none !important;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: calc(100dvh - var(--space-8));
  overflow-y: auto;
  animation: slideUp 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--color-border);
}

.modal-title {
  font-size: var(--font-size-xl);
  font-weight: 700;
}

.modal-close {
  border: none;
  color: var(--color-text-muted);
  font-size: 20px;
}

/* ============================================================
   Location Autocomplete
   ============================================================ */
.autocomplete-wrap {
  position: relative;
}

.autocomplete-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 300;
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  list-style: none;
  overflow: hidden;
  max-height: 280px;
  overflow-y: auto;
}

.ac-item {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  padding: 9px var(--space-4);
  cursor: pointer;
  transition: background var(--transition);
}
.ac-item:not(:last-child) {
  border-bottom: 1px solid var(--color-border);
}
.ac-item:hover,
.ac-item.ac-active {
  background: var(--color-primary-bg);
}

.ac-number {
  font-size: var(--font-size-xs);
  font-weight: 700;
  font-family: 'Cascadia Code', 'Consolas', monospace;
  color: var(--color-text-muted);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  flex-shrink: 0;
}

.ac-name {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text);
  flex: 1;
  min-width: 0;
}

.ac-name mark {
  background: #fef08a;
  color: inherit;
  border-radius: 2px;
}

.ac-city {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Dark mode overrides for autocomplete */
@media (prefers-color-scheme: dark) {
  .ac-name mark {
    background: #713f12;
    color: #fef08a;
  }
  .ac-number {
    background: #0f172a;
  }
}

/* Form type toggle (Shift | Day Off) */
.form-type-toggle {
  display: flex;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
}

.form-type-btn {
  flex: 1;
  padding: 7px var(--space-3);
  border-radius: 5px;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
  cursor: pointer;
  border: none;
  background: none;
}
.form-type-btn:hover { color: var(--color-text); }
.form-type-btn.active {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}
.form-type-btn#btn-type-dayoff.active {
  background: #ffe4e6;
  color: #9f1239;
}

/* Form */
.modal-form {
  padding: var(--space-5) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-group label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
}

.form-group input,
.form-group select {
  padding: 9px var(--space-3);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-bg);
}

.form-group input.error,
.form-group select.error {
  border-color: var(--color-danger);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.form-error {
  background: #fef2f2;
  color: var(--color-danger);
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-size-sm);
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--space-2);
  border-top: 1px solid var(--color-border);
  margin-top: var(--space-2);
}

.modal-actions-left,
.modal-actions-right {
  display: flex;
  gap: var(--space-3);
}

/* ============================================================
   Dashboard View
   ============================================================ */
.dashboard {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: var(--space-6);
  align-items: start;
}

.dash-col-main,
.dash-col-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

@media (max-width: 767px) {
  .dashboard {
    grid-template-columns: 1fr;
  }
}

.dash-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.dash-section-label {
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
}

/* Hero card */
.dash-hero {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--space-5) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.dash-hero.role-shift-leader { border-left-color: var(--color-shift-leader); }
.dash-hero.role-colleague     { border-left-color: var(--color-colleague); }

.dash-hero-when {
  font-size: var(--font-size-xs);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-primary);
}
.dash-hero.role-shift-leader .dash-hero-when { color: var(--color-shift-leader); }
.dash-hero.role-colleague     .dash-hero-when { color: var(--color-colleague); }

.dash-hero-date {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.dash-hero-time {
  font-size: var(--font-size-2xl);
  font-weight: 800;
  color: var(--color-text);
  line-height: 1;
  margin: var(--space-1) 0;
}

.dash-hero-location {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--color-text);
}

.dash-hero-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
}

/* Coming up list */
.dash-upcoming-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.dash-upcoming-item {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  display: grid;
  grid-template-columns: 90px 1fr;
  grid-template-rows: auto auto;
  column-gap: var(--space-3);
  row-gap: 2px;
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition);
}
.dash-upcoming-item:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.dash-upcoming-item.role-shift-leader { border-left-color: var(--color-shift-leader); }
.dash-upcoming-item.role-colleague    { border-left-color: var(--color-colleague); }
.dash-upcoming-item.role-dayoff       { border-left-color: #e11d48; }

.dash-upcoming-when {
  grid-row: 1 / 3;
  grid-column: 1;
  align-self: center;
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

.dash-upcoming-detail {
  grid-row: 1;
  grid-column: 2;
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--color-text);
}

.dash-upcoming-sub {
  grid-row: 2;
  grid-column: 2;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Days off list */
.dash-daysoff-list {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.dash-daysoff-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background var(--transition);
}
.dash-daysoff-item:last-child { border-bottom: none; }
.dash-daysoff-item:hover { background: var(--color-bg); }

.dash-daysoff-icon { font-size: 18px; flex-shrink: 0; }

.dash-daysoff-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.dash-daysoff-range {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
}

.dash-daysoff-when {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

/* Last shift */
.dash-last-shift {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition);
}
.dash-last-shift:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.dash-last-shift.role-shift-leader { border-left-color: var(--color-shift-leader); }
.dash-last-shift.role-colleague    { border-left-color: var(--color-colleague); }

.dash-last-date {
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}
.dash-last-time {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--color-text);
}
.dash-last-location {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

/* Recent stores */
.dash-recent-stores {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.dash-recent-store-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
}
.dash-recent-store-item:last-child { border-bottom: none; }
.dash-recent-store-name {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text);
}
.dash-recent-store-date {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
}

@media (max-width: 639px) {
  .dash-bottom-row { grid-template-columns: 1fr; }
}

/* ============================================================
   Map View
   ============================================================ */
.map-container {
  width: 100%;
  height: calc(100dvh - var(--header-height) - 46px);
  min-height: 400px;
}

/* ============================================================
   Stores View
   ============================================================ */
.stores-page {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

.stores-summary {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  font-weight: 500;
}

.stores-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.stores-section-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.stores-format-label {
  font-size: var(--font-size-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.stores-section-count {
  font-size: var(--font-size-xs);
  font-weight: 600;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 1px 8px;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.stores-section-line {
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

.stores-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-3);
}

.stores-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left-width: 4px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  transition: box-shadow var(--transition), transform var(--transition);
}
.stores-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.stores-card-extra      { border-left-color: var(--color-shift-leader); }
.stores-card-superstore { border-left-color: var(--color-colleague); }
.stores-card-express    { border-left-color: #f59e0b; }
.stores-card-pfs        { border-left-color: #8b5cf6; }

.stores-card-header {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.stores-card-number {
  font-size: var(--font-size-xs);
  font-weight: 700;
  font-family: 'Cascadia Code', 'Consolas', monospace;
  color: var(--color-text-muted);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  flex-shrink: 0;
}

.stores-card-name {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--color-text);
}

.stores-card-address {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

.stores-card-coords {
  font-size: var(--font-size-xs);
  font-family: 'Cascadia Code', 'Consolas', monospace;
  color: var(--color-text-subtle);
  margin-top: 2px;
}

/* ============================================================
   Store History View
   ============================================================ */
.history-page {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.history-summary {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.history-stat {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  flex: 1;
  min-width: 90px;
  text-align: center;
}

.history-stat-value {
  font-size: var(--font-size-2xl);
  font-weight: 800;
  color: var(--color-primary);
  line-height: 1;
}

.history-stat-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.history-store-row {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  transition: box-shadow var(--transition), transform var(--transition);
}
.history-store-row:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.history-store-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.history-store-top {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.history-store-name {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--color-text);
}

.history-shift-count {
  margin-left: auto;
  font-size: var(--font-size-xl);
  font-weight: 800;
  color: var(--color-text);
  white-space: nowrap;
}

.history-store-meta {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2);
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.history-store-hours {
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   Firebase config notice
   ============================================================ */
.config-notice {
  background: #fffbeb;
  border: 1.5px solid #fbbf24;
  border-radius: var(--radius-md);
  padding: var(--space-5) var(--space-6);
  max-width: 560px;
  margin: var(--space-8) auto;
}

.config-notice h3 {
  font-size: var(--font-size-lg);
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.config-notice p {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}

.config-notice code {
  display: block;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-size-sm);
  font-family: 'Cascadia Code', 'Consolas', 'Monaco', monospace;
  white-space: pre;
  overflow-x: auto;
  margin-top: var(--space-2);
}

/* ============================================================
   Responsive — Mobile (<640px)
   ============================================================ */
@media (max-width: 639px) {
  .app-header {
    flex-wrap: wrap;
    height: auto;
    padding: var(--space-3) var(--space-4);
    gap: var(--space-3);
  }

  .header-left { order: 1; }
  .header-right { order: 2; margin-left: auto; }
  .header-center { order: 3; width: 100%; justify-content: center; }

  .app-title { font-size: var(--font-size-lg); }

  .page-nav { position: static; }

  .app-main {
    padding: var(--space-4) var(--space-3);
  }

  /* Calendar: compact cells */
  .calendar-cell {
    min-height: 60px;
    padding: var(--space-1);
  }

  .calendar-weekday {
    font-size: 10px;
    padding: var(--space-1) 0;
  }

  .shift-chip {
    padding: 2px 4px;
    font-size: 10px;
  }

  .chip-label { display: none; }

  /* List: compact cards */
  .shift-card {
    padding: var(--space-3) var(--space-4);
    flex-wrap: wrap;
    gap: var(--space-3);
  }

  .shift-card-time {
    font-size: var(--font-size-base);
    min-width: unset;
  }

  .shift-card-actions { width: 100%; justify-content: flex-end; }

  /* Modal: full-screen bottom sheet */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-width: 100%;
    max-height: 92dvh;
  }
}

/* ============================================================
   Responsive — Tablet / Desktop (≥640px)
   ============================================================ */
@media (min-width: 640px) {
  .calendar-cell {
    min-height: 120px;
  }
}

@media (min-width: 1024px) {
  .calendar-cell {
    min-height: 140px;
  }
}

/* ============================================================
   Utility
   ============================================================ */
[hidden] { display: none !important; }

/* ============================================================
   Dark Mode
   ============================================================ */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #0f172a;
    --color-surface: #1e293b;
    --color-border: #334155;
    --color-border-strong: #475569;
    --color-text: #f1f5f9;
    --color-text-muted: #94a3b8;
    --color-text-subtle: #475569;
    --color-today: #431407;
    --color-today-border: #ea580c;
    --color-primary-bg: #1e1b4b;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.3), 0 1px 2px rgba(0,0,0,.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,.4), 0 2px 4px rgba(0,0,0,.2);
    --shadow-lg: 0 20px 40px rgba(0,0,0,.5), 0 8px 16px rgba(0,0,0,.3);
  }

  /* Role badge colours */
  .role-shift-leader .shift-card-role-badge {
    background: #134e4a;
    color: #5eead4;
  }
  .role-colleague .shift-card-role-badge {
    background: #0c4a6e;
    color: #7dd3fc;
  }

  /* Shift chips */
  .shift-chip.role-shift-leader {
    background: #134e4a;
    color: #5eead4;
  }
  .shift-chip.role-colleague {
    background: #0c4a6e;
    color: #7dd3fc;
  }

  /* Calendar */
  .calendar-cell.has-shifts {
    background: #1e2d40;
  }
  .calendar-cell.is-today.has-shifts {
    background: var(--color-today);
  }

  /* Form inputs */
  .form-group input,
  .form-group select {
    background: #0f172a;
    color: var(--color-text);
    border-color: var(--color-border);
    color-scheme: dark;
  }

  /* Form error box */
  .form-error {
    background: #450a0a;
    border-color: #991b1b;
  }

  /* Config notice */
  .config-notice {
    background: #1c1100;
    border-color: #92400e;
  }
  .config-notice code {
    background: #0f172a;
  }

  /* View toggle */
  .view-toggle {
    background: #0f172a;
  }
  .btn-toggle.active {
    background: var(--color-surface);
  }

  /* Form type toggle */
  .form-type-toggle {
    background: #0f172a;
  }
  .form-type-btn.active {
    background: var(--color-surface);
  }
  .form-type-btn#btn-type-dayoff.active {
    background: #4c0519;
    color: #fda4af;
  }

  /* Day Off cell */
  .calendar-cell.is-dayoff {
    background: repeating-linear-gradient(
      -45deg,
      #2d0d14,
      #2d0d14 5px,
      #3f0f1e 5px,
      #3f0f1e 10px
    );
  }
  .calendar-cell.is-today.is-dayoff {
    background: repeating-linear-gradient(
      -45deg,
      #431407,
      #431407 5px,
      #5a1e0a 5px,
      #5a1e0a 10px
    );
  }

  /* Day Off chip */
  .dayoff-chip {
    background: #4c0519;
    color: #fda4af;
  }

  /* Day Off list card */
  .shift-card.role-dayoff {
    background: #1a0a0e;
  }
  .shift-card.role-dayoff .shift-card-role-badge {
    background: #4c0519;
    color: #fda4af;
  }
}
