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

:root {
  --color-bg: #F4F6FB;
  --color-text-main: #1A1F36;
  --color-text-muted: #6B7280;
  --color-text-soft: #9AA1B2;
  --color-surface: #ffffff;
  --color-surface-alt: #F8FAFF;
  --color-border: #EAEDF5;
  --color-border-strong: #D9DEEC;

  --color-primary: #4F46E5;
  --color-primary-soft: #EEF0FF;
  --color-primary-hover: #4338CA;
  --gradient-primary: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);

  --color-accent-blue: #3B82F6;
  --color-accent-blue-bg: #E0EBFF;
  --color-accent-green: #10B981;
  --color-accent-green-bg: #DCFCE7;
  --color-accent-purple: #8B5CF6;
  --color-accent-purple-bg: #EDE9FE;
  --color-accent-orange: #F59E0B;
  --color-accent-orange-bg: #FEF3C7;
  --color-accent-pink: #EC4899;
  --color-accent-pink-bg: #FCE7F3;
  --color-accent-cyan: #06B6D4;
  --color-accent-cyan-bg: #CFFAFE;

  --color-success-bg: #DCFCE7;
  --color-success-text: #166534;
  --color-error-bg: #FEE2E2;
  --color-error-text: #B91C1C;
  --color-breakout-bg: #FEF3C7;
  --color-breakout-text: #92400E;
  --color-viral-bg: #FEE2E2;
  --color-viral-text: #B91C1C;

  --shadow-xs: 0 1px 2px rgba(17, 24, 39, 0.04);
  --shadow-sm: 0 2px 8px rgba(17, 24, 39, 0.05);
  --shadow-md: 0 8px 24px rgba(17, 24, 39, 0.06);
  --shadow-lg: 0 16px 48px rgba(17, 24, 39, 0.08);

  --font-display: 'Outfit', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --sidebar-width: 260px;
  --sidebar-width-collapsed: 76px;
  --header-height: 76px;
}

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

html, body { height: 100%; }
body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text-main);
  line-height: 1.5;
  font-size: 14.5px;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; transition: color 0.15s ease; }
a:hover { color: var(--color-primary); }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--color-text-main);
  font-weight: 700;
  letter-spacing: -0.015em;
}
h1 { font-size: 1.875rem; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1.125rem; }
p { color: var(--color-text-muted); }
strong { font-weight: 600; color: var(--color-text-main); }

/* ============= LAYOUT ============= */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
  transition: grid-template-columns 0.25s ease;
}
.app-shell.sidebar-collapsed {
  grid-template-columns: var(--sidebar-width-collapsed) 1fr;
}

/* ============= SIDEBAR ============= */

.sidebar {
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 20px;
  border-bottom: 1px solid var(--color-border);
  min-height: var(--header-height);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text-main);
}
.sidebar-brand:hover { color: var(--color-text-main); }
.sidebar-brand .logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
}
.sidebar-brand .logo svg { width: 20px; height: 20px; }

.sidebar-toggle {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: none;
  transition: all 0.15s;
  flex-shrink: 0;
}
.sidebar-toggle:hover {
  background: var(--color-surface-alt);
  color: var(--color-text-main);
  transform: none;
  box-shadow: none;
}
.sidebar-toggle svg { width: 14px; height: 14px; transition: transform 0.25s; }
.app-shell.sidebar-collapsed .sidebar-toggle svg { transform: rotate(180deg); }

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-text-muted);
  transition: all 0.15s ease;
  position: relative;
  white-space: nowrap;
}
.nav-link svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  stroke-width: 2;
}
.nav-link:hover {
  background: var(--color-surface-alt);
  color: var(--color-text-main);
}
.nav-link.active {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}
.nav-link.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 8px;
  bottom: 8px;
  width: 4px;
  background: var(--color-primary);
  border-radius: 0 4px 4px 0;
}

.app-shell.sidebar-collapsed .sidebar-brand span,
.app-shell.sidebar-collapsed .nav-link span {
  display: none;
}
.app-shell.sidebar-collapsed .nav-link {
  justify-content: center;
  padding: 11px;
}
.app-shell.sidebar-collapsed .sidebar-brand { justify-content: center; }

/* ============= MAIN ============= */

.main-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.top-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  height: var(--header-height);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.page-title {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--color-text-main);
  margin: 0;
}
.page-title .pill-tag {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  background: var(--color-primary-soft);
  color: var(--color-primary);
  text-transform: lowercase;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px 8px 8px;
  border-radius: var(--radius-full);
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  cursor: pointer;
  list-style: none;
  transition: all 0.15s;
}
.user-chip::-webkit-details-marker { display: none; }
.user-chip:hover { background: var(--color-primary-soft); }
.user-chip .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gradient-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
}
.user-chip .user-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-main);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main-content {
  padding: 32px;
  flex: 1;
  min-width: 0;
}

/* ============= STAT CARDS ============= */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  align-items: center;
  gap: 18px;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-xs);
}
.stat-card:hover {
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.stat-card .stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-card .stat-icon svg { width: 24px; height: 24px; stroke-width: 2; }
.stat-card .stat-info { display: flex; flex-direction: column; min-width: 0; }
.stat-card .stat-label {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  font-weight: 600;
  margin-bottom: 4px;
}
.stat-card .stat-value {
  font-family: var(--font-display);
  font-size: 1.625rem;
  font-weight: 700;
  color: var(--color-text-main);
  line-height: 1.2;
}

.stat-icon.blue   { background: var(--color-accent-blue-bg);   color: var(--color-accent-blue); }
.stat-icon.green  { background: var(--color-accent-green-bg);  color: var(--color-accent-green); }
.stat-icon.purple { background: var(--color-accent-purple-bg); color: var(--color-accent-purple); }
.stat-icon.orange { background: var(--color-accent-orange-bg); color: var(--color-accent-orange); }
.stat-icon.pink   { background: var(--color-accent-pink-bg);   color: var(--color-accent-pink); }
.stat-icon.cyan   { background: var(--color-accent-cyan-bg);   color: var(--color-accent-cyan); }

/* ============= PANELS / SECTIONS ============= */

.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-xs);
}
.panel + .panel { margin-top: 20px; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}
.panel-header h2 { margin: 0; font-size: 1.25rem; }
.panel-header .panel-actions { display: flex; gap: 10px; align-items: center; }

.section-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.section-subtitle {
  color: var(--color-text-muted);
  font-size: 0.9375rem;
  margin-bottom: 24px;
}

/* ============= QUICK ACTIONS ============= */

.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
.quick-action {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all 0.2s ease;
  cursor: pointer;
  color: var(--color-text-main);
}
.quick-action:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
  color: var(--color-text-main);
}
.quick-action .qa-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.quick-action .qa-icon svg { width: 22px; height: 22px; stroke-width: 2; }
.quick-action .qa-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--color-text-main);
}
.quick-action .qa-desc {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

/* ============= ACCOUNT CARDS ============= */

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-xs);
}
.card:hover {
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.card-title {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--color-text-main);
}
.card-stats { display: flex; flex-direction: column; gap: 10px; }
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
}
.stat-label { color: var(--color-text-muted); font-weight: 500; }
.stat-value { font-weight: 700; color: var(--color-text-main); }
.card-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

/* ============= STAT BOXES (detail) ============= */

.stat-box {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-xs);
}
.stat-box .label {
  font-family: var(--font-body);
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}
.stat-box .value {
  font-family: var(--font-display);
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--color-text-main);
}

/* ============= FORMS / BUTTONS ============= */

.form-group { display: flex; gap: 0.5rem; }

input[type="text"], input[type="password"], input[type="email"] {
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  color: var(--color-text-main);
  padding: 0 14px;
  height: 42px;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 500;
  outline: none;
  transition: all 0.15s;
  width: 100%;
}
input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
input::placeholder { color: var(--color-text-soft); font-weight: 500; }

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--gradient-primary);
  color: #ffffff;
  border: none;
  padding: 0 18px;
  height: 42px;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.18);
  white-space: nowrap;
}
button:hover {
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.28);
  transform: translateY(-1px);
}
button:active { transform: translateY(0); }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

button.outline {
  background: var(--color-surface);
  color: var(--color-text-main);
  border: 1px solid var(--color-border-strong);
  box-shadow: none;
}
button.outline:hover {
  background: var(--color-surface-alt);
  border-color: var(--color-primary);
  color: var(--color-primary);
  box-shadow: var(--shadow-xs);
}

button.danger {
  background: transparent;
  border: none;
  box-shadow: none;
  color: var(--color-text-soft);
  padding: 0.5rem;
  height: auto;
}
button.danger:hover {
  color: var(--color-error-text);
  background: var(--color-error-bg);
  border-radius: var(--radius-sm);
  transform: none;
  box-shadow: none;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  transition: all 0.15s;
  box-shadow: none;
}
.icon-btn:hover { box-shadow: none; transform: none; }
.icon-btn:hover {
  background: var(--color-primary-soft);
  color: var(--color-primary);
  border-color: var(--color-primary);
}

/* ============= DROPDOWN ============= */

details.dropdown { position: relative; }
details.dropdown > summary {
  list-style: none;
  cursor: pointer;
  padding: 8px 14px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  background: var(--color-surface);
  color: var(--color-text-main);
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s;
}
details.dropdown > summary:hover {
  background: var(--color-surface-alt);
  border-color: var(--color-primary);
  color: var(--color-primary);
}
details.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 18px;
  min-width: 280px;
  box-shadow: var(--shadow-lg);
  z-index: 100;
}

/* ============= TABLE ============= */

.table-wrapper {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  box-shadow: var(--shadow-xs);
}
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 0.875rem; }
th, td { padding: 14px 18px; border-bottom: 1px solid var(--color-border); white-space: nowrap; }
th {
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.1s; }
tbody tr:hover td { background: var(--color-surface-alt); }
.truncate { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============= BADGES ============= */

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-full);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  padding: 4px 10px;
}
.badge.viral {
  background: var(--color-viral-bg);
  color: var(--color-viral-text);
}
.badge.breakout {
  background: var(--color-breakout-bg);
  color: var(--color-breakout-text);
}
tr.is-viral td { background: rgba(254, 226, 226, 0.4); }
tr.is-breakout td { background: rgba(254, 243, 199, 0.4); }

/* ============= EMPTY STATE ============= */

.empty-state {
  text-align: center;
  padding: 56px 24px;
  background: var(--color-surface);
  border: 2px dashed var(--color-border-strong);
  border-radius: var(--radius-lg);
  color: var(--color-text-muted);
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: 14px; color: var(--color-text-soft); }
.empty-state h3 { font-family: var(--font-display); margin-bottom: 6px; }
.empty-state p { font-size: 0.9375rem; }

/* ============= STATUS / LOADERS ============= */

.indicator { display: none; }
.htmx-request .indicator { display: inline-flex; }
.htmx-request.indicator { display: inline-flex; }

.status-badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-body);
  font-size: 0.8125rem;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-weight: 600;
}
.status-running { background: var(--color-surface-alt); color: var(--color-text-muted); }
.status-success { background: var(--color-success-bg); color: var(--color-success-text); }
.status-error   { background: var(--color-error-bg); color: var(--color-error-text); }

.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--color-primary-soft);
  border-left-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============= MISC ============= */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--color-text-muted);
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 16px;
  transition: color 0.15s;
}
.back-link:hover { color: var(--color-primary); }

.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.mt-4 { margin-top: 1rem; }
.mt-8 { margin-top: 2rem; }
.w-full { width: 100%; }

/* ============= LOGIN ============= */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: var(--color-bg);
  position: relative;
}
.login-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
}
.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--gradient-primary);
  color: white;
  margin: 0 auto 18px;
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.32);
}
.login-brand svg { width: 28px; height: 28px; }
.login-card h1 {
  font-family: var(--font-display);
  margin: 0 0 6px;
  font-size: 1.625rem;
  text-align: center;
}
.login-card p.subtitle {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin: 0 0 28px;
  text-align: center;
}
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-card label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 6px;
  display: block;
}
.login-card button { width: 100%; margin-top: 8px; height: 46px; }
.login-error {
  background: var(--color-error-bg);
  color: var(--color-error-text);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  margin-bottom: 4px;
  font-weight: 600;
}

/* ============= RESPONSIVE ============= */

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: var(--sidebar-width-collapsed) 1fr;
  }
  .app-shell .sidebar-brand span,
  .app-shell .nav-link span { display: none; }
  .app-shell .nav-link { justify-content: center; padding: 11px; }
  .app-shell .sidebar-brand { justify-content: center; }
  .app-shell .sidebar-toggle { display: none; }
  .main-content { padding: 20px; }
  .top-header { padding: 0 20px; }
  .page-title { font-size: 1.125rem; }
  .grid-cards { grid-template-columns: 1fr; }
  .stat-card .stat-value { font-size: 1.375rem; }
}

@media (max-width: 600px) {
  .header-actions .user-name { display: none; }
  .user-chip { padding: 6px; }
}

/* ---------- Group filter bar ---------- */
.group-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 8px 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
.group-filter-bar .group-chip-toggle {
  text-decoration: none;
}

/* ---------- Group chips & color swatches ---------- */
.group-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}
.group-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.color-swatch {
  position: relative;
  display: inline-block;
  cursor: pointer;
}
.color-swatch input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.color-swatch span {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
.color-swatch:hover span {
  transform: scale(1.08);
}
.color-swatch input[type="radio"]:checked + span {
  border-color: var(--color-text-main);
  box-shadow: 0 0 0 2px var(--color-bg), 0 0 0 4px var(--color-text-main);
}
.admin-tabs .nav-link {
  height: auto;
  border-radius: 8px;
}
.admin-tabs .nav-link.active {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

/* ---------- Group list (compact) ---------- */
.group-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.group-row {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.group-row > summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.group-row > summary::-webkit-details-marker { display: none; }
.group-row .group-meta {
  flex: 1;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}
.group-row .chevron {
  font-size: 0.875rem;
  color: var(--color-text-soft);
  transition: transform 0.15s ease;
}
.group-row[open] .chevron { transform: rotate(180deg); }
.group-row-body {
  padding: 10px 14px 14px;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-alt);
}

/* ---------- Compact admin tables ---------- */
.table-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: auto;
  max-height: 70vh;
}
.compact-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}
.compact-table thead th {
  position: sticky;
  top: 0;
  background: var(--color-surface-alt);
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
  z-index: 1;
}
.compact-table tbody td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}
.compact-table tbody tr:last-child td { border-bottom: none; }
.compact-table tbody tr:hover { background: var(--color-surface-alt); }
.compact-table .cell-handle {
  font-weight: 600;
  color: var(--color-text-main);
  white-space: nowrap;
}
.compact-table .cell-chips { width: 100%; }

.chip-toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.group-chip-toggle {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.6;
  background: transparent;
  color: var(--color-text-soft);
  border: 1px dashed var(--color-border-strong);
  cursor: pointer;
  transition: transform 0.08s ease, background 0.12s ease;
  height: auto;
  min-height: 0;
}
.group-chip-toggle:hover { transform: translateY(-1px); }
.group-chip-toggle.is-on {
  border-style: solid;
}

/* Chip-checkbox: чекбокс скрыт, кликабельный pill переключает состояние */
.chip-check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-left: 0.5rem;
}
.chip-check {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}
.chip-check input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}
.chip-check .pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.5;
  background: transparent;
  color: var(--color-text-soft);
  border: 1px dashed var(--color-border-strong);
  transition: transform 0.08s ease, background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.chip-check:hover .pill { transform: translateY(-1px); }
.chip-check input[type="checkbox"]:checked + .pill {
  background: var(--chip-bg, var(--color-primary-soft));
  color: var(--chip-color, var(--color-primary));
  border-style: solid;
  border-color: var(--chip-color, var(--color-primary));
}
.chip-check .meta {
  margin-left: 6px;
  font-size: 0.6875rem;
  color: var(--color-text-soft);
}

/* ---------- Toggle switch ---------- */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  font-size: 0.8125rem;
  color: var(--color-text-main);
}
.switch input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}
.switch .track {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
  background: var(--color-border-strong);
  border-radius: 999px;
  transition: background 0.18s ease;
  flex-shrink: 0;
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: transform 0.18s ease;
}
.switch input[type="checkbox"]:checked + .track {
  background: var(--color-primary);
}
.switch input[type="checkbox"]:checked + .track::after {
  transform: translateX(14px);
}
.switch:hover .track { filter: brightness(0.97); }
.switch.is-disabled { opacity: 0.5; pointer-events: none; }

/* ---------- Autoscrape ---------- */
.autoscrape-interval {
  font-size: 0.8125rem;
  padding: 0.25rem 0.5rem;
  height: 30px;
  min-width: 110px;
  border-radius: var(--radius-sm, 6px);
}
.autoscrape-interval:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---------- Admin badge ---------- */
.admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--color-primary-soft);
  color: var(--color-primary);
}
.you-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
}

/* ---------- User card (admin) ---------- */
.user-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.user-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-card-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent-purple));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9375rem;
  flex-shrink: 0;
}
.user-card-name {
  flex: 1;
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--color-text-main);
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.user-card-name-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-card-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.user-card-section-title {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-soft);
  margin: 0;
}
.user-card-divider {
  border: 0;
  border-top: 1px solid var(--color-border);
  margin: 0;
}
.user-card-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.user-card-actions .icon-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.12s ease;
}
.user-card-actions .icon-btn:hover {
  background: var(--color-bg);
  color: var(--color-text-main);
}
.user-card-actions .icon-btn.danger:hover {
  background: var(--color-error-bg);
  color: var(--color-error-text);
  border-color: var(--color-error-text);
}

.users-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.user-row {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.user-row[open] {
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-sm);
}
.user-row > summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.user-row > summary::-webkit-details-marker { display: none; }
.user-row > summary:hover { background: var(--color-surface-alt); }

.user-row .row-name {
  flex: 0 0 auto;
  font-weight: 700;
  color: var(--color-text-main);
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 140px;
}
.user-row .row-summary {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  min-width: 0;
}
.user-row .row-summary .access-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--color-surface-alt);
  font-weight: 600;
  font-size: 0.6875rem;
  color: var(--color-text-muted);
}
.user-row .row-summary .access-pill.has { color: var(--color-primary); background: var(--color-primary-soft); }
.user-row .row-summary .access-pill.empty { opacity: 0.5; }
.user-row .row-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.user-row .row-chevron {
  font-size: 0.875rem;
  color: var(--color-text-soft);
  transition: transform 0.15s ease;
  margin-left: 4px;
  flex-shrink: 0;
}
.user-row[open] .row-chevron { transform: rotate(180deg); }

.user-row-body {
  padding: 14px 16px 16px;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-alt);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Create-user — collapsible button */
.create-user-toggle {
  background: var(--color-surface);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.create-user-toggle[open] {
  background: var(--color-surface);
  border-style: solid;
  border-color: var(--color-border);
  box-shadow: var(--shadow-sm);
}
.create-user-toggle > summary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--color-primary);
}
.create-user-toggle > summary::-webkit-details-marker { display: none; }
.create-user-toggle > summary:hover { background: var(--color-primary-soft); }
.create-user-toggle[open] > summary {
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-alt);
}
.create-user-toggle .create-form-body {
  padding: 14px 16px;
}

/* ---------- Impersonation banner ---------- */
.impersonation-banner {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  background: linear-gradient(90deg, #F59E0B, #F97316);
  color: #fff;
  font-size: 0.875rem;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.25);
}
.impersonation-banner .ib-content {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.impersonation-banner strong { font-weight: 700; }
.impersonation-banner .ib-stop {
  background: rgba(255, 255, 255, 0.95);
  color: #B45309;
  border: none;
  padding: 6px 14px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.8125rem;
  cursor: pointer;
  height: auto;
  min-height: 0;
}
.impersonation-banner .ib-stop:hover {
  background: #fff;
  transform: translateY(-1px);
}

/* Compact create-user panel */
.create-user-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-xs);
}
.create-user-panel form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.create-user-panel input[type="text"],
.create-user-panel input[type="password"] {
  flex: 1 1 180px;
  min-width: 160px;
}
.create-user-panel .switch { font-size: 0.8125rem; }
.create-user-panel .submit-btn { height: 38px; padding: 0 18px; }

.table-search {
  width: 100%;
  max-width: 360px;
}

/* ---------- Sub-tabs (within a section) ---------- */
.subtabs {
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 8px;
}
.subtab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: background 0.12s ease, color 0.12s ease;
}
.subtab:hover {
  background: var(--color-surface-alt);
  color: var(--color-text-main);
}
.subtab.active {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}
.subtab svg { flex-shrink: 0; }

/* ---------- Compact account tiles ---------- */
.account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.account-tile {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  text-decoration: none;
  color: inherit;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
  overflow: hidden;
}
.account-tile:hover {
  transform: translateY(-2px);
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-md);
}
.account-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--color-surface-alt);
  flex-shrink: 0;
  border: 1px solid var(--color-border);
}
.account-avatar.avatar-fallback {
  background: linear-gradient(135deg, var(--color-primary-soft), var(--color-accent-purple-bg));
  position: relative;
}
.account-avatar.avatar-fallback::after {
  content: "";
  position: absolute;
  inset: 0;
  background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%238b5cf6" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="8" r="4"/><path d="M4 21v-1a8 8 0 0 1 16 0v1"/></svg>') center/60% no-repeat;
}
.account-tile-body {
  flex: 1;
  min-width: 0;
}
.account-tile-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.account-handle {
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--color-text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.scrape-error-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  color: #fff;
  background: #ef4444;
  flex-shrink: 0;
  cursor: help;
}
.profile-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--color-text-muted);
  flex-shrink: 0;
  opacity: 0.6;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
}
.profile-link:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.05);
  color: var(--color-text-main);
}
.account-tile-stats {
  display: flex;
  gap: 12px;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}
.account-tile-stats span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
}
.account-tile-meta {
  font-size: 0.6875rem;
  color: var(--color-text-soft);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-tile-actions {
  display: flex;
  gap: 4px;
  align-self: flex-start;
}
@media (hover: hover) {
  .account-tile-actions { opacity: 0; transition: opacity 0.12s ease; }
  .account-tile:hover .account-tile-actions { opacity: 1; }
}
.account-tile-actions .icon-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
}
.account-tile-actions .icon-btn:hover {
  background: var(--color-bg);
  color: var(--color-text-main);
}
.account-tile-actions .icon-btn.danger:hover {
  background: var(--color-error-bg);
  color: var(--color-error-text);
  border-color: var(--color-error-text);
}
.account-tile-status {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0 12px;
  font-size: 0.6875rem;
}
.account-tile-status:empty { display: none; }

/* ---------- AI-анализ ---------- */
.ai-status {
  padding: 14px 16px;
  background: var(--color-surface-2, rgba(255,255,255,0.04));
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md, 12px);
  font-size: 0.9rem;
}
.ai-error {
  padding: 12px 14px;
  background: rgba(220, 60, 60, 0.08);
  border: 1px solid rgba(220, 60, 60, 0.35);
  border-radius: var(--radius-md, 12px);
  color: #ff8585;
  font-size: 0.9rem;
}
.ai-empty p { font-size: 0.92rem; line-height: 1.5; }
.ai-meta { font-size: 0.85rem; }
.ai-meta code { font-size: 0.78rem; opacity: 0.75; }
.ai-content {
  font-size: 0.95rem;
  line-height: 1.65;
}
.ai-content h1, .ai-content h2, .ai-content h3, .ai-content h4 {
  margin-top: 1.4em;
  margin-bottom: 0.5em;
  font-weight: 600;
}
.ai-content h1 { font-size: 1.4rem; }
.ai-content h2 { font-size: 1.2rem; }
.ai-content h3 { font-size: 1.05rem; }
.ai-content h4 { font-size: 0.98rem; }
.ai-content p { margin: 0.6em 0; }
.ai-content ul, .ai-content ol { margin: 0.6em 0; padding-left: 1.4em; }
.ai-content li { margin: 0.25em 0; }
.ai-content code {
  background: rgba(255,255,255,0.06);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.85em;
}
.ai-content strong { color: var(--color-text, #fff); }
.ai-content blockquote {
  border-left: 3px solid var(--color-border);
  padding-left: 12px;
  margin: 0.8em 0;
  opacity: 0.85;
}
.ai-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  max-height: 360px;
  overflow-y: auto;
  padding: 4px;
}
.ai-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md, 10px);
  cursor: pointer;
  font-size: 0.88rem;
  transition: background 0.15s ease;
}
.ai-check:hover { background: rgba(255,255,255,0.04); }
.ai-check input { margin: 0; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-flex; }
.htmx-request.htmx-indicator { display: inline-flex; }

/* ---------- Bulk import ---------- */
.bulk-import > summary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8125rem;
  padding: 5px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm, 6px);
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
}
.bulk-import > summary:hover { background: var(--color-bg-soft); color: var(--color-text-main); }
.bulk-import > summary::-webkit-details-marker { display: none; }
.bulk-import-body {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md, 12px);
  padding: 12px;
  margin-top: 8px;
}
.bulk-import-body textarea {
  width: 100%;
  font-size: 0.8125rem;
  resize: vertical;
  margin-bottom: 8px;
  min-height: 80px;
}

/* ---------- Table engine: sortable headers ---------- */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { background: var(--color-bg-soft); }
th.sort-asc::after  { content: " \25B2"; font-size: 0.65em; opacity: 0.6; }
th.sort-desc::after { content: " \25BC"; font-size: 0.65em; opacity: 0.6; }

/* ---------- Table toolbar ---------- */
.table-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 8px;
}
.table-toolbar .btn-columns {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  padding: 5px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm, 6px);
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
}
.table-toolbar .btn-columns:hover {
  background: var(--color-bg-soft);
  color: var(--color-text-main);
}

/* ---------- Column picker side-panel ---------- */
.col-panel-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 900;
}
.col-panel-overlay.open { display: block; }

.col-panel {
  position: fixed;
  right: -380px;
  top: 0;
  width: 360px;
  height: 100vh;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  box-shadow: -4px 0 24px rgba(0,0,0,0.12);
  z-index: 910;
  display: flex;
  flex-direction: column;
  transition: right 0.25s ease;
  overflow: hidden;
}
.col-panel.open { right: 0; }

.col-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--color-border);
}
.col-panel-header h3 { margin: 0; font-size: 1rem; }
.col-panel-close {
  background: none; border: none;
  font-size: 1.5rem; cursor: pointer;
  color: var(--color-text-muted);
  line-height: 1;
}
.col-panel-close:hover { color: var(--color-text-main); }

.col-panel-search {
  padding: 10px 20px;
  border-bottom: 1px solid var(--color-border);
}
.col-panel-search input {
  width: 100%;
  font-size: 0.8125rem;
  padding: 6px 10px;
  border-radius: var(--radius-sm, 6px);
}

.col-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 20px 16px;
}

.col-panel-cat { margin-bottom: 4px; }
.col-panel-cat > summary {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 6px 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.col-panel-cat > summary::before {
  content: "\25B6";
  font-size: 0.55em;
  transition: transform 0.15s;
}
.col-panel-cat[open] > summary::before { transform: rotate(90deg); }
.col-panel-cat > summary::-webkit-details-marker { display: none; }

.col-panel-count { font-weight: 400; opacity: 0.6; font-size: 0.75rem; }

.col-panel-fields { padding: 2px 0 8px 4px; }
.col-panel-field {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  padding: 3px 0;
  cursor: pointer;
}
.col-panel-field:hover { color: var(--color-primary); }
.col-panel-field input { margin: 0; }

.col-panel-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--color-border);
  text-align: center;
}
.col-panel-footer button { width: 100%; }

@media (max-width: 600px) {
  .col-panel { width: 100%; right: -100%; }
}
