/* ==========================================================================
   OrbisX — Calendar
   ========================================================================== */

.cal-page { }

.cal-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.cal-page-title {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  color: var(--color-text-primary);
  line-height: var(--leading-tight);
}

.cal-header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.cal-revenue {
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-2);
  padding: 8px 14px;
  background: var(--color-brand-emerald-50);
  border: 1px solid var(--color-brand-emerald-light);
  border-radius: var(--radius-full);
}
.cal-revenue-label {
  font-size: var(--text-xs);
  color: var(--color-brand-emerald-deep);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.cal-revenue-value {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--color-brand-emerald-deep);
}
.cal-revenue-count {
  font-size: var(--text-xs);
  color: var(--color-brand-emerald-deep);
  opacity: 0.72;
}

/* ── Toolbar ──────────────────────────────────────────────────────────── */

.cal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

.cal-nav {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.cal-nav-btn {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-bg-primary);
  color: var(--color-text-body);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-fast) var(--ease-default);
}
.cal-nav-btn:hover {
  border-color: var(--color-brand-emerald);
  color: var(--color-brand-emerald);
}

.cal-nav-today {
  padding: 7px 14px;
  border: 1px solid var(--color-border);
  background: var(--color-bg-primary);
  color: var(--color-text-body);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-default);
}
.cal-nav-today:hover {
  border-color: var(--color-brand-emerald);
  color: var(--color-brand-emerald);
}

/* ── Dropdown (shared: view switcher + multi-selects) ────────────────── */

.cal-dropdown {
  position: relative;
  display: inline-block;
}

.cal-dropdown-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-bg-primary);
  color: var(--color-text-body);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  font-family: var(--font-primary);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-default);
  line-height: 1.2;
}
.cal-dropdown-btn:hover {
  border-color: var(--color-brand-emerald);
  color: var(--color-brand-emerald);
}
.cal-dropdown.open > .cal-dropdown-btn {
  border-color: var(--color-brand-emerald);
  color: var(--color-brand-emerald);
  background: var(--color-brand-emerald-50);
}

.cal-dropdown-chev {
  transition: transform var(--duration-fast) var(--ease-default);
  flex-shrink: 0;
}
.cal-dropdown.open .cal-dropdown-chev {
  transform: rotate(180deg);
}

.cal-dropdown-panel {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 240px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 50;
}
.cal-dropdown.open > .cal-dropdown-panel { display: block; }
@keyframes calDropdownIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.cal-dropdown-group-label {
  font-size: 10px;
  font-weight: var(--weight-bold);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 10px 10px 4px;
}
.cal-dropdown-group-label:first-child { padding-top: 4px; }

.cal-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--color-text-body);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-default);
}
.cal-dropdown-item svg { flex-shrink: 0; color: var(--color-text-secondary); }
.cal-dropdown-item:hover { background: var(--color-sidebar-hover); color: var(--color-text-primary); }
.cal-dropdown-item:hover svg { color: var(--color-brand-emerald); }
.cal-dropdown-item.active {
  background: var(--color-brand-emerald-50);
  color: var(--color-brand-emerald-deep);
  font-weight: var(--weight-semibold);
}
.cal-dropdown-item.active svg { color: var(--color-brand-emerald); }
.cal-dropdown-item > span { flex: 1; }
.cal-dropdown-tick { color: var(--color-brand-emerald); }

.cal-view-dropdown-btn {
  padding: 8px 14px;
  font-weight: var(--weight-semibold);
}
.cal-view-panel { right: 0; left: auto; min-width: 260px; }

/* ── Filters ──────────────────────────────────────────────────────────── */

.cal-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
}

.cal-filter-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.cal-filter-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-right: 4px;
}

.cal-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-bg-primary);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-default);
  line-height: 1.4;
}
.cal-chip:hover { color: var(--color-text-primary); border-color: var(--color-text-secondary); }
.cal-chip.on {
  background: var(--color-brand-emerald-50);
  color: var(--color-brand-emerald-deep);
  border-color: var(--color-brand-emerald-light);
}

.cal-chip-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--color-text-disabled);
  flex-shrink: 0;
}
.cal-chip-type-mobile .cal-chip-dot,
.cal-chip-type-mobile.on { --chip-accent: var(--tile-violet-fg); }
.cal-chip-type-shop .cal-chip-dot,
.cal-chip-type-shop.on   { --chip-accent: var(--tile-cyan-fg); }
.cal-chip-type-mobile.on { background: var(--tile-violet-bg); color: var(--tile-violet-fg); border-color: var(--tile-violet-bg); }
.cal-chip-type-shop.on   { background: var(--tile-cyan-bg);   color: var(--tile-cyan-fg);   border-color: var(--tile-cyan-bg); }
.cal-chip-type-mobile.on .cal-chip-dot,
.cal-chip-type-shop.on   .cal-chip-dot { background: currentColor; }

.cal-chip-holiday.on {
  background: var(--tile-amber-bg);
  color: var(--tile-amber-fg);
  border-color: var(--tile-amber-bg);
}
.cal-chip-holiday svg { flex-shrink: 0; }

/* ── Viewport ─────────────────────────────────────────────────────────── */

.cal-viewport {
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

/* ── Month view ───────────────────────────────────────────────────────── */

.cal-month-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border-subtle);
}
.cal-month-weekday {
  padding: 10px 12px;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cal-month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: minmax(120px, 1fr);
}

.cal-month-cell {
  border-right: 1px solid var(--color-border-subtle);
  border-bottom: 1px solid var(--color-border-subtle);
  padding: 6px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 120px;
  overflow: hidden;
}
.cal-month-cell:nth-child(7n) { border-right: none; }
.cal-month-grid > .cal-month-cell:nth-last-child(-n+7) { border-bottom: none; }

.cal-month-cell.other-month { background: var(--color-bg-secondary); }
.cal-month-cell.other-month .cal-month-date-num { color: var(--color-text-disabled); }
.cal-month-cell.is-today .cal-month-date-num {
  background: var(--color-brand-emerald);
  color: #fff;
  width: 24px; height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: var(--weight-semibold);
}

.cal-month-date {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
}
.cal-month-date-num {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-body);
}

.cal-holiday-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: var(--weight-semibold);
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: var(--tile-amber-bg);
  color: var(--tile-amber-fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.cal-month-events {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}
.cal-event-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  line-height: 1.3;
  overflow: hidden;
  white-space: nowrap;
  border-left: 3px solid currentColor;
  cursor: pointer;
}
.cal-event-chip-time {
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.cal-event-chip-title {
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-month-more {
  font-size: 11px;
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
  padding: 2px 6px;
}

/* ── Time grid (Week / Day) ──────────────────────────────────────────── */

.cal-tg {
  display: flex;
  flex-direction: column;
}
.cal-tg-header {
  display: grid;
  grid-template-columns: 60px repeat(var(--tg-col-count, 7), 1fr);
  border-bottom: 1px solid var(--color-border-subtle);
  background: var(--color-bg-secondary);
  position: sticky;
  top: 0;
  z-index: 2;
}
.cal-tg-header-spacer { border-right: 1px solid var(--color-border-subtle); }
.cal-tg-day-header {
  padding: 8px;
  text-align: center;
  border-right: 1px solid var(--color-border-subtle);
}
.cal-tg-day-header:last-child { border-right: none; }
.cal-tg-day-wd {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-secondary);
}
.cal-tg-day-num {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--color-text-primary);
}
.cal-tg-day-header.is-today .cal-tg-day-num {
  color: var(--color-brand-emerald);
}

.cal-tg-body {
  display: grid;
  grid-template-columns: 60px 1fr;
}

.cal-tg-hours {
  border-right: 1px solid var(--color-border-subtle);
  background: var(--color-bg-secondary);
}
.cal-tg-hour {
  padding: 4px 8px;
  border-bottom: 1px solid var(--color-border-subtle);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
}

.cal-tg-days {
  display: grid;
  grid-template-columns: repeat(var(--tg-col-count, 7), 1fr);
}
.cal-tg-day-col {
  position: relative;
  border-right: 1px solid var(--color-border-subtle);
}
.cal-tg-day-col:last-child { border-right: none; }
.cal-tg-day-col.is-today { background: var(--color-brand-emerald-50); }
.cal-tg-grid-line {
  position: absolute;
  left: 0; right: 0;
  height: 1px;
  background: var(--color-border-subtle);
  pointer-events: none;
}

.cal-tg-event {
  position: absolute;
  left: 4px; right: 4px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border-left: 3px solid currentColor;
  font-size: var(--text-xs);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: transform var(--duration-fast) var(--ease-default),
              box-shadow var(--duration-fast) var(--ease-default);
}
.cal-tg-event:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
  z-index: 1;
}
.cal-tg-event-title {
  font-weight: var(--weight-semibold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-tg-event-meta {
  opacity: 0.78;
  font-size: 10px;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-type-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 6px; height: 6px;
  border-radius: 50%;
}
.cal-type-dot.cal-chip-type-mobile { background: var(--tile-violet-fg); }
.cal-type-dot.cal-chip-type-shop   { background: var(--tile-cyan-fg); }

/* ── List view ────────────────────────────────────────────────────────── */

.cal-list { padding: var(--space-2) var(--space-3); }

.cal-list-day { padding: var(--space-3) 0; }
.cal-list-day + .cal-list-day { border-top: 1px solid var(--color-border-subtle); }

.cal-list-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 0 var(--space-2) var(--space-2);
  flex-wrap: wrap;
}
.cal-list-day-wd {
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  color: var(--color-text-primary);
  margin-right: 8px;
}
.cal-list-day-date { color: var(--color-text-secondary); font-size: var(--text-sm); }
.cal-list-day-total {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--color-text-secondary);
}

.cal-list-items { display: flex; flex-direction: column; gap: 4px; }

.cal-list-item {
  display: grid;
  grid-template-columns: 72px 4px 1fr auto auto;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-2);
  border-radius: var(--radius-sm);
  transition: background var(--duration-fast) var(--ease-default);
  cursor: pointer;
}
.cal-list-item:hover { background: var(--color-sidebar-hover); }
.cal-list-item-time {
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-size: var(--text-xs);
}
.cal-list-item-start { font-weight: var(--weight-semibold); color: var(--color-text-primary); }
.cal-list-item-end   { color: var(--color-text-secondary); }
.cal-list-item-bar {
  height: 28px;
  border-radius: 2px;
}
.cal-list-item-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
}
.cal-list-item-meta {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 2px;
}
.cal-list-sep { color: var(--color-text-disabled); }
.cal-tag {
  font-size: 10px;
  font-weight: var(--weight-semibold);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: var(--color-bg-tertiary);
  color: var(--color-text-body);
}
.cal-list-item-price {
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--color-text-primary);
  font-variant-numeric: tabular-nums;
}

/* ── Timeline Horizontal ──────────────────────────────────────────────── */

.cal-tl-subhead {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-secondary);
  border-bottom: 1px solid var(--color-border-subtle);
  background: var(--color-bg-secondary);
}

.cal-tlh-scroller {
  overflow-x: auto;
}
.cal-tlh { min-width: 100%; display: flex; flex-direction: column; }

.cal-tlh-header {
  display: flex;
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border-subtle);
  position: sticky; top: 0; z-index: 1;
}
.cal-tlh-staff-spacer,
.cal-tlh-staff {
  width: 180px;
  flex-shrink: 0;
  padding: 10px 12px;
  border-right: 1px solid var(--color-border-subtle);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
}
.cal-tlh-staff-spacer { color: var(--color-text-secondary); text-transform: uppercase; font-size: var(--text-xs); letter-spacing: 0.5px; }

.cal-tlh-hours { display: flex; }
.cal-tlh-hour {
  padding: 10px 8px;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--color-text-secondary);
  border-right: 1px solid var(--color-border-subtle);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.cal-tlh-hour:last-child { border-right: none; }

.cal-tlh-row {
  display: flex;
  border-bottom: 1px solid var(--color-border-subtle);
  min-height: 64px;
}
.cal-tlh-row:last-child { border-bottom: none; }

.cal-tlh-lane {
  position: relative;
  flex-shrink: 0;
}
.cal-tlh-grid-col {
  position: absolute;
  top: 0; bottom: 0;
  width: 1px;
  background: var(--color-border-subtle);
}
.cal-tlh-bar {
  position: absolute;
  top: 8px;
  bottom: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border-left: 3px solid currentColor;
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  transition: transform var(--duration-fast) var(--ease-default),
              box-shadow var(--duration-fast) var(--ease-default);
}
.cal-tlh-bar:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); z-index: 1; }
.cal-tlh-bar-title {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-tlh-bar-meta {
  font-size: 10px;
  opacity: 0.78;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Timeline Vertical ────────────────────────────────────────────────── */

.cal-tlv { display: flex; flex-direction: column; }
.cal-tlv-header {
  display: grid;
  grid-template-columns: 60px 1fr;
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border-subtle);
  position: sticky; top: 0; z-index: 1;
}
.cal-tlv-hours-spacer {
  padding: 10px 8px;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-right: 1px solid var(--color-border-subtle);
}
.cal-tlv-staff-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}
.cal-tlv-staff-header {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
  border-right: 1px solid var(--color-border-subtle);
}
.cal-tlv-staff-header:last-child { border-right: none; }
.cal-tlv-staff-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-tlv-body {
  display: grid;
  grid-template-columns: 60px 1fr;
}
.cal-tlv-hours {
  border-right: 1px solid var(--color-border-subtle);
  background: var(--color-bg-secondary);
}
.cal-tlv-hour {
  padding: 4px 8px;
  border-bottom: 1px solid var(--color-border-subtle);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
}
.cal-tlv-cols {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}
.cal-tlv-staff-col {
  position: relative;
  border-right: 1px solid var(--color-border-subtle);
}
.cal-tlv-staff-col:last-child { border-right: none; }
.cal-tlv-grid-row {
  position: absolute;
  left: 0; right: 0;
  height: 1px;
  background: var(--color-border-subtle);
  pointer-events: none;
}
.cal-tlv-bar {
  position: absolute;
  left: 4px; right: 4px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border-left: 3px solid currentColor;
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: transform var(--duration-fast) var(--ease-default),
              box-shadow var(--duration-fast) var(--ease-default);
}
.cal-tlv-bar:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); z-index: 1; }
.cal-tlv-bar-title {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-tlv-bar-meta {
  font-size: 10px;
  opacity: 0.78;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

/* ── Staff avatar (shared) ────────────────────────────────────────────── */

.cal-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: var(--weight-bold);
  flex-shrink: 0;
}

/* ── Map view ─────────────────────────────────────────────────────────── */

.cal-map {
  display: grid;
  grid-template-columns: 1fr 320px;
  min-height: 560px;
}
.cal-map-canvas {
  position: relative;
  background:
    radial-gradient(circle at 20% 30%, rgba(0, 196, 224, 0.08), transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(0, 196, 224, 0.06), transparent 45%),
    var(--color-bg-secondary);
  overflow: hidden;
  border-right: 1px solid var(--color-border-subtle);
}
.cal-map-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right,  rgba(15, 17, 21, 0.05) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(15, 17, 21, 0.05) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
}
.cal-map-pin {
  position: absolute;
  transform: translate(-50%, -100%);
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid var(--color-bg-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform var(--duration-fast) var(--ease-default);
}
.cal-map-pin:hover { transform: translate(-50%, -100%) scale(1.1); }
.cal-map-pin svg { width: 16px; height: 16px; }

.cal-map-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-8);
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
}

.cal-map-side {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-height: 560px;
  overflow-y: auto;
}
.cal-map-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}
.cal-map-side-head h3 {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
}
.cal-map-side-count {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--color-text-secondary);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--color-bg-secondary);
}
.cal-map-list { display: flex; flex-direction: column; gap: 4px; }
.cal-map-item {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: var(--space-3);
  align-items: center;
  padding: 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-default);
}
.cal-map-item:hover { background: var(--color-sidebar-hover); }
.cal-map-item-pin {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: currentColor;
}
.cal-map-item-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
}
.cal-map-item-meta {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  margin-top: 2px;
}
.cal-map-item-price {
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--color-text-primary);
  font-variant-numeric: tabular-nums;
}
.cal-map-item-empty {
  padding: var(--space-4);
  text-align: center;
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
}

/* ── Responsive ───────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .cal-month-cell { min-height: 80px; padding: 4px; }
  .cal-month-grid { grid-auto-rows: minmax(80px, 1fr); }
  .cal-event-chip-title { display: none; }
  .cal-map { grid-template-columns: 1fr; min-height: auto; }
  .cal-map-canvas { height: 320px; border-right: none; border-bottom: 1px solid var(--color-border-subtle); }
  .cal-map-side { max-height: none; }
  .cal-tlv-staff-row { grid-template-columns: repeat(5, minmax(140px, 1fr)); }
  .cal-tlv-cols { grid-template-columns: repeat(5, minmax(140px, 1fr)); }
  .cal-tlv-header, .cal-tlv-body { overflow-x: auto; }
  .cal-list-item { grid-template-columns: 60px 4px 1fr auto; }
  .cal-list-item-type { display: none; }
  .cal-split { grid-template-columns: 1fr; }
  .cal-split-left { max-height: none; }
  .cal-year-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Mobile layout: compact filters, moved below calendar ─────────────── */

@media (max-width: 640px) {
  /* Reorder: header → toolbar → calendar → filters */
  .cal-page {
    display: flex;
    flex-direction: column;
  }
  .cal-page > .page-header { order: 0; }
  .cal-page > .cal-toolbar { order: 1; }
  .cal-page > .cal-viewport { order: 2; }
  .cal-page > .cal-filters  { order: 3; margin-top: var(--space-3); margin-bottom: 0; }

  /* Header grid:
       row 1: [ date heading | New Booking ]
       row 2: [ revenue pill full-width   ] */
  .cal-page-header {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "title   button"
      "revenue revenue";
    gap: var(--space-2) var(--space-3);
    align-items: center;
  }
  .cal-page-title {
    grid-area: title;
    font-size: var(--text-lg);
    margin: 0;
    min-width: 0;
    line-height: var(--leading-tight);
  }
  /* Let .cal-header-right's children become direct grid items */
  .cal-header-right { display: contents; }
  .cal-new-booking {
    grid-area: button;
    align-self: center;
  }
  .cal-revenue {
    grid-area: revenue;
    display: flex;
    width: 100%;
    padding: 8px 14px;
    gap: var(--space-2);
    justify-content: flex-start;
  }
  .cal-revenue-label {
    font-size: 9px;
    letter-spacing: 0.3px;
  }
  .cal-revenue-value { font-size: var(--text-base); }
  .cal-revenue-count { font-size: 10px; margin-left: auto; }

  /* Compact toolbar */
  .cal-toolbar { gap: var(--space-2); margin-bottom: var(--space-2); }

  /* Filters: remove labels, tighter spacing, specific stack */
  .cal-filters {
    gap: 6px;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
  }
  .cal-filter-label { display: none; }
  .cal-filter-group { gap: 6px; }
  .cal-chip { padding: 5px 10px; }
  .cal-ms-btn { min-width: 0; padding: 6px 10px; width: 100%; }
  .cal-ms-dropdown { flex: 1; }
  .cal-ms-summary { max-width: none; }

  /* Row 1: Type (Mobile + Shop) + Holidays
     Row 2: Tags (full width)
     Row 3: Bay / Van (full width) */
  .cal-filters .cal-filter-group:nth-child(1) { order: 1; } /* Type */
  .cal-filters .cal-filter-group:nth-child(4) { order: 2; } /* Holidays */
  .cal-filters .cal-filter-group:nth-child(2) { order: 3; flex: 1 0 100%; } /* Tags */
  .cal-filters .cal-filter-group:nth-child(3) { order: 4; flex: 1 0 100%; } /* Bay/Van */

  /* Dropdowns: a bit smaller panel so they don't overflow the viewport */
  .cal-dropdown-panel { min-width: 200px; }
  .cal-view-panel { right: auto; left: 0; }
}

/* ── Multi-select dropdown ────────────────────────────────────────────── */

.cal-ms-btn {
  min-width: 160px;
  justify-content: space-between;
}
.cal-ms-summary {
  flex: 1;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}
.cal-ms-count {
  font-size: 11px;
  font-weight: var(--weight-semibold);
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: var(--color-bg-secondary);
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.cal-dropdown.open .cal-ms-count {
  background: var(--color-brand-emerald);
  color: #fff;
}

.cal-ms-panel { min-width: 220px; max-height: 340px; }
.cal-ms-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 8px;
  border-bottom: 1px solid var(--color-border-subtle);
  margin-bottom: 4px;
}
.cal-ms-link {
  background: transparent;
  border: none;
  color: var(--color-brand-emerald);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-family: var(--font-primary);
}
.cal-ms-link:hover { background: var(--color-brand-emerald-50); }

.cal-ms-list { display: flex; flex-direction: column; gap: 1px; }

.cal-ms-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--color-text-body);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-default);
  user-select: none;
}
.cal-ms-item:hover { background: var(--color-sidebar-hover); color: var(--color-text-primary); }

.cal-ms-item input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0; height: 0;
}
.cal-ms-box {
  width: 18px; height: 18px;
  border-radius: 5px;
  border: 1.5px solid var(--color-border);
  background: var(--color-bg-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  flex-shrink: 0;
  transition: all var(--duration-fast) var(--ease-default);
}
.cal-ms-box svg { width: 12px; height: 12px; }
.cal-ms-item.checked .cal-ms-box {
  background: var(--color-brand-emerald);
  border-color: var(--color-brand-emerald);
  color: #fff;
}
.cal-ms-label { flex: 1; }

/* ── Year heatmap ─────────────────────────────────────────────────────── */

.cal-year { padding: var(--space-4); }

.cal-year-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-5);
  margin-bottom: var(--space-5);
}
@media (max-width: 1100px) { .cal-year-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 820px)  { .cal-year-grid { grid-template-columns: repeat(2, 1fr); } }

.cal-year-month { }
.cal-year-month-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
  margin-bottom: 6px;
}
.cal-year-wd {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 4px;
}
.cal-year-wd span {
  text-align: center;
  font-size: 9px;
  font-weight: var(--weight-semibold);
  color: var(--color-text-disabled);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.cal-year-grid-mini {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.cal-year-cell {
  aspect-ratio: 1;
  border-radius: 3px;
  background: var(--color-bg-secondary);
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-default);
}
.cal-year-cell:hover { transform: scale(1.2); outline: 1px solid var(--color-text-secondary); }
.cal-year-cell.empty { background: transparent; cursor: default; pointer-events: none; }
.cal-year-cell[data-level="1"] { background: rgba(0, 196, 224, 0.22); }
.cal-year-cell[data-level="2"] { background: rgba(0, 196, 224, 0.45); }
.cal-year-cell[data-level="3"] { background: rgba(0, 196, 224, 0.72); }
.cal-year-cell[data-level="4"] { background: var(--color-brand-emerald); }
.cal-year-cell.is-today { outline: 1.5px solid var(--color-brand-emerald-deep); outline-offset: 1px; }
.cal-year-cell.is-holiday { box-shadow: inset 0 0 0 1.5px var(--tile-amber-fg); }

.cal-year-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  padding: var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  border-top: 1px solid var(--color-border-subtle);
}
.cal-year-legend-cell {
  width: 12px; height: 12px;
  border-radius: 3px;
}
.cal-year-legend-cell[data-level="1"] { background: rgba(0, 196, 224, 0.22); }
.cal-year-legend-cell[data-level="2"] { background: rgba(0, 196, 224, 0.45); }
.cal-year-legend-cell[data-level="3"] { background: rgba(0, 196, 224, 0.72); }
.cal-year-legend-cell[data-level="4"] { background: var(--color-brand-emerald); }
.cal-year-legend-sep { color: var(--color-text-disabled); margin: 0 6px; }

/* ── Resource (bay/van) ───────────────────────────────────────────────── */

.cal-resource-chip {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.cal-resource-count {
  margin-left: auto;
  font-size: 10px;
  font-weight: var(--weight-semibold);
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: var(--color-bg-secondary);
  color: var(--color-text-secondary);
}

/* ── Split view ───────────────────────────────────────────────────────── */

.cal-split {
  display: grid;
  grid-template-columns: 340px 1fr;
  min-height: 560px;
}
.cal-split-left {
  border-right: 1px solid var(--color-border-subtle);
  padding: var(--space-3);
  max-height: 720px;
  overflow-y: auto;
  background: var(--color-bg-secondary);
}
.cal-split-left-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 4px 4px 10px;
}
.cal-split-left-head h3 {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
}
.cal-split-total {
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--color-brand-emerald-deep);
}
.cal-split-staff-list-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.cal-split-staff-card {
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}
.cal-split-staff-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: 8px;
}
.cal-split-staff-meta { line-height: 1.2; }
.cal-split-staff-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
}
.cal-split-staff-sub {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
}
.cal-split-staff-list { display: flex; flex-direction: column; gap: 2px; }
.cal-split-staff-item {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border-left: 3px solid currentColor;
  font-size: var(--text-xs);
  cursor: pointer;
}
.cal-split-staff-time { font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; }
.cal-split-staff-title { font-weight: var(--weight-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-split-staff-client { opacity: 0.7; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-split-staff-empty {
  font-size: var(--text-xs);
  color: var(--color-text-disabled);
  padding: 4px 8px;
  font-style: italic;
}
.cal-split-right { display: flex; flex-direction: column; overflow-x: auto; }

/* ── Route planner ────────────────────────────────────────────────────── */

.cal-routes .cal-map-canvas { min-height: 480px; }

.cal-route-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.cal-route-pin {
  width: 36px; height: 36px;
}
.cal-route-seq {
  font-size: 13px;
  font-weight: var(--weight-bold);
  color: currentColor;
}

.cal-route-summary {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cal-route-summary-row {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}
.cal-route-summary-row strong {
  color: var(--color-text-primary);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
}
.cal-route-optimize { margin-top: 4px; align-self: flex-start; }

.cal-route-item-seq {
  width: 24px; height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: var(--weight-bold);
  flex-shrink: 0;
}

/* ── Overflow fix for filters row (dropdown must overflow) ─────────────── */

.cal-filters { overflow: visible; }
.cal-filter-group { position: relative; }
