/* ── Reset & Base ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Skip Navigation ── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 10000;
  padding: 0.75rem 1.5rem;
  background: var(--accent);
  color: #000;
  font-weight: 600;
  border-radius: 0 0 8px 8px;
  text-decoration: none;
  transition: top 0.2s;
}
.skip-link:focus {
  top: 0;
}

/* ── Theme Variables ── */
:root {
  --bg-body: #0A0A0A;
  --bg-header: rgba(10, 10, 10, 0.95);
  --bg-card: rgba(26, 26, 46, 0.6);
  --bg-input: rgba(255, 255, 255, 0.04);
  --bg-modal: #12122A;
  --bg-toast: #1A1A2E;
  --bg-thead: rgba(255, 255, 255, 0.03);
  --bg-hover-row: rgba(253, 161, 0, 0.04);
  --bg-input-focus: rgba(253, 161, 0, 0.05);
  --bg-checkbox-checked: rgba(253, 161, 0, 0.08);
  --bg-btn-secondary-hover: rgba(255, 255, 255, 0.04);

  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-card: rgba(255, 255, 255, 0.08);
  --border-input: rgba(255, 255, 255, 0.1);
  --border-row: rgba(255, 255, 255, 0.04);
  --border-btn-secondary: rgba(255, 255, 255, 0.12);

  --text-primary: #FFFFFF;
  --text-body: #E2E8F0;
  --text-muted: rgba(255, 255, 255, 0.5);
  --text-label: rgba(255, 255, 255, 0.6);
  --text-placeholder: rgba(255, 255, 255, 0.25);
  --text-empty: rgba(255, 255, 255, 0.35);
  --text-count: rgba(255, 255, 255, 0.4);

  --accent: #FDA100;
  --accent-gradient: linear-gradient(135deg, #FDA100, #FF6B35);
  --accent-shadow: rgba(253, 161, 0, 0.25);
  --accent-hover-shadow: rgba(253, 161, 0, 0.4);
  --accent-border: rgba(253, 161, 0, 0.3);
  --accent-glow: rgba(253, 161, 0, 0.08);
  --accent-border-checkbox: rgba(253, 161, 0, 0.4);
  --accent-card-border: rgba(253, 161, 0, 0.2);
  --accent-card-shadow: rgba(253, 161, 0, 0.06);
  --accent-highlight-bg: rgba(253, 161, 0, 0.05);

  --success: #9ACA3D;
  --danger: #FF4444;
  --danger-bg: rgba(255, 68, 68, 0.12);
  --danger-border: rgba(255, 68, 68, 0.4);
  --danger-glow: rgba(255, 68, 68, 0.1);
  --danger-hover-bg: rgba(255, 68, 68, 0.06);

  --warning: #F59E0B;

  --info: #3B82F6;
  --info-bg: rgba(59, 130, 246, 0.15);

  --text-secondary: rgba(255, 255, 255, 0.65);

  /* Aliases for legacy / shared tokens */
  --text-heading: var(--text-primary);
  --surface: var(--bg-card);
  --border: var(--border-card);
  --bg-elevated: var(--bg-card);
  --bg-elev: var(--bg-card);
  --bg-hover: var(--bg-hover-row);
  --bg-muted: var(--bg-input);
  --accent-primary: var(--accent);
  --text-on-accent: #0d0d0d;

  --select-option-bg: #1A1A2E;
  --overlay-bg: rgba(0, 0, 0, 0.6);
  --shadow-toast: rgba(0, 0, 0, 0.5);

  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%23FDA100' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");

  --sidebar-width: 240px;
  --topbar-height: 56px;
}

/* ── Light Theme ── */
[data-theme="light"] {
  --bg-body: #F5F5F7;
  --bg-header: rgba(255, 255, 255, 0.95);
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-input: rgba(0, 0, 0, 0.03);
  --bg-modal: #FFFFFF;
  --bg-toast: #FFFFFF;
  --bg-thead: rgba(0, 0, 0, 0.02);
  --bg-hover-row: rgba(253, 161, 0, 0.06);
  --bg-input-focus: rgba(253, 161, 0, 0.06);
  --bg-checkbox-checked: rgba(253, 161, 0, 0.1);
  --bg-btn-secondary-hover: rgba(0, 0, 0, 0.04);

  --border-subtle: rgba(0, 0, 0, 0.06);
  --border-card: rgba(0, 0, 0, 0.1);
  --border-input: rgba(0, 0, 0, 0.15);
  --border-row: rgba(0, 0, 0, 0.05);
  --border-btn-secondary: rgba(0, 0, 0, 0.15);

  --text-primary: #1A1A2E;
  --text-body: #334155;
  --text-muted: rgba(0, 0, 0, 0.5);
  --text-label: rgba(0, 0, 0, 0.6);
  --text-placeholder: rgba(0, 0, 0, 0.3);
  --text-empty: rgba(0, 0, 0, 0.35);
  --text-count: rgba(0, 0, 0, 0.45);
  --text-secondary: rgba(0, 0, 0, 0.65);

  --accent: #E08F00;
  --accent-gradient: linear-gradient(135deg, #E08F00, #E55A2B);
  --accent-shadow: rgba(224, 143, 0, 0.25);
  --accent-hover-shadow: rgba(224, 143, 0, 0.35);
  --accent-border: rgba(224, 143, 0, 0.35);
  --accent-glow: rgba(224, 143, 0, 0.1);
  --accent-border-checkbox: rgba(224, 143, 0, 0.5);
  --accent-card-border: rgba(224, 143, 0, 0.25);
  --accent-card-shadow: rgba(224, 143, 0, 0.08);
  --accent-highlight-bg: rgba(224, 143, 0, 0.06);

  --danger-bg: rgba(255, 68, 68, 0.08);
  --danger-glow: rgba(255, 68, 68, 0.08);
  --danger-hover-bg: rgba(255, 68, 68, 0.06);

  --info-bg: rgba(59, 130, 246, 0.1);

  --text-on-accent: #FFFFFF;

  --select-option-bg: #FFFFFF;
  --overlay-bg: rgba(0, 0, 0, 0.3);
  --shadow-toast: rgba(0, 0, 0, 0.12);

  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%23E08F00' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: 'Poppins', 'Montserrat', sans-serif;
  background: var(--bg-body);
  color: var(--text-body);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-header);
  backdrop-filter: blur(12px);
  border-right: 1px solid var(--border-subtle);
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.3s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar-logo {
  height: 36px;
  object-fit: contain;
}

.sidebar-title {
  font-family: 'Montserrat', 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 18px;
  color: var(--text-primary);
  text-transform: uppercase;
  display: block;
  line-height: 1.2;
  letter-spacing: 1px;
}

.sidebar-tagline {
  font-weight: 500;
  font-size: 9px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  display: block;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.sidebar-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 1.25rem 1.25rem 0.5rem;
  display: block;
}

.sidebar-divider {
  display: block;
  height: 1px;
  background: var(--border-subtle);
  margin: 0.5rem 1.25rem;
}

.sidebar-quick-actions {
  padding: 0.5rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 0.5rem;
}
.sidebar-section-label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 0.5rem;
}
.sidebar-quick-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.sidebar-quick-actions-grid .btn {
  width: 100%;
  min-width: 0;
  min-height: 2.25rem;
  font-size: 0.75rem;
  padding: 0.5rem 0.5rem;
  letter-spacing: 0.5px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1.25rem;
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--text-muted);
  border-left: 3px solid transparent;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}

.nav-link:hover,
.nav-link:focus-visible {
  color: var(--text-primary);
  background: var(--accent-glow);
}

.nav-link.active {
  color: var(--accent);
  background: var(--accent-highlight-bg);
  border-left-color: var(--accent);
  font-weight: 600;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.5;
}

.nav-link:hover .nav-icon,
.nav-link.active .nav-icon {
  opacity: 1;
}

.sidebar-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

/* ── Mobile Topbar ── */
.topbar {
  display: flex;
  position: sticky;
  top: 0;
  z-index: 90;
  background: var(--bg-header);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 1rem;
  height: 56px;
  align-items: center;
  gap: 0.75rem;
  margin-left: var(--sidebar-width);
}

.topbar-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border-input);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, border-color 0.2s;
}

.topbar-toggle:hover {
  color: var(--accent);
  border-color: var(--accent-border);
}

.topbar-title {
  display: none;
  font-family: 'Montserrat', 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
  letter-spacing: 1px;
}

.topbar-branch-scope {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.topbar-branch-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.topbar-branch-scope select {
  font-size: 0.875rem;
  padding: 0.35rem 0.65rem;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  min-width: 160px;
  cursor: pointer;
}

.topbar-branch-scope select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 640px) {
  .topbar-branch-label { display: none; }
  .topbar-branch-scope select { min-width: 120px; }
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  z-index: 99;
}

/* ── Main Content ── */
.main {
  margin-left: var(--sidebar-width);
  max-width: 900px;
  padding: 2.5rem 2.5rem 4rem;
}

.page-header {
  margin-bottom: 2rem;
}

.page-header h1 {
  font-family: 'Montserrat', 'Poppins', sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  letter-spacing: 1px;
}

.page-header p {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.required-star {
  color: var(--accent);
  font-weight: 600;
}

/* ── Form Sections ── */
.form-section {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 16px;
  margin-bottom: 1rem;
  overflow: hidden;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.form-section:focus-within {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 1px var(--accent-glow);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.section-header h2 {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 1.5px;
}

.section-body {
  padding: 1.5rem;
}

/* ── Form Grid ── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-group label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-label);
  margin-bottom: 0.5rem;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.form-group input,
.form-group select,
.form-group textarea {
  font-family: 'Poppins', sans-serif;
  font-size: 0.875rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-input);
  border-radius: 10px;
  color: var(--text-primary);
  background: var(--bg-input);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.form-group select {
  appearance: none;
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

.form-group select option {
  background: var(--select-option-bg);
  color: var(--text-primary);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-placeholder);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  background: var(--bg-input-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
  outline: 2px solid var(--accent);
  outline-offset: 0;
}

.form-group input.invalid,
.form-group select.invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-glow);
}

/* Standalone form controls outside .form-group (page headers, toolbars).
   Mirrors the .form-group input/select look so selects in the page-header
   match the rest of the admin UI. */
.input-control,
.select-control {
  font-family: 'Poppins', sans-serif;
  font-size: 0.8125rem;
  padding: 0.5rem 0.875rem;
  border: 1px solid var(--border-input);
  border-radius: 8px;
  color: var(--text-primary);
  background: var(--bg-input);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.select-control {
  appearance: none;
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
  cursor: pointer;
}

.select-control option {
  background: var(--select-option-bg);
  color: var(--text-primary);
}

.input-control:focus,
.select-control:focus {
  border-color: var(--accent);
  background: var(--bg-input-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
  outline: 2px solid transparent;
}

/* Page-header utility row — replaces ad-hoc inline flex styles. */
.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.form-group textarea {
  resize: vertical;
  min-height: 60px;
}

.error-msg {
  font-size: 0.75rem;
  color: var(--danger);
  min-height: 1.125rem;
  margin-top: 0.25rem;
}

.field-hint {
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* ── Buttons ── */
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 2rem;
}

/* ── Checkbox Group ── */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.25rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  border: 1px solid var(--border-input);
  border-radius: 8px;
  background: var(--bg-input);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  user-select: none;
}

.checkbox-label span {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-label);
  letter-spacing: 0.5px;
  transition: color 0.2s;
}

.checkbox-label input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.checkbox-label:has(input:checked) {
  border-color: var(--accent-border-checkbox);
  background: var(--bg-checkbox-checked);
}

.checkbox-label:has(input:checked) span {
  color: var(--accent);
}

.checkbox-group.invalid .checkbox-label {
  border-color: var(--danger);
}

.btn {
  font-family: 'Poppins', sans-serif;
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.75px;
  padding: 0.75rem 2rem;
  min-height: 2.75rem;
  min-width: 7rem;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s, opacity 0.2s;
  /* Render <a> and <button> identically and keep label centred */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
  vertical-align: middle;
  box-sizing: border-box;
  white-space: nowrap;
  line-height: 1.2;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent-gradient);
  color: #FFFFFF;
  box-shadow: 0 4px 20px var(--accent-shadow);
}

.btn-primary:hover {
  box-shadow: 0 6px 28px var(--accent-hover-shadow);
}

.btn-secondary {
  background: transparent;
  color: var(--text-label);
  border: 1px solid var(--border-btn-secondary);
}

.btn-secondary:hover {
  background: var(--bg-btn-secondary-hover);
  border-color: var(--border-input);
  color: var(--text-primary);
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--bg-toast);
  color: var(--text-primary);
  padding: 1rem 1.5rem;
  border-radius: 12px;
  border: 1px solid var(--border-card);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 12px 40px var(--shadow-toast);
  transform: translateY(120%);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  z-index: 200;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast-icon {
  background: var(--success);
  color: #FFFFFF;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}

.toast.error .toast-icon {
  background: var(--danger);
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 101;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.open {
    display: block;
  }

  .topbar {
    display: flex;
    margin-left: 0;
  }

  .topbar-toggle {
    display: flex;
  }

  .topbar-title {
    display: inline;
  }

  .main {
    margin-left: 0;
    padding: 1.5rem 1rem 3rem;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-actions {
    flex-direction: column-reverse;
  }

  .btn {
    width: 100%;
    text-align: center;
  }

  .list-toolbar {
    flex-direction: column;
    gap: 0.75rem;
  }

  .data-table {
    font-size: 0.75rem;
  }

  .data-table th,
  .data-table td {
    padding: 0.75rem;
  }
}

/* ── List View ── */
.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

/* Auto-theme bare form controls inside toolbars and page-header actions so
   filter dropdowns, date pickers and quick inputs match the rest of the UI
   without needing per-element classes. */
.list-toolbar select,
.list-toolbar input[type="text"],
.list-toolbar input[type="search"],
.list-toolbar input[type="date"],
.list-toolbar input[type="time"],
.list-toolbar input[type="number"],
.page-header-actions select,
.page-header-actions input[type="text"],
.page-header-actions input[type="search"],
.page-header-actions input[type="date"],
.page-header-actions input[type="time"],
.page-header-actions input[type="number"] {
  font-family: 'Poppins', sans-serif;
  font-size: 0.8125rem;
  padding: 0.5rem 0.875rem;
  border: 1px solid var(--border-input);
  border-radius: 8px;
  color: var(--text-primary);
  background: var(--bg-input);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.list-toolbar select,
.page-header-actions select {
  appearance: none;
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
  cursor: pointer;
}

.list-toolbar select option,
.page-header-actions select option {
  background: var(--select-option-bg);
  color: var(--text-primary);
}

.list-toolbar select:focus,
.list-toolbar input:focus,
.page-header-actions select:focus,
.page-header-actions input:focus {
  border-color: var(--accent);
  background: var(--bg-input-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
  outline: 2px solid transparent;
}

.search-box {
  font-family: 'Poppins', sans-serif;
  font-size: 0.875rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-input);
  border-radius: 10px;
  color: var(--text-primary);
  background: var(--bg-input);
  min-width: 240px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box::placeholder {
  color: var(--text-placeholder);
}

.search-box:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  outline: 2px solid transparent;
}

.btn-sm {
  font-size: 0.75rem;
  padding: 0.4rem 1rem;
  min-height: 2.25rem;
  min-width: 5rem;
  letter-spacing: 0.5px;
}

/* ── Data Table ── */
.table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 16px;
  overflow: hidden;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.data-table thead {
  background: var(--bg-thead);
}

.data-table th {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 1px;
  text-transform: uppercase;
  text-align: left;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border-card);
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 1;
}

.data-table th.sortable {
  cursor: pointer;
  user-select: none;
  padding-right: 1.75rem;
}

.data-table th.sortable::after {
  content: '';
  position: absolute;
  right: 0.75rem;
  top: 50%;
  width: 0;
  height: 0;
  margin-top: -0.2rem;
  border-left: 0.3rem solid transparent;
  border-right: 0.3rem solid transparent;
  border-top: 0.35rem solid currentColor;
  opacity: 0.3;
  transition: opacity 0.15s, transform 0.15s;
}

.data-table th.sortable:hover::after {
  opacity: 0.6;
}

.data-table th.sortable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.data-table th.sortable[aria-sort="ascending"]::after {
  opacity: 1;
  transform: rotate(180deg);
}

.data-table th.sortable[aria-sort="descending"]::after {
  opacity: 1;
}

.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-row);
  color: var(--text-body);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background 0.15s;
  cursor: pointer;
}

.data-table tbody tr:hover {
  background: var(--bg-hover-row);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.table-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-empty);
  font-size: 0.875rem;
}

.table-empty svg {
  display: block;
  margin: 0 auto 0.75rem;
  opacity: 0.25;
}

.table-empty .empty-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.table-count {
  font-size: 0.8125rem;
  color: var(--text-count);
  margin-top: 0.75rem;
  text-align: right;
}

/* ── Utility: Right-align ── */
.text-right { text-align: right; }

/* ── Action buttons inside table ── */
.action-btn {
  background: none;
  border: 1px solid var(--border-input);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  min-height: 2.75rem;
  font-size: 0.7rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  font-family: 'Poppins', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  /* Render <a> and <button> identically: always inline-flex centered */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  vertical-align: middle;
  box-sizing: border-box;
  white-space: nowrap;
}

.action-btn:hover,
.action-btn:focus-visible {
  color: var(--accent);
  border-color: var(--accent-border-checkbox);
}

.action-btn.delete:hover,
.action-btn.delete:focus-visible,
.action-btn.action-btn-danger:hover,
.action-btn.action-btn-danger:focus-visible {
  color: var(--danger);
  border-color: var(--danger-border);
  background: var(--danger-hover-bg);
}

.action-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Badge / Status ── */
.badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-active {
  background: rgba(154, 202, 61, 0.15);
  color: var(--success);
}

.badge-inactive {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-online {
  background: var(--info-bg);
  color: var(--info);
}

.badge-info {
  background: var(--info-bg);
  color: var(--info);
}

.badge-inperson {
  background: rgba(253, 161, 0, 0.15);
  color: var(--accent);
}

/* Enquiry status badges */
.badge-new {
  background: var(--info-bg);
  color: var(--info);
}

.badge-contacted {
  background: rgba(245, 158, 11, 0.15);
  color: #F59E0B;
}

.badge-follow_up {
  background: rgba(245, 158, 11, 0.15);
  color: #F59E0B;
}

.badge-interested {
  background: rgba(139, 92, 246, 0.15);
  color: #8B5CF6;
}

.badge-negotiating {
  background: rgba(139, 92, 246, 0.15);
  color: #8B5CF6;
}

.badge-trial {
  background: rgba(253, 161, 0, 0.15);
  color: var(--accent);
}

.badge-converted {
  background: rgba(154, 202, 61, 0.15);
  color: var(--success);
}

.badge-lost {
  background: var(--danger-bg);
  color: var(--danger);
}

/* ── Stat Cards Grid ── */
.stat-grid,
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  grid-auto-rows: 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 10px;
  padding: 1rem 1.25rem 1rem 1.5rem;
  height: 100%;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.stat-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 10px 0 0 10px;
}

.stat-card:hover {
  border-color: var(--accent-card-border);
  box-shadow: 0 4px 20px var(--accent-card-shadow);
}

.stat-card .stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.75px;
  margin-bottom: 0.25rem;
}

.stat-card .stat-value {
  font-family: 'Montserrat', 'Poppins', sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
  font-feature-settings: "tnum";
}

.stat-card .stat-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.stat-card .stat-sub:empty {
  display: none;
}

/* ── Trend Pill (used inside .stat-sub) ── */
.trend-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-feature-settings: "tnum";
}
.trend-pill.up { color: var(--success); }
.trend-pill.down { color: var(--danger); }
.trend-pill.flat { color: var(--text-muted); }
.trend-pill + .trend-prev { color: var(--text-muted); margin-left: 0.25rem; }

/* ── Clickable Stat Card ── */
a.stat-card-link {
  text-decoration: none;
  color: inherit;
  display: block;
  cursor: pointer;
}

a.stat-card-link .stat-card {
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.1s;
}

a.stat-card-link:hover .stat-card,
a.stat-card-link:focus-visible .stat-card {
  border-color: var(--accent-card-border);
  box-shadow: 0 4px 20px var(--accent-card-shadow);
  transform: translateY(-2px);
}

a.stat-card-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 10px;
}

/* Clickable stat card within same page (button-style) */
.stat-card[data-action] {
  cursor: pointer;
}

.stat-card[data-action]:hover,
.stat-card[data-action]:focus-visible {
  transform: translateY(-2px);
}



.stat-card.success .stat-value  { color: var(--success); }
.stat-card.alert .stat-value    { color: var(--danger); }
.stat-card.highlight .stat-value { color: var(--accent); }

.stat-card.stat-success::before,
.stat-card.success::before  { background: var(--success); }
.stat-card.stat-warning::before,
.stat-card.highlight::before { background: var(--warning); }
.stat-card.stat-danger::before,
.stat-card.alert::before     { background: var(--danger); }
.stat-card.stat-info::before    { background: var(--info); }

/* Themed snapshot cards (alerts strip on the dashboard).
   Each variant pairs a soft gradient background with a contrasting icon
   colour so the strip mirrors the supplied "alerts" mock-up. */
.stat-card.has-icon {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 0.75rem;
  align-items: center;
  color: #1f2937;
  border: none;
  overflow: hidden;
}

.stat-card.has-icon::before { display: none; }

.stat-card.has-icon .stat-icon {
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.55);
  color: inherit;
}

.stat-card.has-icon .stat-icon svg {
  width: 26px;
  height: 26px;
  display: block;
}

.stat-card.has-icon .stat-body { min-width: 0; }
.stat-card.has-icon .stat-label { color: inherit; opacity: 0.85; font-weight: 500; }
.stat-card.has-icon .stat-value { color: inherit; font-size: 1.5rem; }
.stat-card.has-icon .stat-sub   { color: inherit; opacity: 0.78; }

/* Gradient palette aligned to the K2BOX brand (gold #FBB117 + accent
   red #FF3C38 + neutral darks/greys). Each card stays distinguishable
   while reading as part of the same family. */
.stat-card.card-warm    { background: linear-gradient(135deg, #fff4d6 0%, #fbb117 100%); color: #4a2c00; }
.stat-card.card-warm    .stat-icon { color: #7a4a00; background: rgba(255,255,255,0.7); }
.stat-card.card-cool    { background: linear-gradient(135deg, #f5f5f5 0%, #d4d4d4 100%); color: #1f1f1f; }
.stat-card.card-cool    .stat-icon { color: #525252; background: rgba(255,255,255,0.75); }
.stat-card.card-pink    { background: linear-gradient(135deg, #ffd9d8 0%, #ff7a77 100%); color: #5a0d0b; }
.stat-card.card-pink    .stat-icon { color: #c81f1c; background: rgba(255,255,255,0.7); }
.stat-card.card-peach   { background: linear-gradient(135deg, #ffe9c2 0%, #ffc56a 100%); color: #5a3300; }
.stat-card.card-peach   .stat-icon { color: #a35d00; background: rgba(255,255,255,0.7); }
.stat-card.card-coral   { background: linear-gradient(135deg, #ffd0cf 0%, #ff3c38 100%); color: #4a0907; }
.stat-card.card-coral   .stat-icon { color: #b32623; background: rgba(255,255,255,0.75); }
.stat-card.card-amber   { background: linear-gradient(135deg, #ffe9b3 0%, #e09e10 100%); color: #4a2c00; }
.stat-card.card-amber   .stat-icon { color: #7a4a00; background: rgba(255,255,255,0.7); }
.stat-card.card-grey    { background: linear-gradient(135deg, #1f1f1f 0%, #0a0a0a 100%); color: #fbb117; }
.stat-card.card-grey    .stat-icon { color: #fbb117; background: rgba(251,177,23,0.18); }
.stat-card.card-grey    .stat-label { color: #ffd36a; opacity: 1; }
.stat-card.card-grey    .stat-value { color: #ffffff; }
.stat-card.card-grey    .stat-sub   { color: #d4d4d4; opacity: 1; }

/* Hover lift mirrors the standard stat-card affordance. */
.stat-card.has-icon:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,0.08); }

@media (prefers-reduced-motion: reduce) {
  .stat-card.has-icon { transition: none; }
  .stat-card.has-icon:hover { transform: none; }
}
.stat-card.stat-accent::before  { background: var(--accent); }

.stat-card.highlight {
  border-color: var(--accent-border);
  background: var(--accent-highlight-bg);
}

/* ── Dashboard Layout ── */
.dashboard-section {
  margin-bottom: 2rem;
}

.dashboard-section h2 {
  font-family: 'Montserrat', 'Poppins', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.alert-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.alert-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
}

.alert-row .alert-actions {
  display: inline-flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.alert-row .alert-meta {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.alert-empty {
  color: var(--text-secondary);
  font-size: 0.875rem;
  padding: 0.75rem 0;
}

/* Hover tooltip used by the dashboard line charts (income trend, churn). */
.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--bg-card, #fff);
  color: var(--text-body, #111827);
  border: 1px solid var(--border-card, #e5e7eb);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  line-height: 1.4;
  min-width: 160px;
  z-index: 10;
}

.chart-tooltip-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--text-heading, #111827);
}

.chart-tooltip-row {
  display: flex;
  align-items: center;
  white-space: nowrap;
}

/* Collapsible Alerts panel on the dashboard */
#alertsSection details > summary,
#recentActivitySection details > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 0.75rem;
  border-radius: 6px;
  transition: background-color 0.15s ease;
}
#alertsSection details > summary:hover,
#recentActivitySection details > summary:hover {
  background: var(--bg-hover-row);
}
#alertsSection details > summary::-webkit-details-marker,
#recentActivitySection details > summary::-webkit-details-marker { display: none; }
#alertsSection details > summary::before,
#recentActivitySection details > summary::before {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 4px 0 4px 6px;
  border-color: transparent transparent transparent currentColor;
  color: var(--text-secondary);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}
#alertsSection details[open] > summary::before,
#recentActivitySection details[open] > summary::before { transform: rotate(90deg); }
#alertsSection details > summary h2,
#recentActivitySection details > summary h2 {
  border: none;
  padding: 0;
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: 0.5px;
}
#alertsSection details > summary:focus-visible,
#recentActivitySection details > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.activity-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
}
.activity-row:hover { background: var(--bg-hover-row); }
.activity-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.activity-icon {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-input);
  border-radius: 50%;
  font-size: 0.875rem;
  flex-shrink: 0;
}
.activity-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.activity-title {
  font-size: 0.875rem;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.activity-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
}
.activity-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.dashboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.dashboard-table th {
  text-align: left;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.75rem 1rem;
  background: var(--bg-thead);
  border-bottom: 1px solid var(--border-row);
}

.dashboard-table td {
  padding: 0.75rem 1rem;
  color: var(--text-body);
  border-bottom: 1px solid var(--border-row);
}

.dashboard-table tbody tr:hover {
  background: var(--bg-hover-row);
}

/* ── Loading Message ── */
.loading-msg {
  text-align: center;
  padding: 3rem;
  color: var(--text-empty);
  font-size: 0.875rem;
}

/* ── Dashboard Responsive ── */
@media (max-width: 640px) {
  .stat-grid,
  .dashboard-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ── Dashboard Page Header Utilities ── */
.page-header-meta {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin: 0.25rem 0 0;
}

.page-header-actions .control-group {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.page-header-actions .checkbox-label {
  font-size: 0.8125rem;
}

.page-header-actions .checkbox-label input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Live indicator next to auto-refresh */
.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--success);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.live-indicator::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  animation: live-pulse 1.6s ease-in-out infinite;
}
@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* Refresh button loading state */
.btn.is-loading {
  opacity: 0.6;
  cursor: progress;
}

/* Onboarding banner (replaces inline styles) */
.onboarding-banner {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-left: 4px solid var(--accent);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.onboarding-banner-summary {
  color: var(--text-muted);
  margin-left: 0.5rem;
}
.onboarding-banner-actions {
  display: inline-flex;
  gap: 0.5rem;
}

/* ── Initials Avatar ── */
.avatar-initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  text-transform: uppercase;
  flex-shrink: 0;
  margin-right: 0.5rem;
  vertical-align: middle;
}

/* ── Photo Avatar (image-based) ── */
.avatar-photo {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  margin-right: 0.5rem;
  vertical-align: middle;
}
.panel-identity .avatar-photo {
  width: 44px;
  height: 44px;
}

/* ── Photo Upload Widget ── */
.photo-upload {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.photo-preview {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--bg-input);
  border: 2px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
}
.photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.photo-preview .photo-placeholder {
  color: var(--text-muted);
  font-size: 0.65rem;
  text-align: center;
  line-height: 1.2;
}
.photo-preview.has-photo {
  border-style: solid;
  border-color: var(--accent);
}
.photo-upload-controls {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}
.photo-upload-controls .btn-sm {
  font-size: 0.7rem;
  padding: 0.25rem 0.75rem;
}
.photo-upload input[type="file"] {
  display: none;
}

.name-cell {
  display: flex;
  align-items: center;
}

/* ── Status Filter Tabs ── */
.filter-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.filter-tab {
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 0.5rem 1rem;
  min-height: 2.75rem;
  border-radius: 20px;
  border: 1px solid var(--border-card);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.filter-tab:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.filter-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  color: var(--text-primary);
}

.filter-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-on-accent);
}

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  backdrop-filter: blur(4px);
  z-index: 300;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--bg-modal);
  border: 1px solid var(--border-input);
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 500px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
}

.modal h2 {
  font-family: 'Montserrat', 'Poppins', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.modal .form-grid {
  gap: 1rem 1.25rem;
}

.modal .form-actions {
  margin-top: 1.5rem;
}

/* ── Wide modal hosting an embedded add page (iframe) ── */
.modal.modal-iframe {
  max-width: 1100px;
  width: 95%;
  max-height: 92vh;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-iframe-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border-input);
  background: var(--bg-card);
}
.modal-iframe-header h2 {
  margin: 0;
  font-size: 1rem;
}
.modal-iframe-body {
  flex: 1;
  min-height: 0;
}
.modal-iframe-body iframe {
  width: 100%;
  height: 100%;
  min-height: 70vh;
  border: 0;
  display: block;
}

/* When a page is embedded inside the Add modal (?embed=1) hide chrome. */
body.embedded-add .sidebar,
body.embedded-add .sidebar-overlay,
body.embedded-add .topbar,
body.embedded-add .skip-link { display: none !important; }
body.embedded-add .main {
  margin-left: 0 !important;
  padding: 1.25rem !important;
  max-width: none !important;
}
body.embedded-add .page-header { margin-top: 0; }

/* ── Wider main for list views ── */
.main-wide {
  max-width: none;
  padding-right: 2.5rem;
}

/* ── Tab Bar ── */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 1.5rem;
  overflow-x: auto;
}

.tab-btn {
  font-family: 'Poppins', sans-serif;
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.75px;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s, border-color 0.2s;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn:focus-visible {
  color: var(--text-primary);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ── Sidebar Expandable Groups ── */
.nav-group-toggle {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1.25rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  border-left: 3px solid transparent;
  width: 100%;
  cursor: pointer;
  text-align: left;
  font-family: 'Poppins', sans-serif;
  transition: color 0.2s, background 0.2s;
}

.nav-group-toggle:hover,
.nav-group-toggle:focus-visible {
  color: var(--text-primary);
  background: var(--accent-glow);
}

.nav-group-toggle.active {
  color: var(--text-primary);
  font-weight: 600;
}

.nav-group-chevron {
  margin-left: auto;
  width: 14px;
  height: 14px;
  transition: transform 0.2s;
  opacity: 0.4;
  flex-shrink: 0;
}

.nav-group-toggle[aria-expanded="true"] .nav-group-chevron {
  transform: rotate(90deg);
}

.nav-group-items {
  display: none;
  padding-left: 1rem;
}

.nav-group-items.open {
  display: block;
}

.nav-group-items .nav-link {
  font-size: 0.75rem;
  padding: 0.5rem 1.25rem;
}

/* ── Theme Toggle ── */
.theme-toggle {
  background: none;
  border: 1px solid var(--border-input);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  flex-shrink: 0;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  color: var(--accent);
  border-color: var(--accent-border-checkbox);
  background: var(--bg-input);
}

/* ── Side Panel (Drawer) ── */
.side-panel-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.side-panel-overlay.open { opacity: 1; pointer-events: auto; }

.side-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 910;
  width: min(460px, 90vw);
  background: var(--bg-modal);
  border-left: 1px solid var(--border-card);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.side-panel.open { transform: translateX(0); }

.side-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-card);
  flex-shrink: 0;
}
.side-panel-header h2 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  color: var(--text-heading);
}

.side-panel-close {
  background: none;
  border: 1px solid var(--border-input);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  flex-shrink: 0;
}
.side-panel-close:hover {
  color: var(--text-heading);
  border-color: var(--accent-border-checkbox);
  background: var(--bg-input);
}
.side-panel-close:focus-visible {
  color: var(--text-heading);
  border-color: var(--accent);
  background: var(--bg-input);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.side-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
}

/* Panel identity card */
.panel-identity {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: 10px;
  background: var(--bg-input);
  margin-bottom: 1.25rem;
}
.panel-identity .avatar-initials {
  width: 44px;
  height: 44px;
  font-size: 0.9rem;
}
.panel-identity-info { min-width: 0; }
.panel-identity-name {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.panel-identity-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Panel sections */
.panel-section { margin-bottom: 1.25rem; }
.panel-section-title {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.625rem;
}

.panel-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.panel-info-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.panel-info-grid.cols-1 { grid-template-columns: 1fr; }

.panel-info-item {
  padding: 0.625rem 0.75rem;
  border-radius: 8px;
  background: var(--bg-input);
}
.panel-info-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.panel-info-value {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-heading);
  word-break: break-word;
}
.panel-info-item.span-2 { grid-column: span 2; }

.panel-divider {
  border: none;
  border-top: 1px solid var(--border-card);
  margin: 1rem 0;
}

/* Panel action buttons */
.panel-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.panel-actions .btn { justify-content: center; }

/* ── View Profile Pages (Read-Only Detail) ── */
.view-profile-card {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1.75rem;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  margin-bottom: 1.5rem;
}
.view-profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.view-avatar-initials {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
}
.view-profile-info { min-width: 0; }
.view-profile-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1.2;
  margin-bottom: 0.25rem;
}
.view-profile-sub {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0.625rem;
  line-height: 1.4;
}
.view-profile-badges {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.view-profile-since {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.view-section {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 12px;
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.25rem;
}
.view-section-title {
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-card);
}
.view-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-card);
}
.view-section-header h2 {
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin: 0;
}
.view-info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 1.75rem;
  row-gap: 0.25rem;
}
.view-info-item {
  padding: 0.625rem 0;
  border-bottom: 1px dashed var(--border-subtle);
  min-width: 0;
}
.view-info-item:last-child,
.view-info-item:nth-last-child(2):nth-child(odd) {
  border-bottom: none;
}
.view-info-label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.view-info-value {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-heading);
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.view-not-provided {
  color: var(--text-muted);
  font-weight: 400;
  font-style: italic;
}
.view-info-meta {
  display: inline-block;
  margin-left: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--text-muted);
}
.view-section .muted,
.view-section p.muted {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0;
  padding: 0.5rem 0;
}
.view-section .help-text {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  line-height: 1.4;
}
.view-section .status-badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  background: var(--bg-input);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

@media (max-width: 600px) {
  .view-profile-card {
    flex-direction: column;
    text-align: center;
    padding: 1.25rem;
  }
  .view-profile-badges { justify-content: center; }
  .view-section {
    padding: 1.25rem;
  }
  .view-info-grid {
    grid-template-columns: 1fr;
    column-gap: 0;
  }
  .view-info-item:nth-last-child(2):nth-child(odd) {
    border-bottom: 1px dashed var(--border-subtle);
  }
}

/* === Settings page === */
.form-help { font-size: 0.8125rem; color: var(--text-muted); margin: 0 0 1rem 0; }
.form-help a { color: var(--accent); text-decoration: none; font-weight: 500; }
.form-help a:hover, .form-help a:focus-visible { text-decoration: underline; }
.subsection-title { font-size: 0.8125rem; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--text-muted); margin: 1.5rem 0 0.75rem; }
.subsection-title:first-of-type { margin-top: 0; }
.toggle-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0.5rem; margin-bottom: 1.25rem; }
.toggle-list:last-child { margin-bottom: 0; }
.settings-nav {
  position: sticky;
  top: var(--topbar-height, 56px);
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  margin: 0 0 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-input);
  border-radius: 10px;
  backdrop-filter: blur(6px);
}
.settings-nav-link {
  padding: 0.4rem 0.85rem;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 6px;
  transition: background 0.15s ease, color 0.15s ease;
}
.settings-nav-link:hover {
  background: var(--bg-input);
  color: var(--text-primary);
}
.settings-nav-link:focus-visible {
  background: var(--bg-input);
  color: var(--text-primary);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.form-section[id] { scroll-margin-top: 70px; }


/* ── Shared utility classes (audit fixes) ── */

/* Back link used on every detail/view page */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.back-link:hover {
  text-decoration: underline;
}
.back-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Modal helper text (small explainer paragraph inside .modal) */
.modal-help {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin: 0 0 1rem;
}

/* Variant: form-actions aligned to the start (instead of default end) */
.form-actions.form-actions--start {
  justify-content: flex-start;
}
/* Variant: form-actions with extra top margin (replaces inline margin-top) */
.form-actions.form-actions--spaced {
  margin-top: 1rem;
}

/* Variant: form with extra top margin */
.form-spaced {
  margin-top: 1rem;
}

/* Variant: table wrapper with extra top margin */
.table-wrapper.table-wrapper--spaced {
  margin-top: 1rem;
}

/* Variant: full-width button (replaces inline width:100%) */
.btn.btn--full {
  width: 100%;
  min-width: 0;
}

/* Portal link box on customer view (replaces inline flex/margin styles) */
.portal-link-box {
  margin-top: 0.75rem;
}
.portal-link-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.portal-link-row input[type="text"] {
  flex: 1;
}

/* Import / Export result panel (preserves whitespace, wraps long errors) */
.import-result {
  font-size: 0.8125rem;
  color: var(--text-label);
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 1rem;
}

/* Login screen shell (hosts a single .form-section) */
.auth-shell {
  max-width: 400px;
  margin: 10vh auto 0;
  padding: 2rem;
}
.auth-shell .form-section {
  text-align: center;
}
.auth-shell .form-section .section-body {
  text-align: left;
}
.auth-shell .auth-logo {
  width: 80px;
  height: 80px;
  margin: 0 auto 1rem;
  display: block;
}
.auth-shell h1 {
  font-family: 'Montserrat', 'Poppins', sans-serif;
  font-size: 1.5rem;
  color: var(--accent);
  margin-bottom: 0.5rem;
  text-align: center;
}
.auth-shell .auth-subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
  text-align: center;
}
.auth-shell .auth-error {
  color: var(--danger);
  font-size: 0.875rem;
  margin-bottom: 1rem;
  min-height: 1.2em;
}
.auth-shell .auth-info {
  background: var(--bg-input);
  border-left: 3px solid var(--accent);
  color: var(--text-primary);
  font-size: 0.875rem;
  padding: 0.625rem 0.875rem;
  margin-bottom: 1rem;
  border-radius: 8px;
  text-align: left;
}
.auth-shell .auth-info[hidden] { display: none; }

/* Onboarding page step list */
.onboarding-progress {
  margin-bottom: 1.5rem;
}
.onboarding-bar-track {
  background: var(--border-input);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}
.onboarding-bar-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 300ms;
}
.onboarding-summary {
  margin-top: 0.5rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}
.onboarding-steps {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.onboarding-step {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: space-between;
  padding: 1rem;
  border: 1px solid var(--border-input);
  border-radius: 8px;
  background: var(--bg-card);
}
.onboarding-step-text { min-width: 0; }
.onboarding-step-text p {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}
.onboarding-step-actions {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
}

/* Long table cell content: truncate with ellipsis (cells get title= for full text) */
.data-table td {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.data-table td.cell-actions,
.data-table th[data-no-sort] {
  max-width: none;
  overflow: visible;
  white-space: nowrap;
}

/* Toast: bound width on small viewports */
.toast {
  max-width: min(420px, calc(100vw - 4rem));
}

/* Side panel: full width on small viewports */
@media (max-width: 480px) {
  .side-panel {
    width: 100vw;
  }
}

/* Form grid: collapse to single column on small viewports */
@media (max-width: 640px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  a.stat-card-link:hover .stat-card,
  a.stat-card-link:focus-visible .stat-card,
  .stat-card[data-action]:hover,
  .stat-card[data-action]:focus-visible,
  .btn:active {
    transform: none !important;
  }
}




/* ── Search Results Dropdown (Attendance quick check-in) ── */
.search-results {
  margin-top: 0.25rem;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.search-results .search-result-item {
  padding: 0.625rem 0.875rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.search-results .search-result-item:last-child { border-bottom: none; }
.search-results .search-result-item:hover,
.search-results .search-result-item:focus {
  background: var(--surface-alt, #f5f5f5);
}
.search-results .search-result-item:focus-visible {
  outline: 2px solid var(--accent, #3b82f6);
  outline-offset: -2px;
}
.search-results .search-result-empty {
  padding: 0.75rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ── File preview (receipts, photos) ── */
.file-preview {
  margin-top: 0.5rem;
  font-size: 0.875rem;
}
.file-preview a { color: var(--accent, #3b82f6); }
