/* ============================================================
   ForgeShift — Global Styles
   Light / Dark / OLED themes, mobile-first responsive
============================================================ */

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

/* ── Design tokens — Light (default) ─────────────────────── */
:root {
  --brand:        #4f46e5;
  --brand-hover:  #4338ca;
  --brand-light:  #eef2ff;
  --brand-text:   #ffffff;
  --green:        #059669;
  --green-light:  #d1fae5;
  --red:          #dc2626;
  --red-light:    #fee2e2;
  --orange:       #d97706;
  --orange-light: #fef3c7;

  --gray-50:  #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  --text:     #111827;
  --text-2:   #374151;
  --text-3:   #6b7280;
  --border:   #e5e7eb;
  --border-2: #f3f4f6;
  --bg:       #f3f4f6;
  --surface:  #ffffff;
  --surface-2:#f9fafb;

  --topbar-h:  56px;
  --topbar-bg: #1e1b4b;
  --sidebar-w: 220px;

  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 10px;
  --r-xl: 14px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.07);
  --shadow-md: 0 3px 8px rgba(0,0,0,.10);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.13);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', monospace;

  --t-fast: 100ms ease;
  --t-base: 180ms ease;

  /* Day note colours */
  --note-blue:   #4f46e5;
  --note-green:  #059669;
  --note-orange: #d97706;
  --note-red:    #dc2626;
  --note-purple: #7c3aed;
  --note-teal:   #0891b2;
  --note-pink:   #db2777;
  --note-gray:   #6b7280;
}

/* ── Dark theme ───────────────────────────────────────────── */
[data-theme="dark"] {
  --text:     #f9fafb;
  --text-2:   #d1d5db;
  --text-3:   #9ca3af;
  --border:   #374151;
  --border-2: #1f2937;
  --bg:       #0f172a;
  --surface:  #1e293b;
  --surface-2:#162032;
  --brand-light: #1e1b4b;
  --topbar-bg: #0f172a;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 3px 8px rgba(0,0,0,.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.5);
  /* Override light-only grays so settings panels don't flash white */
  --gray-50:  #1e293b;
  --gray-100: #162032;
}

/* ── OLED black theme ─────────────────────────────────────── */
[data-theme="oled"] {
  --text:     #f9fafb;
  --text-2:   #d1d5db;
  --text-3:   #9ca3af;
  --border:   #1a1a1a;
  --border-2: #0d0d0d;
  --bg:       #000000;
  --surface:  #0d0d0d;
  --surface-2:#000000;
  --brand-light: #0d0d1a;
  --topbar-bg: #000000;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.8);
  --shadow-md: 0 3px 8px rgba(0,0,0,.8);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.9);
  /* Override light-only grays */
  --gray-50:  #0d0d0d;
  --gray-100: #111111;
}

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background var(--t-base), color var(--t-base);
}

/* Ensure page containers always use theme background */
.app-shell, .app-body { background: var(--bg); }
.page-content { background: var(--bg); }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 600; }
h4 { font-size: 13px; font-weight: 600; }

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }
[data-theme="dark"] ::-webkit-scrollbar-thumb,
[data-theme="oled"] ::-webkit-scrollbar-thumb { background: var(--gray-700); }

/* ── App shell ────────────────────────────────────────────── */
.app-shell   { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.app-body    { display: flex; flex: 1; overflow: hidden; min-height: 0; flex-direction: column; }
.page-content { flex: 1; overflow-y: auto; padding: 24px; min-height: 0; }

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--topbar-bg);
  display: flex; align-items: center; padding: 0 16px;
  gap: 12px; flex-shrink: 0; z-index: 200; position: relative;
  overflow: visible;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.topbar-logo {
  display: flex; align-items: center; gap: 8px;
  text-decoration: none; flex-shrink: 0;
}
.topbar-logo svg { width: 28px; height: 28px; }
.topbar-logo-text { font-size: 16px; font-weight: 800; color: #fff; letter-spacing: -.03em; }
.topbar-logo:hover { text-decoration: none; }

.topbar-spacer { flex: 1; }

/* Desktop nav links shown in topbar */
.topbar-nav { display: flex; gap: 2px; }
.topbar-nav-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: var(--r-md);
  color: rgba(255,255,255,.7); font-size: 13px; font-weight: 500;
  text-decoration: none; transition: background var(--t-fast), color var(--t-fast);
  white-space: nowrap; border: none; background: transparent; cursor: pointer;
}
.topbar-nav-btn:hover { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.topbar-nav-btn.active { background: rgba(255,255,255,.15); color: #fff; }
.topbar-nav-btn svg { width: 16px; height: 16px; flex-shrink: 0; }

/* Inline env badge in topbar (next to logo), ForgeTrack style */
.env-topbar-badge {
  font-size: 11px; font-weight: 800; padding: 3px 10px;
  border-radius: 20px; text-transform: uppercase; letter-spacing: .04em;
  flex-shrink: 0;
}
.env-topbar-badge.development { background: #6554c0; color: #fff; }
.env-topbar-badge.staging     { background: var(--orange); color: #fff; }
.env-topbar-badge.production  { background: var(--green); color: #fff; }

/* Version string next to env badge — monospace pill, ForgeTrack style */
.version-badge {
  font-size: 12px; font-weight: 500; color: rgba(255,255,255,.55);
  font-family: var(--mono); letter-spacing: -.01em; flex-shrink: 0;
  background: rgba(255,255,255,.07); padding: 3px 10px; border-radius: 20px;
}

/* Fixed bottom-right corner env pill (ForgeTrack style) */
.env-badge {
  position: fixed; bottom: 14px; right: 14px; z-index: 9000;
  font-size: 10px; font-weight: 800; padding: 3px 10px;
  border-radius: 20px; text-transform: uppercase; letter-spacing: .04em;
  pointer-events: none;
}
.env-badge.development { background: #6554c0; color: #fff; }
.env-badge.staging     { background: var(--orange); color: #fff; }
.env-badge.production  { background: var(--green); color: #fff; }

.topbar-user-btn {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0;
  border-radius: 50%; border: 2px solid rgba(255,255,255,.2);
  background: transparent; cursor: pointer;
  transition: border-color var(--t-fast);
  overflow: hidden; flex-shrink: 0;
}
.topbar-user-btn:hover { border-color: rgba(255,255,255,.5); }
.topbar-user-btn .avatar { width: 30px; height: 30px; font-size: 11px; }

/* Standalone icon button in topbar (theme picker, etc.) */
.topbar-icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: var(--r-md);
  border: none; background: transparent; cursor: pointer;
  color: rgba(255,255,255,.75); transition: background var(--t-fast), color var(--t-fast);
  flex-shrink: 0;
}
.topbar-icon-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.topbar-icon-btn svg { width: 18px; height: 18px; }
/* Active state for icon-only nav links (e.g. settings cog) */
a.topbar-icon-btn.active-icon,
a.topbar-icon-btn.active-icon:hover { color: #fff; background: rgba(255,255,255,.15); }

/* Theme dropdown — radio-style rows matching ForgeTrack */
.theme-option {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: var(--r-md);
  font-size: 14px; font-weight: 500; color: var(--text-2); cursor: pointer;
  border: none; background: transparent; width: 100%; text-align: left;
  transition: background var(--t-fast), color var(--t-fast);
}
.theme-option:hover { background: var(--bg); color: var(--text); }
.theme-option.active { color: var(--brand); }
.theme-option-icon {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.15); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2);
}
.theme-option.active .theme-option-icon {
  border-color: var(--brand);
  background: var(--brand);
}
.theme-option-check {
  margin-left: auto; color: var(--brand);
  display: none;
}
.theme-option.active .theme-option-check { display: flex; }

/* ── Sidebar — hidden (nav lives in topbar on desktop, dropdown on mobile) ──── */
.sidebar { display: none; }
.sidebar-section { padding: 12px 8px 4px; }
.sidebar-label {
  font-size: 10px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-3); padding: 0 8px 6px;
}
.sidebar-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r-md);
  color: var(--text-2); font-size: 13px; font-weight: 500;
  text-decoration: none; transition: background var(--t-fast), color var(--t-fast);
  cursor: pointer; border: none; background: transparent; width: 100%;
}
.sidebar-item:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.sidebar-item.active { background: var(--brand-light); color: var(--brand); font-weight: 600; }
.sidebar-item svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ── Overlay sidebar (mobile) ─────────────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 150;
}
.sidebar-overlay.open { display: block; }

/* ── Mobile sidebar toggle — hidden on desktop, shown on mobile via media query */
.topbar-menu-btn {
  display: none; align-items: center; justify-content: center;
  width: 36px; height: 36px; border: none; background: transparent;
  color: rgba(255,255,255,.8); cursor: pointer; border-radius: var(--r-md);
  transition: background var(--t-fast);
  flex-shrink: 0;
}
.topbar-menu-btn:hover { background: rgba(255,255,255,.1); }

/* ── Avatar ───────────────────────────────────────────────── */
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0;
  background: var(--brand); text-transform: uppercase;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 40px; height: 40px; font-size: 14px; }
.avatar-xl { width: 56px; height: 56px; font-size: 18px; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--r-md); font-size: 13px;
  font-weight: 600; border: none; cursor: pointer;
  transition: background var(--t-fast), box-shadow var(--t-fast), opacity var(--t-fast);
  text-decoration: none; white-space: nowrap; font-family: inherit;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }

.btn-primary   { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger    { background: var(--red); color: #fff; }
.btn-danger:hover { opacity: .9; }
.btn-ghost     { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm        { padding: 5px 10px; font-size: 12px; }
.btn-icon      { padding: 6px; border-radius: var(--r-md); }

/* ── Form elements ────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--text-2); margin-bottom: 6px;
}
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 8px 12px; font-size: 13px; font-family: inherit;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 11px; color: var(--text-3); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--red); margin-top: 4px; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.card-body { padding: 20px; }
.card-title { font-size: 14px; font-weight: 700; }

/* ── Page header ──────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; gap: 16px; flex-wrap: wrap;
}
.page-title { font-size: 22px; font-weight: 800; color: var(--text); }
.page-subtitle { font-size: 13px; color: var(--text-3); margin-top: 2px; }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600;
}
.badge-blue   { background: #e0e7ff; color: #3730a3; }
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-orange { background: #fef3c7; color: #92400e; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-purple { background: #ede9fe; color: #5b21b6; }
.badge-gray   { background: var(--gray-100); color: var(--gray-600); }
[data-theme="dark"] .badge-blue   { background: #1e1b4b; color: #a5b4fc; }
[data-theme="dark"] .badge-green  { background: #064e3b; color: #6ee7b7; }
[data-theme="dark"] .badge-orange { background: #451a03; color: #fcd34d; }
[data-theme="dark"] .badge-red    { background: #450a0a; color: #fca5a5; }
[data-theme="dark"] .badge-purple { background: #2e1065; color: #c4b5fd; }
[data-theme="dark"] .badge-gray   { background: var(--gray-800); color: var(--gray-400); }
[data-theme="oled"] .badge-blue   { background: #0d0b2e; color: #a5b4fc; }
[data-theme="oled"] .badge-green  { background: #022c22; color: #6ee7b7; }
[data-theme="oled"] .badge-orange { background: #1c0d00; color: #fcd34d; }
[data-theme="oled"] .badge-red    { background: #1c0202; color: #fca5a5; }
[data-theme="oled"] .badge-purple { background: #140b30; color: #c4b5fd; }
[data-theme="oled"] .badge-gray   { background: #1a1a1a; color: var(--gray-400); }

/* ── Calendar ─────────────────────────────────────────────── */
.cal-wrapper { display: flex; flex-direction: column; height: 100%; min-height: 0; gap: 0; }

.cal-toolbar {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 24px 12px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  background: var(--surface); flex-shrink: 0;
}
.cal-nav { display: flex; align-items: center; gap: 4px; }
.cal-nav-btn {
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); color: var(--text-2); cursor: pointer;
  transition: background var(--t-fast); font-size: 14px;
}
.cal-nav-btn:hover { background: var(--bg); }
.cal-title { font-size: 17px; font-weight: 800; min-width: 160px; text-align: center; }
.cal-today-btn {
  padding: 5px 12px; border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); font-size: 12px; font-weight: 600; cursor: pointer;
  color: var(--text-2); transition: background var(--t-fast);
}
.cal-today-btn:hover { background: var(--bg); }
.cal-view-tabs { display: flex; gap: 2px; margin-left: auto; }
.cal-view-tab { padding: 5px 12px; border-radius: var(--r-md); font-size: 12px; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-3);
  cursor: pointer; transition: all var(--t-fast); display: flex; align-items: center; gap: 5px;
}
.cal-view-tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.cal-view-tab-icon { display: none; }
.cal-user-filter {
  padding: 5px 10px; border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); font-size: 12px; color: var(--text); font-family: inherit;
  cursor: pointer;
}

.cal-grid { flex: 1; overflow: auto; min-height: 0; }

/* Month view */
.cal-month { display: grid; grid-template-columns: repeat(7,1fr); height: 100%; }
.cal-day-header {
  padding: 8px 0; text-align: center; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--text-3);
  border-bottom: 1px solid var(--border); background: var(--surface-2);
  border-right: 1px solid var(--border);
}
.cal-day-header:last-child { border-right: none; }
.cal-cell {
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  padding: 6px; min-height: 100px; cursor: pointer; position: relative;
  transition: background var(--t-fast);
}
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell:hover { background: var(--surface-2); }
.cal-cell.other-month { opacity: .4; }
.cal-cell.today .cal-cell-date {
  background: var(--brand); color: #fff; border-radius: 50%;
  width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
}
.cal-cell-date { font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; }
.cal-shift-chip {
  font-size: 10px; padding: 2px 6px; border-radius: 4px; margin-bottom: 2px;
  cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-weight: 600; color: #fff; max-width: 100%;
  transition: opacity var(--t-fast);
}
.cal-shift-chip:hover { opacity: .85; }
.cal-shift-chip.is-off { opacity: .7; font-style: italic; }
.cal-shift-chip.is-oncall {
  outline: 2px dashed rgba(255,255,255,0.6);
  outline-offset: -2px;
}
.cal-week-shift-card.is-oncall {
  outline: 2px dashed rgba(255,255,255,0.5);
  outline-offset: -2px;
}

/* ── Task assignment banners ─────────────────────────────────────────────────── */
.cal-task-banner {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 5px;
  border-radius: 3px;
  margin-bottom: 2px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: default;
}
.cal-task-banner .task-banner-user { opacity: .7; font-weight: 500; }
.cal-task-banner.clickable { cursor: pointer; }
.cal-task-banner.clickable:hover { filter: brightness(1.1); }
.cal-task-banner.task-banner-empty {
  background: transparent !important;
  border-left: 2px dashed var(--border) !important;
  color: var(--text-3) !important;
  font-style: italic;
}
.cal-task-banner.task-banner-empty:hover {
  border-color: var(--brand) !important;
  color: var(--brand) !important;
}
.cal-task-banner.week-task-banner {
  font-size: 11px;
  padding: 3px 6px;
}

/* Week view */
.cal-week {
  display: grid; grid-template-columns: 60px repeat(7,1fr);
  min-height: 100%; border-collapse: collapse;
}
.cal-week-header {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  grid-column: 1 / -1; display: contents;
}
.cal-week-time-col { border-right: 1px solid var(--border); }
.cal-week-day-col {
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  min-height: 600px;
}
.cal-week-day-col:last-child { border-right: none; }
.cal-week-day-header {
  padding: 10px 6px; text-align: center; border-bottom: 1px solid var(--border);
  background: var(--surface-2); position: sticky; top: 0; z-index: 5;
}
.cal-week-day-header .day-name { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; }
.cal-week-day-header .day-num {
  font-size: 20px; font-weight: 800; color: var(--text); margin-top: 2px;
}
.cal-week-day-header.today .day-num {
  width: 32px; height: 32px; background: var(--brand); color: #fff; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; margin: 2px auto 0;
}
.cal-week-shifts { padding: 4px; flex: 1; }
.cal-week-shift-card {
  border-radius: var(--r-md); padding: 6px 8px; margin-bottom: 4px;
  font-size: 11px; color: #fff; cursor: pointer;
  transition: opacity var(--t-fast);
}
.cal-week-shift-card:hover { opacity: .85; }
.cal-week-shift-card .shift-loc { font-weight: 700; margin-bottom: 1px; }
.cal-week-shift-card .shift-time { opacity: .85; }
.cal-week-shift-card .shift-notes { opacity: .8; margin-top: 2px; font-style: italic; }

/* ── Shift modal / drawer ─────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 300; display: flex; align-items: center; justify-content: center;
  padding: 16px; opacity: 0; pointer-events: none;
  transition: opacity var(--t-base);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface); border-radius: var(--r-xl);
  width: 100%; max-width: 500px;
  max-height: min(90vh, 900px);
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: translateY(16px) scale(.98);
  transition: transform var(--t-base);
  overflow: hidden;
}
.modal-overlay.open .modal { transform: none; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 0; flex-shrink: 0;
}
.modal-title { font-size: 16px; font-weight: 800; }
.modal-close {
  width: 32px; height: 32px; border: none; background: var(--bg);
  border-radius: var(--r-md); cursor: pointer; display: flex;
  align-items: center; justify-content: center; color: var(--text-3);
  transition: background var(--t-fast);
}
.modal-close:hover { background: var(--border); }
/* Modal body: scrolls independently, header/footer stay pinned */
.modal-body { flex: 1; overflow-y: auto; min-height: 0; padding: 20px 24px; }
.modal-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 0 24px 20px;
}

/* ── Colour picker ────────────────────────────────────────── */
.colour-picker {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.colour-swatch {
  width: 24px; height: 24px; border-radius: 50%; cursor: pointer; border: 2px solid transparent;
  transition: transform var(--t-fast), border-color var(--t-fast);
}
.colour-swatch:hover { transform: scale(1.15); }
.colour-swatch.selected { border-color: var(--text); transform: scale(1.15); }

/* ── Templates ────────────────────────────────────────────── */
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px,1fr)); gap: 16px; }
.template-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden;
  transition: box-shadow var(--t-fast);
}
.template-card:hover { box-shadow: var(--shadow-md); }
.template-card-header {
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.template-card-title { font-size: 14px; font-weight: 700; }
.template-days-row {
  display: grid; grid-template-columns: repeat(7,1fr); gap: 0;
}
.template-day-cell {
  padding: 8px 4px; text-align: center; border-right: 1px solid var(--border);
  font-size: 10px; border-bottom: 1px solid var(--border);
}
.template-day-cell:last-child { border-right: none; }
.template-day-cell .day-abbr { font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.template-day-cell .day-loc { font-size: 9px; color: var(--text-2); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.template-day-cell .day-swatch { width: 8px; height: 8px; border-radius: 50%; margin: 3px auto 0; }

/* ── Day editor (template) ────────────────────────────────── */
.day-editor-wrap {
  overflow-x: auto; margin: 0 -4px; padding: 0 4px 4px;
}
.day-editor-grid {
  display: grid; grid-template-columns: repeat(7, minmax(130px, 1fr)); gap: 8px;
  min-width: 910px;
}
.day-editor-cell {
  border: 1px solid var(--border); border-radius: var(--r-md); overflow: visible;
  transition: box-shadow var(--t-fast);
}
.day-editor-cell.day-excluded {
  opacity: .6;
  border-style: dashed;
}
.day-excluded-body {
  padding: 16px 8px;
  text-align: center;
  font-size: 11px;
  color: var(--text-3);
  font-style: italic;
}
/* clip only the body content, not the header button */
.day-editor-cell-body {
  padding: 8px;
  border-radius: 0 0 var(--r-md) var(--r-md);
  overflow: hidden;
}
.day-editor-cell-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 4px 0 8px; height: 32px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--border); border-radius: var(--r-md) var(--r-md) 0 0;
  background: var(--surface-2); color: var(--text-3);
  position: relative;
}
.day-editor-cell-header .day-label { flex: 1; text-align: center; }

/* Copy button — sits in the day header */
.day-copy-btn {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 5px;
  background: none; border: none; cursor: pointer;
  color: var(--text-3); transition: background var(--t-fast), color var(--t-fast);
}
.day-copy-btn:hover { background: var(--surface-3); color: var(--text-1); }
.day-copy-btn.active { background: var(--primary); color: #fff; }
.day-copy-btn svg { display: block; }

/* Exclude button — sits in the day header next to copy */
.day-exclude-btn {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 5px;
  background: none; border: none; cursor: pointer;
  color: var(--text-3); transition: background var(--t-fast), color var(--t-fast);
}
.day-exclude-btn:hover { background: var(--red-subtle, rgba(220,38,38,.1)); color: var(--red); }
.day-exclude-btn.excluded { color: var(--green, #16a34a); }
.day-exclude-btn.excluded:hover { background: var(--green-subtle, rgba(22,163,74,.1)); color: var(--green, #16a34a); }
.day-exclude-btn svg { display: block; }

/* Inline copy bar — appears between heading and day grid */
.copy-day-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px; margin-bottom: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-md); font-size: 12px;
}
.copy-day-bar-label { color: var(--text-2); white-space: nowrap; font-weight: 500; }
.copy-day-bar-pills { display: flex; gap: 4px; flex-wrap: wrap; }
.copy-day-pill {
  padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface-1);
  color: var(--text-2); cursor: pointer; transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.copy-day-pill:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.copy-day-pill.all { margin-left: 4px; }
.copy-day-bar-close {
  margin-left: auto; background: none; border: none; cursor: pointer;
  color: var(--text-3); font-size: 16px; line-height: 1; padding: 0 2px;
  transition: color var(--t-fast);
}
.copy-day-bar-close:hover { color: var(--text-1); }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; padding: 10px 12px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; color: var(--text-3);
  border-bottom: 2px solid var(--border); background: var(--surface-2); white-space: nowrap;
}
td { padding: 10px 12px; font-size: 13px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); }

/* ── Alerts / toast ───────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 500;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--r-lg);
  background: var(--gray-900); color: #fff;
  box-shadow: var(--shadow-lg); font-size: 13px; font-weight: 500;
  min-width: 240px; max-width: 360px;
  animation: slideUp .2s ease forwards;
}
.toast.success { background: #065f46; }
.toast.error   { background: #991b1b; }
.toast.warning { background: #92400e; }
@keyframes spin { to { transform: rotate(360deg); } }

@keyframes slideUp {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 64px 24px; text-align: center; color: var(--text-3); gap: 12px;
}
.empty-state svg { width: 48px; height: 48px; opacity: .4; }
.empty-state h3 { color: var(--text-2); font-size: 15px; }

/* User dropdown header — name + email block */
.dropdown-user-header {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.dropdown-user-name { font-size: 14px; font-weight: 700; color: var(--text); }
.dropdown-user-email { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* ── Dropdown ─────────────────────────────────────────────── */
.dropdown-wrapper { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 4px); min-width: 200px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  z-index: 400; padding: 4px; display: none;
}
.dropdown-menu.open { display: flex; flex-direction: column; }
.dropdown-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: var(--r-md);
  font-size: 13px; color: var(--text-2); cursor: pointer;
  border: none; background: transparent; width: 100%; text-align: left;
  transition: background var(--t-fast); text-decoration: none;
}
.dropdown-item:hover { background: var(--bg); color: var(--text); }
.dropdown-item.danger { color: var(--red); }
.dropdown-item.danger:hover { background: var(--red-light); }
.dropdown-sep { height: 1px; background: var(--border); margin: 4px 0; flex-shrink: 0; }

/* ── Semantic light colour dark overrides ─────────────────── */
[data-theme="dark"],
[data-theme="oled"] {
  --red-light:    rgba(220, 38, 38, .15);
  --green-light:  rgba(5, 150, 105, .15);
  --orange-light: rgba(217, 119, 6, .15);
}
.toggle {
  position: relative; display: inline-block; width: 40px; height: 22px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; background: var(--gray-300); border-radius: 22px;
  cursor: pointer; transition: background var(--t-base);
}
.toggle-slider::before {
  content: ''; position: absolute; width: 16px; height: 16px;
  left: 3px; top: 3px; background: #fff; border-radius: 50%;
  transition: transform var(--t-base);
}
.toggle input:checked + .toggle-slider { background: var(--brand); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ── Mobile nav dropdown — hidden globally, shown via JS toggle on mobile only */
.mobile-nav-dropdown { display: none; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Hide desktop topbar nav, show hamburger */
  .topbar-nav { display: none; }
  .topbar-menu-btn { display: flex; }
  /* Hide version badge on mobile — too much clutter */
  .version-badge { display: none; }
  /* Hide the standalone settings icon on mobile (it's in the hamburger menu) */
  a.topbar-icon-btn { display: none; }
  /* Hide theme picker icon on mobile (it's in the hamburger menu) */
  #themeDropdown { display: none; }

  /* Mobile nav dropdown (hamburger) */
  .mobile-nav-dropdown {
    display: none;
    position: fixed;
    top: var(--topbar-h);
    left: 0; right: 0;
    background: var(--topbar-bg);
    z-index: 300;
    flex-direction: column;
    padding: 8px 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    box-shadow: 0 8px 24px rgba(0,0,0,.3);
  }
  .mobile-nav-dropdown.open { display: flex; }
  .mobile-nav-dropdown .topbar-nav-btn {
    padding: 11px 12px;
    border-radius: var(--r-md);
    font-size: 14px;
    color: rgba(255,255,255,.8);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
    border: none;
    background: transparent;
    cursor: pointer;
    width: 100%;
  }
  .mobile-nav-dropdown .topbar-nav-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
  .mobile-nav-dropdown .topbar-nav-btn.active { color: #fff; background: rgba(255,255,255,.12); }
  .mobile-nav-dropdown .topbar-nav-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
  .mobile-nav-dropdown .mobile-nav-sep { height: 1px; background: rgba(255,255,255,.1); margin: 6px 0; }
  .mobile-nav-dropdown .mobile-nav-label {
    padding: 4px 12px 2px;
    font-size: 10px; font-weight: 700; letter-spacing: .08em;
    text-transform: uppercase; color: rgba(255,255,255,.4);
  }
  /* User header at top of mobile menu */
  .mobile-nav-user-header {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px 10px;
  }

  .page-content { padding: 16px; }
  .cal-toolbar { padding: 12px 16px 8px; }
  .cal-view-tabs .cal-view-tab span { display: none; }
  .cal-view-tabs .cal-view-tab-icon { display: inline-block; }
  .cal-title { font-size: 14px; min-width: 120px; }
  .template-grid { grid-template-columns: 1fr; }
  .modal { max-width: 100%; margin: 0; border-radius: var(--r-xl) var(--r-xl) 0 0; align-self: flex-end; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .page-header { flex-direction: column; align-items: flex-start; }
  /* Settings tabs: scroll horizontally on small screens, labels remain visible */
  .settings-tab { padding: 10px 10px; font-size: 12px; }
}

@media (max-width: 480px) {
  /* Compact shift chips on small screens — show colour bar + short name */
  .cal-month .cal-shift-chip {
    font-size: 9px;
    padding: 2px 4px;
    border-radius: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    line-height: 1.4;
  }
  .cal-month .cal-cell { min-height: 64px; padding: 4px; }
  .cal-month .cal-cell-date { font-size: 11px; width: 20px; height: 20px; }

  /* Toast — full width on small screens */
  .toast-container { left: 12px; right: 12px; bottom: 16px; }
  .toast { min-width: 0; max-width: 100%; width: 100%; }

  /* Env badge — smaller, doesn't overlap toast */
  .env-badge { bottom: 64px; right: 12px; }
}

/* ── Holiday cell tints & labels ───────────────────────────────────────────── */
/* Warm amber/honey tint — completely outside the user's shift colour palette.
   pointer-events:none on all holiday elements so they can never be confused
   with or accidentally interact with shift chips. */

/* Month view — cell background tint */
.cal-cell.is-holiday {
  background: rgba(180, 130, 30, 0.07);
}
.cal-cell.is-holiday:hover {
  background: rgba(180, 130, 30, 0.12);
}
[data-theme="dark"] .cal-cell.is-holiday,
[data-theme="oled"] .cal-cell.is-holiday {
  background: rgba(251, 191, 36, 0.08);
}
[data-theme="dark"] .cal-cell.is-holiday:hover,
[data-theme="oled"] .cal-cell.is-holiday:hover {
  background: rgba(251, 191, 36, 0.13);
}

/* Week view — day column tint */
.cal-week-day-col.is-holiday {
  background: rgba(180, 130, 30, 0.06);
}
[data-theme="dark"] .cal-week-day-col.is-holiday,
[data-theme="oled"] .cal-week-day-col.is-holiday {
  background: rgba(251, 191, 36, 0.07);
}

/* Week view — header tint for holiday days */
.cal-week-day-header.is-holiday {
  background: rgba(180, 130, 30, 0.1);
}
[data-theme="dark"] .cal-week-day-header.is-holiday,
[data-theme="oled"] .cal-week-day-header.is-holiday {
  background: rgba(251, 191, 36, 0.1);
}

/* Holiday label — pinned strip, non-interactive in every way */
.cal-holiday-label {
  font-size: 9px;
  font-weight: 600;
  color: #92650a;
  letter-spacing: 0.01em;
  line-height: 1.4;
  padding: 1px 3px 2px;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  pointer-events: none;
  user-select: none;
  cursor: default;
  border-left: 2px solid rgba(180, 130, 30, 0.5);
}
[data-theme="dark"] .cal-holiday-label,
[data-theme="oled"] .cal-holiday-label {
  color: #fbbf24;
  border-left-color: rgba(251, 191, 36, 0.4);
}

/* Week view holiday label — slightly larger, same non-interactive rules */
.cal-holiday-label.week-holiday-label {
  font-size: 10px;
  padding: 3px 6px 3px 5px;
  margin-bottom: 6px;
  background: rgba(180, 130, 30, 0.08);
  border-radius: 0 3px 3px 0;
  border-left-width: 3px;
}
[data-theme="dark"] .cal-holiday-label.week-holiday-label,
[data-theme="oled"] .cal-holiday-label.week-holiday-label {
  background: rgba(251, 191, 36, 0.08);
}

/* ── Week number gutter ────────────────────────────────────────────────────── */
.cal-month.has-weeknums {
  grid-template-columns: 28px repeat(7, 1fr);
}
.cal-wknum-header {
  background: var(--surface-2); border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.cal-wknum {
  background: var(--surface-2); border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border); display: flex; align-items: flex-start;
  justify-content: center; padding-top: 6px;
  font-size: 10px; font-weight: 600; color: var(--text-3); font-family: var(--mono);
}

/* ── Compact chips mode ────────────────────────────────────────────────────── */
.cal-month.compact-chips .cal-shift-chip {
  font-size: 9px; padding: 1px 4px; border-radius: 3px;
}
.cal-month.compact-chips .cal-holiday-label {
  font-size: 8px; padding: 0 2px 1px;
}

/* ── Copy/paste ────────────────────────────────────────────────────────────── */
.cal-cell.can-paste,
.cal-week-day-col.can-paste {
  background: color-mix(in srgb, var(--brand) 6%, var(--surface));
  outline: 2px dashed color-mix(in srgb, var(--brand) 50%, transparent);
  outline-offset: -2px;
}
.cal-paste-hint {
  font-size: 10px; font-weight: 600; color: var(--brand);
  background: var(--brand-light); border: 1px dashed var(--brand);
  border-radius: 3px; padding: 2px 5px; margin-top: 2px;
  cursor: pointer; text-align: center;
  transition: background var(--t-fast);
}
.cal-paste-hint:hover { background: color-mix(in srgb, var(--brand) 18%, transparent); }
.cal-copy-hint {
  display: flex; align-items: center; gap: 6px;
  margin-left: auto; padding: 4px 10px;
  background: var(--brand-light); border: 1px solid var(--brand);
  border-radius: var(--r-md); font-size: 12px; font-weight: 500;
  color: var(--brand); white-space: nowrap;
}

/* ── Right-click context menu ─────────────────────────────────────────────── */
.cal-context-menu {
  position: fixed; z-index: 9999;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: 0 8px 24px rgba(0,0,0,.15);
  padding: 4px; min-width: 160px;
  animation: ctx-in 80ms ease;
}
@keyframes ctx-in { from { opacity:0; transform:scale(.96) } to { opacity:1; transform:scale(1) } }
.ctx-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 7px 10px; border: none; background: none; cursor: pointer;
  font-family: var(--font); font-size: 13px; font-weight: 500;
  color: var(--text); border-radius: var(--r-md); text-align: left;
  transition: background var(--t-fast);
}
.ctx-item:hover { background: var(--surface-2); }
.ctx-item.ctx-danger { color: var(--red); }
.ctx-item.ctx-danger:hover { background: var(--red-light); }
.ctx-sep { height: 1px; background: var(--border); margin: 3px 6px; }

/* ── brand-light variable fallback (if not defined in older builds) ────────── */
:root { --brand-light: rgba(79,70,229,.1); }
[data-theme="dark"]  { --brand-light: rgba(99,102,241,.15); }
[data-theme="oled"]  { --brand-light: rgba(99,102,241,.12); }

/* ── Preferences panel ─────────────────────────────────────────────────────── */
.pref-choice-btn {
  padding: 5px 14px; border-radius: var(--r-md); font-size: 12px; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-3);
  cursor: pointer; transition: all var(--t-fast); font-family: var(--font);
}
.pref-choice-btn:hover { border-color: var(--brand); color: var(--brand); }
.pref-choice-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.holiday-set-row:hover { background: var(--surface-2) !important; }
