/* ──────────────────────────────────────────────────────────────────────────
 * RMS — Design System · Balcons de Barcelona
 * Charte: docs/design.md
 * ──────────────────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

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

:root {
  /* ── Brand ────────────────────────────────────────────── */
  --brand-yellow:      #F4C430;
  --brand-yellow-700:  #B45309;
  --brand-yellow-soft: #FEF6D6;
  --brand-green:       #16A34A;
  --brand-green-700:   #15803D;
  --brand-green-soft:  #DCFCE7;
  --sidebar-bg:        linear-gradient(160deg, #1A9E58 0%, #0B4422 100%);

  /* ── Neutrals ─────────────────────────────────────────── */
  --bg-page:        #F8FAFC;
  --bg-surface:     #FFFFFF;
  --bg-muted:       #F1F5F9;
  --border:         #E2E8F0;
  --border-strong:  #CBD5E1;
  --text-primary:   #0F172A;
  --text-secondary: #475569;
  --text-muted:     #94A3B8;

  /* ── Semantic ─────────────────────────────────────────── */
  --success:       #10B981;
  --success-soft:  #D1FAE5;
  --success-text:  #065F46;
  --warning:       #F59E0B;
  --warning-soft:  #FEF3C7;
  --warning-text:  #92400E;
  --danger:        #EF4444;
  --danger-soft:   #FEE2E2;
  --danger-text:   #991B1B;

  /* ── Typography ───────────────────────────────────────── */
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --text-xs:   13px;
  --text-sm:   15px;
  --text-base: 16px;
  --text-md:   18px;
  --text-lg:   21px;
  --text-xl:   25px;
  --text-2xl:  33px;

  /* ── Spacing ──────────────────────────────────────────── */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px;
  --s-5: 24px; --s-6: 32px; --s-8: 48px; --s-10: 64px;

  /* ── Radii ────────────────────────────────────────────── */
  --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-xl: 16px; --r-full: 9999px;

  /* ── Shadows ──────────────────────────────────────────── */
  --shadow-sm: 0 1px 2px rgba(15,23,42,.04), 0 1px 3px rgba(15,23,42,.06);
  --shadow-md: 0 2px 4px rgba(15,23,42,.06), 0 4px 12px rgba(15,23,42,.08);
  --shadow-lg: 0 8px 24px rgba(15,23,42,.12), 0 2px 8px rgba(15,23,42,.08);

  /* ── Transitions ──────────────────────────────────────── */
  --t-fast: 120ms ease;
  --t-base: 180ms ease;
}

/* ── Base ──────────────────────────────────────────────────────────── */
html { font-size: 100%; height: 100%; }
body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  height: 100%;
}
button { font-family: inherit; }
a { color: var(--brand-green); text-decoration: none; }

/* ════════════════════════════════════════════════════════════════════
   APP SHELL — sidebar + content
   ════════════════════════════════════════════════════════════════════ */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ───────────────────────────────────────────────────────── */
.sidebar {
  width: 220px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
  transition: width .2s ease;
  position: relative;
}
.sidebar.collapsed { width: 56px; }
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 14px 16px;
  border-bottom: 1px solid var(--border);
  min-height: 68px;
}
.sidebar-logo-img { width: 34px; height: 34px; flex-shrink: 0; }
.sidebar-brand {
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: .01em;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity .15s ease, width .15s ease;
}
.sidebar.collapsed .sidebar-brand    { opacity: 0; width: 0; }
.sidebar.collapsed .sidebar-label    { opacity: 0; width: 0; max-width: 0; overflow: hidden; flex: none; }
.sidebar.collapsed .sidebar-soon     { display: none; }
.sidebar.collapsed .sidebar-username { opacity: 0; width: 0; overflow: hidden; }
.sidebar.collapsed .sidebar-item     { justify-content: center; padding: 0; gap: 0; height: 44px; }
.sidebar.collapsed .sidebar-logo     { justify-content: center; }
.sidebar.collapsed .sidebar-logo-img { visibility: hidden; }
.sidebar.collapsed .sidebar-footer   { justify-content: center; flex-direction: column; gap: 6px; }
.sidebar.collapsed .sidebar-user     { justify-content: center; }

.sidebar-toggle {
  position: absolute;
  top: 18px;
  right: 10px;
  width: 24px;
  height: 24px;
  background: var(--bg-muted);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background var(--t-fast), color var(--t-fast), transform .2s ease;
  z-index: 2;
}
.sidebar-toggle:hover { background: var(--border); color: var(--text-primary); }
.sidebar.collapsed .sidebar-toggle { transform: rotate(180deg); right: auto; left: calc(50% - 12px); }
.sidebar-toggle svg { width: 14px; height: 14px; }

/* ── Collapsed tooltips ───────────────────────────────────────────── */
.sidebar-tooltip {
  position: fixed;
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 7px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand-green);
  box-shadow: var(--shadow-md);
  white-space: nowrap;
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 150ms ease, transform 150ms ease;
}
.sidebar-tooltip.visible {
  opacity: 1;
  transform: translateX(0);
}

.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 10px;
  border-radius: var(--r-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 500;
  transition: background var(--t-fast), color var(--t-fast);
  user-select: none;
}
.sidebar-item:hover:not(.disabled) {
  background: var(--bg-muted);
  color: var(--text-primary);
}
.sidebar-item.active {
  background: var(--brand-green-soft);
  color: #065F46;
}
.sidebar-item.active:hover { background: #bbf7d0; }
.sidebar-item.disabled { cursor: default; color: var(--text-muted); }
.sidebar-icon { width: 30px; height: 30px; flex-shrink: 0; display: flex; align-items: center; }
.sidebar-icon svg { width: 30px; height: 30px; }
.sidebar-label { flex: 1; }
.sidebar-soon {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  background: var(--bg-muted);
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: var(--r-sm);
}

.sidebar-expand-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  margin-left: auto;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  flex-shrink: 0;
  border-radius: var(--r-sm);
  transition: color var(--t-fast);
}
.sidebar-expand-btn:hover { color: var(--text-primary); }
.sidebar-expand-btn svg { width: 13px; height: 13px; transition: transform .18s ease; }
.sidebar-expand-btn.open svg { transform: rotate(180deg); }
.sidebar.collapsed .sidebar-expand-btn { display: none; }

.sidebar-subnav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 2px 0 4px 40px;
  overflow: hidden;
}
.sidebar.collapsed .sidebar-subnav { display: none; }
.sidebar-subitem {
  display: block;
  padding: 6px 10px;
  border-radius: var(--r-md);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background var(--t-fast), color var(--t-fast);
}
.sidebar-subitem:hover { background: var(--bg-muted); color: var(--text-primary); }
.sidebar-subitem.active { color: #065F46; font-weight: 600; }

.sidebar-flyout {
  position: fixed;
  z-index: 400;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--s-2);
  min-width: 160px;
}
.sidebar-flyout-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  padding: var(--s-1) var(--s-2) var(--s-2);
}
.sidebar-flyout-item {
  display: block;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-decoration: none;
  transition: background var(--t-fast), color var(--t-fast);
}
.sidebar-flyout-item:hover { background: var(--bg-muted); color: var(--text-primary); }
.sidebar-flyout-item.active { color: #065F46; font-weight: 600; }

.sidebar-footer {
  padding: 10px 8px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-user { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.sidebar-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand-green-soft);
  color: #065F46;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-username {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-logout {
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  transition: background var(--t-fast), color var(--t-fast);
  flex-shrink: 0;
}
.sidebar-logout:hover { background: var(--bg-muted); color: var(--text-primary); }
.sidebar-logout svg { width: 18px; height: 18px; }

/* ── App body ──────────────────────────────────────────────────────── */
.app-body { flex: 1; overflow-y: auto; min-width: 0; }
.main { max-width: 1280px; margin: 0 auto; padding: var(--s-6) var(--s-5); }

/* ════════════════════════════════════════════════════════════════════
   PAGE COMPONENTS
   ════════════════════════════════════════════════════════════════════ */

/* ── Page header ──────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-5);
  flex-wrap: wrap;
  gap: var(--s-3);
}
.page-title { font-size: var(--text-xl); font-weight: 700; letter-spacing: -.01em; }

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: 0 var(--s-4);
  height: 36px;
  border-radius: var(--r-md);
  font-size: var(--text-base);
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--t-fast), border-color var(--t-fast);
  white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { height: 30px; padding: 0 var(--s-3); font-size: var(--text-sm); }
.btn-primary { background: var(--brand-green); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-green-700); }
.btn-secondary { background: var(--bg-surface); color: var(--text-primary); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-muted); }
.btn-ghost  { background: transparent; color: var(--text-secondary); border-color: var(--border); }
.btn-ghost:hover:not(:disabled)  { background: var(--bg-muted); color: var(--text-primary); }
.btn-danger { background: var(--danger-soft); color: var(--danger-text); border-color: var(--danger-soft); }
.btn-danger:hover:not(:disabled) { background: #fecaca; }

/* ── Text + weight utilities ─��────────────────────────────────────────── */
.text-xs   { font-size: var(--text-xs); }
.text-sm   { font-size: var(--text-sm); }
.text-muted { color: var(--text-muted); }
.fw-medium { font-weight: 500; }
.fw-bold   { font-weight: 700; }

/* ── Filters ──────────────────────────────────────────────────────── */
.filters { display: flex; gap: var(--s-2); flex-wrap: wrap; margin-bottom: var(--s-5); }
.filter-select {
  padding: 0 var(--s-3);
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-surface);
  font-family: inherit;
  font-size: var(--text-sm);
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color var(--t-fast);
}
.filter-select:hover { border-color: var(--border-strong); }
.filter-select:focus { outline: none; border-color: var(--brand-green); box-shadow: 0 0 0 3px rgba(27,94,32,.1); }

/* ── Stat cards ───────────────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-3); margin-bottom: var(--s-5); }
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-4) var(--s-5);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent, transparent);
}
.stat-card[data-accent="green"]   { --accent: var(--brand-green); }
.stat-card[data-accent="yellow"]  { --accent: var(--brand-yellow); }
.stat-card[data-accent="muted"]   { --accent: var(--border-strong); }
.stat-card[data-accent="success"] { --accent: var(--success); }
.stat-value { font-size: var(--text-2xl); font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.stat-label { font-size: var(--text-sm); color: var(--text-secondary); margin-top: var(--s-1); font-weight: 500; }

/* ── Table ────────────────────────────────────────────────────────── */
.table-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; }
thead { background: var(--bg-muted); border-bottom: 1px solid var(--border); }
thead th {
  text-align: left;
  padding: 22px var(--s-4);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .07em;
  white-space: nowrap;
}
thead th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color var(--t-fast);
}
thead th.sortable:hover { color: var(--text-primary); }
thead th.sort-active { color: var(--text-secondary); }
.sort-indicator { margin-left: 4px; opacity: .6; }

tbody tr { border-bottom: 1px solid var(--border); transition: background var(--t-fast); }
tbody tr:last-child { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--brand-yellow-soft); }
tbody td { padding: 10px var(--s-4); font-size: var(--text-base); }

.ref-cell { font-weight: 600; font-size: var(--text-sm); color: #065F46; }
.name-cell { font-weight: 500; }
.muted { color: var(--text-muted); }

/* ── Cell icons (type / magic link) ──────────────────────────────── */
.cell-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  transition: background var(--t-fast);
}
.cell-icon svg { width: 16px; height: 16px; }
.cell-icon.tourism   { color: var(--brand-yellow-700); background: var(--brand-yellow-soft); }
.cell-icon.temporada { color: var(--brand-green);      background: var(--brand-green-soft); }
.cell-icon.key-on    { color: var(--brand-green); background: var(--brand-green-soft); }
.cell-icon.key-off   { color: var(--text-muted); opacity: .45; }

/* ── Completion progress ──────────────────────────────────────────── */
.progress-row { display: flex; align-items: center; gap: 6px; }
.progress-track {
  width: 48px;
  height: 4px;
  background: var(--border);
  border-radius: var(--r-full);
  overflow: hidden;
  flex-shrink: 0;
}
.progress-fill { height: 100%; border-radius: var(--r-full); transition: width .3s ease; }
.progress-fill.high { background: var(--success); }
.progress-fill.mid  { background: var(--warning); }
.progress-fill.low  { background: var(--danger); }
.progress-label { font-size: var(--text-xs); font-weight: 600; color: var(--text-muted); min-width: 28px; }

/* ── Status badges ────────────────────────────────────────────────── */
.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
  font-weight: 500;
}
.status-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
  flex-shrink: 0;
}
.status-dot.active   { color: var(--success-text); }
.status-dot.inactive { color: var(--text-muted); }

/* ── Empty state ──────────────────────────────────────────────────── */
.state-msg { text-align: center; padding: var(--s-10) var(--s-4); color: var(--text-muted); font-size: var(--text-sm); }

/* ════════════════════════════════════════════════════════════════════
   LOGIN PAGE
   ════════════════════════════════════════════════════════════════════ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-5);
  background:
    radial-gradient(ellipse at 80% 10%, rgba(244,196,48,.13) 0%, transparent 50%),
    radial-gradient(ellipse at 20% 90%, rgba(27,94,32,.09) 0%, transparent 50%),
    var(--bg-page);
}
.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--s-8) var(--s-6);
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.login-logo { text-align: center; margin-bottom: var(--s-6); }
.login-logo .logo { width: 64px; height: 64px; margin-bottom: var(--s-3); }
.login-logo h1 { font-size: var(--text-xl); font-weight: 700; color: var(--brand-green); letter-spacing: -.01em; }
.login-logo p { font-size: var(--text-sm); color: var(--text-muted); margin-top: var(--s-1); }

/* ── Forms (shared) ───────────────────────────────────────────────── */
.form-group { margin-bottom: var(--s-4); }
.form-group label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0 var(--s-3);
  height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--bg-surface);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.form-group textarea { height: auto; padding: var(--s-2) var(--s-3); resize: vertical; min-height: 72px; }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--brand-green);
  box-shadow: 0 0 0 3px rgba(27,94,32,.12);
}
.form-group input:disabled { background: var(--bg-muted); color: var(--text-muted); cursor: not-allowed; }
.form-group label .hint { font-weight: 400; color: var(--text-muted); }

.btn-block { width: 100%; height: 44px; font-size: var(--text-md); }
.login-error {
  margin-top: var(--s-3);
  padding: var(--s-2) var(--s-3);
  background: var(--danger-soft);
  color: var(--danger-text);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  display: none;
}

/* ── Modal ────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--s-8) var(--s-4);
  z-index: 1000;
  overflow-y: auto;
  backdrop-filter: blur(2px);
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--bg-surface);
  border-radius: var(--r-xl);
  width: 100%;
  max-width: 640px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 6rem);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border);
  background: var(--bg-muted);
}
.modal-header h2 { font-size: var(--text-lg); font-weight: 700; letter-spacing: -.01em; }
.modal-header-actions { display: flex; align-items: center; gap: var(--s-2); }
.modal-close { background: transparent; border: none; font-size: 24px; line-height: 1; cursor: pointer; color: var(--text-muted); padding: 0 2px; }
.modal-close:hover { color: var(--text-primary); }

/* ── Lock button ──────────────────────────────────────────────────── */
.modal-lock-btn {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  border: none; border-radius: var(--r-md); cursor: pointer;
  background: var(--warning-soft); color: var(--warning-text);
  transition: background var(--t-fast), color var(--t-fast);
}
.modal-lock-btn:hover { background: #fde68a; }
.modal-lock-btn.unlocked { background: var(--brand-green-soft); color: #065F46; }
.modal-lock-btn.unlocked:hover { background: #bbf7d0; }
.modal-lock-btn svg { width: 15px; height: 15px; }

/* ── Form locked state ────────────────────────────────────────────── */
.form-locked input:not([type=checkbox]):not([disabled]),
.form-locked textarea {
  background: var(--bg-muted);
  color: var(--text-secondary);
  cursor: text;
}
.form-locked select,
.form-locked .form-checkbox {
  pointer-events: none;
  opacity: .75;
}
.form-locked .modal-footer .btn-primary { display: none; }
.form-locked #modal-cancel::after { content: ' (read only)'; font-size: 11px; opacity: .6; }
.modal-body { padding: var(--s-5); overflow-y: auto; }

.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-3); margin-bottom: var(--s-3); }
.form-row.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-row.cols-4 { grid-template-columns: repeat(4, 1fr); }
.form-row > .form-group { margin-bottom: 0; }

.modal-body .form-group label {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 5px;
}
.form-toggle {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-toggle .toggle-label-text {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.form-toggle label {
  display: flex !important;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding-top: 2px;
  font-size: var(--text-sm) !important;
  font-weight: 500 !important;
  color: var(--text-primary) !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  margin-bottom: 0 !important;
}
.form-toggle input[type="checkbox"] { display: none; }
.toggle-track {
  position: relative;
  width: 36px;
  height: 20px;
  background: var(--border-strong);
  border-radius: var(--r-full);
  flex-shrink: 0;
  transition: background var(--t-base);
}
.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 14px; height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--t-base);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.form-toggle input:checked + .toggle-track { background: var(--brand-green); }
.form-toggle input:checked + .toggle-track::after { transform: translateX(16px); }

/* locked toggle */
.form-locked .form-toggle { pointer-events: none; opacity: .75; }

.modal-error {
  padding: var(--s-2) var(--s-3);
  background: var(--danger-soft);
  color: var(--danger-text);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  margin-bottom: var(--s-3);
}
.modal-error[hidden] { display: none; }
.modal-footer { display: flex; justify-content: flex-end; gap: var(--s-2); padding: var(--s-4) var(--s-5); border-top: 1px solid var(--border); margin-top: var(--s-3); }

/* ── Mobile topbar ────────────────────────────────────────────────── */
.mobile-topbar {
  display: none;
  align-items: center;
  height: 56px;
  padding: 0 var(--s-4);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.mobile-topbar-title {
  flex: 1;
  text-align: center;
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.01em;
}
.topbar-spacer { width: 40px; flex-shrink: 0; }

.hamburger {
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-radius: var(--r-md);
  flex-shrink: 0;
  transition: background var(--t-fast);
}
.hamburger:hover { background: var(--bg-muted); }
.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
}

/* ── Sidebar overlay (mobile) ─────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.45);
  z-index: 199;
  backdrop-filter: blur(1px);
}
.sidebar-overlay.visible { display: block; }

/* ── Responsive ───────────────────────────────────────────────────── */
/* ════════════════════════════════════════════════════════════════════
   BOOKINGS PAGE
   ════════════════════════════════════════════════════════════════════ */

/* ── Filters row ──────────────────────────────────────────────────── */
.bookings-filters { align-items: center; gap: var(--s-2); row-gap: var(--s-2); }
.filter-search { min-width: 160px; }

/* ── Date range picker ────────────────────────────────────────────── */
.daterange-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.daterange-wrap:focus-within {
  border-color: var(--brand-green);
  box-shadow: 0 0 0 3px rgba(27,94,32,.1);
}
.daterange-cal-icon {
  width: 15px; height: 15px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.daterange-input {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: var(--text-sm);
  color: var(--text-primary);
  padding: 0;
  cursor: pointer;
  width: 118px;
}
.daterange-input:focus { outline: none; }
.daterange-sep { color: var(--text-muted); font-size: var(--text-sm); flex-shrink: 0; }

/* ── Date shortcuts ───────────────────────────────────────────────── */
.date-shortcuts { display: flex; gap: 4px; flex-wrap: wrap; }
.shortcut-btn {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-surface);
  font-family: inherit;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
  white-space: nowrap;
}
.shortcut-btn:hover { background: var(--bg-muted); border-color: var(--border-strong); }
.shortcut-btn.active { background: var(--brand-green-soft); border-color: var(--brand-green); color: #065F46; }

/* ── Channel badges ───────────────────────────────────────────────── */
.ch-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .03em;
  white-space: nowrap;
}
.ch-airbnb  { background: #FFF0E6; color: #C24B00; }
.ch-booking { background: #E6F0FF; color: #0044CC; }
.ch-other   { background: var(--bg-muted); color: var(--text-muted); }

/* ── Booking status badges ────────────────────────────────────────── */
.booking-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--text-sm);
  font-weight: 500;
}
.booking-status::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.booking-status.confirmed::before { background: var(--success); }
.booking-status.confirmed { color: var(--success-text); }
.booking-status.canceled::before  { background: var(--text-muted); }
.booking-status.canceled  { color: var(--text-muted); }
.booking-status.payout::before    { background: var(--warning); }
.booking-status.payout    { color: var(--warning-text); }

/* ── Task badges (table) ──────────────────────────────────────────── */
.tasks-group { display: inline-flex; gap: 4px; }
.task-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: var(--r-sm);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .02em;
  text-decoration: none;
  transition: opacity var(--t-fast), transform var(--t-fast);
}
.task-badge:hover { opacity: .8; transform: scale(1.1); }
.task-ci { background: var(--brand-green-soft); color: #065F46; }
.task-mn { background: var(--brand-yellow-soft); color: var(--brand-yellow-700); }

/* ── Canceled row ─────────────────────────────────────────────────── */
.row-canceled td { opacity: .5; }
.row-canceled:hover td { opacity: .7; }

/* ── Table footer ─────────────────────────────────────────────────── */
.table-footer {
  padding: var(--s-2) var(--s-4);
  font-size: var(--text-xs);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Time mode selector ───────────────────────────────────────────── */
.time-modes { display: flex; gap: 4px; flex-wrap: wrap; }
.mode-btn {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-surface);
  font-family: inherit;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.mode-btn:hover { background: var(--bg-muted); border-color: var(--border-strong); }
.mode-btn.active { background: var(--brand-green-soft); border-color: var(--brand-green); color: #065F46; }

/* ── Flag filter ──────────────────────────────────────────────────── */
.flag-filter-group { display: flex; align-items: center; gap: 4px; }
.flag-filter-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 700;
  margin-right: 2px;
}
.flag-filter-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  color: var(--text-muted);
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.flag-filter-btn:hover { border-color: var(--border-strong); color: var(--text-primary); }
.flag-filter-btn.active { background: var(--warning-soft); border-color: var(--warning); color: var(--warning-text); }

/* ── Date cell with time ──────────────────────────────────────────── */
.date-cell { white-space: nowrap; }
.date-main { display: inline; font-size: var(--text-sm); }
.date-time {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  border-radius: 3px;
  padding: 1px 5px;
  margin-left: 5px;
  white-space: nowrap;
  vertical-align: middle;
}
.date-time-checkin  { color: var(--brand-green-700); background: var(--brand-green-soft); }
.date-time-checkin.late  { color: #991B1B; background: #FEE2E2; }
.date-time-checkout { color: #92400E; background: #FEF3C7; }

/* ── Status dot (compact — bookings table) ───────────────────────── */
.bk-dot {
  display: inline-block;
  width: 11px; height: 11px;
  border-radius: 50%;
  vertical-align: middle;
  flex-shrink: 0;
}
.bk-dot-green  { background: var(--success); }
.bk-dot-orange { background: var(--warning); }
.bk-dot-gray   { background: var(--text-muted); }

/* ── Flag pills in table ──────────────────────────────────────────── */
.flags-row { display: inline-flex; gap: 4px; }
.flag-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .01em;
}
.flag-pill.on  { background: var(--brand-green-soft); color: #065F46; }
.flag-pill.off { background: var(--bg-muted); color: var(--text-muted); }
.flag-btn-edit {
  cursor: pointer;
  border: 1px solid transparent;
  font-family: inherit;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.flag-btn-edit.on:hover  { border-color: var(--brand-green); }
.flag-btn-edit.off:hover { background: var(--bg-muted); border-color: var(--border-strong); color: var(--text-secondary); }

/* ── Links cell (CF / K / M / ✉) ─────────────────────────────────── */
.links-cell { white-space: nowrap; }
.links-wrap { display: inline-flex; align-items: center; gap: 3px; }
.link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  padding: 0 4px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  font-size: 10px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  color: var(--text-secondary);
  text-decoration: none;
  transition: opacity var(--t-fast), background var(--t-fast);
  white-space: nowrap;
}
.link-btn:hover            { opacity: .75; }
.link-btn-green            { background: var(--brand-green-soft); border-color: transparent; color: #065F46; }
.link-btn-salmon           { background: #FFF0E6; border-color: transparent; color: #C24B00; }
.link-btn-muted            { border-color: transparent; background: transparent; color: var(--text-muted); cursor: default; }
.link-btn-muted:hover      { opacity: 1; }
.link-btn-msg              { font-size: 22px; padding: 3px; padding-bottom: 10px; line-height: 1; }

/* ── Old CF / Message cell (kept for reference) ───────────────────── */
.cf-cell { white-space: nowrap; }
.cf-wrap { display: inline-flex; align-items: center; gap: 4px; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-surface);
  font-size: 14px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background var(--t-fast), border-color var(--t-fast);
  font-family: inherit;
}
.icon-btn:hover { background: var(--bg-muted); border-color: var(--border-strong); }
.icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 8px;
  border-radius: var(--r-sm);
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
  background: var(--brand-green-soft);
  color: #065F46;
  transition: opacity var(--t-fast);
  white-space: nowrap;
}
.icon-link:hover { opacity: .75; }
.msg-link { background: #FFF0E6; color: #C24B00; }

/* ── Inline row edit ──────────────────────────────────────────────── */
.inline-time {
  width: 82px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-surface);
  font-family: inherit;
  font-size: 12px;
  padding: 0 4px;
  color: var(--text-primary);
  cursor: pointer;
}
.inline-time:focus { outline: none; border-color: var(--brand-green); }

.cell-edit { text-align: center; width: 54px; white-space: nowrap; }

.row-edit-btn {
  width: 26px;
  height: 26px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  transition: background var(--t-fast), color var(--t-fast);
}
.row-edit-btn:hover { background: var(--bg-muted); color: var(--text-primary); }
.row-edit-btn svg { width: 14px; height: 14px; }

.row-action-btn {
  width: 26px;
  height: 26px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.row-save-btn { color: var(--success-text); }
.row-save-btn:hover { background: var(--success-soft); border-color: var(--success); }
.row-cancel-btn { color: var(--danger-text); }
.row-cancel-btn:hover { background: var(--danger-soft); border-color: var(--danger); }

.row-editing { background: var(--brand-yellow-soft) !important; }
.row-editing td { opacity: 1 !important; }

/* ── Load more button ─────────────────────────────────────────────── */
.load-more-btn {
  height: 28px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-surface);
  font-family: inherit;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.load-more-btn:hover { background: var(--bg-muted); border-color: var(--border-strong); }

/* ── Col helpers ──────────────────────────────────────────────────── */
.col-center { text-align: center; }
.th-cf { font-size: 11px; }
.th-status  { width: 32px; padding: 0 4px !important; }
.status-narrow { width: 32px; padding: 4px !important; }

/* ── Task badges — larger ─────────────────────────────────────────── */
.task-badge { width: 28px; height: 28px; font-size: 10px; }

/* ── Bookings page — wider layout ────────────────────────────────── */
[data-page="bookings"] .main { max-width: 1600px; }
[data-page="bookings"] .table-wrap table { min-width: 960px; }

/* ════════════════════════════════════════════════════════════════════
   DETAIL PANEL (right drawer)
   ════════════════════════════════════════════════════════════════════ */
.panel-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.35);
  z-index: 300;
  backdrop-filter: blur(1px);
}
.panel-overlay.visible { display: block; }

.detail-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 380px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 301;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .22s ease;
  overflow: hidden;
}
.detail-panel.open { transform: translateX(0); }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border);
  background: var(--bg-muted);
  flex-shrink: 0;
}
.panel-title-row { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.panel-apt-ref { font-size: var(--text-lg); font-weight: 700; color: #065F46; }
.panel-close {
  background: transparent; border: none; font-size: 22px; line-height: 1;
  cursor: pointer; color: var(--text-muted); padding: 0 2px; flex-shrink: 0;
}
.panel-close:hover { color: var(--text-primary); }

.panel-body { flex: 1; overflow-y: auto; padding: var(--s-4) var(--s-5); }

.panel-section {
  margin-bottom: var(--s-5);
  padding-bottom: var(--s-5);
  border-bottom: 1px solid var(--border);
}
.panel-section:last-child { border-bottom: none; margin-bottom: 0; }
.panel-section-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: var(--s-2);
}
.panel-field-lg { font-size: var(--text-md); font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.panel-field-sm { font-size: var(--text-sm); color: var(--text-secondary); margin-bottom: 2px; }

.panel-kv-grid  { display: flex; flex-direction: column; gap: 6px; }
.panel-kv-row   { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-3); }
.panel-kv-label { font-size: var(--text-sm); color: var(--text-muted); flex-shrink: 0; }
.panel-kv-value { font-size: var(--text-sm); font-weight: 500; color: var(--text-primary); text-align: right; }

/* ── Apartment panel form layout ──────────────────────────────────── */
.pan-section-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
.pan-grid-3      { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-3); }
.pan-grid-4      { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-3); }
.pan-footer {
  padding: var(--s-4) var(--s-5);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  background: var(--bg-surface);
  position: sticky;
  bottom: 0;
}
.pan-error {
  padding: var(--s-2) var(--s-3);
  background: var(--danger-soft);
  color: var(--danger-text);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
}
/* Override modal label style inside panel */
#pan-form .form-group label {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 5px;
}
#pan-form .form-toggle label {
  text-transform: none !important;
  letter-spacing: 0 !important;
  font-size: var(--text-sm) !important;
  color: var(--text-primary) !important;
}
@media (max-width: 640px) {
  .pan-grid-3, .pan-grid-4, .pan-section-row { grid-template-columns: 1fr 1fr; }
}

.panel-dates-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-bottom: var(--s-2);
  flex-wrap: wrap;
}
.panel-date-label { font-size: var(--text-xs); color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.panel-date-value { font-size: var(--text-base); font-weight: 600; color: var(--text-primary); margin-top: 2px; }
.panel-date-arrow { color: var(--text-muted); font-size: var(--text-lg); }
.panel-nights {
  display: inline-block;
  background: var(--bg-muted);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--r-full);
  margin-left: auto;
}

.panel-flags-row { display: flex; flex-direction: column; gap: var(--s-2); }
.panel-status-wrap { margin-bottom: 4px; }
.panel-section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-2); }
.panel-section-header .panel-section-label { margin-bottom: 0; }

.flag-lock-btn {
  display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px;
  border: none; border-radius: var(--r-md); cursor: pointer;
  background: var(--warning-soft); color: var(--warning-text);
  transition: background var(--t-fast), color var(--t-fast);
  flex-shrink: 0;
}
.flag-lock-btn:hover { background: #fde68a; }
.flag-lock-btn.unlocked { background: var(--brand-green-soft); color: #065F46; }
.flag-lock-btn.unlocked:hover { background: #bbf7d0; }
.flag-lock-btn svg { width: 14px; height: 14px; }

.panel-flag-toggles { display: flex; gap: var(--s-2); flex-wrap: wrap; margin-top: var(--s-2); }
.flags-locked .panel-flag-btn { opacity: .6; cursor: not-allowed; }
.panel-flag-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  height: 32px;
  padding: 0 var(--s-2);
  border-radius: var(--r-md);
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: .04em;
  border: 2px solid transparent;
  cursor: pointer;
  font-family: inherit;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.panel-flag-btn:active:not(:disabled) { transform: scale(.95); }
.panel-flag-btn:disabled { opacity: .5; cursor: not-allowed; }
.panel-flag-btn.on  { background: var(--brand-green-soft); border-color: var(--brand-green); color: #065F46; }
.panel-flag-btn.off { background: var(--bg-muted); border-color: var(--border); color: var(--text-muted); }
.panel-flag-btn.off:hover { border-color: var(--border-strong); color: var(--text-secondary); }

.panel-finance-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.panel-finance-table td { padding: 5px 0; }
.panel-finance-table td:first-child { color: var(--text-secondary); }
.panel-finance-table td:last-child  { text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; }
.finance-total td { font-weight: 700; font-size: var(--text-base); border-top: 1px solid var(--border); padding-top: var(--s-2); }

/* ── Access section ───────────────────────────────────────────────── */
.panel-access-row {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-bottom: 8px;
}
.panel-access-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 600;
  width: 90px;
  flex-shrink: 0;
}
.panel-access-code {
  font-family: 'SF Mono', 'Fira Mono', monospace;
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: .08em;
}
.panel-copy-btn {
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 2px 6px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-muted);
  transition: background var(--t-fast);
  display: inline-flex;
  align-items: center;
}
.panel-copy-btn:hover { background: var(--border); color: var(--text-primary); }
.access-tag {
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--r-full);
}
.access-tag.on  { background: var(--brand-green-soft); color: #065F46; }
.access-tag.off { background: var(--bg-muted); color: var(--text-muted); }

/* ── Tasks section (panel) ────────────────────────────────────────── */
.panel-tasks-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.panel-task-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  transition: background var(--t-fast), border-color var(--t-fast);
}
.panel-task-link:hover { background: var(--bg-muted); border-color: var(--border-strong); color: var(--text-primary); }

/* ── Numeric cells ────────────────────────────────────────────────── */
.col-r { text-align: right; }
.num { font-variant-numeric: tabular-nums; }

/* ── Apt ref link in table ────────────────────────────────────────── */
.apt-ref-link {
  color: #065F46;
  font-weight: 600;
  text-decoration: none;
}
.apt-ref-link:hover { text-decoration: underline; }

.panel-link {
  display: inline-block;
  margin-right: var(--s-3);
  margin-bottom: 4px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--brand-green);
}
.panel-link:hover { text-decoration: underline; }

.panel-refs { display: flex; flex-direction: column; gap: 4px; }
.panel-ref-item { font-size: var(--text-xs); color: var(--text-muted); font-family: monospace; }

@media (max-width: 768px) {
  .mobile-topbar { display: flex; }
  .sidebar {
    display: flex;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    width: 260px !important;
    transform: translateX(-100%);
    transition: transform .25s ease, box-shadow .25s ease;
    box-shadow: none;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .sidebar-toggle { display: none; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .main { padding: var(--s-4) var(--s-3); }
  .hide-mobile { display: none !important; }
  .detail-panel { width: 100%; }
  .bookings-filters { flex-direction: column; align-items: stretch; }
  .form-row,
  .form-row.cols-4 { grid-template-columns: 1fr; }
}

/* ════════════════════════════════════════════════════════════════════
   CALENDAR VIEW
   ════════════════════════════════════════════════════════════════════ */

[data-page="calendar"] .app-body { overflow: hidden; }
[data-page="calendar"] .main {
  max-width: none;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Toolbar */
.cal-toolbar {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex-wrap: wrap;
  padding-bottom: var(--s-3);
  flex-shrink: 0;
}
.cal-nav { display: flex; align-items: center; gap: var(--s-2); }
.cal-filters-right { display: flex; gap: var(--s-2); margin-left: auto; }

.cal-nav-btn {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  border-radius: var(--r-md);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  transition: background var(--t-fast);
}
.cal-nav-btn:hover { background: var(--bg-muted); }

.cal-month-label {
  font-size: var(--text-md);
  font-weight: 700;
  min-width: 190px;
  text-align: center;
  letter-spacing: -.01em;
}
.cal-today-btn {
  height: 32px;
  padding: 0 var(--s-3);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  border-radius: var(--r-md);
  cursor: pointer;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
  font-family: inherit;
  transition: background var(--t-fast);
}
.cal-today-btn:hover { background: var(--bg-muted); }

/* Legend */
.cal-legend {
  display: flex;
  gap: var(--s-4);
  flex-wrap: wrap;
  padding-bottom: var(--s-3);
  flex-shrink: 0;
}
.leg-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}
.leg-swatch { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }

/* Scroll container */
.cal-scroll {
  flex: 1;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-surface);
  position: relative;
}

/* Header row */
.cal-head {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  background: var(--bg-surface);
  border-bottom: 2px solid var(--border);
}
.cal-corner {
  position: sticky;
  left: 0;
  z-index: 12;
  background: var(--bg-muted);
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 0 var(--s-3);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}
/* Right side of header: months row stacked above days row */
.cal-head-right { display: flex; flex-direction: column; min-width: 0; }
.cal-months-head {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg-muted);
}
.cal-month-hdr {
  flex-shrink: 0;
  height: 22px;
  border-right: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .03em;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
}
.cal-days-head { display: flex; }
.cal-day-hdr {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 48px;
  border-right: 1px solid var(--border);
  gap: 1px;
}
.cal-day-hdr.weekend { background: rgba(148,163,184,.06); }
.cal-day-hdr.today   { background: #16a34a45; }
.day-letter { font-size: 10px; font-weight: 600; letter-spacing: .06em; color: var(--text-muted); text-transform: uppercase; }
.day-num {
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}
.day-num.today-num { background: var(--brand-green); color: #fff; }

/* Data rows */
.cal-row {
  display: flex;
  border-bottom: 1px solid var(--border);
}
.cal-row:last-child { border-bottom: none; }
.cal-row:hover .cal-apt-label { background: var(--bg-muted); }

.cal-apt-label {
  position: sticky;
  left: 0;
  z-index: 5;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 0 var(--s-3);
  height: 52px;
  transition: background var(--t-fast);
  cursor: default;
}
.apt-bldg {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 4px;
  flex-shrink: 0;
}
.apt-ref {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Timeline */
.cal-timeline {
  position: relative;
  height: 52px;
  flex-shrink: 0;
}
.cal-day-bg { display: flex; height: 100%; }
.cal-day-cell {
  flex-shrink: 0;
  height: 100%;
  border-right: 1px solid var(--border);
}
.cal-day-cell.weekend { background: rgba(148,163,184,.04); }
.cal-day-cell.today   { background: #16a34a45; }

/* Booking bars */
.cal-booking {
  position: absolute;
  height: 30px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 5px;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  z-index: 2;
  box-shadow: 0 1px 3px rgba(0,0,0,.18);
  transition: filter var(--t-fast), box-shadow var(--t-fast);
}
.cal-booking:hover {
  filter: brightness(1.1);
  box-shadow: 0 2px 8px rgba(0,0,0,.22);
  z-index: 3;
}
.cal-booking.canceled { opacity: .4; }

/* Bar states — past (faded), current (darker), future (default) */
.cal-booking.bar-past    { opacity: .74; }
.cal-booking.bar-current { /* no modifier */ }
.cal-booking.bar-future  { /* default — no modifier */ }

/* Search selection */
.cal-booking.bar-dimmed   { opacity: .47 !important; }
.cal-booking.bar-selected { opacity: 1 !important; }

.bar-name { overflow: hidden; text-overflow: ellipsis; min-width: 0; flex-shrink: 1; }
.bar-amt  { flex-shrink: 0; opacity: .88; font-size: 10px; font-weight: 500; }
.bar-msg-btn {
  flex-shrink: 0;
  color: rgba(255,255,255,.88);
  font-size: 30px;
  padding: 0 5px 7px 5px;
  text-decoration: none;
  line-height: 1;
}
.bar-msg-btn:hover { color: #fff; opacity: 1; }

/* Toolbar "open all messages" button */
.cal-msg-all-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 10px;
  background: #FFF0E6;
  color: #C24B00;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-size: var(--text-xs);
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity var(--t-fast);
}
.cal-msg-all-btn:hover { opacity: .8; }

/* Search dropdown */
.cal-search-wrap { position: relative; }
.cal-search-results {
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  min-width: 340px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  max-height: 340px;
  overflow-y: auto;
  display: none;
}
.cal-search-results.open { display: block; }
.cal-sri {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 9px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--t-fast);
}
.cal-sri:last-child { border-bottom: none; }
.cal-sri:hover { background: var(--bg-muted); }
.cal-sri-name  { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.cal-sri-meta  { font-size: 11px; color: var(--text-muted); }
.cal-sri-ch    { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }

/* Empty state */
.cal-empty {
  display: flex; align-items: center; justify-content: center;
  min-height: 200px;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* Calendar tooltip */
.cal-tooltip {
  position: fixed;
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: var(--text-xs);
  font-weight: 500;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand-green);
  box-shadow: var(--shadow-md);
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 120ms ease, transform 120ms ease;
  line-height: 1.6;
  min-width: 180px;
}
.cal-tooltip.visible { opacity: 1; transform: translateY(0); }
.ctt-apt    { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); margin-bottom: 3px; }
.ctt-name   { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.ctt-dates  { color: var(--text-secondary); margin-top: 2px; }
.ctt-meta   { color: var(--text-muted); font-size: 11px; text-transform: capitalize; }
.ctt-amount { font-weight: 700; color: var(--brand-green); margin-top: 4px; font-size: 13px; }

@media (max-width: 768px) {
  .cal-month-label  { min-width: 140px; font-size: var(--text-base); }
  .cal-filters-right { margin-left: 0; }
  [data-page="calendar"] .app-body { overflow: auto; }
  [data-page="calendar"] .main { height: auto; overflow: visible; }
  [data-page="calendar"] .page-header { display: none; }
  [data-page="calendar"] .cal-legend  { display: none; }
  .cal-scroll { min-height: 400px; max-height: 70vh; }
  [data-page="cleaning"] .page-header { display: none; }
}

/* ── Sidebar badge (pending count on subitem) ─────────────────────────────── */
.sidebar-badge {
  margin-left: auto;
  background: var(--danger, #dc2626);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  border-radius: 10px;
  padding: 2px 6px;
  min-width: 18px;
  text-align: center;
}

/* ── Toast notification ───────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: var(--s-6);
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  padding: var(--s-2) var(--s-5);
  border-radius: var(--r-lg);
  font-size: var(--text-sm);
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 2000;
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-success { background: var(--success-soft); color: var(--success-text); border: 1px solid var(--success); }
