﻿/* ===== PROFESSIONAL DESIGN SYSTEM ===== */
:root {
  /* Color Palette from Theme */
  --primary-red: #E63946;
  --cream: #F0F8FA;
  --light-blue: #A8DADC;
  --medium-blue: #457B9D;
  --dark-navy: #1D3557;

  /* Semantic Colors */
  --primary: var(--medium-blue);
  --primary-dark: var(--dark-navy);
  --primary-light: var(--light-blue);
  --accent: var(--primary-red);
  --background: var(--cream);
  --surface: #ffffff;
  --surface-elevated: #ffffff;

  /* Text Colors */
  --text-primary: var(--dark-navy);
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;

  /* Neutral Grays */
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* Status Colors */
  --success: #10b981;
  --warning: #f59e0b;
  --error: var(--primary-red);

  /* Spacing System */
  --space-1: 0.25rem;  /* 4px */
  --space-2: 0.5rem;   /* 8px */
  --space-3: 0.75rem;  /* 12px */
  --space-4: 1rem;     /* 16px */
  --space-5: 1.25rem;  /* 20px */
  --space-6: 1.5rem;   /* 24px */
  --space-8: 2rem;     /* 32px */
  --space-10: 2.5rem;  /* 40px */
  --space-12: 3rem;    /* 48px */
  --space-16: 4rem;    /* 64px */

  /* Layout */
  --max-width: 1440px;
  --content-width: 1200px;
  --sidebar-width: 320px;
  --header-height: 55px;
  --toolbar-height: 72px;

  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', Monaco, 'Roboto Mono', monospace;

  /* Z-Index Scale */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-tooltip: 1060;
}

/* ===== RESET & BASE ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  tab-size: 4;
  height: 100%;
}

body {
  font-family: var(--font-sans);
  background-color: var(--background);
  color: var(--text-primary);
  font-weight: 400;
  font-size: 0.875rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100%;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--gray-100);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 4px;
  transition: background-color 0.2s;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gray-400);
}

/* Firefox scrollbar styling */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--gray-300) var(--gray-100);
}

/* ===== NAVIGATION ===== */
.nav {
  background: var(--surface);
  border-bottom: 1px solid var(--gray-200);
  height: var(--header-height);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  box-shadow: var(--shadow-sm);
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: grid;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 var(--space-6);
  grid-template-columns: 1fr auto 1fr;
}

.nav-left, .nav-center, .nav-right {
  display: flex;
  align-items: center;
}

.nav-left {
  gap: var(--space-2);
  justify-self: start; gap: var(--space-2);
}

.nav-right {
    justify-self: end;
    gap: var(--space-3);
}

.nav-center {
    justify-self: center;
}

/* Modern Tab Style Navigation */
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-1);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.875rem;
  transition: all 0.2s ease;
  position: relative;
  border-bottom: 2px solid transparent;
  height: var(--header-height);
}

.nav-link::before {
  content: '◦';
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: bold;
}

.nav-link[href*="members"]::before { content: '👥'; }
.nav-link[href*="roles"]::before { content: '🛡️'; }
.nav-link[href*="channels"]::before { content: '🗨️'; }
.nav-link[href*="reports"]::before { content: '📊'; }

.nav-link:hover {
  color: var(--text-primary);
  border-bottom-color: var(--primary-light);
}

.nav-link.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: transparent;
}

.nav-link.active::before {
  color: var(--primary);
}

.nav-title {
  font-weight: 600;
  font-size: 1.125rem;
  color: var(--primary-dark);
  letter-spacing: -0.025em;
}

.guild-pill {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  transition: all 0.2s ease;
}

.guild-pill:hover {
  background: var(--gray-100);
  border-color: var(--gray-300);
}

.guild-icon {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.guild-icon.--placeholder {
  background: var(--primary);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
}

/* ===== LAYOUT ===== */
.page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-6);
  display: grid;
  grid-template-columns: 1fr var(--sidebar-width);
  gap: var(--space-6);
  height: calc(100vh - var(--header-height));
}

.left {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-height: 0; /* Important for grid child to shrink */
  max-width: var(--content-width);
}

.side {
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0; /* Important for grid child to shrink */
  height: 100%; /* Use full available height */
}

/* ===== TOOLBAR ===== */
.toolbar {
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.page-title::before {
  font-size: 1.25rem;
  color: var(--primary);
  font-weight: normal;
}

.toolbar > div {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* ===== GRID CONTAINER ===== */
.grid {
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  flex: 1;
  min-height: 0; /* Important for flex child to shrink */
  display: flex;
  flex-direction: column;
}

.grid-footer {
  padding: var(--space-3) var(--space-6);
  background: var(--gray-50);
  border-top: 1px solid var(--gray-200);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: right;
  flex-shrink: 0;
}

/* ===== BUTTON SYSTEM ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--gray-300);
  background: var(--surface);
  color: var(--text-primary);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  white-space: nowrap;
  height: 44px; /* Consistent height with standard inputs */
}

.btn::before {
  font-size: 0.875rem;
  font-weight: bold;
}

.btn:hover {
  background: var(--gray-50);
  border-color: var(--gray-400);
}

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

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--text-inverse);
}

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

/* Button Icons - Simple geometric shapes */
.btn[id="btnRoles"]::before { content: '◐'; }
.btn[id="btnExport"]::before { content: '↓'; }

/* Category Dividers */
.category-divider {
  display: flex;
  align-items: center;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 1rem;
  gap: var(--space-2);
}

/* Category group rows */
#channels-grid .tabulator-row.tabulator-group {
  display: flex !important;
  align-items: center !important;
  background-color: var(--background) !important;
  border-right: none !important;
  border-bottom: 1px solid var(--gray-200);
  cursor: pointer;
  padding: 0 20px;
}

#channels-grid .tabulator-row.tabulator-group:hover {
  background-color: var(--light-blue) !important;
}

/* Hide default Tabulator arrow */
.tabulator-row.tabulator-group .tabulator-arrow {
  display: none;
}

.custom-arrow {
  margin-left: var(--space-2);
  font-size: 0.75rem;
  color: var(--text-secondary) !important;
  transition: transform 0.2s ease;
}

/* Rotate arrow when group is collapsed */
.tabulator-row.tabulator-group:not(.tabulator-group-visible) .custom-arrow {
  transform: rotate(-90deg);
}

/* Override alternating row colors to keep all rows white */
#channels-grid .tabulator-row:not(.tabulator-group) {
  background-color: var(--surface);
}

#channels-grid .tabulator-row:not(.tabulator-group).tabulator-row-even {
  background-color: var(--surface);
}

/* Grid Action Buttons */
.btn-grid-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  margin: 0 var(--space-1);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: bold;
}

.btn-grid-row:hover {
  background: var(--gray-50);
  border-color: var(--gray-400);
  color: var(--text-primary);
}

.btn-grid-row[title*="Edit"] { content: '◗'; }
.btn-grid-row[title*="Delete"],
.btn-grid-row[title*="Kick"] { content: '×'; }

.btn-grid-row[title*="Delete"]:hover,
.btn-grid-row[title*="Kick"]:hover {
  background: #fef2f2;
  border-color: var(--error);
  color: var(--error);
}

.btn-grid-row[title*="Save"]:hover {
  background: #f0fdf4;
  border-color: var(--success);
  color: var(--success);
}

.btn-simple {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: bold;
}

.btn-simple:hover {
  background: var(--gray-100);
  color: var(--text-primary);
}

/* ===== TABULATOR OVERRIDES ===== */
.tabulator {
  font-size: 0.875rem;
  background: transparent;
  border: none;
  flex: 1;
  min-height: 0;
}

.tabulator .tabulator-header {
  background: var(--primary-dark);
  color: var(--text-inverse);
  border: none;
  height: 48px;
}

.tabulator .tabulator-header .tabulator-col {
  background: transparent;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
  vertical-align: middle;
}

.tabulator .tabulator-header .tabulator-col:last-child {
  border-right: none;
}

.tabulator .tabulator-header .tabulator-col .tabulator-col-content {
  padding: var(--space-4);
  text-align: center;
  justify-content: center;
  display: flex;
  align-items: center;
}

.tabulator .tabulator-header .tabulator-col-title {
  color: var(--text-inverse);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: center;
  width: 100%;
}

.tabulator .tabulator-header .tabulator-col:hover {
  background: rgba(255, 255, 255, 0.05);
}

.tabulator .tabulator-tableholder {
  background: var(--surface);
  overflow-y: auto; /* Enable scrolling */
}

.tabulator .tabulator-row {
  background: var(--surface);
  border-bottom: 1px solid var(--gray-200);
  min-height: 40px;
}

.tabulator .tabulator-row:nth-child(even) {
  background: var(--gray-50);
}

.tabulator .tabulator-row:hover {
  background: var(--primary-light) !important;
}

.tabulator .tabulator-cell {
  border-right: 1px solid var(--gray-200);
  padding: var(--space-2) var(--space-3);
  color: var(--text-primary);
  font-size: 0.875rem;
}

.tabulator .tabulator-cell:last-child {
  border-right: none;
}

.filtering .tabulator-arrow {
  display: none !important;
}

/* ===== FORM ELEMENTS ===== */
input[type="text"],
input[type="search"],
input[type="color"],
select {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: inherit;
  font-weight: 500;
  transition: all 0.2s ease;
  height: 44px;
}

select {
  padding: var(--space-1) var(--space-3);
  font-size: 0.925rem;
}

input[type="text"]:hover,
input[type="search"]:hover,
select:hover {
  border-color: var(--gray-400);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

input[type="text"]:focus,
input[type="search"]:focus,
input[type="color"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(69, 123, 157, 0.1);
}

input[type="text"]::placeholder {
  color: var(--text-muted);
  transition: color 0.3s ease;
}

input[type="text"]:focus::placeholder {
  color: var(--gray-400);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--gray-300);
  border-radius: 24px;
  transition: .3s;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: .3s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked + .toggle-slider {
  background-color: var(--primary);
}

input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

.toggle-slider:hover {
  box-shadow: 0 0 8px rgba(69, 123, 157, 0.3);
}

/* ===== PANEL FORM INPUTS - PREMIUM THEMED ===== */
.panel-form input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 2px solid var(--primary-light);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--surface), var(--gray-50));
  color: var(--text-primary);
  font-size: 0.925rem;
  font-family: inherit;
  font-weight: 600;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  height: 48px;
  box-shadow:
    0 2px 6px rgba(69, 123, 157, 0.1),
    0 4px 12px rgba(0, 0, 0, 0.05),
    inset 0 1px 2px rgba(255, 255, 255, 0.1);
  position: relative;
  letter-spacing: 0.025em;
}

.panel-form input:hover {
  border-color: var(--primary);
  background: linear-gradient(135deg, var(--surface), rgba(168, 218, 220, 0.1));
  box-shadow:
    0 3px 8px rgba(69, 123, 157, 0.15),
    0 8px 16px rgba(0, 0, 0, 0.08),
    inset 0 1px 2px rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.panel-form input:focus {
  outline: none;
  border-color: var(--primary-dark);
  background: linear-gradient(135deg, var(--surface), rgba(168, 218, 220, 0.08));
  box-shadow:
    0 0 0 3px rgba(69, 123, 157, 0.15),
    0 4px 12px rgba(69, 123, 157, 0.2),
    0 12px 24px rgba(0, 0, 0, 0.1),
    inset 0 1px 2px rgba(255, 255, 255, 0.2);
  transform: translateY(-2px) scale(1.01);
}

.panel-form input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
  font-style: italic;
  opacity: 0.7;
  transition: all 0.3s ease;
}

.panel-form input:focus::placeholder {
  color: var(--primary);
  transform: translateX(4px);
  opacity: 0.6;
}

/* Special styling for color input with swatch */
.panel-form input[name="color"] {
  padding-right: 48px;
}

.panel-form .swatch {
  position: absolute;
  right: var(--space-3);
  top: calc(100% - 28px - var(--space-3));
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  border: 2px solid var(--primary-light);
  pointer-events: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.panel-form label:hover .swatch {
  border-color: var(--primary);
  transform: scale(1.05) translateY(-1px);
  box-shadow: 0 3px 8px rgba(69, 123, 157, 0.2);
}

/* Enhanced Color Input */
input[type="color"] {
  padding: var(--space-2);
  width: 60px;
  height: 44px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--gray-300);
}

input[type="color"]:hover {
  transform: scale(1.05);
  border-color: var(--gray-400);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

input[type="color"]:focus {
  transform: scale(1.05);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(69, 123, 157, 0.1), 0 6px 16px rgba(0, 0, 0, 0.12);
}



.search-bar {
  width: 280px;
  padding: var(--space-3) var(--space-4) var(--space-3) var(--space-10);
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8' stroke-width='2'%3e%3cpath stroke-linecap='round' stroke-linejoin='round' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'/%3e%3c/svg%3e");
  background-position: var(--space-3) center;
  background-repeat: no-repeat;
  background-size: 16px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  height: 44px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  transition: all 0.2s ease;
}

.search-bar:hover {
  border-color: var(--gray-400);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.search-bar:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(69, 123, 157, 0.1);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23457B9D' stroke-width='2'%3e%3cpath stroke-linecap='round' stroke-linejoin='round' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'/%3e%3c/svg%3e");
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-right: var(--space-2);
  accent-color: var(--primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

input[type="checkbox"]:hover {
  transform: scale(1.1);
  box-shadow: 0 2px 8px rgba(69, 123, 157, 0.2);
}

input[type="checkbox"]:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(69, 123, 157, 0.1);
}

/* Panel Form Checkboxes - Premium Themed */
.panel-form input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-right: var(--space-3);
  accent-color: var(--primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.panel-form input[type="checkbox"]:hover {
  transform: scale(1.1);
  box-shadow: 0 2px 6px rgba(69, 123, 157, 0.2);
}

.panel-form input[type="checkbox"]:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(69, 123, 157, 0.15);
  transform: scale(1.05);
}

/* ===== PANELS ===== */
.panel-header {
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.panel-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.panel-actions {
  display: flex;
  gap: var(--space-2);
}

.panel-form {
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  flex: 1;
  overflow: hidden; /* Prevent form from scrolling */
  min-height: 0;
}

.panel-form > label {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--primary-dark);
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  margin-bottom: var(--space-2);
  position: relative;
}

.panel-form > label:hover {
  color: var(--primary);
}

/* Color label needs relative positioning for swatch */
.panel-form label:has(input[name="color"]) {
  position: relative;
}

.panel-form label:has(.swatch) {
  position: relative;
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--gray-50);
  min-height: 0;
}

.panel-body .panel-search {
  position: sticky;
  top: 0;
  z-index: 10;
  margin: var(--space-3) var(--space-4) var(--space-2) var(--space-4);
  background: var(--surface);
  background-image: none;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  padding: var(--space-1) var(--space-3);
  font-size: 0.875rem;
  width: calc(100% - 2 * var(--space-4) - 2px);
  box-sizing: border-box;
  height: auto;
  min-height: 28px;
}

.panel-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12);
  text-align: center;
  color: var(--text-muted);
  flex: 1;
}

.panel-placeholder svg {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
  margin-bottom: var(--space-4);
}

.panel-placeholder p {
  margin: 0;
  font-size: 0.875rem;
}

.role-item {
  display: flex !important;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--gray-200);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  border-radius: var(--radius-sm);
  margin-bottom: 1px;
}

.role-item.search-hidden {
  display: none !important;
}

.role-item:last-child {
  border-bottom: none;
}

.role-item:hover {
  background: linear-gradient(135deg, var(--primary-light), rgba(241, 250, 238, 0.5));
  border-color: var(--primary-light);
  transform: translateX(2px);
  box-shadow: 0 2px 8px rgba(69, 123, 157, 0.08);
}

.role-item input[type="checkbox"] {
  margin-top: 0;
  margin-right: var(--space-3);
}

.role-item:hover input[type="checkbox"] {
  transform: scale(1.05);
}

.user-list {
  max-height: 120px;
  overflow-y: auto;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
}

.user-item {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--gray-200);
  font-size: 0.875rem;
  color: var(--text-secondary);
  background: var(--surface);
  transition: background-color 0.2s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.user-item:last-child {
  border-bottom: none;
}

.user-item:hover {
  background: var(--gray-50);
}

.panel-cbs {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.panel-cbs:hover {
  background: var(--surface);
  border-color: var(--primary-light);
  box-shadow: 0 2px 8px rgba(69, 123, 157, 0.06);
}

.panel-cb-title {
  flex: 1;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  transition: color 0.3s ease;
}

.panel-cbs:hover .panel-cb-title {
  color: var(--primary-dark);
}

.locked-checkbox {
  opacity: 0.5;
  pointer-events: none;
}

/* ===== ROLE FILTER ===== */


.role-filter label {
  display: flex;
  align-items: center;
  padding: var(--space-3);
  border-radius: var(--radius);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  margin-bottom: var(--space-1);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
}

.role-filter label:hover {
  background: var(--primary-light);
  border-color: var(--primary-light);
  transform: translateX(2px);
  box-shadow: 0 2px 6px rgba(69, 123, 157, 0.1);
}

.role-filter label:hover input[type="checkbox"] {
  transform: scale(1.05);
}


/* ===== LOGIN PAGE ===== */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--background) 0%, var(--gray-50) 100%);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: calc(var(--radius) * 2);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  padding: var(--space-10);
  width: 100%;
  max-width: 400px;
}

.login-header {
  text-align: center;
  margin-bottom: var(--space-8);
}

.login-header h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin: 0 0 var(--space-2);
  letter-spacing: -0.025em;
}

.login-header p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin: 0;
  font-weight: 500;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.login-form label {
  display: block;
  margin-bottom: var(--space-2);
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.login-form .form-control {
  height: 48px;
  font-size: 1rem;
}

.login-form .btn {
  height: 48px;
  font-weight: 600;
  margin-top: var(--space-3);
}

.login-error {
  color: var(--error);
  font-size: 0.875rem;
  font-weight: 500;
  text-align: center;
  margin-top: var(--space-5);
  padding: var(--space-3);
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
}

/* ===== UTILITIES ===== */
.small-text {
  font-size: 0.75rem;
}

.swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-300);
  vertical-align: middle;
}

/* ===== TOAST ===== */
#toast {
  position: fixed;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-900);
  color: var(--text-inverse);
  padding: var(--space-4) var(--space-6);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  font-size: 0.875rem;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: var(--z-tooltip);
}

/* ===== REPORTS PAGE STYLES ===== */
.action-buttons {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
}

.btn-icon:hover {
  background: var(--gray-50);
  border-color: var(--gray-400);
  color: var(--text-primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-icon-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--text-inverse);
}

.btn-icon-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: var(--text-inverse);
}

.btn-icon svg {
  width: 18px;
  height: 18px;
}

.btn-icon.htmx-request {
  pointer-events: none;
  opacity: 0.7;
}

.btn-icon.htmx-request .refresh-icon {
  display: none;
}

.btn-icon.htmx-request .spinner {
  display: block !important;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.reports-page {
  display: block !important;
  grid-template-columns: none !important;
  gap: 0 !important;
}

.reports-page .left {
  width: 100%;
  max-width: none;
}

.result-count {
  font-weight: 400;
  color: var(--text-secondary);
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  transform: translateY(2px);
}

/* Filter Results Grid */
.filter-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(500px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  align-items: start;
}

.filter-result-card {
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.filter-result-card:hover {
  box-shadow: 0 4px 12px rgba(69, 123, 157, 0.1);
  border-color: var(--primary-light);
  transform: translateY(-1px);
}

.filter-result-header {
  padding: var(--space-3) var(--space-4);
  background: var(--primary);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.2s ease;
}

.filter-result-header:hover {
  background: var(--primary-dark);
}

.filter-result-header h4 {
  margin: 0;
  color: var(--text-inverse);
  font-weight: 600;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.filter-result-icon {
  width: 16px;
  height: 16px;
  color: var(--text-inverse);
  opacity: 0.9;
}

.filter-result-count {
  background: var(--accent);
  color: var(--text-inverse);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  min-width: 24px;
  text-align: center;
}

.filter-result-toggle {
  color: var(--text-inverse);
  transition: transform 0.2s;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
}

.filter-result-card.collapsed .filter-result-toggle {
  transform: rotate(-90deg);
}

.filter-result-description {
  padding: var(--space-3) var(--space-4);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

.filter-result-description p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.4;
}

.result-items {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.result-item {
  padding: var(--space-3);
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary-light);
}

.item-title {
  font-weight: 500;
  color: var(--text-primary);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.channel-category {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--gray-200);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  font-weight: 400;
}

.item-detail {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: var(--space-1);
}

.access-user {
  color: #43b581;
}

.filter-result-content {
  padding: var(--space-2);
  height: 300px;
  max-height: 300px;
  overflow-y: auto;
  transition: all 0.3s ease-in-out;
  opacity: 1;
}

.filter-result-card.collapsed .filter-result-content {
  height: 0;
  max-height: 0;
  padding: 0 var(--space-2);
  overflow: hidden;
  opacity: 0;
}

.filter-result-card.collapsed .filter-result-description {
  display: none;
}

.empty-state {
  text-align: center;
  padding: var(--space-16) var(--space-8);
  color: var(--text-secondary);
}

.empty-icon {
  font-size: 4rem;
  margin-bottom: var(--space-4);
}

.empty-state h3 {
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.empty-state p {
  margin-bottom: var(--space-6);
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

/* ===== SCHEDULE SETTINGS STYLES ===== */
.schedule-section {
  padding: 0;
  margin-bottom: var(--space-2);
}

.schedule-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--space-4);
  align-items: start;
  margin-bottom: var(--space-3);
}

.schedule-grid select,
.schedule-grid .time-input,
.schedule-grid .form-control {
  height: 40px;
  padding: var(--space-2) var(--space-3);
  font-size: 0.875rem;
}

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

.time-group label {
  margin-bottom: var(--space-2);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
}

.time-inputs {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.time-separator {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 0 2px;
}

.time-input {
  width: 50px;
  height: 40px;
  text-align: center;
}

.schedule-checkbox {
  margin-top: var(--space-2);
}

.schedule-checkbox .toggle-label {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  width: fit-content;
}

/* ===== CONFIG FORM STYLES ===== */
.config-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.config-section {
  padding: var(--space-4);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--gray-50);
}

.config-section h4 {
  margin: 0 0 var(--space-4) 0;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 1rem;
}

.form-group {
  margin-bottom: var(--space-2);
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  margin-bottom: var(--space-2);
  color: var(--text-primary);
  font-weight: 500;
}

.form-control {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.checkbox-label {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  margin-right: var(--space-2);
}

.dual-list-container {
  display: flex;
  gap: var(--space-4);
  margin-top: var(--space-2);
}

.list-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.list-column label {
  display: block;
  margin-bottom: 0;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.list-column .search-bar {
  width: 100%;
  margin-bottom: 0;
  background-image: none;
  padding-left: var(--space-3);
}

.modal-content .search-bar {
  background-image: none;
  padding-left: var(--space-3);
}

#channel-deletion-confirm-btn:disabled {
  cursor: not-allowed;
  background: var(--gray-300) !important;
  border-color: var(--gray-300) !important;
  color: var(--gray-500) !important;
}

#channel-name-verification {
  transition: border-color 0.2s ease;
}

#channel-name-verification:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(69, 123, 157, 0.1);
}

.count {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.85rem;
}

.user-list {
  width: 100%;
  min-height: 200px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-300);
}

.user-list option {
  padding: var(--space-2);
  cursor: pointer;
  border-bottom: 1px solid var(--gray-100);
}

.user-list option:hover {
  background-color: var(--gray-100);
}

.user-list option:last-child {
  border-bottom: none;
}

.loading-state {
  text-align: center;
  padding: var(--space-2);
  color: var(--text-secondary);
  font-style: italic;
  font-size: 0.9rem;
}

.loading-state span:before {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--gray-300);
  border-radius: 50%;
  border-top-color: var(--primary);
  animation: spin 1s ease-in-out infinite;
  margin-right: var(--space-2);
  vertical-align: middle;
}

.centered-loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  gap: var(--space-6);
}

/* ===== ERROR MESSAGE STYLES ===== */
.error-message {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  color: #dc2626;
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  font-size: 0.875rem;
  line-height: 1.4;
}

/* ===== MODAL STYLES ===== */
.warning-message {
  margin-bottom: var(--space-3);
}

.modal-section {
  margin-bottom: var(--space-4);
}

.modal-label {
  display: block;
  margin-bottom: var(--space-2);
  font-weight: 600;
}

.channel-verification-input {
  font-family: var(--font-mono, monospace);
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-dialog {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  width: 50vw;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--gray-50);
}

.modal-header h3 {
  margin: 0;
  color: var(--text-primary);
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background-color 0.2s;
}

.modal-close:hover {
  background: var(--gray-200);
  color: var(--text-primary);
}

.modal-content {
  padding: var(--space-6);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4);
  margin: 0;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* Filter Management Modal Styles */

.conditions-container {
  overflow-y: auto;
  height: 82px;
  max-height: 82px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  padding: 4px;
}

.condition-row {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-bottom: var(--space-1);
  background: var(--surface);
  overflow: visible;
  min-width: 0;
}

.condition-row select,
.condition-row input[type="text"] {
  height: 34px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 0.85rem;
  flex: 1;
  min-width: 100px;
  transition: border-color 0.2s, box-shadow 0.2s;
  vertical-align: middle;
  line-height: 1.2;
}

.condition-row select:focus,
.condition-row input[type="text"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.condition-row .btn {
  height: 34px;
  width: 34px;
  min-width: 34px;
  flex-shrink: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: bold;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.condition-row .group-btn {
  color: var(--text-primary);
  font-size: 0.7rem;
  font-weight: 500;
  min-width: 50px;
  height: 34px;
}

.condition-row .group-btn:hover {
  background: var(--gray-100);
  border-color: var(--gray-400);
}

.condition-row .group-btn.grouped {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--text-inverse);
}

.condition-row .group-btn.grouped:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .page {
    grid-template-columns: 1fr;
    gap: var(--space-4);
    height: auto;
    min-height: calc(100vh - var(--header-height));
  }

  .side {
    position: static;
  }
}

@media (max-width: 768px) {
  .nav-inner {
    padding: 0 var(--space-4);
  }

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

  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-4);
  }

  .toolbar > div {
    justify-content: center;
  }

  .search-bar {
    width: 100%;
    max-width: 300px;
  }
}

/* ===== Selected chips ===== */
.selected-inline {
  position: relative;
  padding: var(--space-2) var(--space-3);
  margin: 0 0 var(--space-3) 0;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--gray-50);
}

.selected-inline .chip-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.selected-inline .chip-row {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  white-space: nowrap;
  overflow: hidden;
  width: 100%;
}

.selected-inline .chip-row::after {
  content: "";
  position: absolute;
  right: 36px;
  top: 0; bottom: 0;
  width: 32px;
  pointer-events: none;
}

.sel-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-3);
  height: 28px;
  border-radius: var(--radius);
  border: 1px solid var(--gray-300);
  background: var(--surface);
  font-size: 0.75rem;
  color: var(--text-primary);
}

.sel-chip .chip-close {
  border: none;
  background: transparent;
  cursor: pointer;
  font-weight: 700;
  line-height: 1;
  color: var(--text-muted);
}

.sel-chip .chip-close:hover {
  color: var(--error);
}

.more-chip {
  margin-left: var(--space-2);
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 28px;
  border-radius: var(--radius);
  border: 1px dashed var(--gray-300);
  background: var(--surface);
  font-size: 0.75rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.sel-popover {
  position: absolute;
  right: 8px;
  top: calc(100% + 6px);
  min-width: 240px;
  max-height: 240px;
  overflow: auto;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.85), rgba(255,255,255,0.92)) padding-box,
    linear-gradient(135deg, rgba(69,123,157,0.35), rgba(29,53,87,0.15)) border-box;
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.18), 0 2px 8px rgba(0, 0, 0, 0.06);
  padding: var(--space-3);
  z-index: var(--z-tooltip);
  display: none;
}

.sel-popover.open {
  display: block;
  animation: pop-enter 140ms cubic-bezier(.2,.7,.2,1) both;
}

@keyframes pop-enter {
  from { opacity: 0; transform: translateY(-6px) scale(.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.sel-popover::before {
  content: "";
  position: absolute;
  right: 26px;
  top: -6px;
  width: 12px;
  height: 12px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.9), rgba(255,255,255,0.95)) padding-box,
    linear-gradient(135deg, rgba(69,123,157,0.35), rgba(29,53,87,0.15)) border-box;
  border: 1px solid transparent;
  border-bottom: none;
  border-right: none;
  transform: rotate(45deg);
  border-top-left-radius: 4px;
  box-shadow: -2px -2px 4px rgba(15,23,42,0.04);
}

.sel-popover .sel-chip {
  width: 100%;
  justify-content: space-between;
  border: 1px solid var(--gray-200);
  background: linear-gradient(180deg, #fff, #f8fafc);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}

.sel-popover .sel-chip + .sel-chip {
  margin-top: var(--space-2);
}

.sel-popover .sel-chip:hover {
  transform: translateX(2px);
  border-color: var(--primary-light);
  box-shadow: 0 4px 10px rgba(69,123,157,0.12);
}

.sel-popover .chip-close {
  width: 22px; height: 22px;
  border-radius: 9999px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: background .12s ease, color .12s ease;
}
.sel-popover .chip-close:hover {
  background: #fee2e2; color: var(--error);
}

.sel-popover::-webkit-scrollbar {
  height: 6px; width: 6px;
}

.sel-popover::-webkit-scrollbar-thumb {
  background: rgba(69,123,157,0.35);
  border-radius: 8px;
}

.sel-popover::-webkit-scrollbar-track {
  background: transparent;
}

.sel-popover {
  scrollbar-width: thin;
  scrollbar-color: rgba(69,123,157,0.35) transparent;
}

/* ===== REPORT FILTER STYLES ===== */

/* Filter List Styles */
.filter-list {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  max-height: 580px;
}

#filter-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  min-width: 450px;
  max-width: 480px;
  width: 100%;
}

#filter-loader p {
  margin: var(--space-2) 0 0 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.filter-item {
  display: flex;
  align-items: center;
  padding: var(--space-3);
  background: var(--surface);
  cursor: move;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  width: 100%;
  max-width: 480px;
  min-width: 450px;
}

.filter-item:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 4px rgba(69, 123, 157, 0.1);
}

.filter-item.ui-sortable-helper {
  box-shadow: var(--shadow-lg);
  transform: rotate(2deg);
}

.filter-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.filter-header {
  margin-bottom: var(--space-1);
}

.filter-name {
  font-weight: 600;
  color: var(--text-primary);
}


.filter-description {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filter-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-left: var(--space-4);
}

/* Toggle Switch Component */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-switch .toggle-label {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--gray-300);
  transition: all 0.2s ease;
  border-radius: 24px;
}

.toggle-switch .toggle-label:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: var(--surface);
  transition: transform 0.2s ease;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}

.toggle-switch input:checked + .toggle-label {
  background-color: var(--success);
}

.toggle-switch input:checked + .toggle-label:before {
  transform: translateX(20px);
}

.toggle-switch input:focus + .toggle-label {
  box-shadow: 0 0 0 2px var(--primary-light);
}

.drag-handle {
  margin-left: var(--space-2);
  color: var(--text-muted);
  cursor: move;
  font-size: 0.875rem;
  line-height: 1;
  padding: var(--space-1);
  transition: color 0.2s ease;
}

.drag-handle:hover {
  color: var(--text-primary);
}

.ui-sortable-placeholder {
  height: 60px;
  background: var(--gray-50);
  border: 2px dashed var(--gray-200);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
}

.no-filters {
  text-align: center;
  padding: var(--space-8);
  color: var(--text-muted);
}

/* Filter Management Layout */
.filter-management {
  display: flex;
  flex-direction: row;
  height: 100%;
  gap: var(--space-6);
}

.filter-list-section {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  position: sticky;
  top: 0;
  align-self: flex-start;
}

.filter-editor-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--gray-200);
  padding-left: var(--space-6);
  min-width: 0;
}

.filter-editor-section h4,
.filter-list-section h4 {
  margin-top: 0;
  margin-bottom: var(--space-3);
  color: var(--text-primary);
  font-weight: 600;
}

.form-row {
  display: flex;
  gap: var(--space-4);
  align-items: flex-start;
}

.form-row .form-group {
  flex: 1;
  min-width: 0;
}

.conditions-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
}

.conditions-header label {
  display: block;
  margin-bottom: 0;
  color: var(--text-primary);
  font-weight: 500;
}

.conditions-section h5 {
  margin-bottom: var(--space-2);
  color: var(--text-primary);
}

.conditions-section small {
  color: var(--text-secondary);
  margin-bottom: var(--space-3);
  display: block;
  line-height: 1.4;
}


.validation-message {
  color: var(--error);
  font-size: 0.875rem;
  margin-top: var(--space-2);
  display: none;
  white-space: pre-line;
  line-height: 1.4;
}

.validation-message.show {
  display: block;
}

/* Filter Test Results Styles */

.conditions-actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.test-results-section {
  margin-top: var(--space-4);
  border-top: 1px solid var(--gray-200);
  padding-top: var(--space-4);
}

.test-results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
}

.test-results-header h4 {
  margin: 0;
  font-size: 1rem;
  color: var(--text-primary);
  font-weight: 600;
}

.test-results-count {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
}

.test-results-container {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.test-results-table {
  width: 100%;
  display: table;
  table-layout: fixed;
}

.test-results-empty {
  padding: var(--space-6);
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  background: var(--gray-50);
}

.test-results-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  table-layout: fixed;
}

.test-results-table th {
  background: var(--primary-dark);
  color: var(--text-inverse);
  padding: var(--space-3) var(--space-2);
  text-align: left;
  border: 1px solid var(--primary);
  border-right: 1px solid rgba(255, 255, 255, 0.2);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.test-results-table th:last-child {
  border-right: 1px solid var(--primary);
}

.test-results-table td {
  padding: var(--space-2) var(--space-2);
  border: 1px solid var(--gray-200);
  border-right: 1px solid var(--gray-200);
  color: var(--text-primary);
  vertical-align: top;
  font-size: 0.825rem;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
}

.test-results-table td:last-child {
  border-right: none;
}

/* Members table column widths (4 columns) */
.test-results-table th:first-child,
.test-results-table td:first-child {
  width: 25%;
  min-width: 120px;
}

.test-results-table th:nth-child(2),
.test-results-table td:nth-child(2) {
  width: 20%;
  min-width: 100px;
}

.test-results-table th:nth-child(3),
.test-results-table td:nth-child(3) {
  width: 20%;
  min-width: 90px;
}

.test-results-table th:nth-child(4),
.test-results-table td:nth-child(4) {
  width: 35%;
  word-break: break-word;
  white-space: normal;
}

/* Channels table column widths (3 columns) */
.test-results-table.channels-table th:first-child,
.test-results-table.channels-table td:first-child {
  width: 30%;
  min-width: 140px;
}

.test-results-table.channels-table th:nth-child(2),
.test-results-table.channels-table td:nth-child(2) {
  width: 25%;
  min-width: 120px;
}

.test-results-table.channels-table th:nth-child(3),
.test-results-table.channels-table td:nth-child(3) {
  width: 45%;
  word-break: break-word;
  white-space: normal;
}

.test-results-table tbody tr:hover {
  background-color: var(--primary-light);
  transition: background-color 0.2s ease;
}

.test-results-table tbody tr:nth-child(even) {
  background-color: var(--gray-50);
}

.test-results-table tbody tr:nth-child(even):hover {
  background-color: var(--primary-light);
}

.test-results-loading {
  padding: var(--space-4);
  text-align: center;
  color: var(--text-muted);
}

.test-results-error {
  padding: var(--space-4);
  text-align: center;
  color: var(--error);
  background-color: var(--error-light);
  border-radius: var(--border-radius);
  margin: var(--space-2);
}
