:root {
  --bg: #fafaf9;
  --card: #ffffff;
  --text: #1a1a1a;
  --text-muted: #6b6b6b;
  --border: #e7e5e4;
  --primary: #1a1a1a;
  --primary-text: #ffffff;
  --accent: #e11d74;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08), 0 4px 10px rgba(0, 0, 0, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0a;
    --card: #171717;
    --text: #f5f5f5;
    --text-muted: #a3a3a3;
    --border: #262626;
    --primary: #f5f5f5;
    --primary-text: #0a0a0a;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Helvetica Neue", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body {
  background: var(--bg);
  color: var(--text);
  padding: 1rem;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ===== Logo ===== */
.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 0 1rem;
  color: var(--text);
}
.logo svg { width: 200px; height: auto; }

/* ===== Login: employee picker ===== */
.login-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 1rem 0;
}
.login-title {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-muted);
  text-align: center;
  margin: 1rem 0 1.5rem;
}
.employee-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  padding: 0 0.5rem;
}
.employee-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 0.5rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  text-align: center;
  font: inherit;
  color: inherit;
}
.employee-card:active { transform: scale(0.96); box-shadow: var(--shadow-lg); }
.avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: white;
  flex-shrink: 0;
}
.avatar.lg { width: 84px; height: 84px; font-size: 1.6rem; }
.employee-card .name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.2;
}

/* ===== PIN entry ===== */
.pin-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 0;
}
.back-btn {
  align-self: flex-start;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  padding: 0.5rem;
  cursor: pointer;
  margin: 0;
  min-height: auto;
  width: auto;
}
.pin-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0 1.5rem;
}
.pin-name {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}
.pin-hint {
  font-size: 0.9rem;
  color: var(--text-muted);
}
.pin-dots {
  display: flex;
  gap: 1rem;
  margin: 1rem 0;
}
.pin-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  transition: background 0.1s, border-color 0.1s;
}
.pin-dot.filled {
  background: var(--text);
  border-color: var(--text);
}
.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  width: 100%;
  max-width: 280px;
  margin-top: 1rem;
}
.pin-key {
  height: 72px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--border);
  font-size: 1.75rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, transform 0.1s;
  font-family: inherit;
}
.pin-key:active { transform: scale(0.92); background: var(--border); }
.pin-key.ghost { background: transparent; border: none; cursor: default; }
.pin-error-msg {
  margin-top: 1rem;
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 500;
  min-height: 1.2rem;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-6px); }
  20%, 40%, 60%, 80% { transform: translateX(6px); }
}
.shake { animation: shake 0.4s; }

/* ===== Home (clock UI) ===== */
.home-screen { flex: 1; display: flex; flex-direction: column; }
.greeting {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0 1rem;
}
.greeting .name {
  font-size: 1.1rem;
  font-weight: 600;
}
.greeting .avatar { width: 40px; height: 40px; font-size: 0.95rem; }
.status-card {
  padding: 1.5rem;
  border-radius: 20px;
  text-align: center;
  margin: 0.5rem 0 1.5rem;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.status-card.out { }
.status-card.in {
  background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
  color: #065f46;
  border-color: #86efac;
}
.status-card.break {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  color: #92400e;
  border-color: #fcd34d;
}
.status-label {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.7;
  margin-bottom: 0.25rem;
}
.status-since {
  font-size: 0.95rem;
  font-weight: 500;
  opacity: 0.8;
}
.elapsed {
  font-size: 2.5rem;
  font-weight: 700;
  margin-top: 0.5rem;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
button.action {
  display: block;
  width: 100%;
  padding: 1.125rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 14px;
  margin: 0.5rem 0;
  cursor: pointer;
  min-height: 56px;
  letter-spacing: 0.02em;
  transition: transform 0.1s, opacity 0.15s;
  font-family: inherit;
}
button.action:active { transform: scale(0.98); }
button.action:disabled { opacity: 0.5; cursor: not-allowed; }
.action.primary {
  background: var(--primary);
  color: var(--primary-text);
}
.action.secondary {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
}
.summary-card {
  margin-top: 1rem;
  padding: 1rem 1.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
}
.summary-row + .summary-row { border-top: 1px solid var(--border); }
.summary-row .label { font-size: 0.875rem; color: var(--text-muted); }
.summary-row .value { font-size: 1rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.footer-link {
  text-align: center;
  margin-top: auto;
  padding-top: 1.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}
.footer-link a { color: var(--text-muted); text-decoration: none; }
.footer-link a:hover { color: var(--text); }

/* ===== Store picker grid ===== */
.store-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  width: 100%;
  padding: 0 0.5rem;
  margin-top: 1rem;
}
.store-card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 110px;
  padding: 1.25rem;
  border-radius: 16px;
  color: white;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
  border: none;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s;
  box-shadow: var(--shadow);
  font-family: inherit;
}
.store-card:active { transform: scale(0.96); box-shadow: var(--shadow-lg); }

/* ===== Warning banner ===== */
.warn-banner {
  padding: 0.875rem 1rem;
  border-radius: 12px;
  background: #fef3c7;
  color: #92400e;
  font-size: 0.95rem;
  font-weight: 500;
  margin: 0.5rem 0 1rem;
}
.warn-banner.danger { background: #fee2e2; color: #991b1b; }

/* ===== Segment list ===== */
.segments-list {
  margin-top: 1rem;
  padding: 0.5rem 0.75rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.seg-row {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  font-size: 0.9rem;
}
.seg-row + .seg-row { border-top: 1px solid var(--border); }
.seg-type { text-align: center; }
.seg-time { font-variant-numeric: tabular-nums; }
.seg-store { color: var(--text-muted); font-size: 0.85rem; }

/* ===== Correction form ===== */
.correct-screen { padding: 0.5rem 0; }
.correct-title { font-size: 1.25rem; font-weight: 600; margin: 1rem 0 0.5rem; }
.muted-sm { color: var(--text-muted); font-size: 0.875rem; margin-bottom: 1rem; }
.correct-screen form { display: flex; flex-direction: column; gap: 1rem; margin-top: 1rem; }
.correct-screen label { font-size: 0.875rem; color: var(--text-muted); display: block; }
.correct-screen input, .correct-screen select {
  width: 100%;
  padding: 0.875rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 10px;
  margin-top: 0.25rem;
  font-family: inherit;
}
.correct-screen input[type=date], .correct-screen input[type=time] {
  font-variant-numeric: tabular-nums;
}
.error-msg { color: var(--danger); font-size: 0.9rem; min-height: 1.2rem; margin-top: 0.5rem; }

/* ===== Shift planner ===== */
.shifts-screen { padding: 0.5rem 0; }
.shifts-header { display: flex; align-items: center; gap: 0.5rem; margin: 0.5rem 0; }
.shifts-title { flex: 1; text-align: center; font-size: 1.05rem; font-weight: 600; }
.week-nav {
  background: var(--card);
  border: 1px solid var(--border);
  width: 44px;
  height: 44px;
  min-height: auto;
  font-size: 1.3rem;
  border-radius: 12px;
  padding: 0;
  margin: 0;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
}
.plan-link { margin-top: 1rem; }
.week-grid { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.75rem; }
.day-row {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem;
  transition: opacity 0.2s;
}
.day-row.past { opacity: 0.55; }
.day-row.today { border-color: var(--accent); border-width: 2px; }
.day-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.day-label { font-weight: 600; font-size: 0.95rem; }
.day-add {
  background: var(--text);
  color: var(--primary-text);
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  border-radius: 8px;
  min-height: 32px;
  width: auto;
  margin: 0;
  font-family: inherit;
  border: none;
  cursor: pointer;
}
.day-shifts { display: flex; flex-direction: column; gap: 0.35rem; }
.day-empty { color: var(--text-muted); font-size: 0.85rem; }
.shift-chip {
  display: grid;
  grid-template-columns: 22px 95px 1fr;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.65rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s;
}
.shift-chip:active { background: var(--border); }
.shift-chip.sick { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.shift-chip.cancelled { opacity: 0.5; text-decoration: line-through; }
.shift-chip.in_progress { background: #dcfce7; border-color: #86efac; color: #065f46; }
.shift-chip.completed { background: #f3f4f6; }
.shift-chip.no_show { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.shift-time { font-variant-numeric: tabular-nums; font-weight: 600; }
.shift-store { color: var(--text-muted); font-size: 0.85rem; }
.action.danger { background: #fee2e2; color: #991b1b; }

/* ===== Upcoming shifts on home screen ===== */
.upcoming-card {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.upcoming-title {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.upcoming-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  font-size: 0.9rem;
  cursor: pointer;
  transition: opacity 0.15s;
}
.upcoming-row + .upcoming-row { border-top: 1px solid var(--border); }
.upcoming-row:active { opacity: 0.6; }
.up-day { font-weight: 600; }
.up-time { font-variant-numeric: tabular-nums; color: var(--text-muted); font-size: 0.85rem; }
.up-store { text-align: right; color: var(--text-muted); font-size: 0.85rem; }

/* ===== View toggle (My / Team) ===== */
.view-toggle {
  display: flex;
  gap: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.25rem;
  margin: 0.75rem 0 0.5rem;
}
.view-toggle button {
  flex: 1;
  background: transparent;
  border: none;
  padding: 0.55rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: 8px;
  min-height: auto;
  margin: 0;
  cursor: pointer;
  font-family: inherit;
}
.view-toggle button.active {
  background: var(--text);
  color: var(--primary-text);
}
