/* ============================================
   CHAINLINK CSS – Mobile-First, Bubbly & Fluid
   Διορθωμένο ώστε να διατηρεί όλες τις αρχικές
   λειτουργίες (menu-dots, menu-toggle, sidebar
   off‑canvas έως 1024px, sticky από 1024px+).
   ============================================ */

:root {
  /* Opt-out of Chrome's "Auto Dark Theme for Web Contents".
     Without this, Android Chrome silently inverts surfaces on light
     pages — chips render as dark pills, navbar text disappears,
     etc. Declaring color-scheme tells Chromium the page already
     has its own theme story. The dark-mode override sits in the
     [data-theme="dark"] block below. */
  color-scheme: light;

  /* Primary Gradient Colors */
  --primary: #4b8ef1;
  --primary-light: #726ae3;
  --primary-dark: #2a5cb0;
  --accent-cyan: #28e1fd;
  --accent-purple: #5b68eb;
  
  /* Secondary Colors */
  --secondary: #95a5a6;
  --success: #2ecc71;
  --warning: #f39c12;
  --danger: #e74c3c;
  --info: #1abc9c;
  
  /* Background Colors */
  --bg-dark: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  --bg-card: #ffffff;
  --bg-light: #f0f4f8;
  --bg-white: #ffffff;
  --bg-gradient: linear-gradient(105deg, rgba(91,104,235,1) 0%, rgba(40,225,253,1) 100%);
  
  /* Text Colors */
  --text-light: #ffffff;
  --text-dark: #2a2a2a;
  --text-muted: #afafaf;
  
  /* UI Colors */
  --border-color: #e9ecef;
  --border-dashed: #4b8ef1;
  --overlay-bg: rgba(0, 0, 0, 0.5);
  
  /* Shadows – Softer for bubbly feel */
  --shadow-sm: 0 2px 8px rgba(75, 142, 241, 0.08);
  --shadow: 0 4px 20px rgba(75, 142, 241, 0.12);
  --shadow-lg: 0 8px 30px rgba(75, 142, 241, 0.18);
  --shadow-sidebar: 8px 0 30px rgba(75, 142, 241, 0.15);
  --shadow-bubble: 0 10px 40px rgba(91, 104, 235, 0.2);
  
  /* Border Radius – Extra Rounded (Bubbly) */
  --radius-xs: 0.75rem;
  --radius-sm: 1rem;
  --radius: 1.25rem;
  --radius-lg: 1.5rem;
  --radius-xl: 2rem;
  --radius-2xl: 2.5rem;
  --radius-full: 50%;
  --radius-bubble: 3rem;
  
  /* Spacing Scale – Fully fluid with clamp() */
  --space-xs: clamp(0.2rem, 0.4vw, 0.25rem);
  --space-sm: clamp(0.4rem, 0.7vw, 0.5rem);
  --space-md: clamp(0.6rem, 1vw, 0.75rem);
  --space: clamp(0.75rem, 1.5vw, 1rem);
  --space-lg: clamp(1rem, 2vw, 1.25rem);
  --space-xl: clamp(1.25rem, 2.5vw, 1.5rem);
  --space-2xl: clamp(1.5rem, 3vw, 2rem);
  --space-3xl: clamp(2rem, 4vw, 2.5rem);
  
  /* Typography Scale (Fluid) */
  --text-xs: clamp(0.7rem, 0.8vw, 0.75rem);
  --text-sm: clamp(0.8rem, 0.9vw, 0.875rem);
  --text-base: clamp(0.9rem, 1vw, 0.95rem);
  --text-lg: clamp(1rem, 1.2vw, 1.1rem);
  --text-xl: clamp(1.25rem, 1.5vw, 1.5rem);
  --text-2xl: clamp(1.5rem, 2vw, 1.75rem);
  
  /* Transitions */
  --transition-fast: 0.2s ease;
  --transition: 0.3s ease;
  --transition-bounce: 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  --transition-slow: 0.5s ease;
  
  /* Z-Index Scale */
  --z-dropdown: 10;
  --z-sticky: 100;
  --z-modal: 1000;
  --z-toast: 1000;
  --z-menu: 2000;
  
  /* Layout */
  --navbar-height: 3.5rem; /* mobile default */
  --sidebar-width: 17rem;
  --container-max: 1200px;
}

/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-size-adjust: 100%;
}

body {
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text-dark);
  background: var(--bg-light);
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--primary-dark);
}

img {
  max-width: 100%;
  height: auto;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-dark);
}

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }

p {
  margin-bottom: var(--space);
  color: var(--text-muted);
}

.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }

/* ============================================
   LAYOUT - Login Page (Bubbly)
   ============================================ */
.login-page {
  background: var(--bg-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--space);
}

.login-container {
  width: 100%;
  max-width: 26rem;
}

.login-box {
  background: var(--bg-white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-bubble);
  overflow: hidden;
}

.login-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent-purple) 100%);
  color: var(--text-light);
  padding: var(--space-3xl) var(--space-xl);
  text-align: center;
}

.login-header i {
  font-size: 3.5rem;
  color: var(--text-light);
  margin-bottom: var(--space);
  display: inline-block;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
}

.login-header h1 {
  font-size: var(--text-xl);
  margin-bottom: var(--space-sm);
  color: var(--text-light);
}

.login-header p {
  color: rgba(255,255,255,0.8);
  font-size: var(--text-sm);
  margin-bottom: 0;
}

.login-form {
  padding: var(--space-xl);
}

.login-footer {
  padding: var(--space-lg) var(--space-xl);
  text-align: center;
  border-top: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: var(--text-xs);
}

/* ============================================
   NAVIGATION – Mobile first, visible on all sizes
   ============================================ */
.navbar {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent-purple) 100%);
  color: var(--text-light);
  padding: 0 var(--space);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--navbar-height);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  box-shadow: var(--shadow-lg);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-light);
}

.nav-brand i {
  color: var(--text-light);
  font-size: 1.5rem;
}

/* Anchor that wraps the brand icon + label; reset link defaults
   and re-establish the flex pairing of icon and text. */
.brand-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  color: inherit;
  text-decoration: none;
}
.brand-link:hover,
.brand-link:focus { color: inherit; text-decoration: none; }
.brand-link:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.6);
  outline-offset: 4px;
  border-radius: var(--radius-xs);
}

/* Desktop nav links – hidden on mobile */
.nav-links {
  display: none;
  gap: var(--space-xs);
}

.nav-link {
  color: rgba(255, 255, 255, 0.85);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--text-sm);
  transition: var(--transition);
}

.nav-link:hover,
.nav-link.active {
  color: var(--text-light);
  background: rgba(255, 255, 255, 0.2);
}

/* User info – hidden on mobile */
.nav-user {
  display: flex;
  align-items: center;
  gap: var(--space);
}

.user-name,
.user-role {
  display: none;
}

/* Menu toggle (hamburger for sidebar) – visible on mobile */
.menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.2);
  border: none;
  color: var(--text-light);
  font-size: 1.5rem;
  cursor: pointer;
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  transition: var(--transition);
  min-width: 48px;
  min-height: 48px;
  margin-right: var(--space);
}

.menu-toggle:hover {
  background: rgba(255,255,255,0.3);
}

/* 3‑dots button (user menu) – visible on mobile, later hidden on desktop */
.menu-dots {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.2);
  border: none;
  color: var(--text-light);
  font-size: 1.5rem;
  cursor: pointer;
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  transition: var(--transition);
  min-width: 48px;
  min-height: 48px;
}

.menu-dots:hover {
  background: rgba(255,255,255,0.3);
}

/* Dropdown menu for 3‑dots */
.dropdown-menu {
  position: absolute;
  top: calc(var(--navbar-height) + 0.5rem);
  right: var(--space);
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-bubble);
  min-width: 12rem;
  padding: var(--space-sm);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: var(--transition);
  z-index: var(--z-menu);
}

.dropdown-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space) var(--space-md);
  color: var(--text-dark);
  font-size: var(--text-sm);
  border-radius: var(--radius-sm);
  transition: var(--transition);
  min-height: 48px;
}

.dropdown-item:hover {
  background: var(--bg-light);
  color: var(--primary);
}

.dropdown-item i {
  color: var(--primary);
  width: 1.25rem;
}

.dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: var(--space-sm) 0;
}

/* ============================================
   SIDEBAR – off‑canvas on mobile/tablet,
   sticky on desktop (≥1024px)
   ============================================ */
.sidebar {
  position: fixed;
  top: var(--navbar-height);
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--navbar-height));
  background: var(--bg-white);
  box-shadow: var(--shadow-sidebar);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  padding: var(--space-lg);
  overflow-y: auto;
  z-index: var(--z-sticky);
  transform: translateX(-100%);
  transition: transform var(--transition);
}

.sidebar.open {
  transform: translateX(0);
}

/* Optional overlay (if you add a div with class sidebar-overlay) */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: var(--navbar-height);
  left: 0;
  width: 100%;
  height: calc(100vh - var(--navbar-height));
  background: rgba(0,0,0,0.4);
  z-index: calc(var(--z-sticky) - 1);
}

.sidebar.open ~ .sidebar-overlay {
  display: block;
}

.sidebar-section {
  margin-bottom: var(--space-xl);
}

.sidebar-section h3 {
  font-size: var(--text-xs);
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
  letter-spacing: 0.5px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  color: var(--text-dark);
  font-size: var(--text-sm);
  margin-bottom: var(--space-xs);
  transition: var(--transition);
  min-height: 48px;
}

.sidebar-link:hover {
  background: var(--bg-light);
  color: var(--primary);
}

/* ============================================
   MAIN CONTAINER & CONTENT
   ============================================ */
.main-container {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--navbar-height));
}

.main-content {
  flex: 1;
  padding: var(--space);
  overflow-y: auto;
}

/* ============================================
   PAGE HEADER (Bubbly)
   ============================================ */
.page-header {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: var(--space);
  margin-bottom: var(--space-xl);
  padding: var(--space) var(--space-lg);
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.page-header h1 {
  font-size: var(--text-xl);
  color: var(--text-dark);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.page-header h1 i {
  color: var(--primary);
  font-size: 1.5rem;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  width: 100%;
}

.page-actions .btn {
  flex: 1 1 auto;
  justify-content: center;
}

/* ============================================
   BUTTONS (Extra Bubbly, touch friendly)
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius-bubble);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-bounce);
  line-height: 1.5;
  box-shadow: var(--shadow-sm);
  min-height: 48px;
  min-width: 48px;
}

.btn:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.btn:active {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Button Variants */
.btn-primary {
  background: var(--bg-gradient);
  color: var(--bg-white);
}

.btn-primary:hover {
  background: linear-gradient(105deg, rgba(75,142,241,1) 0%, rgba(91,104,235,1) 100%);
  color: var(--bg-white);
}

.btn-secondary {
  background: var(--secondary);
  color: var(--bg-white);
}

.btn-secondary:hover {
  background: #7f8c8d;
  color: var(--bg-white);
}

.btn-success {
  background: var(--success);
  color: var(--bg-white);
}

.btn-success:hover {
  background: #27ae60;
  color: var(--bg-white);
}

.btn-warning {
  background: var(--warning);
  color: var(--bg-white);
}

.btn-warning:hover {
  background: #e67e22;
  color: var(--bg-white);
}

.btn-danger {
  background: var(--danger);
  color: var(--bg-white);
}

.btn-danger:hover {
  background: #c0392b;
  color: var(--bg-white);
}

.btn-link {
  background: transparent;
  color: var(--primary);
  box-shadow: none;
}

.btn-link:hover {
  text-decoration: underline;
  transform: none;
  box-shadow: none;
}

/* Button Sizes */
.btn-sm {
  padding: 0.5rem 1rem;
  font-size: var(--text-xs);
  border-radius: var(--radius-lg);
  min-height: 44px;
}

.btn-lg {
  padding: 1rem 2rem;
  font-size: var(--text-base);
  border-radius: var(--radius-xl);
  min-height: 56px;
}

.btn-block {
  width: 100%;
}

/* Action Buttons */
.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.action-buttons .btn {
  flex: 1 1 auto;
}

/* ============================================
   FORMS (Bubbly Inputs, mobile stacked)
   ============================================ */
.form-group {
  margin-bottom: var(--space-lg);
}

.form-group label {
  display: block;
  margin-bottom: var(--space-xs);
  font-weight: 500;
  font-size: var(--text-sm);
  color: var(--text-dark);
}

.form-control {
  width: 100%;
  padding: 0.875rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  font-size: var(--text-base);
  transition: var(--transition);
  background: var(--bg-white);
  line-height: 1.5;
  min-height: 48px;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(75, 142, 241, 0.15);
}

.form-control.is-invalid {
  border-color: var(--danger);
}

.invalid-feedback {
  color: var(--danger);
  font-size: var(--text-xs);
  margin-top: var(--space-xs);
}

.form-text {
  color: var(--text-muted);
  font-size: var(--text-xs);
  margin-top: var(--space-xs);
}

/* Form Row – default column for mobile */
.form-row {
  display: flex;
  flex-direction: column;
  gap: var(--space);
}

.form-row .form-group {
  flex: 1 1 100%;
  max-width: 100%;
}

.form-row .col-4,
.form-row .col-6 {
  flex: 1 1 100%;
  max-width: 100%;
}

/* Select */
select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234b8ef1' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

/* Textarea */
textarea.form-control {
  resize: vertical;
  min-height: 6rem;
  border-radius: var(--radius);
}

/* Input Group */
.input-group {
  display: flex;
}

.input-group .form-control {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.input-group .btn {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

/* ============================================
   FORM SECTIONS (Bubbly Cards)
   ============================================ */
.form-sections {
  display: grid;
  gap: var(--space-xl);
}

.form-section {
  background: var(--bg-white);
  border-radius: var(--radius-xl);
  padding: var(--space);
  box-shadow: var(--shadow);
}

.form-section h3 {
  font-size: var(--text-lg);
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space);
  border-bottom: 2px solid var(--border-color);
  color: var(--text-dark);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.form-section h3 i {
  color: var(--primary);
  font-size: 1.25rem;
}

.form-actions {
  display: flex;
  gap: var(--space);
  align-items: center;
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
  border-top: 2px solid var(--border-color);
  flex-wrap: wrap;
}

/* ============================================
   TABLES (Responsive wrapper)
   ============================================ */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.table {
  width: 100%;
  min-width: 600px; /* ensures horizontal scroll on small screens */
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-white);
  border-radius: var(--radius-lg);
}

.table th,
.table td {
  padding: var(--space-sm);
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.table th {
  background: linear-gradient(135deg, var(--bg-light) 0%, #e8eef5 100%);
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.table tbody tr:hover {
  background: var(--cc-surface-2, var(--bg-light));
}

.table-striped tbody tr:nth-child(even) {
  /* token-driven so light/dark stay legible; previously #fafafa was
     hardcoded and dark-mode rows rendered white under light text. */
  background: var(--cc-surface-2, #fafafa);
}
.table-striped tbody tr:nth-child(even) > * { background: transparent; }

.table-sm th,
.table-sm td {
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--text-xs);
}

/* ============================================
   BADGES & STATUS (Pills)
   ============================================ */
.badge {
  display: inline-block;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-bubble);
  font-size: var(--text-xs);
  font-weight: 600;
}

.status-badge {
  display: inline-block;
  padding: 0.375rem 0.875rem;
  border-radius: var(--radius-bubble);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.status-pending {
  background: #fff3cd;
  color: #856404;
}

.status-registered {
  background: #d1ecf1;
  color: #0c5460;
}

.status-active {
  background: #d4edda;
  color: #155724;
}

.status-cancelled {
  background: #f8d7da;
  color: #721c24;
}

/* ============================================
   ALERTS (Bubbly)
   ============================================ */
.alert {
  padding: var(--space) var(--space-lg);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  border: none;
}

.alert-success {
  background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
  color: #155724;
}

.alert-error,
.alert-danger {
  background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
  color: #721c24;
}

.alert-warning {
  background: linear-gradient(135deg, #fff3cd 0%, #ffeeba 100%);
  color: #856404;
}

.alert-info {
  background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
  color: #0c5460;
}

.alert .close {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  opacity: 0.5;
  transition: var(--transition-fast);
}

.alert .close:hover {
  opacity: 1;
}

/* ============================================
   FILTERS BAR (Bubbly)
   ============================================ */
.filters-bar {
  background: var(--bg-white);
  padding: var(--space);
  border-radius: var(--radius-xl);
  margin-bottom: var(--space-xl);
  box-shadow: var(--shadow);
}

.filters-form {
  display: flex;
  flex-direction: column;
  gap: var(--space);
  align-items: stretch;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  width: 100%;
}

.filter-group label {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.filter-group .form-control {
  min-width: 0;
}

/* ============================================
   STATS CARDS (Super Bubbly)
   ============================================ */
.stats-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.stat-card {
  background: var(--bg-white);
  border-radius: var(--radius-xl);
  padding: var(--space);
  display: flex;
  align-items: center;
  gap: var(--space);
  box-shadow: var(--shadow);
  transition: var(--transition-bounce);
}

.stat-card:hover {
  box-shadow: var(--shadow-bubble);
  transform: translateY(-5px);
}

.stat-icon {
  width: 3rem;
  height: 3rem;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--bg-light) 0%, #e8eef5 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--primary);
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.stat-content {
  flex: 1;
  min-width: 0;
}

.stat-value {
  font-size: clamp(1.5rem, 2.5vw, 2rem);
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1.2;
}

.stat-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ============================================
   STATS SECTION (Bubbly)
   ============================================ */
.stats-section {
  background: var(--bg-white);
  border-radius: var(--radius-xl);
  padding: var(--space);
  margin-bottom: var(--space-xl);
  box-shadow: var(--shadow);
}

.stats-section h3 {
  font-size: var(--text-lg);
  margin-bottom: var(--space-lg);
  color: var(--text-dark);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.stats-section h3 i {
  color: var(--primary);
  font-size: 1.25rem;
}

.chart-container {
  height: 18rem;
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
}

/* ============================================
   AFM SEARCH BAR (Bubbly)
   ============================================ */
.afm-search-bar {
  background: var(--bg-white);
  border-radius: var(--radius-xl);
  padding: var(--space);
  margin-bottom: var(--space-xl);
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
}

.afm-search-bar .form-group {
  margin-bottom: 0;
}

/* ============================================
   DROP ZONE (Bubbly File Upload)
   ============================================ */
.drop-zone {
  max-width: 100%;
  height: 8rem;
  padding: var(--space);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-weight: 500;
  font-size: var(--text-sm);
  cursor: pointer;
  color: var(--text-muted);
  border: 3px dashed var(--primary);
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, var(--bg-light) 0%, #e8eef5 100%);
  transition: var(--transition-bounce);
  position: relative;
  overflow: hidden;
}

.drop-zone:hover {
  border-color: var(--accent-purple);
  background: linear-gradient(135deg, #e8eef5 0%, #dce5f0 100%);
}

.drop-zone--over {
  border-color: var(--success);
  background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
  color: var(--success);
}

.drop-zone__input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* File Preview List */
.file-preview-list {
  margin-top: var(--space);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.file-preview-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-white);
  border: 2px solid var(--border-color);
  padding: var(--space-sm) var(--space);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.file-preview-item:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

.file-preview-item i {
  margin-right: var(--space-sm);
  color: var(--primary);
}

.remove-file-btn {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: var(--text-lg);
  padding: var(--space-xs);
  border-radius: var(--radius-full);
  transition: var(--transition-fast);
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
}

.remove-file-btn:hover {
  background: #f8d7da;
  color: #c0392b;
  transform: scale(1.1);
}

/* ============================================
   DRAFT INDICATOR (Bubbly Toast)
   ============================================ */
.draft-indicator {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  background: var(--success);
  color: var(--bg-white);
  padding: var(--space) var(--space-lg);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-bubble);
  z-index: var(--z-toast);
  animation: slideIn 0.4s var(--transition-bounce);
}

.draft-indicator.draft-error {
  background: var(--danger);
}

@keyframes slideIn {
  from {
    transform: translateX(100%) scale(0.8);
    opacity: 0;
  }
  to {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
}

/* ============================================
   TOAST NOTIFICATIONS (Bubbly)
   ============================================ */
.toast {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  padding: var(--space) var(--space-lg);
  border-radius: var(--radius-xl);
  background: #333;
  color: var(--bg-white);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  box-shadow: var(--shadow-bubble);
  z-index: var(--z-toast);
  transform: translateY(100px) scale(0.9);
  opacity: 0;
  transition: var(--transition-bounce);
}

.toast.show {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.toast-success {
  background: var(--success);
}

.toast-error {
  background: var(--danger);
}

/* ============================================
   AUTO-FILLED HIGHLIGHT
   ============================================ */
.auto-filled {
  animation: highlight 2s ease;
}

@keyframes highlight {
  0%, 100% {
    background: var(--bg-white);
  }
  50% {
    background: #d4edda;
  }
}

/* ============================================
   SUPPORT CHAT WIDGET (Mobile friendly)
   ============================================ */
.support-chat-widget {
  position: fixed;
  /* respect notched / home-indicator safe areas so the launcher
     never sits under the home bar or off the visible right edge */
  bottom: max(10px, env(safe-area-inset-bottom));
  right: max(10px, env(safe-area-inset-right));
  z-index: 9999;
  font-family: inherit;
  /* defensive: block the absolutely-positioned hint from creating
     horizontal page overflow on narrow viewports */
  max-width: 100vw;
}

/* Touch devices have no real :hover -- tapping the launcher could briefly
   flash the "Χρειάζεστε βοήθεια;" tooltip and push the page width.
   On any pointer-less device we drop the hint entirely. */
@media (hover: none) {
  .support-chat-widget .hint { display: none; }
}

/* Launcher Button */
.chat-launcher {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-full);
  background: var(--bg-gradient);
  border: none;
  box-shadow: 0 4px 15px rgba(75, 142, 241, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  font-size: 24px;
  color: #fff;
  transition: transform 0.2s var(--transition-bounce);
}

.chat-launcher:hover {
  transform: scale(1.1);
}

.launcher-icon {
  display: block;
}

.hint {
  position: absolute;
  bottom: 60px;
  right: 0;
  background: #333;
  color: #fff;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s;
  pointer-events: none;
}

.chat-launcher:hover .hint {
  opacity: 1;
  visibility: visible;
}

/* Chat Panel */
.chat-panel {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: calc(100vw - 20px);
  max-width: 340px;
  max-height: 60vh;
  background: var(--bg-white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-bubble);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.chat-panel-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent-purple) 100%);
  color: #fff;
  padding: var(--space) var(--space-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: var(--text-base);
}

.chat-close-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  opacity: 0.9;
  transition: opacity var(--transition-fast);
}
.chat-close-btn:hover {
  opacity: 1;
}

/* Start screen */
.chat-start-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  text-align: center;
  background: #f9f9fb;
}

.chat-start-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: var(--space-sm);
}

.chat-start-subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-xl);
  line-height: 1.5;
}

.chat-start-btn {
  background: var(--bg-gradient);
  color: #fff;
  border: none;
  border-radius: var(--radius-bubble);
  padding: 0.75rem 1.75rem;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-bounce);
  box-shadow: var(--shadow);
}

.chat-start-btn:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

/* Messages area */
.chat-messages {
  flex: 1;
  padding: var(--space);
  overflow-y: auto;
  background: var(--cc-surface, #f9f9fb);
  min-height: 200px;
  /* Flex column so chat-bubble.user (align-self: flex-end), agent
     (flex-start), and chat-msg-system (center) all line up cleanly
     in their own row with consistent vertical rhythm. */
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.chat-status-text {
  padding: 0 var(--space) var(--space-xs);
  font-size: var(--text-xs);
  color: var(--text-muted);
  min-height: 1.2em;
}

.chat-input-area {
  display: flex;
  padding: var(--space);
  border-top: 1px solid var(--border-color);
  background: #fff;
}

.chat-input {
  flex: 1;
  min-width: 0; /* allow shrinking inside the flex row on narrow phones */
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space);
  resize: none;
  /* iOS Safari auto-zooms inputs when font-size < 16px on focus.
     16px here keeps the rendered field tap-zoom-free without changing
     the visual size meaningfully (was ~14px). */
  font-size: 16px;
  font-family: inherit;
  transition: border-color var(--transition-fast);
}

.chat-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(75, 142, 241, 0.1);
}

.chat-send-btn {
  margin-left: var(--space-sm);
  background: var(--bg-gradient);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0 15px;
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 500;
  transition: var(--transition-bounce);
  box-shadow: var(--shadow-sm);
  min-height: 48px;
}

.chat-send-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

/* Chat bubbles — flex children of .chat-messages (column).
   align-self handles the user/agent/system positioning cleanly,
   replacing the legacy float-based layout that conflicted with
   the centered system messages and made them stack on top. */
.chat-bubble {
  max-width: 80%;
  padding: var(--space-sm) var(--space);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.chat-bubble.user {
  align-self: flex-end;
  background: #dcf8c6;
  text-align: left;
  border-bottom-right-radius: var(--radius-xs);
}

.chat-bubble.agent {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--border-color);
  border-bottom-left-radius: var(--radius-xs);
  box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .chat-bubble.user  { background: #2a3a2c; color: var(--cc-ink); }
[data-theme="dark"] .chat-bubble.agent { background: var(--cc-surface-2); color: var(--cc-ink); border-color: var(--cc-line); }

/* ============================================
   SUPPORT ADMIN INBOX (Mobile first stacking)
   ============================================ */
.support-admin {
  display: flex;
  flex-direction: column;
  height: auto;
  min-height: calc(100vh - var(--navbar-height) - 2rem);
  margin: var(--space);
  gap: 0;
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--bg-white);
}

.admin-left {
  width: 100%;
  border-right: none;
  border-bottom: 1px solid var(--border-color);
  max-height: 35vh;
  overflow-y: auto;
  background: #fafbfc;
  padding: var(--space);
}

.admin-left h3 {
  margin-top: 0;
  margin-bottom: var(--space);
  font-size: var(--text-base);
  color: var(--text-dark);
  padding-bottom: var(--space-sm);
  border-bottom: 2px solid var(--border-color);
}

.ticket-list .ticket-item {
  padding: var(--space-sm) var(--space);
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background var(--transition-fast);
  border-radius: var(--radius-sm);
  margin-bottom: 2px;
}

.ticket-item:hover {
  background: #f0f4f8;
}

.ticket-item.active {
  background: #e0f0ff;
  border-left: 3px solid var(--primary);
}

.ticket-no {
  font-weight: 600;
  font-size: var(--text-xs);
  color: var(--primary);
}

.ticket-user {
  font-size: var(--text-sm);
  margin: 2px 0;
}

.ticket-status {
  display: inline-block;
  font-size: var(--text-xs);
  color: #666;
}

.ticket-time {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

.unread-badge {
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-full);
  padding: 1px 6px;
  font-size: var(--text-xs);
  margin-left: var(--space-xs);
}

.admin-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #fff;
  min-height: 50vh;
}

.no-ticket-selected {
  padding: var(--space-2xl);
  color: var(--text-muted);
  text-align: center;
  font-size: var(--text-base);
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.conversation-header {
  padding: var(--space);
  border-bottom: 1px solid var(--border-color);
  background: #f9f9fb;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--text-sm);
}

.conversation-messages {
  flex: 1;
  padding: var(--space);
  overflow-y: auto;
  background: var(--cc-surface, #f5f6fa);
  /* Flex column so .chat-bubble.user (align-self: flex-end), .agent
     (flex-start), and .chat-msg-system (center) line up cleanly. */
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.admin-bubble {
  margin-bottom: var(--space);
  padding: var(--space-sm) var(--space);
  border-radius: var(--radius);
  max-width: 70%;
  font-size: var(--text-sm);
  line-height: 1.5;
  clear: both;
  word-wrap: break-word;
}

.admin-bubble.user {
  background: #e6f7e6;
  float: right;
  text-align: left;
  border-bottom-right-radius: var(--radius-xs);
}

.admin-bubble.agent {
  background: #e6f0ff;
  float: left;
  border-bottom-left-radius: var(--radius-xs);
}

.conversation-messages::after {
  content: "";
  display: table;
  clear: both;
}

.conversation-reply {
  padding: var(--space);
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: var(--space-sm);
  align-items: center;
  background: #fff;
}

.reply-input {
  flex: 1;
  height: 42px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space);
  resize: none;
  font-family: inherit;
  font-size: var(--text-sm);
}

.reply-input:focus {
  outline: none;
  border-color: var(--primary);
}

.reply-send-btn {
  background: var(--bg-gradient);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0 15px;
  height: 42px;
  cursor: pointer;
  font-weight: 500;
  transition: var(--transition-bounce);
  min-height: 48px;
}

.reply-send-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.status-select {
  height: 42px;
  padding: 0 var(--space-sm);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: var(--text-xs);
  color: var(--text-dark);
}

/* ============================================
   MEDIA QUERIES – Mobile‑First (min‑width)
   ============================================ */

/* 481px + : Μικρά tablets / landscape phones */
@media (min-width: 481px) {
  :root {
    --navbar-height: 3.5rem;
  }
  
  .page-header {
    flex-direction: row;
    align-items: center;
  }
  
  .page-actions {
    width: auto;
  }
  
  .page-actions .btn {
    flex: none;
  }
  
  .stats-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .chat-panel {
    width: 340px;
    max-width: 90vw;
  }

  /* Admin inbox side‑by‑side από 481px (αρχική συμπεριφορά) */
  .support-admin {
    flex-direction: row;
    height: calc(100vh - var(--navbar-height) - 2rem);
  }
  .admin-left {
    width: 250px;
    border-right: 1px solid var(--border-color);
    border-bottom: none;
    max-height: none;
  }
  .admin-right {
    min-height: auto;
  }
}

/* 640px + : Μεγαλύτερα phones / μικρά tablets */
@media (min-width: 640px) {
  .form-row {
    flex-direction: row;
    flex-wrap: wrap;
  }
  
  .form-row .form-group {
    flex: 1;
  }
  
  .form-row .col-4 {
    flex: 0 0 calc(33.333% - var(--space));
    max-width: calc(33.333% - var(--space));
  }
  
  .form-row .col-6 {
    flex: 0 0 calc(50% - var(--space));
    max-width: calc(50% - var(--space));
  }
  
  .filters-form {
    flex-direction: row;
    align-items: flex-end;
  }
  
  .filter-group {
    width: auto;
    flex: 1;
  }
}

/* 769px + : Tablets – εμφάνιση nav links, απόκρυψη mobile κουμπιών */
@media (min-width: 769px) {
  :root {
    --navbar-height: 4rem;
  }
  
  .nav-links {
    display: flex;
  }
  
  .user-name,
  .user-role {
    display: block;
  }
  
  .menu-toggle,
  .menu-dots {
    display: none !important;
  }
  
  .main-content {
    padding: var(--space-xl);
  }
  
  .stats-cards {
    grid-template-columns: repeat(3, 1fr);
  }

  /* Sidebar παραμένει off‑canvas ακόμα (θα γίνει sticky στο 1024px) */
  .sidebar {
    /* κρατάει τις ίδιες off‑canvas ρυθμίσεις */
  }

  .admin-left {
    width: 300px;
  }
}

/* 1024px + : Laptops/Desktops – sidebar γίνεται sticky */
@media (min-width: 1024px) {
  /* Sidebar sticky αντί για off‑canvas */
  .sidebar {
    position: sticky;
    top: var(--navbar-height);
    height: calc(100vh - var(--navbar-height));
    transform: none;
    box-shadow: none;
    border-radius: 0;
    border-right: 1px solid var(--border-color);
    z-index: auto;
  }
  
  .main-container {
    flex-direction: row;
  }
  
  .stats-cards {
    grid-template-columns: repeat(4, 1fr);
  }
  
  .form-section {
    padding: var(--space-xl);
  }
  
  .filters-bar {
    padding: var(--space-lg);
  }
  
  .afm-search-bar {
    padding: var(--space-lg);
  }
  
  .drop-zone {
    height: 10rem;
    padding: var(--space-xl);
    font-size: var(--text-base);
  }
}

/* 1280px + : Μεγάλα desktops */
@media (min-width: 1280px) {
  .main-content {
    max-width: var(--container-max);
    margin: 0 auto;
    width: 100%;
  }
}

/* 1440px + : Έξτρα μεγάλες οθόνες */
@media (min-width: 1440px) {
  /* περαιτέρω ρυθμίσεις αν χρειαστεί */
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
  .navbar,
  .sidebar,
  .page-actions,
  .filters-bar,
  .btn:not(.btn-print),
  .menu-toggle,
  .menu-dots,
  .dropdown-menu,
  .draft-indicator,
  .toast,
  .support-chat-widget {
    display: none !important;
  }

  .main-content {
    padding: 0;
    margin: 0;
  }

  .table {
    box-shadow: none;
    border: 1px solid var(--border-color);
  }

  .form-section {
    box-shadow: none;
    border: 1px solid var(--border-color);
    break-inside: avoid;
  }

  .page-header {
    box-shadow: none;
    border: 1px solid var(--border-color);
  }
}

/* ============================================================
   THEME OVERLAY

   - LIGHT mode  = the original Chainlink (blue, bubbly) design above.
     Nothing in this block should restyle the light theme.
   - DARK mode   = quiet, off-black, low-chroma surfaces.
     All re-skin rules below are scoped to [data-theme="dark"].

   The only unscoped rules are for the new header action buttons
   (.nav-action / .theme-toggle), which didn't exist in the original
   CSS but must render correctly in both themes.
   ============================================================ */

/* ---- Dark-mode tokens ------------------------------------------ */
[data-theme="dark"] {
  /* Match the CSS color-scheme to the active theme so native form
     controls, scrollbars, and Chrome's auto-dark heuristic all
     agree with what the rest of the stylesheet is painting. */
  color-scheme: dark;

  --cc-surface:        #111214;
  --cc-surface-2:      #181a1d;
  --cc-card:           #1a1c1f;
  --cc-ink:            #ececec;
  --cc-ink-soft:       #c4c2bc;
  --cc-ink-muted:      #8b887f;
  --cc-line:           #262a2f;
  --cc-line-strong:    #333740;
  --cc-accent:         #ececec;
  --cc-accent-on:      #1d1d1f;
  --cc-focus-ring:     rgba(236,236,236,0.22);
  --cc-shadow-soft:    0 1px 2px rgba(0,0,0,0.32), 0 8px 24px rgba(0,0,0,0.28);

  --cc-navbar-bg:      #0e0f11;
  --cc-navbar-ink:     #ececec;
  --cc-sidebar-bg:     #111214;

  /* Re-tint legacy vars so existing components blend in without rewriting them */
  --bg-light:          var(--cc-surface);
  --bg-white:          var(--cc-card);
  --bg-card:           var(--cc-card);
  --text-dark:         var(--cc-ink);
  --text-muted:        var(--cc-ink-muted);
  --border-color:      var(--cc-line);
  --shadow-sm:         var(--cc-shadow-soft);
  --shadow:            var(--cc-shadow-soft);
  --shadow-lg:         var(--cc-shadow-soft);
  --shadow-bubble:     var(--cc-shadow-soft);
}

/* ============================================================
   Header action buttons — apply in BOTH themes.
   They sit on the navbar which is dark in both modes (blue
   gradient in light, espresso in dark), so white text + a
   translucent white bg reads correctly either way.
   ============================================================ */
/* ----------------------------------------------------------------
   Navbar action buttons (profile / logout / theme toggle).
   Hard reset of every browser default so iOS/Android Safari
   doesn't paint a native button chrome, and a clean shape that
   works on both the blue light navbar and the espresso dark one. */
/* Explicit a.nav-action + button.nav-action selectors so we always
   beat the generic `a` rules (color: var(--primary)) AND the UA
   defaults for <button>. Without this, mobile Chrome occasionally
   falls back to the link-blue text on the <a> variants while
   Firefox honours .nav-action just fine. */
a.nav-action,
button.nav-action,
.nav-action {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 40px;
  padding: 0 0.95rem;
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}
a.nav-action:link,
a.nav-action:visited { color: #ffffff; }
.nav-action i { font-size: 0.95rem; pointer-events: none; /* taps always hit the button */ }
.nav-action:hover,
.nav-action:focus,
.nav-action:focus-visible {
  background: rgba(255, 255, 255, 0.26);
  border-color: rgba(255, 255, 255, 0.4);
  color: #ffffff;
  text-decoration: none;
  outline: none;
}
.nav-action:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.55);
  outline-offset: 2px;
}
.nav-action:active { transform: scale(0.95); }

.theme-toggle {
  width: 40px;
  padding: 0;
}
.theme-toggle i { font-size: 1.05rem; transition: transform 0.25s ease; }
.theme-toggle:hover i { transform: rotate(15deg); }

/* Mobile: icon-only round buttons; labels return ≥640px.
   Sized at 40x40 so the dark-mode toggle is obviously tappable
   and meets the 40-44px tap-target heuristic. */
@media (max-width: 639.98px) {
  .nav-user { gap: 0.35rem; }
  .nav-action {
    width: 40px;
    height: 40px;
    padding: 0;
    font-size: 0.95rem;
  }
  .nav-action__label { display: none; }
}
@media (min-width: 640px) {
  .nav-action__label { display: inline; }
}

/* Dark mode: same shape language, neutral ink instead of white-on-blue. */
[data-theme="dark"] a.nav-action,
[data-theme="dark"] a.nav-action:link,
[data-theme="dark"] a.nav-action:visited,
[data-theme="dark"] button.nav-action,
[data-theme="dark"] .nav-action {
  background: color-mix(in srgb, var(--cc-navbar-ink) 8%, transparent);
  color: var(--cc-navbar-ink);
  border-color: color-mix(in srgb, var(--cc-navbar-ink) 22%, transparent);
  box-shadow: none;
}
[data-theme="dark"] .nav-action:hover,
[data-theme="dark"] .nav-action:focus,
[data-theme="dark"] .nav-action:focus-visible {
  background: color-mix(in srgb, var(--cc-navbar-ink) 16%, transparent);
  border-color: color-mix(in srgb, var(--cc-navbar-ink) 38%, transparent);
  color: var(--cc-navbar-ink);
}

/* nav-action dark variants are defined above with the main rule —
   one consistent pill shape in both themes so iOS Safari doesn't
   fall back to the native button chrome that prompted "old HTML"
   feedback on mobile. */

/* On very narrow phones the navbar can overflow when brand text +
   hamburger + 3 round buttons fight for space. Trim the brand label
   so the dark-mode toggle is always visible. The icon stays. */
@media (max-width: 419.98px) {
  .brand-link span { display: none; }
  .navbar { padding: 0 0.6rem; }
}

/* ============================================================
   DARK-MODE SKIN  — everything below applies only in dark
   ============================================================ */

[data-theme="dark"] body {
  background: var(--cc-surface);
  color: var(--cc-ink);
  -webkit-font-smoothing: antialiased;
}

/* Top bar */
[data-theme="dark"] .navbar {
  background: var(--cc-navbar-bg);
  border-bottom: 1px solid color-mix(in srgb, var(--cc-navbar-ink) 8%, transparent);
  box-shadow: none;
}
[data-theme="dark"] .nav-brand,
[data-theme="dark"] .nav-brand i,
[data-theme="dark"] .brand-link,
[data-theme="dark"] .brand-link:hover,
[data-theme="dark"] .brand-link:focus {
  color: var(--cc-navbar-ink);
}
[data-theme="dark"] .nav-link {
  color: color-mix(in srgb, var(--cc-navbar-ink) 78%, transparent);
  border-radius: 6px;
  font-weight: 500;
}
[data-theme="dark"] .nav-link.active,
[data-theme="dark"] .nav-link:hover {
  color: var(--cc-navbar-ink);
  background: color-mix(in srgb, var(--cc-navbar-ink) 12%, transparent);
}

/* Sidebar */
[data-theme="dark"] .sidebar {
  background: var(--cc-sidebar-bg);
  border-right: 1px solid var(--cc-line);
  box-shadow: none;
}
[data-theme="dark"] .sidebar-section h3 {
  color: var(--cc-ink-muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
[data-theme="dark"] .sidebar-link {
  border-radius: 6px;
  color: var(--cc-ink-soft);
  font-weight: 500;
}
[data-theme="dark"] .sidebar-link:hover {
  background: var(--cc-surface-2);
  color: var(--cc-ink);
}
[data-theme="dark"] .sidebar-link.active {
  background: var(--cc-ink);
  color: var(--cc-accent-on);
}
[data-theme="dark"] .sidebar-link.active i { color: var(--cc-accent-on); }

/* Page header / cards / sections */
[data-theme="dark"] .page-header,
[data-theme="dark"] .form-section,
[data-theme="dark"] .stats-section,
[data-theme="dark"] .filters-bar,
[data-theme="dark"] .afm-search-bar,
[data-theme="dark"] .table-responsive {
  background: var(--cc-card);
  border: 1px solid var(--cc-line);
  border-radius: 8px;
  box-shadow: none;
}
[data-theme="dark"] .page-header h1,
[data-theme="dark"] .form-section h3,
[data-theme="dark"] .stats-section h3 {
  color: var(--cc-ink);
}
[data-theme="dark"] .page-header h1 i,
[data-theme="dark"] .form-section h3 i,
[data-theme="dark"] .stats-section h3 i {
  color: var(--cc-ink-muted);
}
[data-theme="dark"] .form-section h3,
[data-theme="dark"] .stats-section h3 { border-color: var(--cc-line); }

/* Tables — token-driven striping + readable text */
[data-theme="dark"] .table { font-variant-numeric: tabular-nums; }
[data-theme="dark"] .table thead th {
  background: var(--cc-surface-2);
  color: var(--cc-ink-muted);
  font-weight: 600;
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--cc-line);
}
[data-theme="dark"] .table tbody td,
[data-theme="dark"] .table tbody th {
  border-color: var(--cc-line);
  color: var(--cc-ink);
  background: transparent;
}
[data-theme="dark"] .table tbody tr { background: transparent; }
[data-theme="dark"] .table tbody tr:hover,
[data-theme="dark"] .table tbody tr:hover > * {
  background: color-mix(in srgb, var(--cc-ink) 6%, transparent);
}

/* Buttons */
[data-theme="dark"] .btn { box-shadow: none; }
[data-theme="dark"] .btn-primary {
  background: var(--cc-ink);
  border-color: var(--cc-ink);
  color: var(--cc-accent-on);
}
[data-theme="dark"] .btn-primary:hover,
[data-theme="dark"] .btn-primary:focus {
  background: color-mix(in srgb, var(--cc-ink) 88%, var(--cc-surface));
  border-color: color-mix(in srgb, var(--cc-ink) 88%, var(--cc-surface));
  color: var(--cc-accent-on);
  transform: none;
}
[data-theme="dark"] .btn-secondary,
[data-theme="dark"] .btn-outline-primary,
[data-theme="dark"] .btn-outline-secondary {
  background: var(--cc-card);
  color: var(--cc-ink);
  border: 1px solid var(--cc-line-strong);
}
[data-theme="dark"] .btn-secondary:hover,
[data-theme="dark"] .btn-outline-primary:hover,
[data-theme="dark"] .btn-outline-secondary:hover {
  background: var(--cc-surface-2);
  border-color: var(--cc-ink-muted);
  color: var(--cc-ink);
}
[data-theme="dark"] .btn-link { color: var(--cc-ink-muted); }
[data-theme="dark"] .btn-link:hover { color: var(--cc-ink); text-decoration: underline; }

/* Forms */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select,
[data-theme="dark"] input.form-control,
[data-theme="dark"] select.form-control,
[data-theme="dark"] textarea.form-control {
  background: var(--cc-card);
  color: var(--cc-ink);
  border: 1px solid var(--cc-line-strong);
}
[data-theme="dark"] .form-control::placeholder { color: var(--cc-ink-muted); }
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
  border-color: var(--cc-ink);
  box-shadow: 0 0 0 3px var(--cc-focus-ring);
  outline: none;
}

/* Alerts */
[data-theme="dark"] .alert-success { background: #14231a; color: #cde4d6; border-color: #1f3a2a; }
[data-theme="dark"] .alert-danger,
[data-theme="dark"] .alert-error   { background: #2a1717; color: #f0c9c5; border-color: #4a2222; }
[data-theme="dark"] .alert-warning { background: #271f10; color: #e7d6a5; border-color: #41331a; }
[data-theme="dark"] .alert-info    { background: #122028; color: #c5dde7; border-color: #1f3744; }

/* Chat widget */
/* ============================================================
   LIGHT-MODE token set
   IMPORTANT: scoped to :root:not([data-theme="dark"]) so dark-mode
   tokens (defined earlier with selector [data-theme="dark"]) keep
   winning the cascade. A plain :root would have equal specificity
   to [data-theme="dark"] and, being written later in the file, would
   silently override every dark token — which is the bug we just fixed.
   ============================================================ */
:root:not([data-theme="dark"]) {
    /* Slightly tinted neutrals — never pure #000 / #fff (WCAG AA). */
    --cc-surface:        #fafaf8;
    --cc-surface-2:      #f3f3ef;
    --cc-card:           #ffffff;
    --cc-ink:            #1d1d1f;   /* body text on surface (contrast > 14:1) */
    --cc-ink-soft:       #2c2c30;
    --cc-ink-muted:      #6b6b73;   /* muted text (contrast ≥ 4.6:1) */
    --cc-line:           #e6e3dd;
    --cc-line-strong:    #cfcdc6;
    --cc-accent:         #1d1d1f;   /* warm-neutral accent, not blue */
    --cc-accent-on:      #ffffff;
    --cc-focus-ring:     rgba(29,29,31,0.22);
    --cc-shadow-soft:    0 1px 2px rgba(20,20,30,0.05), 0 8px 24px rgba(20,20,30,0.08);

    /* Status colors for light mode. */
    --cc-success:        #2f8a5b;
    --cc-warning:        #b87d1e;
    --cc-error:          #b04240;
}

/* Dark mode: tuned status colors. Specificity (0,2,0) to match the
   light block above so the cascade order is well-defined. */
:root[data-theme="dark"] {
    --cc-success:        #6dc28b;
    --cc-warning:        #e0b66a;
    --cc-error:          #e88b89;
}

/* ============================================================
   ROLE BADGE DOTS — filled colored circles, no labels.
   Discord-style: each role exposes a color; we render a 8px dot
   with tooltip via title attribute. Stack horizontally with overlap.
   ============================================================ */
.role-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
    vertical-align: middle;
}
.role-dots--inline { margin-left: 6px; }
.role-dots--stacked {
    /* Tight overlap variant used in dense tables; saves horizontal space. */
    gap: 0;
}
.role-dots--stacked .role-dot { margin-left: -3px; box-shadow: 0 0 0 1.5px var(--cc-card); }
.role-dots--stacked .role-dot:first-child { margin-left: 0; }
.role-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: currentColor; /* color set inline per role */
    transition: transform .12s ease-out;
    cursor: default;
}
.role-dot:hover { transform: scale(1.35); }
.role-dot:focus-visible { outline: 2px solid var(--cc-focus-ring); outline-offset: 2px; }

/* ============================================================
   PRIVACY BANNER — sticky bottom, restrained quiet-luxury surface.
   Two-row on mobile, single row on desktop. Survives both themes.
   ============================================================ */
.privacy-banner {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    background: var(--cc-card);
    color: var(--cc-ink);
    border-top: 1px solid var(--cc-line);
    box-shadow: var(--cc-shadow-soft);
    transition: transform .32s cubic-bezier(0.16, 1, 0.3, 1), opacity .32s ease-out;
}
.privacy-banner--leaving {
    transform: translateY(120%);
    opacity: 0;
    pointer-events: none;
}
.privacy-banner__inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.85rem clamp(1rem, 3vw, 1.75rem);
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    align-items: center;
}
@media (min-width: 768px) {
    .privacy-banner__inner {
        grid-template-columns: 1fr auto;
        gap: 1.5rem;
        padding: 0.95rem 2rem;
    }
}
.privacy-banner__title {
    margin: 0 0 0.15rem 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--cc-ink);
    letter-spacing: -0.005em;
}
.privacy-banner__text {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--cc-ink-muted);
    max-width: 70ch;
}
.privacy-banner__link {
    color: var(--cc-ink);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}
.privacy-banner__link:hover { text-decoration-thickness: 2px; }
.privacy-banner__actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.privacy-banner__btn {
    appearance: none;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0.55rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    transition: background-color .15s ease, border-color .15s ease, transform .12s ease;
    font-family: inherit;
}
.privacy-banner__btn:active { transform: translateY(1px); }
.privacy-banner__btn:focus-visible { outline: 2px solid var(--cc-focus-ring); outline-offset: 2px; }
.privacy-banner__btn--ghost {
    background: transparent;
    color: var(--cc-ink);
    border-color: var(--cc-line-strong);
}
.privacy-banner__btn--ghost:hover { background: var(--cc-surface-2); color: var(--cc-ink); text-decoration: none; }
.privacy-banner__btn--primary {
    background: var(--cc-accent);
    color: var(--cc-accent-on);
    border-color: var(--cc-accent);
}
.privacy-banner__btn--primary:hover { background: color-mix(in srgb, var(--cc-accent) 88%, transparent); }
.privacy-banner__btn[disabled] { opacity: 0.55; cursor: progress; }
.privacy-banner__status {
    grid-column: 1 / -1;
    min-height: 0;
    font-size: 0.78rem;
    color: var(--cc-ink-muted);
    transition: min-height .2s ease;
}
.privacy-banner__status:not(:empty) { min-height: 1.2em; }
.privacy-banner__status[data-state="error"]   { color: var(--cc-error); }
.privacy-banner__status[data-state="success"] { color: var(--cc-success); }

/* Reserve space at the bottom so the banner doesn't overlap content. */
body:has(.privacy-banner:not(.privacy-banner--leaving)) {
    padding-bottom: 168px;
}
@media (min-width: 768px) {
    body:has(.privacy-banner:not(.privacy-banner--leaving)) {
        padding-bottom: 90px;
    }
}

/* ============================================================
   PRIVACY BANNER — mobile refinements
   - Tighter spacing on small screens
   - Buttons go full-width and stack on phones (44px touch targets)
   - Safe-area inset support for iPhone home indicator
   - Respect viewport zoom; never block content
   ============================================================ */
@media (max-width: 767.98px) {
    .privacy-banner {
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
    .privacy-banner__inner {
        padding: 0.75rem 1rem;
        gap: 0.55rem;
    }
    .privacy-banner__title { font-size: 0.9rem; }
    .privacy-banner__text  { font-size: 0.8rem; line-height: 1.45; }
    .privacy-banner__actions {
        flex-direction: row;
        gap: 0.5rem;
    }
    .privacy-banner__btn {
        flex: 1;
        min-height: 44px;
        padding: 0.65rem 0.85rem;
        font-size: 0.85rem;
        text-align: center;
        justify-content: center;
    }
}
@media (max-width: 380px) {
    .privacy-banner__actions { flex-direction: column; }
    .privacy-banner__btn { width: 100%; }
}

/* ============================================================
   CHAT WIDGET — mobile refinements
   - Panel becomes a near-fullscreen sheet on phones (was a
     cramped floating card). Sticky header, scroll body, sticky
     input bar, safe-area insets.
   - Launcher honours safe-area; bigger tap target.
   - Category picker becomes a comfortable single column with
     44px touch targets.
   ============================================================ */
@media (max-width: 767.98px) {
    .support-chat-widget {
        right: env(safe-area-inset-right, 0);
        bottom: env(safe-area-inset-bottom, 0);
    }
    .chat-launcher {
        min-width: 56px;
        min-height: 56px;
    }
    .chat-launcher .hint { display: none; }

    /* Full-bleed sheet on phones — fixed to the viewport, edge-to-edge. */
    .chat-panel {
        position: fixed !important;
        inset: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-width: none !important;
        max-height: none !important;
        border-radius: 0 !important;
        margin: 0 !important;
        display: flex;
        flex-direction: column;
        z-index: 70;
    }
    .chat-panel-header {
        position: sticky;
        top: 0;
        z-index: 2;
        padding: 0.85rem 1rem;
        padding-top: calc(0.85rem + env(safe-area-inset-top, 0));
        min-height: 56px;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    .chat-close-btn {
        min-width: 44px;
        min-height: 44px;
        font-size: 1.5rem;
    }
    .chat-messages,
    .chat-loading,
    .chat-empty,
    .chat-error,
    .chat-category-picker {
        flex: 1 1 auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 1rem;
    }
    .chat-input-area {
        position: sticky;
        bottom: 0;
        padding: 0.65rem 0.85rem;
        padding-bottom: calc(0.65rem + env(safe-area-inset-bottom, 0));
        background: var(--cc-card);
        border-top: 1px solid var(--cc-line);
        display: flex;
        align-items: flex-end;
        gap: 0.5rem;
    }
    .chat-input {
        flex: 1;
        min-height: 44px;
        font-size: 16px; /* prevents iOS Safari auto-zoom on focus */
    }
    .chat-send-btn {
        min-width: 44px;
        min-height: 44px;
    }
    .chat-category-btn {
        min-height: 56px;
        padding: 0.9rem 1rem;
        font-size: 0.95rem;
    }
    .chat-step-title { font-size: 1rem; }
}

/* ============================================================
   CHAT POLISH — quiet-luxury, restrained.
   Adds: system message style, loading skeleton, empty / error
   states. All via tokens so they work in both themes.
   ============================================================ */

/* CRITICAL: HTML [hidden] is normally display:none, but several chat
   panes set explicit display:flex which silently outranks [hidden].
   Restore the contract so the state machine actually hides things. */
.chat-panel [data-pane][hidden],
.chat-panel .chat-input-area[hidden] {
    display: none !important;
}

/* ============================================================
   ADMIN / STAFF INBOX — ticket list items.
   Used by views/chat/admin.php and views/chat/staff_inbox.php.
   Plain quiet-luxury surface, no card shells, all via tokens.
   ============================================================ */
.ticket-list { display: flex; flex-direction: column; gap: 2px; padding: 0.25rem 0; }
.ticket-item {
    appearance: none;
    width: 100%;
    text-align: left;
    background: transparent;
    color: var(--cc-ink, var(--text-dark));
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0.65rem 0.8rem;
    cursor: pointer;
    transition: background-color .12s ease, border-color .12s ease;
    font-family: inherit;
    display: block;
}
.ticket-item:hover {
    background: var(--cc-surface-2, var(--bg-light));
    border-color: var(--cc-line, var(--border-color));
}
.ticket-item.active {
    background: var(--cc-surface-2, var(--bg-light));
    border-color: var(--cc-ink, var(--text-dark));
}
.ticket-item.has-unread { font-weight: 600; }
.ticket-item__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.2rem;
    font-size: 0.78rem;
    color: var(--cc-ink-muted, var(--text-muted));
    font-variant-numeric: tabular-nums;
}
.ticket-item__no { font-weight: 600; color: var(--cc-ink, var(--text-dark)); }
.ticket-item__cat {
    display: inline-flex;
    align-items: center;
    gap: 0.25em;
    padding: 0.18em 0.65em;
    border-radius: 999px;
    background: color-mix(in srgb, var(--cat-color, var(--cc-ink-muted)) 12%, transparent);
    color: var(--cat-color, var(--cc-ink-muted));
    border: 1px solid color-mix(in srgb, var(--cat-color, var(--cc-line)) 30%, transparent);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

/* Filter chip bar above the ticket list */
.ticket-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0.5rem 0;
    margin-bottom: 0.25rem;
    border-bottom: 1px solid var(--cc-line, var(--border-color));
}
.ticket-chip {
    appearance: none;
    background: transparent;
    color: var(--cc-ink-muted, var(--text-muted));
    border: 1px solid var(--cc-line, var(--border-color));
    border-radius: 999px;
    padding: 0.3rem 0.7rem;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color .12s ease, color .12s ease, border-color .12s ease;
    font-family: inherit;
    line-height: 1.2;
    white-space: nowrap;
}
.ticket-chip:hover {
    background: var(--cc-surface-2, var(--bg-light));
    color: var(--cc-ink, var(--text-dark));
}
.ticket-chip--active {
    background: var(--cat-color, var(--cc-ink, var(--text-dark)));
    color: var(--cc-accent-on, #fff);
    border-color: var(--cat-color, var(--cc-ink, var(--text-dark)));
}

/* Empty state for the ticket list */
.ticket-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 2rem 1rem;
    gap: 0.5rem;
    color: var(--cc-ink-muted, var(--text-muted));
}
.ticket-empty__icon {
    font-size: 1.75rem;
    opacity: 0.55;
}
.ticket-empty__text {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
    max-width: 32ch;
}
.ticket-item__user {
    font-size: 0.92rem;
    color: var(--cc-ink, var(--text-dark));
    margin-bottom: 0.15rem;
}
.ticket-item__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.74rem;
    color: var(--cc-ink-muted, var(--text-muted));
    font-variant-numeric: tabular-nums;
}
.ticket-item__unread {
    background: var(--cc-error, #b04240);
    color: #fff;
    font-weight: 600;
    padding: 0.1em 0.5em;
    border-radius: 999px;
    min-width: 1.5em;
    text-align: center;
}

.chat-msg-system {
    align-self: center;
    max-width: 90%;
    margin: 0.65rem 0;
    padding: 0.4rem 0.85rem;
    font-size: 0.78rem;
    line-height: 1.4;
    color: var(--cc-ink-muted);
    background: var(--cc-surface-2);
    border-radius: 999px;
    text-align: center;
    letter-spacing: 0.005em;
}
.chat-msg-system .chat-msg-system__icon { margin-right: 0.4em; opacity: 0.7; }

.chat-loading {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem;
}
.chat-loading__row {
    height: 36px;
    border-radius: 12px;
    background: linear-gradient(90deg,
        var(--cc-surface-2) 0%,
        var(--cc-line) 50%,
        var(--cc-surface-2) 100%);
    background-size: 200% 100%;
    animation: chatSkeleton 1.4s ease-in-out infinite;
}
.chat-loading__row--short { width: 62%; }
.chat-loading__row--long  { width: 88%; align-self: flex-end; }
@keyframes chatSkeleton {
    0%   { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}
@media (prefers-reduced-motion: reduce) {
    .chat-loading__row { animation: none; }
}

.chat-empty,
.chat-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem 1.25rem;
    gap: 0.5rem;
}
.chat-empty__icon,
.chat-error__icon {
    font-size: 2rem;
    color: var(--cc-ink-muted);
    margin-bottom: 0.25rem;
}
.chat-empty__title,
.chat-error__title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--cc-ink);
    margin: 0;
}
.chat-empty__text,
.chat-error__text {
    font-size: 0.82rem;
    color: var(--cc-ink-muted);
    margin: 0;
    max-width: 32ch;
    line-height: 1.45;
}
.chat-error__icon  { color: var(--cc-error); }

/* Category picker — six muted chips, single column on mobile. */
.chat-categories {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
    padding: 1rem;
}
.chat-category {
    appearance: none;
    width: 100%;
    text-align: left;
    background: var(--cc-card);
    color: var(--cc-ink);
    border: 1px solid var(--cc-line);
    border-radius: 12px;
    padding: 0.8rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.3;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    transition: border-color .15s ease, background-color .15s ease, transform .12s ease;
    font-family: inherit;
}
.chat-category:hover {
    border-color: var(--cc-line-strong);
    background: var(--cc-surface-2);
}
.chat-category:active { transform: translateY(1px); }
.chat-category:focus-visible { outline: 2px solid var(--cc-focus-ring); outline-offset: 2px; }
.chat-category__emoji { font-size: 1.2rem; line-height: 1; }
.chat-category__label { flex: 1; }
.chat-category__arrow { color: var(--cc-ink-muted); transition: transform .15s ease; }
.chat-category:hover .chat-category__arrow { transform: translateX(2px); }

/* The legacy chat-bubble.agent styles in light mode rely on --primary
   gradient backgrounds. Override only the new system bubble; the
   user/agent bubbles keep their existing identity. */

[data-theme="dark"] .chat-panel,
[data-theme="dark"] .chat-start-screen { background: var(--cc-card); }
[data-theme="dark"] .chat-messages     { background: var(--cc-surface); }
[data-theme="dark"] .chat-input-area   { background: var(--cc-card); border-top-color: var(--cc-line); }
[data-theme="dark"] .chat-input        { background: var(--cc-surface); color: var(--cc-ink); border-color: var(--cc-line-strong); }
[data-theme="dark"] .chat-bubble.user  { background: #2a3a2c; color: var(--cc-ink); }
[data-theme="dark"] .chat-bubble.agent { background: var(--cc-surface-2); color: var(--cc-ink); border-color: var(--cc-line); }

/* Dropdown menus */
[data-theme="dark"] .dropdown-menu { background: var(--cc-card); box-shadow: var(--cc-shadow-soft); border: 1px solid var(--cc-line); }
[data-theme="dark"] .dropdown-item { color: var(--cc-ink); }
[data-theme="dark"] .dropdown-item:hover { background: var(--cc-surface-2); color: var(--cc-ink); }
[data-theme="dark"] .dropdown-item i { color: var(--cc-ink-muted); }
[data-theme="dark"] .dropdown-divider { background: var(--cc-line); }

/* Login */
[data-theme="dark"] body.login-page {
  background: linear-gradient(180deg, #0b0c0e 0%, #14161a 100%);
}
[data-theme="dark"] .login-box {
  background: var(--cc-card);
  border: 1px solid var(--cc-line);
  box-shadow: var(--cc-shadow-soft);
}
[data-theme="dark"] .login-header h1 { color: var(--cc-ink); }
[data-theme="dark"] .login-header i {
  background: none;
  -webkit-background-clip: initial;
  -webkit-text-fill-color: currentColor;
  background-clip: initial;
  color: var(--cc-ink);
}

/* Stat cards */
[data-theme="dark"] .stat-card {
  background: var(--cc-card);
  border: 1px solid var(--cc-line);
  box-shadow: none;
}
[data-theme="dark"] .stat-card:hover { transform: none; box-shadow: var(--cc-shadow-soft); }
[data-theme="dark"] .stat-card .stat-icon {
  background: var(--cc-surface-2);
  color: var(--cc-ink);
}
[data-theme="dark"] .stat-card .stat-value { color: var(--cc-ink); }
[data-theme="dark"] .stat-card .stat-label { color: var(--cc-ink-muted); }

/* ============================================================
   Chat — Support Admin inbox (the ?page=chat page).
   The original block uses hardcoded light hex values for panes,
   rows and bubbles. Re-tint them token-style in dark mode only.
   ============================================================ */
[data-theme="dark"] .support-admin       { background: var(--cc-card); border: 1px solid var(--cc-line); }
[data-theme="dark"] .admin-left          { background: var(--cc-surface); border-color: var(--cc-line); }
[data-theme="dark"] .admin-left h3       { color: var(--cc-ink); border-color: var(--cc-line); }
[data-theme="dark"] .ticket-list .ticket-item { border-color: var(--cc-line); color: var(--cc-ink); }
[data-theme="dark"] .ticket-item:hover   { background: var(--cc-surface-2); }
[data-theme="dark"] .ticket-item.active  { background: color-mix(in srgb, var(--cc-ink) 10%, transparent); border-left-color: var(--cc-ink); }
[data-theme="dark"] .ticket-no           { color: var(--cc-ink); }
[data-theme="dark"] .ticket-user         { color: var(--cc-ink); }
[data-theme="dark"] .ticket-status,
[data-theme="dark"] .ticket-time         { color: var(--cc-ink-muted); }
[data-theme="dark"] .unread-badge        { background: var(--cc-ink); color: var(--cc-accent-on); }

[data-theme="dark"] .admin-right         { background: var(--cc-card); }
[data-theme="dark"] .no-ticket-selected  { color: var(--cc-ink-muted); }
[data-theme="dark"] .conversation-header { background: var(--cc-surface); color: var(--cc-ink); border-color: var(--cc-line); }
[data-theme="dark"] .conversation-messages { background: var(--cc-surface); }
[data-theme="dark"] .conversation-reply  { background: var(--cc-card); border-color: var(--cc-line); }
[data-theme="dark"] .reply-input,
[data-theme="dark"] .status-select       { background: var(--cc-surface); color: var(--cc-ink); border-color: var(--cc-line-strong); }
[data-theme="dark"] .reply-input:focus,
[data-theme="dark"] .status-select:focus { border-color: var(--cc-ink); }
[data-theme="dark"] .admin-bubble.user   { background: #2a3a2c; color: var(--cc-ink); }
[data-theme="dark"] .admin-bubble.agent  { background: var(--cc-surface-2); color: var(--cc-ink); border: 1px solid var(--cc-line); }

/* ============================================================
   Pricelist page — overrides the page's own scoped CSS variables
   so its self-contained palette flips along with the global theme.
   Pricelist defines tokens on .pricelist; we shadow them here.
   ============================================================ */
[data-theme="dark"] .pricelist {
  --bg:         var(--cc-surface);
  --surface:    var(--cc-card);
  --surface-2:  var(--cc-surface-2);
  --border:     var(--cc-line);
  --text:       var(--cc-ink);
  --muted:      var(--cc-ink-muted);
  --primary:    #6ea8ff;
  --primary-2:  #8ab8ff;
  --success:    #4cc38a;
  --danger:     #e88a8a;
  --danger-bg:  #2a1717;
  --success-bg: #14231a;
  --shadow:     var(--cc-shadow-soft);
  color: var(--cc-ink);
  background: var(--cc-surface);
}
[data-theme="dark"] .pricelist .page { color: var(--cc-ink); }
[data-theme="dark"] .pricelist code  { background: var(--cc-surface-2); color: var(--cc-ink); }

/* ============================================================
   User tree (?page=users&action=tree).
   The view ships its own <style> block with hardcoded light
   panels and dark text — illegible in dark mode. Shadow the
   surfaces here; keep the role accent colors on the left rail
   so SuperAdmin / Admin / Partner stay scannable.
   ============================================================ */
[data-theme="dark"] .tree-container,
[data-theme="dark"] .tree-legend        { background: var(--cc-card); border: 1px solid var(--cc-line); box-shadow: none; }
[data-theme="dark"] .tree-item          { background: var(--cc-surface-2); border-left-color: var(--cc-line-strong); }
[data-theme="dark"] .tree-item.role-superadmin { background: color-mix(in srgb, #e74c3c 14%, var(--cc-card)); }
[data-theme="dark"] .tree-item.role-admin      { background: color-mix(in srgb, #f39c12 12%, var(--cc-card)); }
[data-theme="dark"] .tree-item.role-partner    { background: color-mix(in srgb, #27ae60 14%, var(--cc-card)); }
[data-theme="dark"] .tree-item.role-reseller   { background: color-mix(in srgb, #7f8c8d 12%, var(--cc-card)); }
[data-theme="dark"] .tree-username      { color: var(--cc-ink); }
[data-theme="dark"] .tree-role          { color: var(--cc-ink-muted); }
[data-theme="dark"] .tree-status        { color: #f0a5a0; }
[data-theme="dark"] .tree-item.status-inactive { opacity: 0.5; }

/* Focus ring (dark mode only — light mode keeps the original focus rings) */
[data-theme="dark"] :where(a, button, [role="button"]):focus-visible {
  outline: 2px solid var(--cc-focus-ring);
  outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .btn, .sidebar-link, .nav-link, .nav-action,
  .stat-card, .chat-launcher, .form-control, .form-select {
    transition: none;
  }
}

/* ============================================================
   Energy CRM additions — dark mode coverage.
   Scoped under [data-theme="dark"] so the light theme stays
   untouched (we kept the original Chainlink blue/bubbly look).
   ============================================================ */

/* Application + pricelist category pickers */
[data-theme="dark"] .category-option {
    background: var(--cc-card);
    border-color: var(--cc-line);
    color: var(--cc-ink);
}
[data-theme="dark"] .category-option:hover,
[data-theme="dark"] .category-option:focus-visible {
    background: var(--cc-surface-2);
    border-color: var(--cc-ink);
}
[data-theme="dark"] .category-option__icon {
    background: var(--cc-surface-2);
    color: var(--cc-ink);
}
[data-theme="dark"] .category-option__desc,
[data-theme="dark"] .category-option__arrow {
    color: var(--cc-ink-muted);
}

/* Applications list — tab pills + category cell */
[data-theme="dark"] .category-tab {
    background: var(--cc-surface-2);
    color: var(--cc-ink-muted);
}
[data-theme="dark"] .category-tab:hover { color: var(--cc-ink); }
[data-theme="dark"] .category-tab.active {
    background: var(--cc-ink);
    color: var(--cc-accent-on);
    border-color: var(--cc-ink);
}
[data-theme="dark"] .cat-pill.cat-energy  { background: color-mix(in srgb, #f0a23a 18%, var(--cc-card)); color: #f5d28a; }
[data-theme="dark"] .cat-pill.cat-telecom { background: color-mix(in srgb, #5a9bff 18%, var(--cc-card)); color: #b8d2ff; }

/* Energy pricelist view: programs table + calculator chrome */
[data-theme="dark"] #energy-calc-section { background: var(--cc-card); border-color: var(--cc-line); }
[data-theme="dark"] #energy-pricelist-table { background: var(--cc-card); color: var(--cc-ink); }
[data-theme="dark"] #energy-pricelist-table thead th {
    background: var(--cc-surface-2);
    color: var(--cc-ink-muted);
    border-color: var(--cc-line);
}
[data-theme="dark"] #energy-pricelist-table tbody td,
[data-theme="dark"] #energy-pricelist-table tbody th {
    border-color: var(--cc-line);
    color: var(--cc-ink);
    background: transparent;
}
[data-theme="dark"] #energy-pricelist-table tbody tr:nth-child(even) > * {
    background: color-mix(in srgb, var(--cc-surface-2) 70%, transparent);
}
[data-theme="dark"] #energy-pricelist-table tbody tr:hover > * {
    background: color-mix(in srgb, var(--cc-ink) 6%, transparent);
}
[data-theme="dark"] #energy-pricelist-table tr.calc-winner > * { background: color-mix(in srgb, var(--success) 18%, var(--cc-card)); }
[data-theme="dark"] #energy-pricelist-table tr.calc-warn   > * { background: color-mix(in srgb, var(--warning) 16%, var(--cc-card)); }
[data-theme="dark"] #energy-pricelist-table .calc-delta.positive { color: #6fd99a; }
[data-theme="dark"] #energy-pricelist-table .calc-delta.negative { color: #f0a5a0; }
[data-theme="dark"] #energy-pricelist-table tr[data-expired="1"] { opacity: 0.55; }

/* Calculator inputs inherit existing form-control dark styles — no extra rules needed. */

/* ============================================================
   Site footer — composed two-tier rail
   ────────────────────────────────────────────────────────────
   Quiet luxury composition: a slim top hairline, the brand on
   the left and the section nav on the right (uppercase eyebrow
   weight), then a finer internal divider before the bottom row
   of copyright + site mark. Background stays transparent so the
   footer reads as a closing edge of the page, not a card.
   Works on both the Chainlink light theme and the dark skin.
   ============================================================ */
.site-footer {
    margin-top: clamp(2.5rem, 6vw, 4.5rem);
    padding: clamp(1.5rem, 3vw, 2.25rem) clamp(1rem, 3vw, 2rem);
    background: transparent;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.55;
    font-feature-settings: "ss01", "cv11";
}
.site-footer__inner {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}
.site-footer__row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    row-gap: 0.85rem;
}
.site-footer__row--bottom {
    padding-top: 1.05rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.78rem;
}

/* Brand */
.site-footer__brand {
    display: inline-flex;
    align-items: baseline;
    text-decoration: none;
    color: inherit;
    transition: color 0.18s ease;
}
.site-footer__brand:hover,
.site-footer__brand:focus-visible {
    color: var(--text-dark);
    text-decoration: none;
}
.site-footer__brand:focus-visible {
    outline: 2px solid var(--text-muted);
    outline-offset: 4px;
    border-radius: 2px;
}
.site-footer__logo {
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--text-dark);
    font-size: 1rem;
    line-height: 1;
}
.site-footer__logo sup {
    font-size: 0.5em;
    font-weight: 500;
    margin-left: 1px;
    color: var(--text-muted);
    top: -0.6em;
    position: relative;
}

/* Section nav — newspaper-link feel, uppercase tracked */
.site-footer__nav {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 1.6rem;
}
.site-footer__nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.72rem;
    padding-block: 2px;
    border-bottom: 1px solid transparent;
    transition: color 0.18s ease, border-color 0.18s ease;
}
.site-footer__nav a:hover,
.site-footer__nav a:focus-visible {
    color: var(--text-dark);
    border-bottom-color: currentColor;
    text-decoration: none;
    outline: none;
}

/* Bottom row */
.site-footer__copy {
    letter-spacing: 0.01em;
}
.site-footer__site-link {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    letter-spacing: 0.02em;
    transition: color 0.18s ease;
}
.site-footer__site-link:hover,
.site-footer__site-link:focus-visible {
    color: var(--text-dark);
    text-decoration: none;
}

/* Mobile — stack to a single column, keep rhythm */
@media (max-width: 539.98px) {
    .site-footer { padding-block: 1.4rem; }
    .site-footer__row { flex-direction: column; align-items: flex-start; }
    .site-footer__nav { gap: 1.2rem; }
    .site-footer__row--bottom { padding-top: 0.85rem; }
}

/* ─── Dark mode ─────────────────────────────────────────────
   Same composition, ink palette. Stays transparent so it picks
   up the page surface (off-black) rather than the card tone —
   feels like a closing edge, not a stacked block. */
[data-theme="dark"] .site-footer {
    border-top-color: var(--cc-line);
    color: var(--cc-ink-muted);
}
[data-theme="dark"] .site-footer__row--bottom {
    border-top-color: var(--cc-line);
}
[data-theme="dark"] .site-footer__brand:hover,
[data-theme="dark"] .site-footer__brand:focus-visible {
    color: var(--cc-ink);
}
[data-theme="dark"] .site-footer__logo      { color: var(--cc-ink); }
[data-theme="dark"] .site-footer__logo sup  { color: var(--cc-ink-muted); }
[data-theme="dark"] .site-footer__nav a,
[data-theme="dark"] .site-footer__site-link { color: var(--cc-ink-muted); }
[data-theme="dark"] .site-footer__nav a:hover,
[data-theme="dark"] .site-footer__nav a:focus-visible,
[data-theme="dark"] .site-footer__site-link:hover,
[data-theme="dark"] .site-footer__site-link:focus-visible {
    color: var(--cc-ink);
}


/* ====================================================================
 * Migration 12 — Capability role badges in nav + lists
 * ==================================================================== */
.user-role-badges {
    display: inline-flex;
    flex-wrap: wrap;
    gap: .25rem;
    margin-left: .35rem;
    vertical-align: middle;
}
.role-badge {
    display: inline-flex;
    align-items: center;
    padding: .15rem .55rem;
    border-radius: 999px;
    color: #fff;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .01em;
    text-shadow: 0 1px 1px rgba(0,0,0,.18);
    white-space: nowrap;
    line-height: 1.2;
}

/* ====================================================================
 * Chromium-mobile hardening (Android Chrome + Chromium-based browsers)
 *
 * Firefox already gives us most of the behaviour we want on mobile.
 * Chrome differs in a handful of stubborn ways that produce the
 * "doesn't look right" effect on phones — fix them in one place so
 * we don't sprinkle browser hacks across the codebase.
 *
 * What this block does, and why:
 *
 * 1. Lock auto text-size-adjust. Chrome on Android silently bumps up
 *    fonts when it thinks a column is too narrow → ruins our spacing.
 *
 * 2. Kill the default tap-highlight rectangle. Chrome paints a blue
 *    box on every tap; Firefox doesn't. With our own focus/active
 *    styles, the blue box is just noise.
 *
 * 3. Switch viewport-height math to dvh / svh. `100vh` on Chrome
 *    mobile = "viewport when the URL bar is hidden" → sidebar +
 *    support-admin overflow under the address bar until you scroll.
 *    `dvh` updates dynamically; `svh` is the safe minimum.
 *
 * 4. Form-control min-font 16px on mobile. <16px triggers Chrome's
 *    focus auto-zoom (Firefox is more lenient), which then breaks
 *    the layout and forces a horizontal scroll.
 *
 * 5. Replace the legacy `float:` chat bubbles with flex `align-self`.
 *    Floats interact badly with the parent's `display: flex` (used
 *    for the customer widget) and Chrome and Firefox disagree on
 *    where the float should clear → bubbles overlap on Chrome.
 *
 * 6. Reconcile a height/min-height conflict on the reply send button
 *    that Chrome resolves differently than Firefox.
 *
 * Scoped via @media + @supports so desktop and capable older browsers
 * are not affected.
 * ==================================================================== */

/* 1) + 2) — global resets, cheap to apply everywhere */
html {
    -webkit-text-size-adjust: 100%;
            text-size-adjust: 100%;

    /* Block every forced-color mode from re-painting our surfaces.
       Covers:
         • Android Chrome's "Auto Dark Theme for Web Contents"
         • Chrome desktop's chrome://flags force-dark variants
         • Windows High Contrast (forced-colors media)
       Combined with the `color-scheme` declaration at the top of
       :root, this is a belt + suspenders opt-out — the page
       paints exactly the way we wrote it. */
    forced-color-adjust: none;
}
body {
    forced-color-adjust: none;
}
*,
*::before,
*::after {
    -webkit-tap-highlight-color: transparent;
    /* Inherit so children of html/body never gain back the default
       "auto" value via specificity. Without this, Chrome can still
       invert an isolated element with `background: transparent`. */
    forced-color-adjust: inherit;
}

/* 3) Dynamic viewport heights — uses dvh where supported,
       falls back to vh on older browsers automatically. */
@supports (height: 100dvh) {
    .sidebar,
    .sidebar-overlay {
        height: calc(100dvh - var(--navbar-height));
    }
    @media (min-width: 1024px) {
        .sidebar {
            height: calc(100dvh - var(--navbar-height));
        }
    }
    .support-admin {
        min-height: calc(100dvh - var(--navbar-height) - 2rem);
    }
    @media (min-width: 481px) {
        .support-admin {
            height: calc(100dvh - var(--navbar-height) - 2rem);
        }
    }
}

/* 4) Stop iOS / Android Chrome from zooming on focus. 16px is the
       smallest size that does NOT trigger the focus-zoom heuristic. */
@media (max-width: 768px) {
    .form-control,
    .form-select,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    input[type="tel"],
    input[type="url"],
    input[type="number"],
    input[type="date"],
    input[type="datetime-local"],
    select,
    textarea,
    .reply-input,
    .chat-input {
        font-size: 16px;
    }
}

/* 5) Admin chat bubbles → flex column alignment.
       The container .conversation-messages is already
       `display: flex; flex-direction: column;` (line ~1620), so we
       only need to flip the children from float to align-self. */
.admin-bubble {
    float: none;
    clear: none;
    max-width: 78%;
}
.admin-bubble.user  { align-self: flex-end;   float: none; }
.admin-bubble.agent { align-self: flex-start; float: none; }
.conversation-messages::after { display: none; }

/* 6) Reply send button — single source of truth for height so Chrome
       and Firefox agree on tap target size. */
.reply-send-btn {
    height: 48px;
    min-height: 48px;
    line-height: 1;
}
.reply-input,
.status-select {
    min-height: 48px;
}

/* 7) Navbar — Chrome's sticky + URL-bar interaction is jittery.
       Promote to its own compositor layer so the bar holds position
       instead of bouncing on scroll. translateZ(0) also stops sub-
       pixel rounding artefacts on Android Chrome high-DPI screens. */
.navbar {
    transform: translateZ(0);
    backface-visibility: hidden;
}
@media (max-width: 768px) {
    .navbar {
        /* iOS Safari and some Chromium builds drop the sticky on
           rotation; explicit sticky+top+z keep it pinned. */
        position: sticky;
        top: 0;
        z-index: var(--z-sticky, 30);
    }
    /* Brand label can crowd the right-side actions on narrow phones —
       the rule already exists at <420px; widen the threshold to 380px
       so the icon-only fallback kicks in earlier on Chrome Android,
       which renders the address-bar action area wider than Firefox. */
    @media (max-width: 379.98px) {
        .brand-link span { display: none; }
    }
}

/* 8) Horizontal-scroll guard. A single overflowing element on a long
       page can let Chrome push the body wider than the viewport.
       Use `clip` (not `hidden`) so it does NOT create a scroll
       container that would trap our sticky navbar. */
html, body {
    overflow-x: clip;
}
/* Older Chromium / browsers that don't know `clip` — fall back to
   hidden, but only on html. Hidden on body still works with sticky
   when html is the scrollport. */
@supports not (overflow-x: clip) {
    html { overflow-x: hidden; }
}

/* 9) Safe-area insets — notched Android (Chrome) shows a gesture pill
       at the bottom which can overlap fixed UI. Push the privacy
       banner + chat widget up by env() so they clear the pill. */
.privacy-banner,
.support-chat-widget,
.chat-launcher {
    padding-bottom: max(0px, env(safe-area-inset-bottom));
}
