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

:root {
  --sidebar-w: 250px;
  --navy: #0f172a;
  --navy-mid: #1e293b;
  --navy-light: #334155;
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --success: #22c55e;
  --success-bg: #dcfce7;
  --success-text: #166534;
  --danger: #ef4444;
  --danger-bg: #fee2e2;
  --danger-text: #991b1b;
  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --warning-text: #92400e;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --radius: 8px;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ─── Auth layout ─────────────────────────────────────────── */

.auth-bg {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  padding: 24px;
}

.auth-card {
  background: var(--card);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
}

.auth-logo h1 span {
  color: var(--primary);
}

.auth-logo p {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

.auth-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
}

.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--muted);
}

/* ─── App layout ──────────────────────────────────────────── */

.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 24px 20px 0;
}

.sidebar-brand h1 {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.sidebar-brand h1 span {
  color: var(--primary);
}

.sidebar-brand small {
  font-size: 11px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar-logo {
  max-width: 100%;
  max-height: 60px;
  height: auto;
  margin: 12px auto;
  display: block;
}

.sidebar-logo-wrapper {
  padding: 0 20px 0px;
  border-bottom: 1px solid var(--navy-mid);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.nav-section-label {
  padding: 12px 20px 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #475569;
}

.nav-item {
  display: block;
  padding: 10px 20px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 14px;
  transition: background 0.12s, color 0.12s;
}

.nav-item:hover {
  background: var(--navy-mid);
  color: #fff;
}

.nav-item.active {
  background: var(--navy-mid);
  color: #fff;
  border-left: 3px solid var(--primary);
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--navy-mid);
}

.sidebar-user {
  font-size: 13px;
  color: #fff;
  font-weight: 500;
  margin-bottom: 8px;
}

.sidebar-user small {
  display: block;
  color: #64748b;
  font-size: 11px;
  font-weight: 400;
}

.main {
  margin-left: var(--sidebar-w);
  padding: 32px;
  width: calc(100vw - var(--sidebar-w));
  max-width: calc(100vw - var(--sidebar-w));
  min-height: 100vh;
}

/* ─── Page header ─────────────────────────────────────────── */

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

.page-header h1 {
  font-size: 22px;
  font-weight: 700;
}

.page-header-actions {
  display: flex;
  gap: 8px;
}

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

.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.card + .card,
.card-gap {
  margin-top: 20px;
}

.card h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
}

/* ─── Dashboard grid ──────────────────────────────────────── */

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  align-items: start;
}

/* ─── Shift status ────────────────────────────────────────── */

.shift-status {
  display: flex;
  align-items: center;
  gap: 12px;
}

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

.shift-status--active .shift-dot {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}

.shift-status--idle .shift-dot {
  background: var(--muted);
}

.shift-status--active strong {
  color: var(--success-text);
}

.shift-status small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

/* ─── Vacation item (dashboard) ───────────────────────────── */

.vacation-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  flex-wrap: wrap;
}

.vacation-item:last-child {
  border-bottom: none;
}

/* ─── Filter form ─────────────────────────────────────────── */

.filter-form {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
  white-space: nowrap;
  font-family: inherit;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

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

.btn-danger:hover {
  background: #dc2626;
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-outline:hover {
  background: var(--bg);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 13px;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 15px;
}

/* ─── Forms ───────────────────────────────────────────────── */

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

label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  outline: none;
  font-family: inherit;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.form-control[readonly] {
  background: #f8fafc;
  color: var(--muted);
  cursor: not-allowed;
}

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

select.form-control {
  cursor: pointer;
}

.form-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 24px;
}

/* ─── Alerts ──────────────────────────────────────────────── */

.alert {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 14px;
  border: 1px solid transparent;
}

.alert-error {
  background: var(--danger-bg);
  color: var(--danger-text);
  border-color: #fca5a5;
}

.alert-success {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: #86efac;
}

.alert-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
  border-color: #fcd34d;
}

/* ─── Badges ──────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-success {
  background: var(--success-bg);
  color: var(--success-text);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.badge-info {
  background: #dbeafe;
  color: #1e40af;
}

.badge-admin {
  background: #ede9fe;
  color: #5b21b6;
}

/* ─── Tables ──────────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th {
  background: #f8fafc;
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

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

.table tbody tr:hover td {
  background: #f8fafc;
}

/* ─── Stats grid ──────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}

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

.stat-label {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

/* ─── Utilities ───────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--muted);
  font-size: 15px;
}

.text-muted { color: var(--muted); }
.text-sm { font-size: 13px; }
.mb-0 { margin-bottom: 0 !important; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.font-semibold { font-weight: 600; }

/* ─── Calendar ────────────────────────────────────────────── */

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

.cal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.cal-legend {
  display: flex;
  gap: 20px;
  font-size: 13px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.cal-legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
}

.cal-legend-dot {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
}

.cal-legend-dot--shift    { background: #bfdbfe; border: 1px solid #93c5fd; }
.cal-legend-dot--vacation { background: #fde68a; border: 1px solid #fcd34d; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}

.cal-header-cell {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 6px 0;
}

.cal-cell {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  min-height: 72px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cal-cell--empty {
  background: transparent;
  border-color: transparent;
}

.cal-cell--today {
  border-color: var(--primary) !important;
  border-width: 2px;
}

.cal-cell--shift    { background: #dbeafe; border-color: #93c5fd; }
.cal-cell--vacation { background: #fef3c7; border-color: #fcd34d; }

.cal-cell--shift.cal-cell--vacation {
  background: linear-gradient(135deg, #dbeafe 55%, #fef3c7 55%);
  border-color: #93c5fd;
}

.cal-cell--has-activity {
  background: #f0f9ff;
  border-color: #bae6fd;
}

.cal-day-num {
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
}

.cal-cell--today .cal-day-num {
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  font-size: 12px;
}

.cal-tag {
  display: inline-block;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 500;
  line-height: 1.4;
}

.cal-tag--shift    { background: #bfdbfe; color: #1e40af; }
.cal-tag--vacation { background: #fde68a; color: #92400e; }

/* Admin calendar */
.cal-admin .cal-cell {
  min-height: 100px;
}

.cal-chips {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  max-height: 76px;
}

.cal-person-chip {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  font-weight: 500;
  line-height: 1.5;
}

.cal-person-chip--shift    { background: #bfdbfe; color: #1e40af; }
.cal-person-chip--vacation { background: #fde68a; color: #92400e; }

/* Clickable cell overlay (admin calendar) */
.cal-cell {
  position: relative;
}

.cal-cell-link {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  z-index: 0;
}

.cal-cell:has(.cal-cell-link):hover {
  border-color: var(--primary);
  cursor: pointer;
}

.cal-cell .cal-day-num,
.cal-cell .cal-chips {
  position: relative;
  z-index: 1;
  pointer-events: none;
}
