/* ============================================================
   MediShift – Stylesheet
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* --- Color: unchanged, this palette is working --- */
  --bg:        #0f172a;
  --bg2:       rgba(30, 41, 59, 0.7);
  --bg3:       rgba(51, 65, 85, 0.6);
  --bg4:       rgba(71, 85, 105, 0.8);
  --border:    rgba(148, 163, 184, 0.15);
  --text:      #f8fafc;
  --text2:     #cbd5e1;
  --text3:     #94a3b8;
  --accent:    #38bdf8;
  --accent2:   #0284c7;
  --green:     #10b981;
  --yellow:    #eab308;
  --red:       #ef4444;
  --orange:    #f97316;
  --purple:    #a855f7;

  /* --- Semantic financial aliases (Calm Ledger identity) ---
     Same colors as above, but named for what they mean in a money context,
     so financial UI code reads intentionally rather than borrowing "success green". */
  --paid:        var(--green);
  --outstanding: var(--red);
  --partial:     var(--yellow);

  /* --- Type scale: 6 sizes, replaces the ad-hoc values previously in use ---
     xs/sm = meta, labels, table cells. base = default body/buttons.
     lg = card/section titles. xl = page titles. 2xl = hero numbers. */
  --text-xs:   11px;
  --text-sm:   13px;
  --text-base: 15px;
  --text-lg:   18px;
  --text-xl:   24px;
  --text-2xl:  32px;

  /* --- Spacing scale: 4px base unit --- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  /* --- Radius: 3 values --- */
  --radius-sm:   8px;   /* inputs, small buttons, chips */
  --radius-md:   16px;  /* cards, modals — same as old --radius, kept for continuity */
  --radius-full: 999px; /* pills/badges */

  /* --- Shadow: 3 elevation levels --- */
  --shadow-sm: var(--shadow-sm);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.35);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.5); /* = old --shadow */
  --shadow:    var(--shadow-lg);

  --sidebar-w: 240px;
  --radius:    var(--radius-md); /* alias so existing var(--radius) references keep working */
}

html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  font-size: var(--text-base);
  position: relative;
  z-index: 1;
}

/* ── ANIMATED BACKGROUND ── */
.glass-bg {
  position: fixed; top: -50%; left: -50%; width: 200%; height: 200%;
  background: radial-gradient(circle at 50% 50%, rgba(2,132,199,0.15) 0%, rgba(15,23,42,0) 50%);
  z-index: -1; animation: rotateBg 40s linear infinite;
  pointer-events: none;
}
.glass-bg-2 {
  position: fixed; top: -50%; left: -50%; width: 200%; height: 200%;
  background: radial-gradient(circle at 30% 70%, rgba(168,85,247,0.1) 0%, rgba(15,23,42,0) 40%);
  z-index: -1; animation: rotateBg 30s linear infinite reverse;
  pointer-events: none;
}
@keyframes rotateBg { 100% { transform: rotate(360deg); } }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: var(--radius-sm); }

/* ════════════════════════════════════
   SIDEBAR
════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface-deep-60);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  transition: width .3s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
}
.sidebar.collapsed { width: 60px; }
.sidebar.collapsed .logo { display: none; }
.sidebar.collapsed .sidebar-header { justify-content: center; padding: var(--space-4) 0 var(--space-4); }
.sidebar.collapsed .nav-btn { justify-content: center; padding: var(--space-2) 0; }
.sidebar.collapsed .sidebar-section { display: none; }
.sidebar.collapsed .nav-label,
.sidebar.collapsed .logo-title,
.sidebar.collapsed .logo-sub { display: none; }
.sidebar.collapsed .sidebar-toggle { transform: rotate(180deg); }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-4) var(--space-4);
  border-bottom: 1px solid var(--border);
  gap: 8px;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { font-size: var(--text-xl); }
.logo-title { font-size: var(--text-base); font-weight: 700; color: var(--text); }
.logo-sub   { font-size: var(--text-xs); font-weight: 500; color: var(--accent); letter-spacing: 1px; text-transform: uppercase; }

.sidebar-toggle {
  background: none; border: none; color: var(--text2);
  cursor: pointer; font-size: var(--text-lg); padding: var(--space-2) var(--space-2); border-radius: var(--radius-sm);
  transition: background .15s, color .15s, transform .3s;
  line-height: 1;
}
.sidebar-toggle:hover { background: var(--bg3); color: var(--text); }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: var(--space-2);
  gap: 2px;
}
.nav-btn {
  display: flex; align-items: center; gap: 10px;
  padding: var(--space-2) var(--space-3);
  border: none; background: none; color: var(--text2);
  cursor: pointer; border-radius: var(--radius-sm);
  font-size: var(--text-sm); font-weight: 500; text-align: left;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.nav-btn:hover { background: var(--bg3); color: var(--text); }
.nav-btn.active { background: rgba(88,166,255,.12); color: var(--accent); }
.nav-icon { font-size: var(--text-base); flex-shrink: 0; }

.sidebar-section {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.section-title {
  font-size: var(--text-xs); font-weight: 600; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text3); margin-bottom: var(--space-1);
}
.quick-btn {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: var(--space-2) var(--space-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 500;
  text-align: left;
  transition: background .15s, color .15s, border-color .15s;
}
.quick-btn:hover { background: var(--bg4); color: var(--accent); border-color: var(--accent); }

.legend-list { display: flex; flex-direction: column; gap: 6px; }
.legend-item {
  display: flex; align-items: center; gap: 8px;
  font-size: var(--text-sm); color: var(--text2);
}
.legend-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}

.month-stats { display: flex; flex-direction: column; gap: 6px; }
.stat-row {
  display: flex; justify-content: space-between;
  font-size: var(--text-sm); color: var(--text2);
}
.stat-val { font-weight: 600; color: var(--text); }

/* ════════════════════════════════════
   MAIN
════════════════════════════════════ */
.main {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.view {
  display: none;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}
.view.active { display: flex; }

/* ── VIEW HEADER ── */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  background: var(--surface-deep-60);
  backdrop-filter: blur(10px);
  flex-shrink: 0;
}
.view-header-left { display: flex; align-items: center; gap: 12px; }
.view-header-right { display: flex; align-items: center; gap: 10px; }
.cal-title { font-size: var(--text-xl); font-weight: 700; color: var(--text); }
.icon-btn {
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text2); width: 36px; height: 36px;
  border-radius: var(--radius-sm); cursor: pointer; font-size: var(--text-lg);
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--bg4); color: var(--text); }
.today-btn {
  background: var(--accent2); border: none; color: #fff;
  padding: var(--space-2) var(--space-4); border-radius: var(--radius-sm);
  cursor: pointer; font-size: var(--text-sm); font-weight: 600;
  transition: background .15s, opacity .15s;
}
.today-btn:hover { opacity: .85; }
.search-input {
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm);
  font-size: var(--text-sm); outline: none; width: 220px;
  transition: border-color .15s;
}
.search-input:focus { border-color: var(--accent); }

/* ════════════════════════════════════
   CALENDAR GRID
════════════════════════════════════ */
.calendar-grid-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--surface-deep-40);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.cal-day-header {
  padding: var(--space-2) 0;
  text-align: center;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text3);
}
.cal-day-header.weekend { color: var(--accent); }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  flex: 1;
  overflow-y: auto;
  background: var(--border);
  gap: 1px;
}
.cal-cell {
  background: var(--surface-deep-40);
  backdrop-filter: blur(4px);
  min-height: 125px;
  padding: 0;
  cursor: pointer;
  transition: background .12s, transform .12s;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.cal-cell:hover { background: var(--bg3); z-index: 5; transform: scale(1.02); box-shadow: var(--shadow-md); border-radius: var(--radius-sm); }
.cal-cell.other-month { background: var(--surface-deep-20); }
.cal-cell.other-month .cell-date { color: var(--text3); }
.cal-cell.today .cell-date {
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
}
.cal-cell.weekend .cell-date { color: var(--accent); }
.cal-cell.other-month.weekend .cell-date { color: var(--bg4); }

.cell-date {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 10;
  pointer-events: none;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  text-shadow: var(--shadow-sm);
}

.holiday-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 10;
  pointer-events: none;
  font-size: var(--text-xs);
  background: rgba(248,81,73,.85);
  color: #fff;
  border: 1px solid rgba(248,81,73,.5);
  border-radius: var(--radius-sm);
  padding: 1px var(--space-1);
  line-height: 1.3;
  font-weight: 600;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}

/* Booking Slots */
.booking-slot {
  position: absolute;
  left: 4px;
  right: 4px;
  z-index: 2;
  color: #fff;
  padding: var(--space-1) var(--space-2);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 1px;
  cursor: pointer;
  box-sizing: border-box;
  transition: filter .12s, opacity .12s, transform .12s, box-shadow .12s;
  overflow: hidden;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}
.booking-slot:hover {
  filter: brightness(1.1);
  z-index: 3;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.slot-full {
  top: 28px;
  bottom: 4px;
}
.slot-morning {
  top: 28px;
  height: calc(50% - 16px);
}
.slot-afternoon {
  bottom: 4px;
  height: calc(50% - 16px);
}
.slot-split {
  top: 28px;
  bottom: 4px;
}
.slot-split::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--bg);
  transform: translateY(-50%);
  z-index: 5;
}
.slot-practice {
  font-size: var(--text-xs);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.slot-meta {
  font-size: var(--text-xs);
  opacity: 0.95;
  display: flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.booking-slot.slot-tentative {
  opacity: 0.85;
  background-image: repeating-linear-gradient(45deg, rgba(255,255,255,0.05), rgba(255,255,255,0.05) 10px, transparent 10px, transparent 20px);
  border: 1px dashed rgba(255,255,255,0.4);
}
.booking-slot.slot-pending {
  opacity: 0.7;
  background-image: repeating-linear-gradient(-45deg, rgba(0,0,0,0.1), rgba(0,0,0,0.1) 8px, transparent 8px, transparent 16px);
}

.booking-chip {
  font-size: var(--text-xs);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  font-weight: 600;
  color: #fff;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  transition: opacity .12s;
  display: flex;
  align-items: center;
  gap: 3px;
}
.booking-chip:hover { opacity: .8; }
.booking-chip .chip-icon { font-size: var(--text-xs); flex-shrink: 0; }
.chip-tentative { opacity: .7; border: 1px dashed rgba(255,255,255,.4); }
.chip-pending   { opacity: .6; }

/* ════════════════════════════════════
   WEEK VIEW (Horizontal Rows)
════════════════════════════════════ */
.week-grid {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: transparent;
  padding: var(--space-4) var(--space-5);
  overflow-y: auto;
  align-items: flex-start; /* Align short cells to the left */
}

.week-cell {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-2) var(--space-4);
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 16px;
  min-height: 70px;
  cursor: pointer;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), background 0.15s, border-color 0.15s;
  overflow: hidden;
  position: relative;
  box-sizing: border-box;
  width: 320px; /* Collapsed width of horizontal bars (larger to show clinic names by default) */
}

.week-cell.active {
  width: 100%; /* Expand active bar to full width */
}

.week-cell:hover {
  background: var(--bg3);
  border-color: rgba(148, 163, 184, 0.3);
}

.week-cell.today {
  border-color: rgba(56, 189, 248, 0.3);
  background: rgba(56, 189, 248, 0.03);
}

.week-cell.weekend {
  background: rgba(148, 163, 184, 0.02);
}

.week-cell-summary {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.week-date-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  width: 48px;
  height: 48px;
  transition: background 0.3s ease;
  flex-shrink: 0;
}

.week-cell.today .week-date-badge {
  background: var(--accent);
}

.week-cell.today .week-date-badge .week-day-name,
.week-cell.today .week-date-badge .week-date-num {
  color: #fff !important;
}

.week-day-name {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text3);
  line-height: 1.1;
}

.week-cell.weekend .week-day-name {
  color: var(--accent);
}

.week-date-num {
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}

.week-cell-indicators {
  display: flex;
  gap: 6px;
  align-items: center;
  transition: opacity 0.3s ease;
  overflow: hidden;
  max-width: 100%;
}

.week-cell.active .week-cell-indicators {
  opacity: 0;
  pointer-events: none;
}

/* ── WEEK VIEW BOOKING PILLS ── */
.week-booking-pill {
  font-size: var(--text-xs);
  font-weight: 700;
  color: #fff;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  display: inline-block;
  flex-shrink: 0;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.week-booking-pill.blocked {
  background: var(--red) !important;
}

.week-cell-details {
  display: flex;
  flex-direction: row;
  gap: 12px;
  align-items: center;
  flex: 1;
  width: 0;
  opacity: 0;
  pointer-events: none;
  overflow-x: auto;
  overflow-y: hidden;
  margin-left: 0;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s, margin-left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  padding: var(--space-1) 2px;
  scrollbar-width: none; /* Hide scrollbar on Firefox */
}

.week-cell-details::-webkit-scrollbar {
  display: none; /* Hide scrollbar on Chrome/Safari */
}

.week-cell.active .week-cell-details {
  width: 100%;
  opacity: 1;
  pointer-events: auto;
  margin-left: var(--space-3);
}

.week-booking-card-horizontal {
  background: var(--surface-card-80);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 160px;
  max-width: 220px;
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.week-booking-card-horizontal:hover {
  border-color: var(--accent);
  background: var(--bg4);
  transform: translateY(-1px);
}

.week-booking-card-horizontal.wbc-blocked {
  background: rgba(239, 68, 68, 0.05);
  border-color: rgba(239, 68, 68, 0.15);
}

.week-booking-card-horizontal.wbc-blocked:hover {
  border-color: var(--red);
  background: rgba(239, 68, 68, 0.1);
}

.week-add-btn-horizontal:hover {
  border-color: var(--accent) !important;
  color: var(--accent) !important;
}

.week-cell.cell-blocked {
  border-left: 3px solid var(--red) !important;
}

.week-cell.cell-done {
  border-left: 3px solid var(--green) !important;
}

.cal-cell.cell-done {
  border-left: 3px solid var(--green) !important;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(16, 185, 129, 0.03) 100%) !important;
}

.cal-cell.cell-done:hover {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.16) 0%, rgba(16, 185, 129, 0.05) 100%) !important;
  border-color: rgba(16, 185, 129, 0.35) !important;
  border-left-color: var(--green) !important;
}

.cal-cell.cell-done .cell-date {
  color: #a7f3d0 !important;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.done-badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: var(--green);
  color: #fff;
  border-radius: 50%;
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 700;
  box-shadow: var(--shadow-sm);
  pointer-events: none;
  z-index: 10;
}

/* ════════════════════════════════════
   BOOKINGS LIST
════════════════════════════════════ */
.bookings-list { flex: 1; overflow-y: auto; padding: var(--space-4) var(--space-5); display: flex; flex-direction: column; gap: 12px; }
.booking-card {
  background: var(--bg2);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4) var(--space-4);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color .2s, background .2s, transform .2s, box-shadow .2s;
  cursor: pointer;
}
.booking-card:hover { border-color: var(--accent); background: var(--bg3); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.booking-card-bar { width: 5px; border-radius: var(--radius-sm); align-self: stretch; flex-shrink: 0; }
.booking-card-info { flex: 1; min-width: 0; }
.booking-card-practice { font-size: var(--text-base); font-weight: 700; color: var(--text); }
.booking-card-date { font-size: var(--text-sm); color: var(--text2); margin-top: 3px; }
.booking-card-notes { font-size: var(--text-sm); color: var(--text3); margin-top: var(--space-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.booking-card-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.status-badge {
  font-size: var(--text-xs); font-weight: 700; padding: var(--space-1) var(--space-2); border-radius: var(--radius-full);
  text-transform: uppercase; letter-spacing: .5px;
}
.status-confirmed  { background: rgba(16,185,129,.15); color: var(--green); }
.status-tentative  { background: rgba(234,179,8,.15); color: var(--yellow); }
.status-pending    { background: rgba(56,189,248,.15); color: var(--accent); }
.inv-paid          { background: rgba(16,185,129,.15); color: var(--green); }
.inv-invoiced      { background: rgba(16,185,129,.15); color: var(--green); }
.inv-sent          { background: rgba(168,85,247,.15); color: var(--purple); }
.inv-uninvoiced    { background: rgba(249,115,22,.15); color: var(--orange); }

.unchecked-row {
  opacity: 0.4 !important;
  transition: opacity 0.2s ease;
}

.type-badge {
  font-size: var(--text-xs); color: var(--text3); font-weight: 500;
}
.rate-badge { font-size: var(--text-base); font-weight: 700; color: var(--text); }
.empty-state {
  text-align: center; padding: var(--space-7) var(--space-4); color: var(--text3);
}
.empty-state .es-icon { font-size: 48px; margin-bottom: var(--space-3); }
.empty-state .es-msg { font-size: var(--text-base); font-weight: 500; }
.empty-state .es-sub { font-size: var(--text-sm); margin-top: var(--space-2); }
.month-group-header {
  font-size: var(--text-sm); font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text3);
  padding: var(--space-1) 0;
  border-bottom: 1px solid var(--border);
  margin-top: var(--space-2);
}

/* ════════════════════════════════════
   PRACTICES LIST
════════════════════════════════════ */
.practices-list { flex: 1; overflow-y: auto; padding: var(--space-4) var(--space-5); display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; align-content: start; }
.practice-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--space-4);
  display: flex; flex-direction: column; gap: 12px;
  transition: border-color .15s, transform .15s;
  cursor: pointer;
}
.practice-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.practice-card-header { display: flex; align-items: center; gap: 14px; }
.practice-icon {
  width: 44px; height: 44px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-lg); flex-shrink: 0;
}
.practice-name { font-size: var(--text-base); font-weight: 700; color: var(--text); }
.practice-contact { font-size: var(--text-sm); color: var(--text2); margin-top: 2px; }
.practice-detail { display: flex; align-items: center; gap: 8px; font-size: var(--text-sm); color: var(--text2); }
.practice-detail-icon { font-size: var(--text-base); }
.practice-stats { display: flex; gap: 16px; padding-top: var(--space-3); border-top: 1px solid var(--border); }
.pstat { display: flex; flex-direction: column; gap: 2px; }
.pstat-val { font-size: var(--text-base); font-weight: 700; color: var(--text); }
.pstat-label { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .7px; color: var(--text3); }

.practice-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: auto;
  padding-top: var(--space-3);
  opacity: 0;
  transition: opacity .2s ease;
}
.practice-card:hover .practice-card-actions { opacity: 1; }
.p-action-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .2s ease;
  font-size: var(--text-base);
}
.p-action-btn:hover { background: var(--bg4); color: var(--text); border-color: var(--accent); }
.p-action-btn.del:hover { color: var(--red); border-color: var(--red); }

/* ════════════════════════════════════
   MODALS
════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
  animation: fadeIn .15s ease;
}
.modal-overlay.open { display: flex; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--glass-card);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 520px;
  max-width: 95vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  animation: slideUp .25s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-sm { width: 420px; }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: var(--text-lg); font-weight: 700; }
.modal-close {
  background: none; border: none; color: var(--text2); cursor: pointer;
  font-size: var(--text-lg); width: 30px; height: 30px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.modal-close:hover { background: var(--bg4); color: var(--red); }

.modal-body { padding: var(--space-4) var(--space-5); overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: var(--space-4) var(--space-5); border-top: 1px solid var(--border);
}

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: var(--text-sm); font-weight: 600; color: var(--text2); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

input, select, textarea {
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm); font-size: var(--text-sm);
  font-family: 'Inter', sans-serif; outline: none;
  transition: border-color .15s;
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; }
select option { background: var(--bg3); }

.inline-link {
  background: none; border: none; color: var(--accent);
  cursor: pointer; font-size: var(--text-sm); text-align: left;
  padding: 2px 0;
}
.inline-link:hover { text-decoration: underline; }

/* Segmented Control */
.segmented-control {
  display: flex;
  background: var(--bg3);
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  gap: 4px;
}
.segment-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 600;
  transition: all .2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.segment-btn:hover { color: var(--text); }
.segment-btn.active {
  background: var(--bg4);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.btn-primary {
  background: var(--accent2); border: none; color: #fff;
  padding: var(--space-2) var(--space-5); border-radius: var(--radius-sm);
  cursor: pointer; font-size: var(--text-sm); font-weight: 600;
  transition: opacity .15s;
}
.btn-primary:hover { opacity: .85; }
.btn-secondary {
  background: var(--bg3); border: 1px solid var(--border); color: var(--text2);
  padding: var(--space-2) var(--space-5); border-radius: var(--radius-sm);
  cursor: pointer; font-size: var(--text-sm); font-weight: 600;
  transition: background .15s;
}
.btn-secondary:hover { background: var(--bg4); }
.btn-danger {
  background: rgba(248,81,73,.15); border: 1px solid rgba(248,81,73,.3);
  color: var(--red); padding: var(--space-2) var(--space-5); border-radius: var(--radius-sm);
  cursor: pointer; font-size: var(--text-sm); font-weight: 600;
  transition: background .15s;
}
.btn-danger:hover { background: rgba(248,81,73,.25); }

/* Color Picker */
/* Colour picker: trigger button + horizontally scrollable swatch row */
.color-trigger {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  transition: border-color .15s;
}
.color-trigger:hover { border-color: var(--accent); }
.color-trigger-dot {
  width: 20px; height: 20px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.color-trigger-chev { margin-left: auto; color: var(--text3); }
.color-trigger[aria-expanded="true"] .color-trigger-chev { transform: rotate(180deg); }

.color-picker {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: var(--space-2);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding: var(--space-3) var(--space-1);
  margin-top: var(--space-2);
  background: var(--surface-deep-30);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.color-picker[hidden] { display: none; }
.color-picker::-webkit-scrollbar { height: 5px; }

.color-swatch {
  width: 30px; height: 30px;
  flex: 0 0 auto;
  border-radius: var(--radius-full);
  cursor: pointer;
  padding: 0;
  border: 2px solid transparent;
  box-shadow: 0 0 0 1px var(--border) inset;
  transition: transform .15s, box-shadow .15s, opacity .15s;
  position: relative;
}
.color-swatch:hover { transform: scale(1.12); }
.color-swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Selected: ring + check */
.color-swatch.selected {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text);
  opacity: 1;
}
.color-swatch.selected::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: var(--text-sm);
  font-weight: 800;
  text-shadow: 0 1px 2px rgba(0,0,0,0.55);
}
/* Already used by another business — dimmed, but still clickable */
.color-swatch.in-use:not(.selected) { opacity: 0.3; }
.color-swatch.in-use:not(.selected):hover { opacity: 0.65; }

.color-auto-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  flex: 0 0 auto;
  height: 30px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-full);
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  font-family: inherit;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.color-auto-pill:hover { border-color: var(--accent); color: var(--text); }
.color-auto-pill:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.color-auto-pill.selected {
  border-color: var(--text);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--text);
}
.color-auto-dot {
  width: 14px; height: 14px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  border: 1px solid var(--border);
}

/* Day Modal */
.day-modal-bookings { display: flex; flex-direction: column; gap: 10px; }
.day-booking-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.day-booking-item:hover { border-color: var(--accent); background: var(--bg4); }
.day-booking-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.day-booking-info { flex: 1; min-width: 0; }
.day-booking-name { font-size: var(--text-sm); font-weight: 600; }
.day-booking-sub  { font-size: var(--text-xs); color: var(--text2); }
.day-holiday-info {
  background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.25);
  border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm); color: #f87171; font-weight: 500;
  display: flex; align-items: center; gap: 8px;
}

/* DASHBOARD CSS */
.dashboard-content {
  padding: var(--space-5);
  overflow-y: auto;
  flex: 1;
}
.dash-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: var(--space-6);
}
.dash-metric-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: 8px;
  backdrop-filter: blur(10px);
  transition: transform .2s, box-shadow .2s;
}
.dash-metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.dash-metric-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.dash-metric-value {
  font-size: var(--text-2xl);
  font-weight: 800;
}
.dash-section {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-5);
  backdrop-filter: blur(10px);
}
.dash-section-title {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--space-4);
}
.dash-bars {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.dash-bar-row {
  display: flex;
  align-items: center;
  gap: 16px;
}
.dash-bar-label {
  width: 140px;
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-bar-track {
  flex: 1;
  height: 8px;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.dash-bar-fill {
  height: 100%;
  border-radius: var(--radius-sm);
}
.dash-bar-val {
  width: 100px;
  text-align: right;
  font-size: var(--text-sm);
  font-weight: 600;
}
.dash-upcoming-list { display: flex; flex-direction: column; gap: 10px; }
.dash-upcoming-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface-deep-40); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: var(--space-3) var(--space-4);
  cursor: pointer;
  transition: all .2s;
}
.dash-upcoming-item:hover {
  background: var(--bg3); border-color: var(--accent); transform: translateX(4px);
}
.dash-upcoming-date {
  display: flex; flex-direction: column; align-items: center;
  background: rgba(255,255,255,0.05); border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-2); width: 44px;
}
.dash-up-day { font-size: var(--text-base); font-weight: 700; color: var(--text); }
.dash-up-mon { font-size: var(--text-xs); text-transform: uppercase; color: var(--accent); font-weight: 600; letter-spacing: .5px; }
.dash-upcoming-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 8px currentColor; }
.dash-upcoming-info { flex: 1; min-width: 0; }
.dash-upcoming-name { font-size: var(--text-base); font-weight: 700; }
.dash-upcoming-sub { font-size: var(--text-sm); color: var(--text2); margin-top: 2px; }
.dash-upcoming-rate { font-size: var(--text-base); font-weight: 700; color: var(--green); }

/* ============================================================
   INVOICE STUDIO VIEW
   ============================================================ */
.invoices-studio {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

.invoices-sidebar {
  width: 320px;
  background: var(--surface-deep-40);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: var(--space-4);
  overflow-y: auto;
  flex-shrink: 0;
}

.studio-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--surface-card-30);
  border: 1px solid var(--border);
  padding: var(--space-4);
  border-radius: var(--radius-sm);
}

.studio-section-title {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--accent);
  margin-bottom: var(--space-1);
}

.invoice-container {
  flex: 1;
  background: var(--surface-deep-60);
  padding: var(--space-6);
  overflow-y: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.invoice-sheet {
  width: 100%;
  max-width: 800px;
  background: #ffffff;
  color: #1e293b;
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-sm);
  padding: var(--space-7);
  font-size: var(--text-sm);
  line-height: 1.5;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

/* Hide native browser calendar icons and number spinners inside the invoice sheet */
.invoice-sheet input[type="date"]::-webkit-calendar-picker-indicator,
.invoice-sheet input[type="date"]::-webkit-inner-spin-button,
.invoice-sheet input[type="date"]::-webkit-clear-button {
  display: none !important;
  -webkit-appearance: none !important;
  margin: 0 !important;
}

.invoice-sheet input[type="number"]::-webkit-inner-spin-button,
.invoice-sheet input[type="number"]::-webkit-outer-spin-button {
  display: none !important;
  -webkit-appearance: none !important;
  margin: 0 !important;
}

.invoice-sheet input[type="number"] {
  -moz-appearance: textfield !important;
}

/* Header & Letterhead */
.inv-sheet-header {
  display: flex;
  justify-content: space-between;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: var(--space-5);
  margin-bottom: var(--space-5);
}

.inv-header-left {
  display: flex;
  flex-direction: column;
}

.inv-logo-title {
  font-size: var(--text-xl);
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.inv-logo-sub {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--accent2);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-top: var(--space-1);
}

.inv-locum-details {
  margin-top: var(--space-3);
  font-size: var(--text-sm);
  color: #475569;
  line-height: 1.5;
}

.inv-header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
}

.inv-title {
  font-size: var(--text-xl);
  font-weight: 800;
  color: #0f172a;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-3);
}

.inv-meta-table {
  border-collapse: collapse;
}

.inv-meta-table td {
  padding: 3px var(--space-2);
  font-size: var(--text-sm);
  color: #475569;
}

.inv-meta-table td:first-child {
  font-weight: 600;
  color: #64748b;
  text-align: right;
}

/* Inline Edit Controls */
.inv-inline-edit {
  background: transparent !important;
  border: none !important;
  border-bottom: 1px dashed var(--surface-card-20) !important;
  border-radius: 0 !important;
  padding: 2px var(--space-1) !important;
  color: #0f172a !important;
  font-family: inherit !important;
  font-size: inherit !important;
  width: auto !important;
  min-width: 80px;
  transition: border-color 0.15s;
  height: auto !important;
}

.inv-inline-edit:hover, .inv-inline-edit:focus {
  border-bottom-color: var(--accent2) !important;
  background: rgba(56, 189, 248, 0.05) !important;
}

input[type="date"].inv-inline-edit {
  width: 125px !important;
}

/* Billing & Payment Info Columns */
.inv-billing-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  gap: 20px;
}

.inv-bill-to {
  flex: 1;
}

.inv-payment-method {
  flex: 1;
  background: #f8fafc;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid #e2e8f0;
}

.inv-label {
  font-size: var(--text-xs);
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  display: block;
  margin-bottom: var(--space-2);
}

.inv-value {
  font-size: var(--text-sm);
  color: #1e293b;
  line-height: 1.5;
}

.inv-payment-bank {
  font-size: var(--text-sm);
  color: #334155;
  line-height: 1.5;
}

/* Grid Line Items */
.inv-items-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--space-2);
  margin-bottom: var(--space-4);
}

.inv-items-table th {
  font-size: var(--text-xs);
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: var(--space-2) var(--space-2);
  border-bottom: 2px solid #cbd5e1;
  text-align: left;
}

.inv-items-table th.col-hours,
.inv-items-table th.col-rate,
.inv-items-table th.col-surcharge,
.inv-items-table th.col-total {
  text-align: right;
}

.inv-items-table td {
  padding: var(--space-2) var(--space-2);
  border-bottom: 1px solid #e2e8f0;
  color: #334155;
  vertical-align: middle;
}

.inv-items-table tbody tr:hover {
  background-color: #f8fafc;
}

.inv-table-input {
  background: transparent !important;
  border: none !important;
  border-bottom: 1px dashed var(--surface-card-20) !important;
  border-radius: 0 !important;
  padding: var(--space-1) 0 !important;
  color: #334155 !important;
  font-family: inherit !important;
  font-size: var(--text-sm) !important;
  width: 100% !important;
  text-align: inherit;
  transition: all 0.15s;
  height: auto !important;
}

.inv-table-input:hover, .inv-table-input:focus {
  border-bottom-color: var(--accent2) !important;
  background: rgba(56, 189, 248, 0.05) !important;
}

/* Specific column overrides */
.inv-items-table td.col-hours,
.inv-items-table td.col-rate,
.inv-items-table td.col-surcharge,
.inv-items-table td.col-total {
  text-align: right;
}

.inv-items-table .col-check {
  text-align: center;
}

.inv-items-table .col-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.inv-items-table .col-actions button.del-btn {
  background: none;
  border: none;
  color: var(--red);
  font-weight: 700;
  cursor: pointer;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  opacity: 0.4;
  transition: opacity 0.15s;
}

.inv-items-table tr:hover .col-actions button.del-btn {
  opacity: 1;
}

.inv-items-table .col-actions button.del-btn:hover {
  background-color: rgba(239, 68, 68, 0.1);
}

.inv-add-custom-row {
  margin-bottom: var(--space-6);
}

/* Footer Totals & Greetings */
.inv-footer-block {
  display: flex;
  justify-content: space-between;
  margin-top: auto;
  padding-top: var(--space-4);
  border-top: 1px solid #e2e8f0;
  gap: 30px;
}

.inv-message-section {
  width: 55%;
  display: flex;
  flex-direction: column;
}

.inv-message-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
}

.inv-ai-control {
  display: flex;
  gap: 8px;
  align-items: center;
}

.inv-inline-select {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 2px var(--space-2);
  font-size: var(--text-xs);
  color: #334155;
  cursor: pointer;
  width: auto;
}

.inv-message-textarea {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  color: #334155;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  line-height: 1.6;
  width: 100%;
  resize: none;
  font-family: inherit;
  transition: border-color 0.15s;
}

.inv-message-textarea:focus {
  border-color: var(--accent2);
  outline: none;
}

.inv-totals-section {
  width: 38%;
}

.inv-totals-table {
  width: 100%;
  border-collapse: collapse;
}

.inv-totals-table td {
  padding: var(--space-2) 0;
  font-size: var(--text-sm);
  color: #475569;
}

.inv-totals-table td:first-child {
  color: #64748b;
  font-weight: 500;
  text-align: left;
}

.inv-totals-table td:last-child {
  text-align: right;
  font-weight: 600;
  color: #1e293b;
}

.inv-totals-table .inv-total-row td {
  border-top: 2px solid #cbd5e1;
  padding-top: var(--space-3);
  font-size: var(--text-base);
  font-weight: 800;
  color: #0f172a;
}

.inv-totals-table .inv-total-row td:last-child {
  font-size: var(--text-lg);
  color: var(--green) !important;
}

/* ============================================================
   HIGH FIDELITY PRINT STYLES
   ============================================================ */
@media print {
  /* Hide interactive chrome and layout elements */
  #sidebar,
  .sidebar,
  .sidebar-backdrop,
  #toastContainer,
  .view-header,
  .invoices-sidebar,
  .invoices-history-container,
  .no-print,
  .col-check,
  .col-actions,
  .inv-add-custom-row,
  .inv-message-title-row,
  .glass-bg,
  .glass-bg-2,
  .unchecked-row {
    display: none !important;
  }
  
  /* Reset document flow and colors */
  html, body {
    background: #ffffff !important;
    color: #000000 !important;
    height: auto !important;
    overflow: visible !important;
    font-size: 12px !important;
  }

  body {
    display: block !important;
  }
  
  .main {
    flex: none !important;
    display: block !important;
    overflow: visible !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  
  .view {
    display: none !important;
    overflow: visible !important;
    height: auto !important;
  }
  
  .view.active {
    display: block !important;
  }
  
  .invoices-studio {
    display: block !important;
    overflow: visible !important;
    height: auto !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  
  .invoice-container {
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    display: block !important;
    overflow: visible !important;
    height: auto !important;
  }
  
  .invoice-sheet {
    max-width: 100% !important;
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 12px !important;
  }
  
  /* Flatten input editing controls */
  .inv-inline-edit,
  .inv-table-input {
    border-bottom: none !important;
    padding: 0 !important;
    background: transparent !important;
    color: #000000 !important;
    text-shadow: none !important;
    box-shadow: none !important;
  }

  input, select, textarea {
    color: #000000 !important;
  }

  /* Table styling */
  .inv-items-table th {
    color: #000000 !important;
    border-bottom: 2px solid #000000 !important;
  }

  .inv-items-table td {
    border-bottom: 1px solid #e2e8f0 !important;
    color: #000000 !important;
  }

  /* Display textareas fully flat */
  .inv-message-textarea {
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
    color: #000000 !important;
    resize: none !important;
    font-size: 12px !important;
    overflow: visible !important;
    height: auto !important;
  }

  .inv-payment-method {
    background: #f8fafc !important;
    border: 1px solid #cbd5e1 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Grid totals border */
  .inv-totals-table .inv-total-row td {
    border-top: 2px solid #000000 !important;
  }
  
  .inv-totals-table .inv-total-row td:last-child {
    color: #000000 !important;
  }

  @page {
    size: A4 portrait;
    margin: 15mm 15mm 15mm 15mm;
  }
}

/* Block Off Dates (No Bookings) premium styles */
.cal-cell.cell-blocked {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.2) 0%, rgba(239, 68, 68, 0.08) 100%) !important;
  border: 1px solid rgba(239, 68, 68, 0.35) !important;
  border-left: 3px solid var(--red) !important;
}
.cal-cell.cell-blocked:hover {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.3) 0%, rgba(239, 68, 68, 0.12) 100%) !important;
  border-color: rgba(239, 68, 68, 0.5) !important;
  border-left-color: var(--red) !important;
}
.cal-cell.cell-blocked .cell-date {
  color: #f87171 !important;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.slot-blocked {
  background: repeating-linear-gradient(45deg, rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.15) 10px, rgba(239, 68, 68, 0.25) 10px, rgba(239, 68, 68, 0.25) 20px) !important;
  border-left: 3px solid var(--red) !important;
  color: #f87171 !important;
}
.wbc-blocked {
  background: repeating-linear-gradient(45deg, rgba(239, 68, 68, 0.12), rgba(239, 68, 68, 0.12) 8px, rgba(239, 68, 68, 0.22) 8px, rgba(239, 68, 68, 0.22) 16px) !important;
  border-left: 3px solid var(--red) !important;
  color: #f87171 !important;
}

/* Blocked mode toggle logic */
.blocked-mode #bkPracticeGroup,
.blocked-mode #bkChargeTypeGroup,
.blocked-mode #dayRateRow,
.blocked-mode #hourlyRateRow,
.blocked-mode #calculatedTotalRow,
.blocked-mode #bkWorkHoursSection,
.blocked-mode #setHoursRow,
.blocked-mode #splitShiftsRow,
.blocked-mode #bkStatusGroup {
  display: none !important;
}

.blocked-mode #bkShiftTypeGroup {
  grid-column: 1 / span 2 !important;
}

/* ════════════════════════════════════
   MOBILE RESPONSIVE (Phase 2)
════════════════════════════════════ */
@media screen and (max-width: 768px) {
  /* Sidebar Drawer */
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 200;
    transform: translateX(0);
    transition: transform 0.3s ease;
    box-shadow: 4px 0 15px rgba(0,0,0,0.5);
    width: var(--sidebar-w) !important; 
  }
  .sidebar.collapsed {
    transform: translateX(-100%);
    width: var(--sidebar-w) !important;
    overflow: visible !important; /* Prevents clipping of absolute positioned toggle button */
  }
  
  .sidebar.collapsed .logo,
  .sidebar.collapsed .sidebar-section,
  .sidebar.collapsed .nav-label,
  .sidebar.collapsed .logo-title,
  .sidebar.collapsed .logo-sub { 
    display: flex !important; /* Undo collapsed hiding */
  }
  
  .sidebar.collapsed .sidebar-header {
    justify-content: space-between !important;
  }

  /* The toggle button sits outside when collapsed */
  #sidebarToggle {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 201;
  }
  .sidebar.collapsed #sidebarToggle {
    right: -45px;
    background: var(--bg3);
    border: 1px solid var(--border);
    transform: rotate(180deg);
  }

  /* Main content padding adjustment when sidebar active */
  .main {
    width: 100%;
  }
  
  .view-header {
    padding-left: var(--space-7) !important;
    flex-wrap: wrap;
    gap: 12px;
  }
  .view-header-left {
    flex-wrap: wrap;
  }
  .view-header-right {
    width: 100%;
    justify-content: flex-start;
  }
  
  .cal-title {
    font-size: var(--text-lg) !important;
  }

  /* Modals Full Screen */
  .modal {
    width: 100%;
    height: 100%;
    max-width: 100vw;
    max-height: 100vh;  /* fallback */
    max-height: 100dvh; /* dynamic viewport: excludes mobile browser chrome */
    border-radius: 0;
    margin: 0;
  }
  
  .modal-body {
    flex: 1;
  }
  
  /* Calendar Layout Compress */
  .calendar-grid-header {
    font-size: var(--text-xs);
  }
  .cal-day-header {
    padding: var(--space-2) 0;
  }
  .cal-cell {
    min-height: 85px;
  }
  .cell-date {
    width: 20px;
    height: 20px;
    font-size: var(--text-xs);
    top: 4px;
    left: 4px;
  }
  .holiday-badge {
    top: 4px;
    right: 4px;
    font-size: var(--text-xs);
    padding: 0px 3px;
  }
  .booking-slot {
    left: 2px;
    right: 2px;
    padding: 2px var(--space-1);
    border-radius: var(--radius-sm);
  }
  .slot-full {
    top: 24px;
    bottom: 3px;
  }
  .slot-morning {
    top: 24px;
    height: calc(50% - 13.5px);
  }
  .slot-afternoon {
    bottom: 3px;
    height: calc(50% - 13.5px);
  }
  .slot-split {
    top: 24px;
    bottom: 3px;
  }
  .slot-practice {
    font-size: var(--text-xs);
  }
  .slot-meta {
    font-size: var(--text-xs);
    flex-wrap: wrap;
  }

  /* Dashboard Streams */
  .dash-metrics {
    grid-template-columns: 1fr;
  }
  
  /* Invoice layout */
  .invoices-studio {
    flex-direction: column;
    overflow-y: auto;
  }
  .invoices-sidebar {
    width: 100%;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .invoice-container {
    padding: var(--space-2);
    overflow-y: visible;
    height: auto;
  }
  
  /* Form Rows */
  .form-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  
  .practices-list {
    grid-template-columns: 1fr;
  }
  
  .week-grid {
    padding: var(--space-3) var(--space-3);
    gap: 6px;
    align-items: flex-start;
  }
  
  .week-cell {
    padding: var(--space-2) var(--space-3);
    min-height: 65px;
    gap: 8px;
    width: 240px; /* Collapsed width on mobile (larger to show clinic names by default) */
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), background 0.15s, border-color 0.15s;
  }
  
  .week-cell.active {
    width: 100%;
  }
  
  .week-booking-pill {
    font-size: var(--text-xs);
    padding: 3px var(--space-2);
    max-width: 100px;
  }
  
  .week-cell.active .week-cell-details {
    margin-left: var(--space-2);
  }
  
  .week-booking-card-horizontal {
    min-width: 140px;
    padding: var(--space-2) var(--space-2);
  }
}

/* ── CALENDAR DOTS & COLLAPSED/EXPANDED ANIMATION ── */
.cell-indicators {
  position: absolute;
  bottom: 8px;
  left: 6px;
  right: 6px;
  display: flex;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
  pointer-events: none;
}
.indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}
.indicator-dot.blocked {
  border-radius: var(--radius-sm);
}

/* Dimming other grid cells when one is focused */
.calendar-grid.grid-focused .cal-cell:not(.expanded):not(.cal-cell-placeholder) {
  opacity: 0.12;
  transform: scale(0.92);
  filter: blur(2px);
  pointer-events: none;
}
.calendar-grid {
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.cal-cell {
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1), background 0.12s, transform 0.12s;
}

/* Placeholder element that replaces the moving cell in the grid */
.cal-cell-placeholder {
  background: transparent;
  visibility: hidden;
}

/* Backdrop Dimming Layer */
.calendar-backdrop {
  position: fixed;
  inset: 0;
  background: var(--surface-deep-70);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.calendar-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* Expanded Card style (shared-element layout) */
.cal-cell.expanded {
  background: var(--surface-card-95) !important;
  backdrop-filter: blur(30px) !important;
  -webkit-backdrop-filter: blur(30px) !important;
  border: 1px solid rgba(148, 163, 184, 0.2) !important;
  box-shadow: var(--shadow-lg) !important;
  border-radius: var(--radius-md) !important;
  cursor: default;
  display: flex !important;
  flex-direction: column;
  padding: var(--space-5) !important;
  z-index: 1000 !important;
  transform: none !important;
  overflow-y: auto !important;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Expanded contents design styling */
.cal-cell .expanded-header,
.cal-cell .expanded-body,
.cal-cell .expanded-footer {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease-out;
}

.cal-cell.expanded .expanded-header,
.cal-cell.expanded .expanded-body,
.cal-cell.expanded .expanded-footer {
  opacity: 1;
  pointer-events: auto;
  transition-delay: 0.3s;
}

.expanded-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-4);
  flex-shrink: 0;
}
.expanded-title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text);
}
.expanded-back-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
  width: auto !important;
}
.expanded-back-btn:hover {
  background: var(--bg4);
  color: var(--text);
}

.expanded-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  overflow-y: auto;
}

/* Accordion list inside expanded day card */
.day-modal-bookings {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.accordion-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-card-40);
  overflow: hidden;
  transition: border-color 0.25s, background 0.25s;
}

.accordion-item.active {
  border-color: rgba(56, 189, 248, 0.4);
  background: rgba(30, 41, 59, 0.7);
}

.accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  user-select: none;
}

.accordion-toggle-btn {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: var(--space-1);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s ease, color 0.25s;
}

.accordion-item.active .chevron-icon {
  transform: rotate(180deg);
  color: var(--accent);
}

.accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.accordion-item.active .accordion-content {
  max-height: 600px;
}

.accordion-details {
  padding: 0 var(--space-4) var(--space-4) var(--space-4);
  border-top: 1px solid rgba(148, 163, 184, 0.08);
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: var(--space-1);
}

.detail-row {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-sm);
  color: var(--text2);
  padding: var(--space-1) 0;
}

.detail-row span {
  color: var(--text3);
  font-weight: 500;
}

.detail-row strong {
  color: var(--text);
  font-weight: 600;
}

.notes-row {
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  border-top: 1px dashed rgba(148, 163, 184, 0.1);
  padding-top: var(--space-2);
  margin-top: var(--space-1);
}

.notes-row p {
  color: var(--text2);
  font-size: var(--text-sm);
  line-height: 1.5;
  background: var(--surface-deep-30);
  padding: var(--space-2) var(--space-2);
  border-radius: var(--radius-sm);
  width: 100%;
  box-sizing: border-box;
}

.detail-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: var(--space-2);
  border-top: 1px solid rgba(148, 163, 184, 0.08);
  padding-top: var(--space-3);
}

.btn-secondary.sm {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  border-radius: var(--radius-sm);
  width: auto !important;
}

/* ── BOOKING DETAIL GRID ── */
.booking-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  width: 100%;
}

.booking-grid-item {
  background: rgba(148, 163, 184, 0.05);
  border: 1px solid rgba(148, 163, 184, 0.1);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.booking-grid-item.span-2 {
  grid-column: span 2;
}

.booking-grid-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text3);
}

.booking-grid-value {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text);
}

.booking-notes-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: var(--space-2);
  width: 100%;
}

.booking-notes-text {
  color: var(--text2);
  font-size: var(--text-sm);
  line-height: 1.5;
  background: rgba(148, 163, 184, 0.05);
  border: 1px solid rgba(148, 163, 184, 0.08);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  width: 100%;
  box-sizing: border-box;
  margin: 0;
}

/* ════════════════════════════════════
   DESKTOP OVERRIDES FOR PC LAYOUT
════════════════════════════════════ */
@media (min-width: 769px) {
  .week-grid {
    display: grid !important;
    grid-template-columns: repeat(7, 1fr) !important;
    gap: 1px !important;
    background: var(--border) !important;
    padding: 0 !important;
    overflow-y: auto !important;
    align-items: stretch !important;
  }
  
  .week-cell {
    background: var(--bg) !important;
    padding: var(--space-4) var(--space-3) !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    min-height: 300px !important;
    cursor: pointer !important;
    transition: background .12s !important;
    width: auto !important;
    border: none !important;
    border-radius: 0 !important;
    box-sizing: border-box !important;
  }
  
  .week-cell:hover {
    background: var(--bg3) !important;
  }
  
  .week-cell.today {
    background: rgba(88, 166, 255, 0.04) !important;
    border: none !important;
  }
  
  .week-cell.weekend {
    background: rgba(88, 166, 255, 0.02) !important;
  }
  
  .week-cell-header {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 4px !important;
  }
  
  .week-day-name {
    font-size: var(--text-xs) !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: .8px !important;
    color: var(--text3) !important;
  }
  
  .week-date-num {
    font-size: var(--text-xl) !important;
    font-weight: 700 !important;
    color: var(--text) !important;
    width: 42px !important;
    height: 42px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 50% !important;
  }
  
  .week-cell.today .week-date-num {
    background: var(--accent) !important;
    color: #fff !important;
  }
  
  .week-cell.weekend .week-day-name {
    color: var(--accent) !important;
  }
  
  /* Vertical booking card styling for week grid */
  .week-booking-card {
    border-radius: var(--radius-sm) !important;
    padding: var(--space-2) !important;
    color: #fff !important;
    font-size: var(--text-sm) !important;
    cursor: pointer !important;
    transition: opacity .12s !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 3px !important;
    box-shadow: var(--shadow-sm) !important;
  }
  
  .week-booking-card:hover {
    opacity: .85 !important;
  }
  
  .week-booking-card .wbc-practice {
    font-weight: 700 !important;
    margin-bottom: 3px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  
  .week-booking-card .wbc-type {
    font-size: var(--text-xs) !important;
    opacity: .8 !important;
  }
  
  .week-booking-card.wbc-blocked {
    background: var(--red) !important;
  }
  
  .week-booking-card.wbc-tentative {
    opacity: 0.85 !important;
    background-image: repeating-linear-gradient(45deg, rgba(255,255,255,0.05), rgba(255,255,255,0.05) 10px, transparent 10px, transparent 20px) !important;
    border: 1px dashed rgba(255,255,255,0.4) !important;
  }
  
  .week-booking-card.wbc-pending {
    opacity: 0.7 !important;
    background-image: repeating-linear-gradient(-45deg, rgba(0,0,0,0.1), rgba(0,0,0,0.1) 8px, transparent 8px, transparent 16px) !important;
  }
  
  .week-add-btn {
    display: block !important;
    background: none !important;
    border: 1px dashed var(--border) !important;
    color: var(--text3) !important;
    width: 100% !important;
    padding: var(--space-2) !important;
    border-radius: var(--radius-sm) !important;
    cursor: pointer !important;
    font-size: var(--text-xs) !important;
    transition: border-color .15s, color .15s !important;
    margin-top: auto !important; /* Push add button to bottom of week cell */
  }
  
  .week-add-btn:hover {
    border-color: var(--accent) !important;
    color: var(--accent) !important;
  }
}

/* ============================================================
   RECEIPTS TRACKER STYLE RULES
   ============================================================ */
.receipt-dashboard-widgets {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 20px;
  flex-shrink: 0;
}

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

.receipts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-top: var(--space-2);
}

.receipt-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color .15s, transform .15s;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

.receipt-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.receipt-img-wrapper {
  width: 100%;
  height: 140px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-deep-40);
  border: 1px solid var(--border);
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

.receipt-img-wrapper img {
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
  transition: transform 0.2s ease;
}

.receipt-card:hover .receipt-img-wrapper img {
  transform: scale(1.05);
}

.receipt-card-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.receipt-card-merchant {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.receipt-card-date {
  font-size: var(--text-xs);
  color: var(--text3);
}

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

.receipt-card-amount {
  font-size: var(--text-base);
  font-weight: 800;
  color: var(--green);
}

.receipt-category-tag {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px var(--space-2);
  border-radius: var(--radius-full);
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent);
  display: inline-block;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Category Specific Tags */
.tag-petrol-diesel { background: rgba(249, 115, 22, 0.12) !important; color: var(--orange) !important; }
.tag-food-snacks { background: rgba(234, 179, 8, 0.12) !important; color: var(--yellow) !important; }
.tag-equipment { background: rgba(168, 85, 247, 0.12) !important; color: var(--purple) !important; }
.tag-scrubs-uniforms { background: rgba(56, 189, 248, 0.12) !important; color: var(--accent) !important; }
.tag-professional-fees { background: rgba(16, 185, 129, 0.12) !important; color: var(--green) !important; }
.tag-cpd-training { background: rgba(56, 189, 248, 0.12) !important; color: var(--accent) !important; }
.tag-travel-accommodation { background: rgba(239, 68, 68, 0.12) !important; color: var(--red) !important; }
.tag-office-admin { background: rgba(148, 163, 184, 0.12) !important; color: var(--text2) !important; }
.tag-other { background: rgba(148, 163, 184, 0.12) !important; color: var(--text3) !important; }

.receipt-card-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 10;
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.receipt-card:hover .receipt-card-actions {
  opacity: 1;
}

.rc-action-btn {
  background: var(--glass-card);
  border: 1px solid var(--border);
  color: var(--text2);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: var(--text-xs);
}

.rc-action-btn:hover {
  background: var(--bg4);
  color: var(--text);
  border-color: var(--accent);
  transform: scale(1.1);
}

.rc-action-btn.del:hover {
  color: var(--red);
  border-color: var(--red);
  background: rgba(239, 68, 68, 0.1);
}

/* ============================================================
   INVOICE HISTORY & PRINTING STYLE RULES
   ============================================================ */
.badge-status {
  display: inline-block;
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: var(--radius-full);
  text-align: center;
  white-space: nowrap;
}
.badge-unpaid {
  background: rgba(239, 68, 68, 0.12) !important;
  color: var(--red) !important;
  border: 1px solid rgba(239, 68, 68, 0.25) !important;
}
.badge-paid {
  background: rgba(16, 185, 129, 0.12) !important;
  color: var(--green) !important;
  border: 1px solid rgba(16, 185, 129, 0.25) !important;
}

.history-action-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.history-action-btn:hover {
  background: var(--bg4);
  color: var(--text);
  border-color: var(--accent);
}
.history-action-btn.btn-pay:hover {
  border-color: var(--green) !important;
  color: var(--green) !important;
  background: rgba(16, 185, 129, 0.08) !important;
}
.history-action-btn.btn-unpay:hover {
  border-color: var(--yellow) !important;
  color: var(--yellow) !important;
  background: rgba(234, 179, 8, 0.08) !important;
}
.history-action-btn.btn-del-inv:hover {
  border-color: var(--red) !important;
  color: var(--red) !important;
  background: rgba(239, 68, 68, 0.08) !important;
}

@media print {
  body.modal-open #invoiceReprintModal {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    height: auto !important;
    background: #ffffff !important;
    border: none !important;
    box-shadow: none !important;
    overflow: visible !important;
    display: block !important;
    z-index: 99999 !important;
  }
  
  body.modal-open #invoiceReprintModal .modal {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
  }
  
  body.modal-open #invoiceReprintModal .modal-body {
    padding: 0 !important;
    overflow: visible !important;
    background: transparent !important;
  }
  
  body.modal-open #reprintInvoiceSheet {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    background: #ffffff !important;
  }
}




/* ============================================================
   MOBILE DRAWER BACKDROP, TOASTS, COMPACT CONFIRM, SAFE AREAS
   ============================================================ */

/* Backdrop behind the mobile nav drawer */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  z-index: 199; /* just under the drawer (200) */
  opacity: 0;
  transition: opacity 0.25s ease;
}
.sidebar-backdrop.show {
  display: block;
  opacity: 1;
}

/* Toast notifications */
#toastContainer {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(480px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.45;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  max-width: 100%;
  pointer-events: auto;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.toast-success { border-left-color: var(--green); }
.toast-error   { border-left-color: var(--red); }

/* Compact confirm dialog: stays a card even on mobile (where .modal goes fullscreen) */
.modal.modal-compact {
  width: min(420px, calc(100vw - 32px)) !important;
  height: auto !important;
  max-height: 80vh;
  max-height: 80dvh;
  border-radius: var(--radius) !important;
  margin: 0 !important;
}

/* Safe-area padding for notched / gesture-nav devices */
@media screen and (max-width: 768px) {
  .sidebar {
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-top: env(safe-area-inset-top, 0px);
  }
  .modal-footer {
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }
}

/* ============================================================
   LUCIDE ICON SIZING + BALANCE BAR (Calm Ledger signature)
   ============================================================ */
svg.lucide {
  width: var(--text-lg);
  height: var(--text-lg);
  vertical-align: middle;
  flex-shrink: 0;
}
.history-action-btn svg.lucide,
.p-action-btn svg.lucide,
.rc-action-btn svg.lucide,
.inline-link svg.lucide,
.segment-btn svg.lucide,
.icon-btn svg.lucide {
  width: var(--text-base);
  height: var(--text-base);
}
.nav-icon { display: inline-flex; align-items: center; justify-content: center; }

/* Balance Bar — green fill = paid portion, muted red track = outstanding */
.balance-bar {
  display: block;
  width: 100%;
  height: 5px;
  border-radius: var(--radius-full);
  background: rgba(239, 68, 68, 0.25); /* outstanding track */
  overflow: hidden;
  margin-top: var(--space-2);
}
.balance-bar-fill {
  display: block;
  height: 100%;
  background: var(--paid);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

/* Payment status badges (partial / overdue) */
.badge-partial {
  background: rgba(234, 179, 8, 0.12) !important;
  color: var(--partial) !important;
  border: 1px solid rgba(234, 179, 8, 0.25) !important;
}
.badge-overdue {
  background: rgba(239, 68, 68, 0.18) !important;
  color: var(--outstanding) !important;
  border: 1px solid rgba(239, 68, 68, 0.4) !important;
  font-weight: 800;
}

/* ============================================================
   THEMES — dark is the default; light overrides below.
   Surface tokens back the former hardcoded navy/slate rgba()s.
   ============================================================ */
:root {
  --surface-deep-20: rgba(15, 23, 42, 0.2);
  --surface-deep-30: rgba(15, 23, 42, 0.3);
  --surface-deep-40: rgba(15, 23, 42, 0.4);
  --surface-deep-60: rgba(15, 23, 42, 0.6);
  --surface-deep-70: rgba(15, 23, 42, 0.7);
  --overlay:         rgba(15, 23, 42, 0.85);
  --glass-card:      rgba(15, 23, 42, 0.85);
  --surface-card-20: rgba(30, 41, 59, 0.2);
  --surface-card-30: rgba(30, 41, 59, 0.3);
  --surface-card-40: rgba(30, 41, 59, 0.4);
  --surface-card-80: rgba(30, 41, 59, 0.8);
  --surface-card-95: rgba(30, 41, 59, 0.95);
}

html[data-theme="light"] {
  --bg:        #eef2f7;
  --bg2:       rgba(255, 255, 255, 0.85);
  --bg3:       rgba(226, 232, 240, 0.9);
  --bg4:       rgba(203, 213, 225, 0.95);
  --border:    rgba(15, 23, 42, 0.12);
  --text:      #0f172a;
  --text2:     #334155;
  --text3:     #64748b;
  --accent:    #0284c7;
  --accent2:   #0369a1;
  --green:     #059669;
  --yellow:    #b45309;
  --red:       #dc2626;
  --orange:    #c2410c;
  --purple:    #7e22ce;

  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.12);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.18);

  /* Near-white in light mode so practice color dots stay clearly visible */
  --surface-deep-20: rgba(255, 255, 255, 0.6);
  --surface-deep-30: rgba(255, 255, 255, 0.75);
  --surface-deep-40: rgba(255, 255, 255, 0.85);
  --surface-deep-60: rgba(241, 245, 249, 0.92);
  --surface-deep-70: rgba(241, 245, 249, 0.95);
  --overlay:         rgba(51, 65, 85, 0.45);
  --glass-card:      rgba(255, 255, 255, 0.92);
  --surface-card-20: rgba(255, 255, 255, 0.55);
  --surface-card-30: rgba(255, 255, 255, 0.65);
  --surface-card-40: rgba(255, 255, 255, 0.75);
  --surface-card-80: rgba(255, 255, 255, 0.9);
  --surface-card-95: rgba(255, 255, 255, 0.97);
}

html[data-theme="light"] body {
  background: var(--bg);
}
html[data-theme="light"] .glass-bg {
  background: radial-gradient(circle at 50% 50%, rgba(2, 132, 199, 0.08) 0%, rgba(238, 242, 247, 0) 50%);
}
html[data-theme="light"] .glass-bg-2 {
  background: radial-gradient(circle at 30% 70%, rgba(126, 34, 206, 0.05) 0%, rgba(238, 242, 247, 0) 40%);
}
html[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.4);
}

/* ── Calendar month-swipe feedback ── */
@keyframes calSwipeInLeft {
  from { opacity: 0.4; transform: translateX(28px); }
  to   { opacity: 1;   transform: translateX(0); }
}
@keyframes calSwipeInRight {
  from { opacity: 0.4; transform: translateX(-28px); }
  to   { opacity: 1;   transform: translateX(0); }
}
.cal-swipe-left  { animation: calSwipeInLeft 0.22s ease-out; }
.cal-swipe-right { animation: calSwipeInRight 0.22s ease-out; }

/* ============================================================
   YEAR OVERVIEW + AVAILABILITY PREVIEW
   ============================================================ */
#yearOverviewBody { padding: var(--space-4); }

.year-ov-year-label {
  position: sticky;
  top: calc(-1 * var(--space-4));
  background: var(--glass-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--accent);
  padding: var(--space-2) var(--space-1);
  margin: 0 calc(-1 * var(--space-1));
  z-index: 2;
  border-radius: var(--radius-sm);
}

.year-ov-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  margin: var(--space-2) 0 var(--space-5);
}

.year-ov-month {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-2);
  cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.year-ov-month:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.year-ov-month-name {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: var(--space-1);
}

.year-ov-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.ymd {
  aspect-ratio: 1;
  border-radius: 3px;
  background: var(--surface-deep-30);
  min-width: 0;
}
.ymd.empty { background: transparent; }
.ymd.blocked { background: rgba(239, 68, 68, 0.55); }
.ymd.today { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Availability editable preview */
.avail-preview {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
  min-height: 160px;
  max-height: 45vh;
  overflow-y: auto;
  font-size: var(--text-sm);
  line-height: 1.7;
  color: var(--text2);
  outline: none;
}
.avail-preview:focus {
  border-color: var(--accent);
}
.avail-head {
  font-weight: 800;
  font-size: var(--text-base);
  color: var(--text);
  margin-bottom: var(--space-2);
}
.avail-month-title {
  font-weight: 700;
  color: var(--accent);
  margin-top: var(--space-3);
}
.avail-line { color: var(--text2); }
.avail-line.muted { color: var(--text3); font-style: italic; }
.avail-foot {
  margin-top: var(--space-3);
  color: var(--text3);
}

/* ============================================================
   MOBILE PORTRAIT FIXES — invoice preview + modal action rows
   ============================================================ */

/* Wide invoice line-item tables scroll inside their own container
   (never widen the sheet or push content off-screen). */
.inv-table-scroll { width: 100%; }

@media screen and (max-width: 768px) {
  /* ── Invoice preview sheet ── */
  .invoice-sheet {
    padding: var(--space-4);
    font-size: var(--text-xs);
  }

  /* Letterhead: stack instead of squeezing two columns together */
  .inv-sheet-header {
    flex-direction: column;
    gap: var(--space-4);
    padding-bottom: var(--space-4);
    margin-bottom: var(--space-4);
  }
  .inv-header-right {
    align-items: flex-start;
    text-align: left;
    width: 100%;
  }
  .inv-meta-table { width: 100%; }
  .inv-meta-table td:first-child { text-align: left; white-space: nowrap; }
  .inv-title { font-size: var(--text-lg); margin-bottom: var(--space-2); }
  .inv-logo-title { font-size: var(--text-lg); }

  /* Billed-to / payment method: stack */
  .inv-billing-info {
    flex-direction: column;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
  }
  .inv-bill-to, .inv-payment-method { width: 100%; }

  /* Line items: horizontal scroll, columns keep readable widths */
  .inv-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 calc(-1 * var(--space-2));
    padding: 0 var(--space-2);
  }
  .inv-table-scroll .inv-items-table {
    min-width: 620px;
  }
  .inv-items-table th,
  .inv-items-table td { white-space: nowrap; }
  .inv-items-table .col-desc,
  .inv-items-table td.col-desc { white-space: normal; min-width: 160px; }

  /* Totals + closing message: stack, totals full width */
  .inv-footer-block {
    flex-direction: column;
    gap: var(--space-4);
    padding-top: var(--space-3);
  }
  .inv-message-section,
  .inv-totals-section { width: 100% !important; }

  /* The sheet's own container shouldn't clip or side-scroll the page */
  .invoice-container { overflow-x: hidden; }

  /* ── Modal action rows (booking modal especially) ──
     Was: single nowrap row, justify-content flex-end — overflowing
     buttons were pushed off the LEFT edge. Now they wrap and fill. */
  .modal-footer {
    flex-wrap: wrap;
    justify-content: stretch;
    gap: var(--space-2);
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }
  /* Secondary actions share a row (Cancel / Duplicate / Delete) */
  .modal-footer > button {
    flex: 1 1 28%;
    min-width: 0;
    margin-right: 0 !important; /* clears inline margin-right:auto on Mark Done */
    margin-left: 0 !important;
    padding-left: var(--space-2);
    padding-right: var(--space-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  /* Primary confirm action gets its own full-width row at the bottom */
  .modal-footer > .btn-primary:last-child {
    flex: 1 1 100%;
    order: 10;
  }
  /* Mark Done reads as a primary-but-secondary action: full width, above Save */
  .modal-footer > #bkMarkDoneBtn { flex: 1 1 100%; order: 9; }

  /* Keep the action row pinned and never let it outgrow the sheet */
  .modal-footer { flex-shrink: 0; }
  .modal-body { min-height: 0; overflow-y: auto; }

  /* Full-screen sheets must not translate — a 20px slide pushes the
     footer (Save / Mark Done) below the viewport edge. Fade only. */
  .modal { animation: fadeIn .2s ease; }
  /* The compact confirm dialog stays a centred card, so it keeps the slide */
  .modal.modal-compact { animation: slideUp .25s cubic-bezier(0.16, 1, 0.3, 1); }
}

/* Account deletion link (sidebar, signed-in only) */
.account-danger-link {
  display: block;
  width: 100%;
  margin-top: var(--space-2);
  padding: var(--space-1) 0;
  background: none;
  border: none;
  color: var(--text3);
  font-family: inherit;
  font-size: var(--text-xs);
  font-weight: 600;
  text-align: left;
  text-decoration: underline;
  cursor: pointer;
  transition: color .15s;
}
.account-danger-link:hover { color: var(--outstanding); }

/* Sidebar legal links (store compliance: reachable in-app) */
.sidebar-legal {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border-top: none;
  padding-top: 0;
  font-size: var(--text-xs);
  color: var(--text3);
}
.sidebar-legal a {
  color: var(--text3);
  text-decoration: none;
}
.sidebar-legal a:hover { color: var(--accent); text-decoration: underline; }

/* ── Accessibility refinements ── */

/* Legal links were 14px tall — below the 24px minimum target size */
.sidebar-legal a {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 var(--space-1);
}

/* Respect the OS "reduce motion" setting: keep state changes, drop the movement */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .cal-swipe-left,
  .cal-swipe-right { animation: none !important; }
}

/* Toast with an action (undo / back up now) */
.toast-undo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  border-left-color: var(--accent);
}
.toast-undo-btn {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: inherit;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: var(--space-1) var(--space-3);
  min-height: 28px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.toast-undo-btn:hover { background: var(--accent); color: var(--bg); }
.toast-undo-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
