/* ============================================================
   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;

  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --mobile-ui-clearance: 0px;
}

/* ── 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%;
  overflow: hidden;
  overscroll-behavior: none;
  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; min-height: 100vh; height: 100vh; height: 100dvh; 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; padding-bottom: calc(24px + var(--safe-bottom)); 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-img { width: 28px; height: 28px; border-radius: 8px; object-fit: cover; display: block; }
.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: 900;
  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;
  min-width: 0;
  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[type="date"],
.form-input[type="time"] {
  min-width: 0;
}
.modal-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.modal-grid-2 > * {
  min-width: 0;
}
.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; }

/* ── Collapsible settings sections ───────────────────────── */
.section-collapse-btn {
  background: none; border: none; cursor: pointer; padding: 2px; margin-left: auto;
  color: var(--text-3); border-radius: var(--r-sm); flex-shrink: 0;
  display: flex; align-items: center; transition: color .15s;
}
.section-collapse-btn:hover { color: var(--text-1); }
.section-collapse-btn svg { transition: transform .2s ease; }
.section-collapse-rotated svg { transform: rotate(-90deg); }
.section-collapsed .card-body { display: none; }
.section-collapsed .card-header { border-bottom: none; }

/* ── 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;
  position: relative;
  height: 100%;
  min-height: 0;
  gap: 0;
  margin: 14px;
}
.cal-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--brand) 8%, #ffffff) 0%, color-mix(in srgb, var(--brand) 2%, #ffffff) 36%, var(--surface) 78%),
    var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.08);
  overflow: hidden;
}
[data-theme="dark"] .cal-main,
[data-theme="oled"] .cal-main {
  background: var(--surface);
}

.cal-toolbar {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 24px 12px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--brand) 18%, transparent) 0%, color-mix(in srgb, var(--brand) 6%, transparent) 58%, transparent 88%),
    var(--surface);
  flex-shrink: 0;
}
[data-theme="dark"] .cal-toolbar,
[data-theme="oled"] .cal-toolbar {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--brand) 16%, transparent) 0%, transparent 72%),
    var(--surface);
}
.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-today-btn--away { border-color: var(--brand); color: var(--brand); }
.cal-today-btn--away:hover { background: var(--brand-light); }
.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-toolbar-end {
  margin-left: auto; display: flex; align-items: center; gap: 4px;
}
.cal-hours-stat {
  display: inline-flex; align-items: center; height: 32px;
  padding: 0 10px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--r-md); font-size: 12px; font-weight: 600;
  color: var(--text-2); white-space: nowrap;
}
.cal-toolbar-sep {
  width: 1px; height: 20px; background: var(--border); flex-shrink: 0; margin: 0 2px;
}
.cal-live-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #10b981; flex-shrink: 0;
}

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

/* 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.selected-day {
  box-shadow: inset 0 0 0 2px var(--brand);
  background: color-mix(in srgb, var(--brand) 10%, var(--surface));
}
.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-day-summary {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--text-3);
  margin-bottom: 4px;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  max-width: 100%;
}
.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;
}
/* ── 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;
}
.cal-task-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 2px;
}
.cal-task-summary {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-2);
  padding: 2px 7px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface-2) 78%, var(--brand) 22%);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  margin-bottom: 2px;
  margin-top: -1px;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-task-summary.clickable { cursor: pointer; }
.cal-task-summary.clickable:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: color-mix(in srgb, var(--brand-light) 70%, var(--surface) 30%);
}
.cal-task-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0 0 3px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.cal-task-dots.clickable { cursor: pointer; }
.cal-task-dots.clickable:hover {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand-light) 55%, var(--surface) 45%);
}
.cal-task-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.cal-task-dot-row {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.cal-task-dot-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-2);
  letter-spacing: .01em;
}
.week-task-dots {
  margin-top: 1px;
  margin-bottom: 1px;
}

/* ── Week view — time grid ────────────────────────────────────────────────────── */

/* Outer wrapper: header row + scrollable body below */
.cal-week-outer {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  border-top: 1px solid var(--border);
}

/* Sticky header row — time gutter + day headers */
.cal-week-header-row {
  display: grid;
  grid-template-columns: 52px repeat(7, 1fr);
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.cal-week-header-gutter {
  border-right: 1px solid var(--border);
}
.cal-week-day-header {
  padding: 8px 6px; text-align: center;
  border-right: 1px solid var(--border);
}
.cal-week-day-header:last-child { border-right: none; }
.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-day-header.is-holiday .day-num { color: #b45309; }
[data-theme="dark"] .cal-week-day-header.is-holiday .day-num,
[data-theme="oled"] .cal-week-day-header.is-holiday .day-num { color: #fbbf24; }

/* Scrollable body: time gutter + 7 day columns */
.cal-week-body {
  display: grid;
  grid-template-columns: 52px repeat(7, 1fr);
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
}

/* Time gutter */
.cal-week-time-gutter {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 5;
}
.cal-week-hour-label {
  height: 60px;
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 2px 6px 0;
  font-size: 10px;
  color: var(--text-3);
  font-weight: 600;
  pointer-events: none;
}
.cal-week-hour-label:first-child { visibility: hidden; } /* midnight label hidden */

/* Day columns */
.cal-week-day-col {
  border-right: 1px solid var(--border);
  position: relative;
  cursor: pointer;
}
.cal-week-day-col.selected-day > .cal-week-col-inner {
  box-shadow: inset 0 0 0 2px var(--brand);
  background: color-mix(in srgb, var(--brand) 8%, transparent);
}
.cal-week-day-col:last-child { border-right: none; }
.cal-week-day-col.is-holiday { background: rgba(180,130,30,.04); }
[data-theme="dark"] .cal-week-day-col.is-holiday,
[data-theme="oled"] .cal-week-day-col.is-holiday { background: rgba(251,191,36,.04); }

/* Hour grid lines inside each day column */
.cal-week-hour-row {
  height: 60px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  pointer-events: none;
}
.cal-week-hour-row:last-child { border-bottom: none; }

/* The inner relative container that holds hour rows + positioned events */
.cal-week-col-inner {
  position: relative;
  height: 1440px; /* 24h × 60px */
}

/* Positioned shift blocks */
.cal-week-shift-card {
  position: absolute;
  left: 3px; right: 3px;
  border-radius: var(--r-md);
  padding: 4px 7px;
  font-size: 11px;
  color: #fff;
  cursor: pointer;
  overflow: hidden;
  transition: opacity var(--t-fast), box-shadow var(--t-fast);
  z-index: 2;
  box-sizing: border-box;
  min-height: 20px;
}
.cal-week-shift-card:hover { opacity: .88; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.cal-week-shift-card.is-oncall {
  outline: 2px dashed rgba(255,255,255,0.5);
  outline-offset: -2px;
}
.cal-week-shift-card .shift-loc { font-weight: 700; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-week-shift-card .shift-time { opacity: .9; font-size: 10px; white-space: nowrap; }
.cal-week-shift-card .shift-notes { opacity: .8; margin-top: 2px; font-size: 10px; font-style: italic; line-height: 1.3; }

/* Drag-and-drop */
.cal-week-shift-card { cursor: grab; user-select: none; }
.cal-week-shift-card.dragging { opacity: .35 !important; cursor: grabbing; }
.cal-week-shift-ghost { border-radius: var(--r-md); padding: 4px 8px; color: #fff; font-size: 12px; font-weight: 600; overflow: hidden; }
.cal-week-day-col.drop-target > .cal-week-col-inner { background: var(--accent-light, rgba(79,70,229,.08)); }
.shift-resize-handle { position: absolute; bottom: 0; left: 0; right: 0; height: 8px; cursor: ns-resize; border-radius: 0 0 var(--r-md) var(--r-md); }
.shift-resize-handle:hover { background: rgba(255,255,255,.3); }

/* Keyboard shortcut key badges */
kbd.kbd-key { display:inline-flex;align-items:center;justify-content:center;padding:2px 8px;background:var(--surface-2);border:1px solid var(--border);border-radius:5px;font-family:inherit;font-size:12px;font-weight:600;color:var(--text-1);white-space:nowrap; }

/* All-day / no-time shifts — float at top as chips */
.cal-week-allday-area {
  padding: 4px 3px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-bottom: 1px solid var(--border);
}
.cal-week-allday-chip {
  border-radius: var(--r-sm);
  padding: 3px 7px;
  font-size: 11px;
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
  transition: opacity var(--t-fast);
}
.cal-week-allday-chip:hover { opacity: .85; }

/* Paste hint */
.cal-week-paste-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--text-3);
  pointer-events: none;
  z-index: 1;
}

/* Current time indicator */
.cal-week-now-line {
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: var(--brand);
  z-index: 4;
  pointer-events: none;
}
.cal-week-now-line::before {
  content: '';
  position: absolute;
  left: -4px;
  top: -4px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--brand);
}

/* ── 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: calc(16px + var(--safe-top)) calc(16px + var(--safe-right)) calc(16px + var(--safe-bottom)) calc(16px + var(--safe-left));
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-base);
  touch-action: pan-y;
}
.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--readonly .form-input,
.modal--readonly .form-select,
.modal--readonly .form-textarea,
.modal--readonly input[type="checkbox"] { pointer-events: none; opacity: .7; }
.modal--readonly .btn-primary { display: 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; overflow-x: hidden; min-height: 0; padding: 20px 24px; -webkit-overflow-scrolling: touch; }
.modal-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 0 24px 20px;
  flex-wrap: wrap;
}

/* ── 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;
  background: var(--swatch-colour, transparent);
  transition: transform var(--t-fast), border-color var(--t-fast);
}
.colour-swatch.is-none,
.inline-colour-swatch.is-none {
  background:
    linear-gradient(135deg, transparent 0 43%, rgba(220, 38, 38, .85) 44%, rgba(220, 38, 38, .85) 56%, transparent 57%),
    repeating-linear-gradient(-45deg, rgba(148, 163, 184, .12) 0 4px, var(--surface-2) 4px 8px);
}
.colour-swatch.is-none { border-color: var(--border); }
.colour-swatch:hover { transform: scale(1.15); }
.colour-swatch.selected { border-color: var(--text); transform: scale(1.15); }
.inline-colour-swatch {
  display: inline-block;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--swatch-colour, transparent);
}
.inline-colour-swatch.is-round { border-radius: 50%; }

/* ── 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 { display: block; 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 ────────────────────────────────────────────── */
/* ── Week view scroll wrapper (mobile horizontal scroll) ────────────────────── */
.cal-week-scroll-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.cal-week-scroll-wrap .cal-week-outer {
  min-width: 560px;
}

@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;
  }

  :root {
    --mobile-ui-clearance: 40px;
  }
  .standalone-app {
    --mobile-ui-clearance: 72px;
  }
  .page-content { padding: 16px; padding-bottom: calc(16px + var(--mobile-ui-clearance) + var(--safe-bottom)); }
  .cal-grid {
    padding-bottom: calc(16px + var(--mobile-ui-clearance) + var(--safe-bottom));
    scroll-padding-bottom: calc(16px + var(--mobile-ui-clearance) + var(--safe-bottom));
  }
  .cal-toolbar { padding: 12px 16px 8px; }
  .cal-wrapper { margin: 10px; }
  .cal-main { border-radius: 14px; }
  .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 var(--safe-right) 0 var(--safe-left);
  }
  .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; }
  .cal-wrapper { margin: 8px; }
  .cal-main { border-radius: 12px; }

  /* 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 — 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; }

/* ── Quick-add hover indicator on empty month cells ──────── */
.cal-cell.can-add::after {
  content: '+';
  position: absolute;
  bottom: 5px; right: 6px;
  font-size: 16px; font-weight: 300; line-height: 1;
  color: var(--text-3);
  opacity: 0;
  transition: opacity var(--t-fast);
  pointer-events: none;
}
.cal-cell.can-add:hover::after { opacity: .6; }

/* ── +N more badge in month view ─────────────────────────── */
.cal-more-badge {
  font-size: 10px; font-weight: 600;
  color: var(--text-3);
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  display: inline-block;
  margin-top: 1px;
}
.cal-more-badge:hover { background: var(--brand-light); color: var(--brand); border-color: var(--brand); }
.cal-task-more-badge {
  margin-bottom: 2px;
}
.cal-task-more-badge.clickable {
  cursor: pointer;
}

/* ── Print styles ─────────────────────────────────────────── */
@media print {
  /* Hide chrome, keep only the calendar grid */
  .topbar, .cal-toolbar, .modal-overlay,
  .toast-container, .env-badge, .env-topbar-badge,
  #copyWeekBtn, #csvExportBtn, #liveIndicator { display: none !important; }

  html, body { height: auto; overflow: visible; background: #fff; }
  .app-shell { height: auto; overflow: visible; }
  .page-content { overflow: visible; padding: 0; }
  .cal-wrapper { height: auto; overflow: visible; margin: 0; }
  .cal-main { border: none; border-radius: 0; box-shadow: none; }
  .cal-grid { overflow: visible; height: auto; }

  /* Month view: ensure full grid prints */
  .cal-month { height: auto; }
  .cal-cell { min-height: 80px; page-break-inside: avoid; }

  /* Week view: ensure full time grid prints */
  .cal-week-scroll-wrap { overflow: visible; }
  .cal-week-outer { overflow: visible; }
  .cal-week-body { overflow: visible; }

  /* Force light theme colours on print */
  :root {
    --text:     #111827;
    --text-2:   #374151;
    --text-3:   #6b7280;
    --border:   #e5e7eb;
    --bg:       #fff;
    --surface:  #fff;
    --surface-2:#f9fafb;
  }

  /* Add the month/week title at top */
  .cal-title { font-size: 18px; font-weight: 800; display: block !important; margin: 0 0 8px; }

  /* Shift chips render with a border so they're legible on B&W printers */
  .cal-shift-chip, .cal-week-shift-card {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* ── Mobile: bottom-sheet modals ─────────────────────────────────────────────── */
@media (max-width: 640px) {
  .modal-overlay {
    align-items: flex-end;
    padding: 0 var(--safe-right) 0 var(--safe-left);
  }
  .modal {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 92dvh;
    border-radius: 20px 20px 0 0;
    overflow-y: auto;
    overflow-x: hidden;
    touch-action: pan-y;
    margin: 0;
    animation: slideUp .25s cubic-bezier(.32,1,.23,1);
  }
  @keyframes slideUp {
    from { transform: translateY(30%); opacity: 0; }
    to   { transform: translateY(0);   opacity: 1; }
  }
  /* Reduce padding on mobile — 20/24px desktop values are too wide for phone screens */
  .modal-header { padding: 16px 16px 0; }
  .modal-body { max-height: 70dvh; overflow-y: auto; padding: 16px; }
  .modal-footer {
    padding: 0 16px calc(16px + var(--safe-bottom));
  }
  .modal--shift .modal-body .form-input,
  .modal--shift .modal-body .form-select {
    min-height: 44px;
  }
  .modal--shift .form-input[type="date"],
  .modal--shift .form-input[type="time"] {
    line-height: 1.35;
    -webkit-appearance: none;
    appearance: none;
  }
  .modal--shift .form-input[type="date"]::-webkit-date-and-time-value,
  .modal--shift .form-input[type="time"]::-webkit-date-and-time-value {
    min-height: 1.35em;
    text-align: left;
  }
  .modal--shift .form-input[type="date"]::-webkit-datetime-edit,
  .modal--shift .form-input[type="time"]::-webkit-datetime-edit {
    display: inline-flex;
    align-items: center;
    min-height: 1.35em;
    padding: 0;
  }
  .modal--shift .modal-footer {
    flex-wrap: nowrap;
    gap: 6px;
  }
  .modal--shift .modal-footer .btn {
    flex: 0 0 auto;
    justify-content: center;
    min-width: 0;
    padding-inline: 10px;
    font-size: 12px;
  }
  .toast-container { bottom: calc(16px + var(--safe-bottom)); }
  .env-badge { bottom: calc(64px + var(--safe-bottom)); }
}

@media (max-width: 390px) {
  .modal--shift .modal-grid-2 {
    grid-template-columns: 1fr;
  }
}
