/* =====================================================================
   SAI RAM CRM — Layout & Component Library
   Every module reuses these classes. No module writes its own card,
   table or badge markup.
   ===================================================================== */

/* ═════════════════════════════════════════════════════════════════
   1. APP SHELL
   ═════════════════════════════════════════════════════════════════ */

#sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sidebar);
  transition: width var(--transition), transform var(--transition);
}

#main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition);
}

body.sidebar-collapsed #sidebar { width: var(--sidebar-collapsed-w); }
body.sidebar-collapsed #main    { margin-left: var(--sidebar-collapsed-w); }

/* ── Brand ──────────────────────────────────────────────────────── */
.sidebar-brand {
  height: var(--topbar-h);
  flex: 0 0 var(--topbar-h);
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: 0 1rem;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.brand-mark {
  width: 34px; height: 34px;
  flex: 0 0 34px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary), #1E40AF);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: .02em;
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; border-radius: inherit; }
.brand-text { min-width: 0; }
.brand-name {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-sub {
  font-size: var(--fs-xs);
  color: var(--text-faint);
  white-space: nowrap;
}

/* ── Navigation ─────────────────────────────────────────────────── */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: .75rem .6rem 1rem;
}

.nav-section {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: .85rem .6rem .35rem;
  white-space: nowrap;
}

.nav-item-link {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .5rem .6rem;
  margin-bottom: 1px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--fs-base);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  position: relative;
  transition: background var(--transition), color var(--transition);
}
.nav-item-link:hover { background: var(--surface-alt); color: var(--text); text-decoration: none; }

.nav-item-link.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}
.nav-item-link.active::before {
  content: '';
  position: absolute;
  left: -.6rem; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 18px;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}

.nav-item-link i {
  width: 18px;
  flex: 0 0 18px;
  text-align: center;
  font-size: 14px;
}
.nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }

.nav-count {
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Collapsed rail: icons only, label shown as a hover tooltip */
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .nav-section,
body.sidebar-collapsed .brand-text,
body.sidebar-collapsed .sidebar-user-info,
body.sidebar-collapsed .nav-count { display: none; }

body.sidebar-collapsed .nav-item-link { justify-content: center; padding: .55rem; }
body.sidebar-collapsed .nav-item-link::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--text);
  color: #fff;
  font-size: var(--fs-xs);
  font-weight: 500;
  padding: .3rem .55rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  z-index: 10;
}
body.sidebar-collapsed .nav-item-link:hover::after { opacity: 1; }
body.sidebar-collapsed .sidebar-user { justify-content: center; }

/* ── Sidebar footer user ────────────────────────────────────────── */
.sidebar-user {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .7rem 1rem;
  border-top: 1px solid var(--border);
  overflow: hidden;
}
.sidebar-user-info { min-width: 0; }
.sidebar-user-name {
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-role { font-size: var(--fs-xs); color: var(--text-muted); white-space: nowrap; }

/* ═════════════════════════════════════════════════════════════════
   2. TOPBAR
   ═════════════════════════════════════════════════════════════════ */

#topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  flex: 0 0 var(--topbar-h);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 0 var(--content-pad);
  z-index: var(--z-topbar);
}

.topbar-btn {
  width: 34px; height: 34px;
  border: 0;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.topbar-btn:hover { background: var(--surface-alt); color: var(--text); }

.topbar-search { position: relative; flex: 1; max-width: 380px; }
.topbar-search i {
  position: absolute; left: .65rem; top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: 12px;
  pointer-events: none;
}
.topbar-search .form-control {
  padding-left: 2rem;
  background: var(--surface-alt);
  border-color: transparent;
}
.topbar-search .form-control:focus { background: var(--surface); border-color: var(--primary); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .35rem; }

.topbar-badge {
  position: absolute;
  top: 4px; right: 4px;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  background: var(--danger);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--surface);
}

.topbar-divider { width: 1px; height: 22px; background: var(--border); margin: 0 .3rem; }

/* Site switcher (R13 — multi-site) */
.site-switcher .btn {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-weight: 500;
  gap: .45rem;
}
.site-switcher .btn:hover { background: var(--surface); border-color: var(--border-strong); }
.site-switcher .site-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--success);
  flex: 0 0 7px;
}

/* Profile chip */
.topbar-profile {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .25rem .5rem .25rem .25rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background var(--transition);
}
.topbar-profile:hover { background: var(--surface-alt); }
.topbar-profile-name { font-size: var(--fs-base); font-weight: 600; color: var(--text); line-height: 1.2; }
.topbar-profile-role { font-size: var(--fs-xs); color: var(--text-muted); line-height: 1.2; }

/* ═════════════════════════════════════════════════════════════════
   3. AVATARS
   ═════════════════════════════════════════════════════════════════ */

.avatar {
  width: 34px; height: 34px;
  flex: 0 0 34px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: var(--fs-sm);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  text-transform: uppercase;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 26px; height: 26px; flex-basis: 26px; font-size: var(--fs-xs); }
.avatar-lg { width: 48px; height: 48px; flex-basis: 48px; font-size: var(--fs-md); }
.avatar-xl { width: 72px; height: 72px; flex-basis: 72px; font-size: var(--fs-xl); }

/* ═════════════════════════════════════════════════════════════════
   4. PAGE STRUCTURE
   ═════════════════════════════════════════════════════════════════ */

.page { flex: 1; padding: var(--content-pad); }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.page-title { font-size: var(--fs-xl); font-weight: 700; margin: 0; letter-spacing: -.01em; }
.page-subtitle { font-size: var(--fs-base); color: var(--text-muted); margin: .15rem 0 0; }
.page-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

.breadcrumb-bar {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-bottom: .4rem;
}
.breadcrumb-bar a { color: var(--text-muted); }
.breadcrumb-bar a:hover { color: var(--primary); text-decoration: none; }
.breadcrumb-bar .sep { color: var(--text-faint); font-size: 10px; }

/* ═════════════════════════════════════════════════════════════════
   5. CARDS
   ═════════════════════════════════════════════════════════════════ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .85rem 1.1rem;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-size: var(--fs-md);
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.card-title i { color: var(--text-faint); font-size: 13px; }
.card-body { padding: 1.1rem; }
.card-body.tight { padding: .75rem; }
.card-body.flush { padding: 0; }
.card-foot {
  padding: .7rem 1.1rem;
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ═════════════════════════════════════════════════════════════════
   6. STAT TILES
   ═════════════════════════════════════════════════════════════════ */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  padding: 1rem 1.1rem;
  display: flex;
  align-items: flex-start;
  gap: .9rem;
  transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.stat-icon {
  width: 40px; height: 40px;
  flex: 0 0 40px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  background: var(--primary-soft);
  color: var(--primary);
}
.stat-icon.success { background: var(--success-soft); color: var(--success); }
.stat-icon.warning { background: var(--warning-soft); color: var(--warning); }
.stat-icon.danger  { background: var(--danger-soft);  color: var(--danger); }
.stat-icon.info    { background: var(--info-soft);    color: var(--info); }
.stat-icon.muted   { background: var(--muted-soft);   color: var(--text-muted); }

.stat-body { min-width: 0; flex: 1; }
.stat-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: .15rem;
}
.stat-value {
  font-size: var(--fs-2xl);
  font-weight: 700;
  color: var(--text);
  line-height: 1.15;
  letter-spacing: -.02em;
}
.stat-meta { font-size: var(--fs-xs); color: var(--text-faint); margin-top: .2rem; }
.stat-trend { font-size: var(--fs-xs); font-weight: 600; display: inline-flex; align-items: center; gap: .2rem; }
.stat-trend.up   { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* ═════════════════════════════════════════════════════════════════
   7. BADGES
   ═════════════════════════════════════════════════════════════════ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: .01em;
  padding: .22rem .55rem;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  white-space: nowrap;
  line-height: 1.4;
}
.badge-success { background: var(--success-soft); color: #047857; border-color: var(--success-border); }
.badge-warning { background: var(--warning-soft); color: #B45309; border-color: var(--warning-border); }
.badge-info    { background: var(--info-soft);    color: #1D4ED8; border-color: var(--info-border); }
.badge-danger  { background: var(--danger-soft);  color: #B91C1C; border-color: var(--danger-border); }
.badge-primary { background: var(--primary-soft); color: var(--primary); border-color: var(--primary-border); }
.badge-muted   { background: var(--muted-soft);   color: var(--text-muted); border-color: var(--muted-border); }

.badge-dot::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 6px;
}

/* ═════════════════════════════════════════════════════════════════
   8. DATA TABLE
   ═════════════════════════════════════════════════════════════════ */

.table-card { overflow: hidden; }

.table-toolbar {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
  padding: .75rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.table-toolbar .form-control,
.table-toolbar .form-select { max-width: 200px; }
.table-toolbar .search-box { position: relative; min-width: 200px; flex: 1; max-width: 300px; }
.table-toolbar .search-box i {
  position: absolute; left: .6rem; top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint); font-size: 12px;
}
.table-toolbar .search-box .form-control { padding-left: 1.9rem; max-width: none; }

.table-wrap { overflow-x: auto; }
.table-wrap > .table { min-width: 700px; }

.table-actions { display: flex; align-items: center; gap: .25rem; justify-content: flex-end; }

.table-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
  padding: .7rem 1.1rem;
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

/* Cell helpers */
.cell-primary { color: var(--text); font-weight: 600; }
.cell-sub     { font-size: var(--fs-xs); color: var(--text-faint); }
.cell-num     { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
th.cell-num   { text-align: right; }

/* ═════════════════════════════════════════════════════════════════
   9. EMPTY STATE
   ═════════════════════════════════════════════════════════════════ */

.empty-state { text-align: center; padding: 3rem 1.5rem; }
.empty-icon {
  width: 56px; height: 56px;
  margin: 0 auto .9rem;
  border-radius: 50%;
  background: var(--surface-alt);
  color: var(--text-faint);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.empty-title { font-size: var(--fs-md); font-weight: 600; color: var(--text); margin-bottom: .25rem; }
.empty-text  { font-size: var(--fs-base); color: var(--text-muted); max-width: 380px; margin: 0 auto 1rem; }

/* ═════════════════════════════════════════════════════════════════
   10. FORMS
   ═════════════════════════════════════════════════════════════════ */

.form-section { margin-bottom: 1.5rem; }
.form-section-title {
  font-size: var(--fs-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  padding-bottom: .5rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-full { grid-column: 1 / -1; }
@media (max-width: 640px) {
  .form-grid .span-2, .form-grid .span-full { grid-column: auto; }
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  margin-top: 1.25rem;
}

/* ═════════════════════════════════════════════════════════════════
   11. DETAIL LIST (key/value pairs)
   ═════════════════════════════════════════════════════════════════ */

.detail-list { display: grid; gap: .1rem; }
.detail-row {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: .5rem 0;
  border-bottom: 1px dashed var(--border-light);
}
.detail-row:last-child { border-bottom: 0; }
.detail-key   { flex: 0 0 40%; max-width: 200px; font-size: var(--fs-sm); color: var(--text-muted); }
.detail-value { flex: 1; font-size: var(--fs-base); color: var(--text); font-weight: 500; word-break: break-word; }

/* ═════════════════════════════════════════════════════════════════
   12. PROGRESS
   ═════════════════════════════════════════════════════════════════ */

.meter {
  height: 6px;
  background: var(--surface-alt);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 400ms cubic-bezier(.4, 0, .2, 1);
}
.meter-fill.success { background: var(--success); }
.meter-fill.warning { background: var(--warning); }
.meter-fill.danger  { background: var(--danger); }

.meter-row { display: flex; align-items: center; gap: .6rem; }
.meter-row .meter { flex: 1; }
.meter-label { font-size: var(--fs-xs); color: var(--text-muted); white-space: nowrap; min-width: 52px; text-align: right; }

/* ═════════════════════════════════════════════════════════════════
   13. TIMELINE
   ═════════════════════════════════════════════════════════════════ */

.timeline { position: relative; padding-left: 1.4rem; }
.timeline::before {
  content: '';
  position: absolute;
  left: 5px; top: 4px; bottom: 4px;
  width: 2px;
  background: var(--border);
}
.timeline-item { position: relative; padding-bottom: 1.1rem; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: '';
  position: absolute;
  left: -1.4rem; top: 4px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--primary);
}
.timeline-item.success::before { border-color: var(--success); }
.timeline-item.warning::before { border-color: var(--warning); }
.timeline-item.danger::before  { border-color: var(--danger); }
.timeline-item.muted::before   { border-color: var(--border-strong); }
.timeline-title { font-size: var(--fs-base); font-weight: 600; color: var(--text); }
.timeline-meta  { font-size: var(--fs-xs); color: var(--text-faint); }
.timeline-text  { font-size: var(--fs-base); color: var(--text-secondary); margin-top: .15rem; }

/* ═════════════════════════════════════════════════════════════════
   14. STEPPER (booking wizard)
   ═════════════════════════════════════════════════════════════════ */

.stepper { display: flex; align-items: center; gap: .25rem; overflow-x: auto; padding-bottom: .25rem; }
.step { display: flex; align-items: center; gap: .5rem; flex: 0 0 auto; }
.step-dot {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--surface-alt);
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-size: var(--fs-xs);
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.step-label { font-size: var(--fs-sm); color: var(--text-muted); white-space: nowrap; }
.step-line  { width: 28px; height: 1px; background: var(--border); flex: 0 0 28px; }

.step.active .step-dot   { background: var(--primary); border-color: var(--primary); color: #fff; }
.step.active .step-label { color: var(--text); font-weight: 600; }
.step.done .step-dot     { background: var(--success); border-color: var(--success); color: #fff; }
.step.done .step-label   { color: var(--text-secondary); }

/* ═════════════════════════════════════════════════════════════════
   15. PLOT TILES & MAP LEGEND
   ═════════════════════════════════════════════════════════════════ */

.legend { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.legend-item { display: inline-flex; align-items: center; gap: .35rem; font-size: var(--fs-sm); color: var(--text-secondary); }
.legend-swatch { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 11px; }

.sw-available { background: var(--plot-available); }
.sw-hold      { background: var(--plot-hold); }
.sw-booked    { background: var(--plot-booked); }
.sw-sold      { background: var(--plot-sold); }
.sw-blocked   { background: var(--plot-blocked); }

.plot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: .5rem;
}
.plot-tile {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .5rem;
  background: var(--surface);
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition);
  border-left: 3px solid var(--plot-blocked);
}
.plot-tile:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.plot-tile.available { border-left-color: var(--plot-available); }
.plot-tile.hold      { border-left-color: var(--plot-hold); }
.plot-tile.booked    { border-left-color: var(--plot-booked); }
.plot-tile.sold      { border-left-color: var(--plot-sold); }
.plot-tile-no   { font-size: var(--fs-base); font-weight: 700; color: var(--text); }
.plot-tile-meta { font-size: var(--fs-xs); color: var(--text-muted); }

/* ═════════════════════════════════════════════════════════════════
   16. NETWORK TREE (MLM genealogy)
   ═════════════════════════════════════════════════════════════════ */

.tree { --tree-indent: 26px; font-size: var(--fs-base); }
.tree-node { position: relative; padding-left: var(--tree-indent); }
.tree-node::before {
  content: '';
  position: absolute;
  left: 10px; top: 0; bottom: 0;
  border-left: 1px dashed var(--border-strong);
}
.tree-node:last-child::before { bottom: calc(100% - 20px); }
.tree-node::after {
  content: '';
  position: absolute;
  left: 10px; top: 20px;
  width: 14px;
  border-top: 1px dashed var(--border-strong);
}
.tree-root > .tree-node-card { margin-left: 0; }
.tree-root::before, .tree-root::after { display: none; }

.tree-node-card {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .5rem .7rem;
  margin: .25rem 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.tree-node-card:hover { border-color: var(--primary-border); box-shadow: var(--shadow-sm); }
.tree-node-card.is-self { border-color: var(--primary); background: var(--primary-soft); }

.tree-level-tag {
  font-size: 10px;
  font-weight: 700;
  padding: .1rem .35rem;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--text-muted);
  flex: 0 0 auto;
}

/* ═════════════════════════════════════════════════════════════════
   17. TOASTS
   ═════════════════════════════════════════════════════════════════ */

#toast-stack {
  position: fixed;
  bottom: 20px; right: 20px;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  z-index: var(--z-toast);
  max-width: 340px;
}
.toast-item {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  padding: .7rem .85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-base);
  color: var(--text-secondary);
  animation: toast-in 220ms cubic-bezier(.4, 0, .2, 1);
}
.toast-item.success { border-left-color: var(--success); }
.toast-item.danger  { border-left-color: var(--danger); }
.toast-item.warning { border-left-color: var(--warning); }
.toast-item .toast-close {
  margin-left: auto; border: 0; background: none;
  color: var(--text-faint); cursor: pointer; padding: 0 .15rem;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: none; }
}

/* ═════════════════════════════════════════════════════════════════
   18. AUTH SCREENS
   ═════════════════════════════════════════════════════════════════ */

.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }

.auth-brand-panel {
  background: linear-gradient(150deg, #1E3A8A 0%, #2563EB 55%, #1D4ED8 100%);
  color: #fff;
  padding: 3rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.auth-brand-panel::after {
  content: '';
  position: absolute;
  right: -140px; bottom: -140px;
  width: 420px; height: 420px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .06);
}
.auth-brand-panel::before {
  content: '';
  position: absolute;
  right: 40px; top: -100px;
  width: 260px; height: 260px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .05);
}
.auth-logo { display: flex; align-items: center; gap: .75rem; position: relative; z-index: 1; }
.auth-logo .brand-mark { background: rgba(255, 255, 255, .18); backdrop-filter: blur(4px); }
.auth-logo .brand-name { color: #fff; font-size: var(--fs-lg); }
.auth-logo .brand-sub  { color: rgba(255, 255, 255, .7); }

.auth-pitch { position: relative; z-index: 1; max-width: 420px; }
.auth-pitch h2 { color: #fff; font-size: 1.75rem; font-weight: 700; line-height: 1.25; margin-bottom: .75rem; }
.auth-pitch p  { color: rgba(255, 255, 255, .82); font-size: var(--fs-md); }

.auth-features { list-style: none; margin: 1.5rem 0 0; padding: 0; display: grid; gap: .6rem; }
.auth-features li {
  display: flex; align-items: center; gap: .6rem;
  color: rgba(255, 255, 255, .9);
  font-size: var(--fs-base);
}
.auth-features i {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .15);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px;
  flex: 0 0 22px;
}
.auth-foot { position: relative; z-index: 1; font-size: var(--fs-xs); color: rgba(255, 255, 255, .6); }

.auth-form-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--surface);
}
.auth-form { width: 100%; max-width: 380px; }
.auth-form h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: .3rem; }
.auth-form .lead { font-size: var(--fs-md); color: var(--text-muted); margin-bottom: 1.75rem; }
.auth-form .form-control { padding: .6rem .8rem; }

.password-field { position: relative; }
.password-toggle {
  position: absolute; right: .55rem; top: 50%;
  transform: translateY(-50%);
  border: 0; background: none;
  color: var(--text-faint);
  cursor: pointer;
  padding: .2rem;
}
.password-toggle:hover { color: var(--text-secondary); }

.auth-hint {
  margin-top: 1.25rem;
  padding: .7rem .85rem;
  background: var(--info-soft);
  border: 1px solid var(--info-border);
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  color: #1E40AF;
}

@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand-panel { display: none; }
}

/* ═════════════════════════════════════════════════════════════════
   19. ERROR PAGES
   ═════════════════════════════════════════════════════════════════ */

.error-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
}
.error-code {
  font-size: 5rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.04em;
  background: linear-gradient(135deg, var(--primary), #1E40AF);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.error-title { font-size: var(--fs-xl); font-weight: 700; margin: .75rem 0 .4rem; }
.error-text  { color: var(--text-muted); max-width: 420px; margin: 0 auto 1.5rem; }
.error-trace {
  text-align: left;
  max-width: 760px;
  margin: 1.5rem auto 0;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  overflow: auto;
  max-height: 320px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ═════════════════════════════════════════════════════════════════
   20. UTILITIES
   ═════════════════════════════════════════════════════════════════ */

.text-xs   { font-size: var(--fs-xs) !important; }
.text-sm   { font-size: var(--fs-sm) !important; }
.text-md   { font-size: var(--fs-md) !important; }
.fw-600    { font-weight: 600 !important; }
.fw-700    { font-weight: 700 !important; }
.text-faint { color: var(--text-faint) !important; }
.text-body-secondary { color: var(--text-secondary) !important; }
.gap-xs { gap: .25rem !important; }
.cursor-pointer { cursor: pointer; }
.nowrap { white-space: nowrap; }

.divider-v { width: 1px; align-self: stretch; background: var(--border); }

.soft-panel {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .75rem .9rem;
}

/* ═════════════════════════════════════════════════════════════════
   21. RESPONSIVE
   ═════════════════════════════════════════════════════════════════ */

#sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  z-index: var(--z-overlay);
  display: none;
}

@media (max-width: 991.98px) {
  #sidebar { transform: translateX(-100%); width: var(--sidebar-w); }
  body.sidebar-open #sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.sidebar-open #sidebar-overlay { display: block; }
  #main, body.sidebar-collapsed #main { margin-left: 0; }

  /* The rail behaviour is desktop-only */
  body.sidebar-collapsed #sidebar { width: var(--sidebar-w); }
  body.sidebar-collapsed .nav-label,
  body.sidebar-collapsed .nav-section,
  body.sidebar-collapsed .brand-text,
  body.sidebar-collapsed .sidebar-user-info,
  body.sidebar-collapsed .nav-count { display: revert; }
  body.sidebar-collapsed .nav-item-link { justify-content: flex-start; padding: .5rem .6rem; }
  body.sidebar-collapsed .nav-item-link::after { display: none; }

  :root { --content-pad: 16px; }
  .topbar-search { display: none; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; }
  .stat-value { font-size: var(--fs-xl); }
}

@media (max-width: 767.98px) {
  .page-header { flex-direction: column; align-items: stretch; }
  .page-actions { justify-content: flex-start; }
  .topbar-profile-name, .topbar-profile-role { display: none; }
  .detail-row { flex-direction: column; gap: .1rem; }
  .detail-key { flex-basis: auto; max-width: none; }

  /* Stacked card view for tables marked .table-stack */
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: .6rem;
    padding: .5rem .7rem;
    background: var(--surface);
  }
  .table-stack td {
    border: 0 !important;
    padding: .3rem 0 !important;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
  }
  .table-stack td::before {
    content: attr(data-label);
    font-size: var(--fs-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-faint);
    flex: 0 0 auto;
  }
  .table-stack .cell-num { text-align: right; }
  .table-wrap > .table.table-stack { min-width: 0; }
}

/* =====================================================================
   Choice cards — a radio group that reads as a row of options.

   These were previously built out of `.btn btn-outline-*`, which does not
   work here: theme.css gives every .btn `display:inline-flex` with
   `white-space:nowrap`, so a card with a title *and* a description laid
   them out side by side on one unwrappable line and spilled over the
   neighbouring cards. A button is a single line of text by design; this
   is a card, so it gets its own component.
   ===================================================================== */
/* Fixed columns rather than auto-fit. auto-fit packs as many as will fit,
   which for four options in a normal form column meant three across and a
   lonely fourth underneath. Halving instead keeps the group reading as one
   block: 4 → 2×2 → stacked. Override with --choice-cols for other counts. */
.choice-grid {
  display: grid;
  grid-template-columns: repeat(var(--choice-cols, 4), minmax(0, 1fr));
  gap: .75rem;
}

@media (max-width: 1399.98px) {
  .choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 575.98px) {
  .choice-grid { grid-template-columns: 1fr; }
}

/* The radio itself stays in the accessibility tree — reachable by keyboard
   and announced by screen readers — but is never painted. */
.choice-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.choice-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .2rem;
  min-height: 100%;
  padding: .85rem .95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: var(--transition);
}

.choice-card:hover {
  border-color: var(--border-strong);
  background: var(--surface-alt);
}

.choice-card-title {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.choice-card-hint {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  line-height: 1.45;
  white-space: normal;      /* the whole point: descriptions wrap */
}

/* Selected state. Driven by :checked on the sibling input, so it needs no
   JavaScript and survives a page reload with old input repopulated. */
.choice-input:checked + .choice-card {
  border-color: var(--accent, var(--primary));
  background: var(--accent-soft, var(--primary-soft));
  box-shadow: inset 0 0 0 1px var(--accent, var(--primary));
}

.choice-input:checked + .choice-card .choice-card-title { color: var(--accent-text, var(--primary-active)); }
.choice-input:focus-visible + .choice-card { box-shadow: var(--shadow-focus); }

/* Per-card accent, set inline where the card is used. */
.choice-card[data-accent="warning"] { --accent: var(--warning); --accent-soft: var(--warning-soft); --accent-text: var(--warning); }
.choice-card[data-accent="primary"] { --accent: var(--primary); --accent-soft: var(--primary-soft); --accent-text: var(--primary-active); }
.choice-card[data-accent="success"] { --accent: var(--success); --accent-soft: var(--success-soft); --accent-text: var(--success); }
.choice-card[data-accent="info"]    { --accent: var(--info);    --accent-soft: var(--info-soft);    --accent-text: var(--info); }

/* A row that is still true but no longer active — a cancelled booking on
   an associate's sales list, say. Dimmed rather than hidden: the sale
   happened, and hiding it makes the numbers look like they never added up. */
.table tr.is-muted { opacity: .55; }
.table tr.is-muted .cell-primary { text-decoration: line-through; }
