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

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --border: #e4dff7;
  --text: #1e1535;
  --text-muted: #6b7280;
  --primary: #3f0346;
  --primary-dark: #2d0232;
  --primary-light: #f0e0f2;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --warning: #b45309;
  --warning-bg: #fffbeb;
  --error: #dc2626;
  --error-bg: #fef2f2;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(63,3,70,.07), 0 4px 16px rgba(63,3,70,.06);
  --shadow-lg: 0 4px 6px rgba(63,3,70,.05), 0 10px 40px rgba(63,3,70,.1);
}

body {
  font-family: 'Libre Franklin', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Layout ───────────────────────────────────────────────────────────────── */
.app { display: flex; flex-direction: row; min-height: 100vh; }
.app-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }

.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 60px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 var(--border);
}
/* Hide header when sidebar is visible (authenticated state) */
body.sidebar-visible .header { display: none; }

.header-inner {
  width: 100%;
  max-width: 1920px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.1rem; color: var(--text); }
.logo-icon { width: 1.35rem; height: 1.35rem; flex-shrink: 0; border-radius: 3px; }

.main {
  flex: 1;
  padding: 4rem 5rem;
  max-width: 1920px;
  margin: 0 auto;
  width: 100%;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
:root {
  --sidebar-bg:          #3f0346;
  --sidebar-bg-hover:    #551260;
  --sidebar-bg-active:   #6b1f7a;
  --sidebar-text:        #a0a0b8;
  --sidebar-text-active: #ffffff;
  --sidebar-accent:      #8915bf;
  --sidebar-w-collapsed: 56px;
  --sidebar-w-expanded:  160px;
}

.sidebar {
  width: var(--sidebar-w-collapsed);
  min-width: var(--sidebar-w-collapsed);
  height: 100vh;
  position: sticky;
  top: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  overflow: visible;
  transition: width .2s cubic-bezier(.4,0,.2,1), min-width .2s cubic-bezier(.4,0,.2,1);
  z-index: 200;
}
/* Sidebar only expands via the .expanded class (toggle button) — no hover expand */
.sidebar.hidden { display: none !important; }

/* Logo area */
.sidebar-top {
  padding: .75rem .75rem .5rem;
  flex-shrink: 0;
  overflow: hidden;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: .6rem;
  text-decoration: none;
  color: var(--sidebar-text-active);
  padding: .35rem .3rem;
  border-radius: 6px;
  transition: background .15s;
}
.sidebar-logo:hover { background: var(--sidebar-bg-hover); }
.sidebar-logo-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: 4px;
}
.sidebar-logo-text {
  font-size: .85rem;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .15s;
}
/* logo text shown only when expanded */

/* Nav list */
.sidebar-nav {
  list-style: none;
  padding: .25rem 0;
  flex: 1;
  overflow: visible;
}
/* Keep overflow visible so flyout submenus can escape the nav area */
.sidebar.expanded .sidebar-nav {
  overflow: visible;
}

/* Nav item */
.sidebar-item {
  position: relative;
  margin: 2px .5rem;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .5rem .65rem;
  border-radius: 6px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .85rem;
  font-weight: 500;
  white-space: nowrap;
  transition: background .12s, color .12s;
  cursor: pointer;
}
.sidebar-link:hover {
  background: var(--sidebar-bg-hover);
  color: var(--sidebar-text-active);
}

/* Button variant of sidebar-link (for disconnect) */
.sidebar-link--btn {
  background: none;
  border: none;
  font-family: inherit;
  width: 100%;
  text-align: left;
}

/* Active state */
.sidebar-item.active .sidebar-link {
  background: var(--sidebar-bg-active);
  color: var(--sidebar-text-active);
}
.sidebar-item.active::before {
  content: '';
  position: absolute;
  left: -.5rem;
  top: .25rem;
  bottom: .25rem;
  width: 3px;
  background: var(--sidebar-accent);
  border-radius: 0 3px 3px 0;
}

/* Icons */
.sidebar-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* Labels - positioned as flyout when collapsed, inline when expanded */
.sidebar:not(.expanded) .sidebar-link {
  position: relative;
}
.sidebar:not(.expanded) .sidebar-label {
  position: absolute;
  left: calc(100% + 4px);
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  padding: 0 .75rem;
  background: var(--sidebar-bg);
  border-radius: 0 6px 6px 0;
  color: var(--sidebar-text-active);
  font-size: .85rem;
  font-weight: 500;
  white-space: nowrap;
  z-index: 300;
  pointer-events: none;
  box-shadow: 4px 0 12px rgba(0,0,0,.2);
  opacity: 0;
  transition: opacity .12s;
}
.sidebar:not(.expanded) .sidebar-link::after {
  content: '';
  position: absolute;
  right: -8px;
  top: 0;
  bottom: 0;
  width: 8px;
}
.sidebar:not(.expanded) .sidebar-link:hover .sidebar-label {
  opacity: 1;
  pointer-events: auto;
}
.sidebar:not(.expanded) .sidebar-label:hover {
  background: var(--sidebar-bg-hover);
}
/* When expanded: show label inline */
.sidebar.expanded .sidebar-label {
  position: static;
  display: inline;
  padding: 0;
  background: none;
  border-radius: 0;
  box-shadow: none;
  pointer-events: auto;
  white-space: nowrap;
  opacity: 1;
  transition: none;
}

/* ── Sidebar groups & submenus ──────────────────────────────────────────── */
.sidebar-group {
  position: relative;
  margin: 2px .5rem;
}

/* Chevron icon in group toggle */
.sidebar-chevron {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  margin-left: auto;
  transition: transform .2s;
  opacity: 0.5;
}

/* ── Collapsed mode: flyout submenu on hover ─────────────────────────── */
.sidebar:not(.expanded) .sidebar-chevron { display: none; }

.sidebar:not(.expanded) .sidebar-submenu {
  display: none;
  position: absolute;
  left: 100%;
  top: 0;
  min-width: 180px;
  background: var(--sidebar-bg);
  border-radius: 0 8px 8px 0;
  box-shadow: 6px 4px 18px rgba(0,0,0,.3);
  padding: .35rem 0;
  z-index: 310;
  list-style: none;
}
.sidebar:not(.expanded) .sidebar-group:hover .sidebar-submenu {
  display: block;
}
/* Show labels inline inside the flyout (not absolute tooltips) */
.sidebar:not(.expanded) .sidebar-submenu .sidebar-label {
  position: static;
  opacity: 1;
  display: inline;
  padding: 0;
  background: none;
  box-shadow: none;
  pointer-events: auto;
}
/* Hide group-toggle label flyout (submenu acts as the flyout) */
.sidebar:not(.expanded) .sidebar-group > .sidebar-group-toggle .sidebar-label {
  display: none;
}
/* Sub-items in flyout */
.sidebar:not(.expanded) .sidebar-submenu .sidebar-subitem {
  margin: 0;
}
.sidebar:not(.expanded) .sidebar-submenu .sidebar-link {
  padding: .45rem .85rem;
  font-size: .82rem;
  gap: .55rem;
}
.sidebar:not(.expanded) .sidebar-submenu .sidebar-link:hover {
  background: var(--sidebar-bg-hover);
  color: var(--sidebar-text-active);
}

/* ── Expanded mode: flyout submenu on hover (right side) ─────────────── */
.sidebar.expanded .sidebar-chevron { display: none; }

.sidebar.expanded .sidebar-submenu {
  display: none;
  position: absolute;
  left: 100%;
  top: 0;
  min-width: 200px;
  background: var(--sidebar-bg);
  border-radius: 0 8px 8px 0;
  box-shadow: 6px 4px 18px rgba(0,0,0,.3);
  padding: .35rem 0;
  z-index: 310;
  list-style: none;
}
.sidebar.expanded .sidebar-group:hover .sidebar-submenu {
  display: block;
}
/* Show labels inline inside the flyout */
.sidebar.expanded .sidebar-submenu .sidebar-label {
  position: static;
  opacity: 1;
  display: inline;
  padding: 0;
  background: none;
  box-shadow: none;
  pointer-events: auto;
}
/* Sub-items in expanded flyout */
.sidebar.expanded .sidebar-submenu .sidebar-subitem {
  margin: 0;
}
.sidebar.expanded .sidebar-submenu .sidebar-link {
  padding: .45rem .85rem;
  font-size: .82rem;
  gap: .55rem;
}
.sidebar.expanded .sidebar-submenu .sidebar-link:hover {
  background: var(--sidebar-bg-hover);
  color: var(--sidebar-text-active);
}

/* Active accent bar for groups containing active child */
.sidebar-group:has(.sidebar-item.active)::before {
  content: '';
  position: absolute;
  left: -.5rem;
  top: .25rem;
  bottom: .25rem;
  width: 3px;
  background: var(--sidebar-accent);
  border-radius: 0 3px 3px 0;
}

/* ── Admin menu config editor ────────────────────────────────────────── */
.admin-menu-desc {
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}
.admin-menu-container {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  margin-bottom: 1rem;
}
.admin-menu-group-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .75rem;
  background: var(--bg);
}
.admin-menu-group-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .5rem;
}
.admin-menu-group-header .input {
  flex: 1;
  font-size: .85rem;
  padding: .3rem .5rem;
}
.admin-menu-group-children {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  padding-left: .5rem;
}
.admin-menu-tool-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .35rem .5rem;
  border-radius: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: .85rem;
}
.admin-menu-tool-label {
  flex: 1;
}
.admin-menu-drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: .75rem;
  user-select: none;
}
.admin-menu-section-title {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: .5rem;
}
.admin-menu-unassigned-list {
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
.admin-menu-actions {
  margin-top: 1rem;
}
.admin-menu-top-level-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: .85rem;
}
.admin-menu-top-level-item .admin-menu-tool-label {
  flex: 1;
  font-weight: 500;
}
.admin-menu-btn-group {
  display: flex;
  gap: .25rem;
}
.admin-menu-btn-group .btn {
  padding: .15rem .35rem;
  font-size: .7rem;
  min-width: 0;
}

/* Bottom area */
.sidebar-bottom {
  padding: .5rem 0 .75rem;
  flex-shrink: 0;
  overflow: visible;
}
/* Admin group in sidebar-bottom: flyout opens upward to avoid going off-screen */
.sidebar-group--bottom .sidebar-submenu {
  top: auto !important;
  bottom: 0;
}
.sidebar-divider {
  height: 1px;
  background: rgba(255,255,255,.08);
  margin: .25rem .75rem .5rem;
}
.sidebar-portal {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .4rem 1.15rem;
  font-size: .75rem;
  color: var(--sidebar-text);
  white-space: nowrap;
}
.sidebar-portal-dot {
  color: var(--success);
  font-size: .6rem;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
  display: inline-block;
}
.sidebar-portal-name {
  opacity: 0;
  transition: opacity .15s;
}
/* portal name shown only when expanded */

/* Disconnect — no special overrides; uses the same .sidebar-link:hover
   rules as every other sidebar item. */

/* Expand / Collapse toggle */
.sidebar-expand-toggle {
  display: flex;
  align-items: center;
  gap: .5rem;
  width: 100%;
  padding: .55rem calc(.5rem + .65rem);
  background: none;
  border: none;
  border-top: 1px solid rgba(255,255,255,.08);
  color: var(--sidebar-text);
  font-family: inherit;
  font-size: .78rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, color .12s;
  flex-shrink: 0;
}
.sidebar-expand-toggle:hover {
  background: var(--sidebar-bg-hover);
  color: var(--sidebar-text-active);
}
.sidebar-expand-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  transition: transform .2s;
}
/* Pinned-expanded sidebar — auto-grows to fit the widest label / portal name */
.sidebar.expanded {
  width: fit-content;
  min-width: var(--sidebar-w-expanded);
}
.sidebar.expanded .sidebar-top { overflow: visible; }
.sidebar.expanded .sidebar-logo-text,
.sidebar.expanded .sidebar-portal-name { opacity: 1; }
.sidebar.expanded .sidebar-expand-icon { transform: rotate(180deg); }
/* No flyout labels when pinned open (shown inline instead) */

/* ── Responsive sidebar ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
  }
  .sidebar.expanded {
    box-shadow: 4px 0 24px rgba(0,0,0,.35);
  }
  .app-body {
    margin-left: var(--sidebar-w-collapsed);
  }
}


/* ── Dashboard ─────────────────────────────────────────────────────────────── */
.dashboard {
  max-width: 100%;
}
.dashboard-heading {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 .25rem;
}
.dashboard-subheading {
  font-size: .9rem;
  color: var(--text-light);
  margin: 0 0 2rem;
}
.dashboard-portal-info {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.5rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 2rem;
}
.dashboard-portal-detail {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 100px;
}
.dashboard-portal-detail-label {
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-light);
}
.dashboard-portal-detail-value {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text);
}
a.dashboard-portal-link {
  text-decoration: none;
  color: var(--text);
  transition: color .15s;
}
a.dashboard-portal-link:hover {
  color: var(--primary);
  text-decoration: underline;
}
/* ── Dashboard config panel (inside portal info card) ──────────────────── */
.dash-config-panel {
  width: 100%;
  border-top: 1px solid var(--border);
  padding-top: .75rem;
  margin-top: .5rem;
}
.dash-config-panel.hidden { display: none !important; }
.dash-config-table {
  width: auto;
  border-collapse: collapse;
}
.dash-config-table td {
  padding: .3rem .75rem .3rem 0;
  vertical-align: middle;
}
.dash-config-label {
  font-size: .8rem;
  color: var(--text);
  white-space: nowrap;
}
.dash-config-toggle-cell {
  text-align: center;
}

/* ── Dashboard Charts ───────────────────────────────────────────────────── */
.dashboard-charts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}
@media (min-width: 1400px) {
  .dashboard-charts { grid-template-columns: repeat(4, 1fr); }
  #users-chart-card { grid-column: span 2; }
}
@media (max-width: 700px) {
  .dashboard-charts { grid-template-columns: 1fr; }
}
.dashboard-chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem 1rem;
  transition: box-shadow .15s, border-color .15s;
}
.dashboard-chart-card:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 12px rgba(124, 58, 237, .08);
}
.dashboard-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .75rem;
}
.dashboard-chart-title {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-light);
  margin: 0;
}
.dashboard-chart-legend {
  display: flex;
  gap: .75rem;
  font-size: .7rem;
  color: var(--text-light);
}
.users-chart-legend-wrap {
  flex-wrap: wrap;
  padding: 0 0 .25rem;
}
.super-admin-stats-wrap {
  display: flex;
  gap: 1.5rem;
  padding-bottom: 3px;
}
#users-chart-card .dashboard-chart-wrap {
  height: auto;
  overflow: visible;
}
.dashboard-chart-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}
.dashboard-chart-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dashboard-chart-wrap {
  position: relative;
  height: 180px;
  margin-bottom: .75rem;
}
.dashboard-chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}
.dashboard-chart-counts {
  display: flex;
  gap: 1.5rem;
  padding-top: .75rem;
  border-top: 1px solid var(--border);
}
.dashboard-chart-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dashboard-chart-stat-count {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}
.dashboard-chart-stat-label {
  font-size: .7rem;
  color: var(--text-light);
  font-weight: 500;
}
/* Loading skeleton pulse */
.dashboard-chart-card--loading .dashboard-chart-stat-count {
  display: inline-block;
  width: 60px;
  height: 1.4rem;
  background: linear-gradient(90deg, var(--border) 25%, var(--bg) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: dash-shimmer 1.5s infinite;
  border-radius: 6px;
  color: transparent;
}
@keyframes dash-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}
.center-card { max-width: 460px; margin: 0 auto; text-align: center; }
/* Login button uses sidebar dark purple */
#login-section .btn-primary {
  background: var(--sidebar-bg);
}
#login-section .btn-primary:not(:disabled):hover {
  background: var(--sidebar-bg-hover);
  box-shadow: 0 2px 8px rgba(63,3,70,.45);
}
.translator-card {}

.card-icon { font-size: 2.5rem; margin-bottom: 1rem; }
h1 { font-size: 1.6rem; font-weight: 700; margin-bottom: .5rem; }
h2 { font-size: 1.2rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }

.section-title { margin-bottom: 1.5rem; }

.subtitle {
  color: var(--text-muted);
  font-size: .95rem;
  margin-bottom: 1.5rem;
}
.note {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: .75rem;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .55rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .15s, opacity .15s, box-shadow .15s;
  text-decoration: none;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:not(:disabled):hover {
  background: var(--primary-dark);
  box-shadow: 0 2px 8px rgba(63,3,70,.35);
}
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); }
.btn-lg { padding: .75rem 1.75rem; font-size: 1rem; }
.btn-sm { padding: .35rem .85rem; font-size: .8rem; }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: #f3f4f6; color: var(--text-main); }
.btn-block { width: 100%; margin-top: .5rem; }

/* ── Form elements ────────────────────────────────────────────────────────── */
.field-group { margin-bottom: 1.25rem; }
.field-label {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 600;
  font-size: .9rem;
  margin-bottom: .5rem;
}
.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 50%;
  font-size: .75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.input {
  width: 100%;
  padding: .6rem .85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .9rem;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(63,3,70,.15);
}
.select { appearance: none; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .75rem center; padding-right: 2rem; }

.search-wrapper { position: relative; }
.dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  max-height: 260px;
  overflow-y: auto;
  z-index: 50;
}
.dropdown-item {
  padding: .6rem 1rem;
  cursor: pointer;
  font-size: .875rem;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: var(--bg); }
.dropdown-item .item-url {
  font-size: .75rem;
  color: var(--text-muted);
  display: block;
  margin-top: 1px;
}
.dropdown-empty {
  padding: .75rem 1rem;
  color: var(--text-muted);
  font-size: .875rem;
  text-align: center;
}
.dropdown-item-added { opacity: .55; cursor: default; }
.page-added-check {
  font-size: .75rem;
  color: var(--success);
  font-weight: 700;
  margin-left: .3rem;
}
.page-type-badge {
  display: inline-block;
  font-size: .68rem;
  font-weight: 600;
  padding: .1rem .4rem;
  border-radius: 4px;
  background: var(--primary-light);
  color: var(--primary);
  margin-left: .35rem;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.page-lang-badge {
  display: inline-block;
  font-size: .68rem;
  font-weight: 600;
  padding: .1rem .4rem;
  border-radius: 4px;
  background: #f0fdf4;
  color: #16a34a;
  margin-left: .25rem;
  vertical-align: middle;
  letter-spacing: .04em;
}
/* Existing translation variation badge — amber, to signal "already translated" */
.page-lang-badge--exists {
  background: #fffbeb;
  color: #b45309;
}

.selected-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: .5rem .85rem;
  font-size: .875rem;
  font-weight: 500;
  color: var(--primary-dark);
  margin-top: .4rem;
}
.clear-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--primary);
  line-height: 1;
  padding: 0;
  margin-left: .5rem;
}

.select-wrapper { position: relative; }

.lang-warning {
  margin-top: .4rem;
  font-size: .8rem;
  color: var(--warning);
  background: var(--warning-bg);
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  padding: .45rem .75rem;
}

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert {
  border-radius: var(--radius-sm);
  padding: .75rem 1rem;
  font-size: .875rem;
  margin-bottom: 1rem;
}
.alert-error {
  background: var(--error-bg);
  border: 1px solid #fca5a5;
  color: var(--error);
}

/* ── Progress steps ───────────────────────────────────────────────────────── */
.step-list { display: flex; flex-direction: column; gap: .6rem; margin-bottom: 1.25rem; }
.step-item { display: flex; align-items: center; gap: .75rem; font-size: .9rem; }
.step-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  flex-shrink: 0;
  transition: all .2s;
}
.step-icon.idle { color: var(--text-muted); }
.step-icon.running {
  background: var(--primary-light);
  color: var(--primary);
  animation: pulse 1.2s ease-in-out infinite;
}
.step-icon.done { background: var(--success-bg); color: var(--success); }
.step-icon.error { background: var(--error-bg); color: var(--error); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}

/* ── Success result ───────────────────────────────────────────────────────── */
.result-success {
  text-align: center;
  padding-top: .5rem;
}
.success-icon { width: 52px; height: 52px; margin: 0 auto .75rem; display: block; }
.success-icon svg { width: 100%; height: 100%; }
.tmpl-screenshot-thumb {
  width: 100%;
  max-width: 320px;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
  margin-bottom: .75rem;
  display: block;
  margin-left: auto;
  margin-right: auto;
}
.result-success h3 { font-size: 1.2rem; margin-bottom: .35rem; }
.result-success p { color: var(--text-muted); font-size: .9rem; margin-bottom: 1.25rem; }
.result-actions { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 30, 0.45);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  animation: modal-in .18s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(-10px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: .2rem .4rem;
  border-radius: 4px;
  transition: background .12s;
}
.modal-close:hover { background: var(--bg); }

.modal-body { padding: 1.5rem; }
.modal-desc { font-size: .875rem; color: var(--text-muted); margin-bottom: 1.25rem; }

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  gap: .75rem;
}
.modal-footer-right { display: flex; gap: .75rem; }

/* Input with inline button */
.input-row {
  display: flex;
  gap: .5rem;
  align-items: stretch;
}
.input-row .input { flex: 1; }
.input-row .btn { flex-shrink: 0; white-space: nowrap; }

/* Key status banner */
.key-status-banner {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem .85rem;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 500;
  margin-bottom: 1.25rem;
}
.key-status-banner.configured {
  background: var(--success-bg);
  border: 1px solid #86efac;
  color: var(--success);
}
.key-status-banner.not-configured {
  background: var(--warning-bg);
  border: 1px solid #fde68a;
  color: var(--warning);
}

/* Usage info */
.usage-info {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .65rem 1rem;
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: .75rem;
}
.usage-info .usage-bar-track {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  margin-top: .5rem;
  overflow: hidden;
}
.usage-info .usage-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 99px;
  transition: width .4s ease;
}

/* Danger ghost button */
.btn-danger { color: var(--error) !important; border-color: #fca5a5 !important; }
.btn-danger:hover { background: var(--error-bg) !important; }

/* Settings btn always visible pre-auth */
#pre-auth-bar { display: flex; }

/* Hide pre-auth bar once app section is shown */
.app-visible #pre-auth-bar { display: none; }

/* ── Page count badge ────────────────────────────────────────────────────── */
.page-count-badge {
  font-size: .75rem;
  font-weight: 600;
  padding: .1rem .5rem;
  border-radius: 99px;
  background: var(--primary-light);
  color: var(--primary);
  margin-left: auto;
}

/* ── Page queue (selected pages list) ────────────────────────────────────── */
.page-queue {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-top: .4rem;
}
.queue-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .5rem .85rem;
  border-bottom: 1px solid var(--border);
  font-size: .875rem;
  gap: .5rem;
  background: var(--surface);
}
.queue-item:last-child { border-bottom: none; }
.queue-item-info {
  display: flex;
  align-items: center;
  gap: .3rem;
  flex: 1;
  flex-wrap: wrap;
  min-width: 0;
}
.queue-item-name { font-weight: 500; color: var(--text); }
.queue-item-slug {
  font-size: .73rem;
  color: var(--text-muted);
  flex-basis: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Batch progress list ─────────────────────────────────────────────────── */
.batch-list { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1.25rem; }
.batch-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .65rem .9rem;
  background: var(--bg);
}
.batch-item-header { display: flex; align-items: center; gap: .6rem; }
.batch-item-info {
  display: flex;
  align-items: center;
  gap: .3rem;
  flex: 1;
  flex-wrap: wrap;
}
.batch-item-name { font-weight: 500; font-size: .875rem; }
.batch-item-detail {
  margin-top: .35rem;
  margin-left: calc(22px + .6rem);
  font-size: .8rem;
  color: var(--text-muted);
}
.batch-item-detail.error { color: var(--error); }
.batch-hs-link {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  margin-left: .4rem;
}
.batch-hs-link:hover { text-decoration: underline; }

/* ── Tool selection home screen ──────────────────────────────────────────── */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 360px));
  gap: 1.25rem;
}
.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  box-shadow: var(--shadow);
  transition: box-shadow .15s, border-color .15s;
}
.tool-card:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}
.tool-icon {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.tool-icon svg {
  width: 28px;
  height: 28px;
  color: var(--primary);
}
.tool-title { font-size: 1.15rem; font-weight: 700; color: var(--text); margin: 0; }
.tool-desc  { font-size: .875rem; color: var(--text-muted); flex: 1; margin: 0; }
.tool-btn   { align-self: flex-start; margin-top: .5rem; }

/* ── Back navigation bar ─────────────────────────────────────────────────── */
/* Tool sub-page header: icon + name on first line, back button on second */
.tool-page-header {
  margin-bottom: 1.5rem;
}
.tool-page-heading {
  display: flex;
  align-items: center;
  gap: .65rem;
  margin-bottom: .4rem;
}
.tool-page-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--primary-light, #ede9fe);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.tool-page-icon svg {
  width: 17px;
  height: 17px;
}
.tool-page-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  line-height: 1.2;
}
/* .tool-page-back removed — sidebar replaces back buttons */

/* ── Template tool — selected page chip ──────────────────────────────────── */
.tmpl-selected-page {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .5rem .85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  font-size: .875rem;
  margin-top: .4rem;
}
.tmpl-selected-info {
  display: flex;
  align-items: center;
  gap: .3rem;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}
.tmpl-selected-name { font-weight: 500; color: var(--text); }

/* ── Translate — per-page progress stepper ───────────────────────────────── */
.trans-stepper {
  display: flex;
  align-items: flex-start;
  margin-top: .65rem;
  padding: 0 .1rem;
}
.trans-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  gap: .35rem;
}
.trans-step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 9px;
  left: 50%;
  width: 100%;
  height: 2px;
  background: var(--border);
  z-index: 0;
  transition: background .35s;
}
.trans-step.done:not(:last-child)::after { background: var(--primary); }
.trans-step-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--border);
  color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .6rem;
  font-weight: 700;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  transition: background .25s, color .25s, box-shadow .25s;
}
.trans-step.running .trans-step-dot {
  background: var(--primary);
  color: #fff;
  animation: trans-pulse 1.2s ease-in-out infinite;
}
.trans-step.done  .trans-step-dot { background: var(--primary); color: #fff; }
.trans-step.error .trans-step-dot { background: var(--error);   color: #fff; }
.trans-step-label {
  font-size: .58rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.3;
  max-width: 72px;
  word-break: break-word;
  transition: color .25s;
}
.trans-step.running .trans-step-label { color: var(--primary);      font-weight: 600; }
.trans-step.done    .trans-step-label { color: var(--primary-dark); }
.trans-step.error   .trans-step-label { color: var(--error); }
@keyframes trans-pulse {
  0%,  100% { box-shadow: 0 0 0 3px rgba(124, 58, 237, .35); }
  50%        { box-shadow: 0 0 0 6px rgba(124, 58, 237, .12); }
}

/* ── Template horizontal stepper ─────────────────────────────────────────── */
.tmpl-stepper {
  display: flex;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  padding: 0 .25rem;
}
.tmpl-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  gap: .45rem;
}
/* Connecting line: runs from the centre of this dot to the centre of the next */
.tmpl-step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 11px;
  left: 50%;
  width: 100%;
  height: 2px;
  background: var(--border);
  z-index: 0;
  transition: background .35s;
}
.tmpl-step.done:not(:last-child)::after {
  background: var(--primary);
}
.tmpl-step-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--border);
  color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .68rem;
  font-weight: 700;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  transition: background .25s, color .25s, box-shadow .25s;
}
.tmpl-step.running .tmpl-step-dot {
  background: var(--primary);
  color: #fff;
  animation: tmpl-pulse 1.2s ease-in-out infinite;
}
.tmpl-step.done .tmpl-step-dot {
  background: var(--primary);
  color: #fff;
}
.tmpl-step.error .tmpl-step-dot {
  background: var(--error);
  color: #fff;
}
.tmpl-step-label {
  font-size: .62rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.3;
  max-width: 68px;
  word-break: break-word;
  transition: color .25s;
}
.tmpl-step.running .tmpl-step-label {
  color: var(--primary);
  font-weight: 600;
}
.tmpl-step.done .tmpl-step-label {
  color: var(--primary-dark);
}
.tmpl-step.error .tmpl-step-label {
  color: var(--error);
}
@keyframes tmpl-pulse {
  0%,  100% { box-shadow: 0 0 0 3px rgba(124, 58, 237, .35); }
  50%        { box-shadow: 0 0 0 6px rgba(124, 58, 237, .12); }
}

/* ── Blog info bar (primary language + variation badges below blog dropdown) */
.blog-info-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem;
  margin-top: .4rem;
  font-size: .8rem;
  color: var(--text-muted);
}

/* ── Blog name badge ─────────────────────────────────────────────────────── */
.blog-name-badge {
  display: inline-block;
  font-size: .68rem;
  font-weight: 500;
  padding: .1rem .4rem;
  border-radius: 4px;
  background: #f3f4f6;
  color: var(--text-muted);
  margin-left: .25rem;
  vertical-align: middle;
}

/* ── Bowtie Visualization ────────────────────────────────────────────────── */
#bowtie-section { display: flex; flex-direction: column; gap: 1.25rem; }
#bowtie-section > .card { margin-bottom: 0; }

/* ── Filters bar ─────────────────────────────────────────────────────────── */
.bowtie-filters-bar {
  padding: .85rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .85rem;
}

.bowtie-bar-label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
}

.bowtie-period-group,
.bowtie-segment-group {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}

.bowtie-bar-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  flex-shrink: 0;
}

/* Period type pills */
.bowtie-period-pills {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.bowtie-pill {
  padding: .3rem .7rem;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-muted);
  transition: background .15s, color .15s;
  line-height: 1;
  font-family: inherit;
}
.bowtie-pill:not(:last-child) { border-right: 1px solid var(--border); }
.bowtie-pill:hover:not(.bowtie-pill--active) { background: var(--bg); }
.bowtie-pill--active { background: var(--primary); color: #fff; }

/* Period value dropdown */
.bowtie-period-select-wrap { min-width: 120px; }
.bowtie-period-select { padding: .3rem .65rem; font-size: .82rem; }

/* ── Segment single-select ───────────────────────────────────────────────── */
.bowtie-segment-wrap { position: relative; }

.bowtie-segment-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .32rem .75rem;
  font-size: .82rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  transition: border-color .15s, background .15s;
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bowtie-segment-btn:hover { border-color: var(--primary); background: var(--bg); }
.bowtie-segment-btn--selected { border-color: var(--primary); color: var(--primary); }

.bowtie-segment-caret {
  font-size: .65rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.bowtie-segment-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  min-width: 250px;
  max-width: 340px;
}
.bowtie-segment-dropdown.hidden { display: none !important; }

.bowtie-segment-search-row {
  padding: .5rem;
  border-bottom: 1px solid var(--border);
}
.bowtie-segment-search-row input {
  width: 100%;
  padding: .35rem .6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .8rem;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  outline: none;
}
.bowtie-segment-search-row input:focus { border-color: var(--primary); }

.bowtie-segment-options { max-height: 220px; overflow-y: auto; }

.bowtie-segment-option {
  padding: .45rem .85rem;
  font-size: .82rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  transition: background .1s;
}
.bowtie-segment-option:hover { background: var(--bg); }
.bowtie-segment-option--selected { color: var(--primary); font-weight: 600; }

.bowtie-segment-size {
  font-size: .72rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ── Saved Views ─────────────────────────────────────────────────────────── */
.bowtie-views-group { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }

.bowtie-views-save-row {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem;
  border-bottom: 1px solid var(--border);
}
.bowtie-views-save-row input {
  flex: 1;
  min-width: 0;
  padding: .32rem .6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .8rem;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  outline: none;
}
.bowtie-views-save-row input:focus { border-color: var(--primary); }

.bowtie-views-item {
  padding: .42rem .85rem;
  font-size: .82rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  transition: background .1s;
}
.bowtie-views-item:hover { background: var(--bg); }
.bowtie-views-item--active { color: var(--primary); font-weight: 600; }

.bowtie-views-item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bowtie-views-delete-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: .75rem;
  padding: .1rem .25rem;
  border-radius: 4px;
  line-height: 1;
  font-family: inherit;
  transition: color .12s, background .12s;
}
.bowtie-views-delete-btn:hover { color: #dc2626; background: #fef2f2; }

.bowtie-views-empty {
  padding: .65rem .85rem;
  font-size: .78rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Chart container ─────────────────────────────────────────────────────── */
.bowtie-chart-container { padding: 1.25rem; min-height: 180px; }

/* Spinner */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}

/* Chart states */
.bowtie-loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .65rem;
  padding: 3.5rem 0;
  color: var(--text-muted);
  font-size: .875rem;
}
.bowtie-empty-state {
  padding: 3rem 0;
  text-align: center;
  color: var(--text-muted);
  font-size: .875rem;
}
.bowtie-empty-state p { margin-top: .35rem; font-size: .8rem; }
.bowtie-error-state {
  padding: .75rem 1rem;
  color: var(--error);
  background: var(--error-bg);
  border: 1px solid #fca5a5;
  border-radius: var(--radius-sm);
  font-size: .875rem;
}

/* SVG chart overflow */
#bowtie-chart { overflow-x: auto; }
#bowtie-chart svg { display: block; }

/* ── Collapsible panels (Trendlines) ─────────────────────────────────────── */
.bowtie-panel { padding: 0; overflow: hidden; }

.bowtie-panel-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .85rem 1.25rem;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: .875rem;
  font-weight: 600;
  color: var(--text);
  gap: .5rem;
  transition: background .15s;
}
.bowtie-panel-toggle:hover { background: var(--bg); }
.bowtie-panel-title { flex: 1; text-align: left; }
.bowtie-panel-arrow {
  font-size: .75rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}
.bowtie-panel-body {
  border-top: 1px solid var(--border);
  padding: 1.25rem;
}

/* Trendlines period range bar */
.bowtie-trend-range-bar {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem 0 .75rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: .75rem;
  flex-wrap: wrap;
}
.bowtie-trend-range-select-wrap { flex-shrink: 0; }
.bowtie-trend-range-select { min-width: 110px; font-size: .82rem; padding: .28rem .5rem; }

.bowtie-trend-loading {
  display: flex;
  align-items: center;
  gap: .5rem;
  color: var(--text-muted);
  font-size: .875rem;
  padding: .5rem 0;
}
.bowtie-trend-error {
  color: var(--error);
  font-size: .875rem;
  background: var(--error-bg);
  border: 1px solid #fca5a5;
  border-radius: var(--radius-sm);
  padding: .6rem .85rem;
}

/* ── Config toggle (gear icon) ──────────────────────────────────────────── */
.bowtie-config-toggle-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: .25rem;
  border-radius: var(--radius-sm);
  transition: color .15s, background .15s;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.bowtie-config-toggle-btn:hover { color: var(--primary); background: var(--bg); }
.bowtie-config-toggle-btn.active { color: var(--primary); }

/* ── Inline config panel (inside filters bar) ──────────────────────────── */
.bowtie-config-panel {
  width: 100%;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  margin-top: .75rem;
}
.bowtie-config-panel.hidden { display: none !important; }

/* ── Stage config card ───────────────────────────────────────────────────── */
.bowtie-config-card { padding: 1.5rem; }

/* Header */
.bowtie-config-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .75rem;
}
.bowtie-config-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}
.bowtie-config-header-actions { display: flex; align-items: center; gap: .75rem; }
.bowtie-config-reset-btn {
  font-size: .75rem;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.bowtie-config-reset-btn:hover { color: var(--text); }
.bowtie-config-desc {
  font-size: .8rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 1.25rem;
}

/* Object type toggle container (gray box like original) */
.bowtie-objtype-container {
  background: var(--surface, #f9fafb);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .75rem 1rem;
  margin-bottom: 1.25rem;
}
.bowtie-objtype-container .bowtie-bar-label { display: block; margin-bottom: .5rem; }

/* Override the joined segmented-control style for the objtype toggle:
   two separate equal-width pill buttons, left-aligned. */
.bowtie-objtype-container .bowtie-period-pills {
  display: inline-flex;
  border: none;
  overflow: visible;
  gap: .4rem;
}
.bowtie-objtype-container .bowtie-pill {
  border: 1px solid var(--border);
  border-radius: 100px;
  min-width: 90px;
  text-align: center;
}
.bowtie-objtype-container .bowtie-pill:not(:last-child) {
  border-right: 1px solid var(--border); /* restore — global rule removed it */
}
.bowtie-objtype-container .bowtie-pill--active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.bowtie-objtype-hint {
  font-size: .7rem;
  color: var(--text-muted);
  margin-top: .4rem;
  margin-bottom: 0;
}

/* Config sections */
.bowtie-config-section { margin-bottom: 1rem; }
.bowtie-config-section:last-child { margin-bottom: 0; }
.bowtie-config-section-hdr {
  font-size: .875rem;
  font-weight: 500;
  margin-bottom: .5rem;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.bowtie-config-section-hdr--left  { color: #7c3aed; }
.bowtie-config-section-hdr--center { color: var(--text); }
.bowtie-config-section-hdr--right { color: #3f0346; }
.bowtie-config-dot {
  width: .7rem;
  height: .7rem;
  border-radius: 50%;
  flex-shrink: 0;
}
.bowtie-config-dot--left   { background: #7c3aed; }
.bowtie-config-dot--center { background: #1f2937; }
.bowtie-config-dot--right  { background: #3f0346; }

/* Stage rows — original single-flex-row format */
.bowtie-stage-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem .65rem;
  border-radius: .5rem;
  border: 1px solid;
  margin-bottom: .375rem;
}
.bowtie-stage-row:last-child { margin-bottom: 0; }
.bowtie-stage-row--left   { border-color: rgba(63,3,70,.3);  background: rgba(63,3,70,.03); }
.bowtie-stage-row--center { border-color: rgba(137,21,191,.3);  background: rgba(137,21,191,.03); }
.bowtie-stage-row--right  { border-color: rgba(63,3,70,.3);     background: rgba(63,3,70,.03); }
.bowtie-stage-row--excluded { opacity: .4; }
.bowtie-stage-row--excluded .bowtie-label-input { text-decoration: line-through; }

/* Exclude toggle */
.bowtie-exclude-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: .7rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  margin-left: auto;
  white-space: nowrap;
  flex-shrink: 0;
}
.bowtie-exclude-toggle input[type="checkbox"] {
  cursor: pointer;
  accent-color: #ef4444;
  width: 13px;
  height: 13px;
}

.bowtie-vm-badge {
  font-size: .7rem;
  font-weight: 700;
  padding: .2rem .45rem;
  border-radius: .25rem;
  flex-shrink: 0;
  white-space: nowrap;
}
.bowtie-vm-badge--left   { background: #ede9fe; color: #7c3aed; }
.bowtie-vm-badge--center { background: #1f2937; color: #fff; }
.bowtie-vm-badge--right  { background: #f0e0f2; color: #3f0346; }

.bowtie-label-input {
  border: none !important;
  border-bottom: 1px dashed var(--border) !important;
  box-shadow: none !important;
  background: transparent !important;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text);
  width: 110px;
  flex-shrink: 0;
  padding: 0 .25rem .15rem;
  font-family: inherit;
  outline: none;
  border-radius: 0 !important;
  cursor: text;
}
.bowtie-label-input:hover {
  border-bottom-color: var(--text-muted) !important;
}
.bowtie-label-input:focus {
  background: rgba(0,0,0,.04) !important;
  border-bottom: 1px solid var(--primary) !important;
  border-radius: 0 !important;
}

.bowtie-row-arrow { color: #9ca3af; font-size: .75rem; flex-shrink: 0; }

.bowtie-row-select {
  flex: 1;
  min-width: 0;
  font-size: .75rem;
  padding: .25rem .5rem;
  border: 1px solid var(--border);
  border-radius: .25rem;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  outline: none;
}
.bowtie-row-select:focus { border-color: var(--primary); }
.bowtie-row-select--wide { flex: 2; }

.bowtie-obj-type {
  font-size: .6rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  width: 52px;
  text-align: right;
  flex-shrink: 0;
}

/* ── Trendlines mini-charts (btl = bowtie trendlines) ───────────────────── */
.btl-section { margin-bottom: 1.5rem; }
.btl-section:last-child { margin-bottom: 0; }
.btl-section-title {
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .75rem;
}
.btl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: .75rem;
}
.btl-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .75rem 1rem;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.btl-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0,0,0,.08);
}
.btl-no-data {
  font-size: .8rem;
  color: var(--text-muted);
  padding: .25rem 0;
}
.btl-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .35rem;
  margin-bottom: .5rem;
  flex-wrap: wrap;
}
.btl-card-title {
  font-size: .8rem;
  font-weight: 700;
  white-space: nowrap;
}
.btl-card-sub {
  font-size: .7rem;
  color: var(--text-muted);
  font-weight: 400;
}
.btl-card-suffix {
  font-size: .7rem;
  color: var(--text-muted);
  white-space: nowrap;
  margin-left: auto;
}
.btl-svg { display: block; width: 100%; overflow: visible; }

/* Data-point hover tooltips */
.btl-point-group { cursor: crosshair; }
.btl-tooltip { display: none; pointer-events: none; }
.btl-point-group:hover .btl-tooltip { display: block; }
.btl-point-group:hover .btl-dot { stroke-width: 2.5; r: 4px; }

/* ── Bowtie SVG wrapper — scales down then scrolls at extreme narrows ──────── */
.bowtie-svg-wrap {
  background: #fff;
  border-radius: 10px;
  overflow-x: auto;   /* fallback scroll if viewport < 420px */
}
.bowtie-svg-wrap svg {
  min-width: 420px;   /* below this the chart becomes unreadable → scroll instead */
}
.bowtie-attribution {
  text-align: center;
  font-size: .75rem;
  color: var(--text-muted);
  padding: .5rem 0 .75rem;
}
.bowtie-attribution a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}
.bowtie-attribution a:hover {
  text-decoration: underline;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

/* ≤ 1100px: trendline cards go to 3 columns */
@media (max-width: 1100px) {
  .btl-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}

/* ≤ 800px: filter bar wraps, trendlines go to 2 columns */
@media (max-width: 800px) {
  .bowtie-filters-bar { flex-wrap: wrap; gap: .6rem; }
  .bowtie-bar-divider { display: none; }
  .btl-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ≤ 600px: filter bar stacks, stage rows tighten */
@media (max-width: 600px) {
  .bowtie-filters-bar { flex-direction: column; align-items: flex-start; }
  .bowtie-label-input { width: 80px; }
  .bowtie-stage-row { gap: .35rem; padding: .4rem .5rem; }
}

/* ≤ 480px: trendlines single column */
@media (max-width: 480px) {
  .btl-grid { grid-template-columns: 1fr; }
  .bowtie-config-card { padding: 1rem; }
}

/* Trendline zoom modal ──────────────────────────────────────────────────────── */
.btl-zoom-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1.5rem;
  backdrop-filter: blur(2px);
}
.btl-zoom-modal {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 860px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .22);
  overflow: hidden;
  animation: btl-zoom-in .18s ease;
}
@keyframes btl-zoom-in {
  from { opacity: 0; transform: scale(.95); }
  to   { opacity: 1; transform: scale(1); }
}
.btl-zoom-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem .85rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.btl-zoom-title-group {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  flex-wrap: wrap;
}
.btl-zoom-title {
  font-size: 1.05rem;
  font-weight: 700;
}
.btl-zoom-sub {
  font-size: .78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.btl-zoom-suffix {
  font-size: .75rem;
  color: var(--text-muted);
}
.btl-zoom-close {
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: .15rem .4rem;
  border-radius: 4px;
  transition: color .12s, background .12s;
}
.btl-zoom-close:hover { color: var(--text); background: var(--bg); }
.btl-zoom-chart {
  flex: 1;
  padding: 1.5rem 1.75rem 1.25rem;
  min-height: 0;
  display: flex;
  align-items: stretch;
  border-radius: 0 0 14px 14px;
}
.btl-zoom-chart svg {
  width: 100%;
  height: 100%;
  max-height: calc(88vh - 90px);
  overflow: visible;
}

/* ── Admin Panel ────────────────────────────────────────────────────────────── */

.admin-card {
  margin-bottom: 1.25rem;
}

.admin-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.admin-card-header .section-title { margin-bottom: 0; }
.admin-card-actions { display: flex; gap: .5rem; align-items: center; }

/* Add-user inline form */
.admin-add-form {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.admin-add-input { flex: 1; min-width: 200px; max-width: 320px; }
.admin-add-error { color: var(--error); font-size: .82rem; flex-basis: 100%; }

/* Pending badge + delete button */
.admin-badge--pending { background: #f59e0b; }
.admin-pending-label  { color: var(--text-muted); font-size: .82rem; font-style: italic; }
.admin-actions-cell   { width: 40px; text-align: center; }
.admin-delete-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: .95rem;
  padding: .25rem .4rem;
  border-radius: 4px;
  line-height: 1;
  transition: color .12s, background .12s;
}
.admin-delete-btn:hover { color: var(--error); background: var(--error-bg); }

.admin-loading {
  color: var(--text-muted);
  font-size: .9rem;
  padding: .75rem 0;
}

.admin-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

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

.admin-table th {
  padding: .6rem .85rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: .78rem;
  letter-spacing: .03em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

/* Sortable column headers */
.admin-th-sortable { cursor: pointer; user-select: none; }
.admin-th-sortable:hover { background: rgba(0,0,0,.05); }
.admin-th-sortable::after { content: ' ⇅'; opacity: .3; font-size: .8em; }
.admin-th-sortable.sort-asc::after  { content: ' ▲'; opacity: .65; }
.admin-th-sortable.sort-desc::after { content: ' ▼'; opacity: .65; }

.admin-th-tool {
  text-align: center !important;
  line-height: 1.2;
}

.admin-table td {
  padding: .65rem .85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

.admin-table tbody tr:hover { background: none; }

.admin-user-cell { width: 220px; min-width: 220px; }
.admin-portal-cell { color: var(--text-muted); font-size: .82rem; width: 160px; min-width: 160px; }
.admin-portal-lastseen { display: block; font-size: .72rem; color: var(--text-muted); opacity: .7; margin-top: 1px; }
.admin-date-cell { color: var(--text-muted); font-size: .82rem; white-space: nowrap; width: 150px; min-width: 150px; }
.admin-tool-cell { width: 150px; min-width: 150px; }
.admin-count-cell { text-align: left; }


/* Usage table — user grouping */
.admin-usage-user-cell { vertical-align: top; padding-top: .65rem; width: 220px; min-width: 220px; }
.usage-portals { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .35rem; }
.usage-portal-badge {
  font-size: .72rem;
  padding: .1rem .5rem;
  background: #f3f4f6;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}
tr.admin-usage-group-end > td { border-bottom: 2px solid var(--border); }
tr.admin-usage-portal-end > td { border-bottom: 1px dashed var(--border); }
.admin-portal-group-cell { vertical-align: top; padding-top: .65rem; }

/* Usage total row in tfoot */
.admin-usage-total-row td {
  border-top: 2px solid var(--border);
  background: #f9fafb;
  padding: .55rem .75rem;
}
.admin-usage-total-label {
  font-weight: 600;
  color: var(--text-main);
}
.admin-usage-total-count {
  font-weight: 700;
  font-size: 1rem;
  color: var(--primary);
}

/* Per-portal event count chips */
.usage-count-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  align-items: center;
}
.usage-count-chip {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .75rem;
  padding: .15rem .5rem;
  background: #f3f4f6;
  border: 1px solid var(--border);
  border-radius: 10px;
  white-space: nowrap;
}
.usage-count-chip-portal { color: var(--text-muted); }
.usage-count-chip-count  { font-weight: 500; color: var(--text-main); }
.usage-count-total       { font-size: .8rem; color: var(--text-muted); }

.admin-user-name  { display: block; font-weight: 600; font-size: .9rem; line-height: 1.3; }
.admin-user-email { font-weight: 500; }
.admin-user-name + .admin-user-email { font-weight: 400; font-size: .8rem; color: var(--text-muted); }

.admin-badge {
  display: inline-block;
  margin-left: .4rem;
  padding: .1rem .45rem;
  border-radius: 99px;
  background: var(--primary);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .04em;
  vertical-align: middle;
  text-transform: uppercase;
}

.admin-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 1.5rem !important;
  font-style: italic;
}

/* Toggle switch */
.admin-toggle-cell { text-align: center; }

.admin-toggle {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  position: relative;
}

.admin-toggle-input,
.admin-admin-input,
.admin-charts-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.admin-toggle-slider {
  width: 28px;
  height: 16px;
  background: #d1d5db;
  border-radius: 8px;
  position: relative;
  transition: background .18s;
  flex-shrink: 0;
}

.admin-toggle-slider::after {
  content: '';
  position: absolute;
  left: 2px;
  top: 2px;
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 50%;
  transition: transform .18s;
  box-shadow: 0 1px 3px rgba(0,0,0,.18);
}

.admin-toggle-input:checked + .admin-toggle-slider,
.admin-admin-input:checked + .admin-toggle-slider,
.admin-charts-input:checked + .admin-toggle-slider {
  background: var(--primary);
}
.admin-toggle-input:checked + .admin-toggle-slider::after,
.admin-admin-input:checked + .admin-toggle-slider::after,
.admin-charts-input:checked + .admin-toggle-slider::after {
  transform: translateX(12px);
}

.admin-toggle-input:disabled + .admin-toggle-slider,
.admin-admin-input:disabled + .admin-toggle-slider,
.admin-charts-input:disabled + .admin-toggle-slider {
  opacity: .45;
  cursor: not-allowed;
}

/* Usage period filter bar */
.admin-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: .5rem;
}
.admin-card-header .section-title {
  margin-bottom: 0;
}
.admin-usage-filter {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.admin-filter-label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.admin-filter-select {
  font-family: inherit;
  font-size: .875rem;
  padding: .3rem .6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text-main);
  cursor: pointer;
  outline: none;
}
.admin-filter-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(99,102,241,.15);
}
.admin-custom-range {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
}
.admin-date-input {
  font-family: inherit;
  font-size: .875rem;
  padding: .28rem .5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text-main);
  outline: none;
}
.admin-date-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(99,102,241,.15);
}
.admin-filter-divider {
  display: inline-block;
  width: 1px;
  height: 1.2rem;
  background: var(--border);
  margin: 0 .25rem;
  vertical-align: middle;
}
.admin-range-sep {
  color: var(--text-muted);
  font-size: .85rem;
}
.btn-sm {
  padding: .28rem .75rem;
  font-size: .8rem;
}

/* Toast notification */
.admin-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: var(--text);
  color: #fff;
  padding: .6rem 1.25rem;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
  transition: transform .22s cubic-bezier(.34,1.56,.64,1);
  z-index: 9999;
  pointer-events: none;
  white-space: nowrap;
}
.admin-toast--visible {
  transform: translateX(-50%) translateY(0);
}
.admin-toast--error { background: var(--error); }

/* ── Custom Select (replaces native <select> dropdowns) ───────────────────── */
.custom-select-wrap {
  position: relative;
  display: inline-flex;
}
.custom-select-wrap select { /* hide native select but keep it in DOM */
  position: absolute !important;
  width: 0 !important; height: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
  overflow: hidden !important;
}
.custom-select-trigger {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .6rem .85rem;
  padding-right: 2rem;
  font-size: .9rem;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: border-color .15s, box-shadow .15s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  width: 100%;
  min-width: 0;
}
.custom-select-trigger:hover { border-color: var(--primary); }
.custom-select-trigger:focus,
.custom-select-trigger.cs-open {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(63,3,70,.15);
  outline: none;
}
.custom-select-dropdown {
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  min-width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  max-height: 240px;
  overflow-y: auto;
  z-index: 200;
}
.custom-select-dropdown.hidden { display: none !important; }
.custom-select-option {
  padding: .5rem .85rem;
  font-size: .875rem;
  cursor: pointer;
  transition: background .08s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.custom-select-option:hover { background: var(--bg); }
.custom-select-option--selected {
  color: var(--primary);
  font-weight: 600;
  background: var(--primary-light);
}
.custom-select-option--selected:hover { background: var(--primary-light); }
.custom-select-option--disabled { opacity: .45; cursor: default; }
.custom-select-option--disabled:hover { background: transparent; }
.custom-select-trigger:disabled { opacity: .55; cursor: default; }

/* Context-specific size overrides for custom selects */
.bowtie-period-select-wrap .custom-select-trigger {
  padding: .3rem .65rem; padding-right: 1.6rem; font-size: .82rem;
  background-position: right .45rem center;
}
.bowtie-period-select-wrap .custom-select-dropdown { font-size: .82rem; }
.bowtie-period-select-wrap .custom-select-option { padding: .35rem .65rem; font-size: .82rem; }

.bowtie-trend-range-select-wrap .custom-select-trigger {
  min-width: 110px; font-size: .82rem; padding: .28rem .5rem; padding-right: 1.6rem;
  background-position: right .35rem center;
}
.bowtie-trend-range-select-wrap .custom-select-dropdown { font-size: .82rem; }
.bowtie-trend-range-select-wrap .custom-select-option { padding: .3rem .55rem; font-size: .82rem; }

.bowtie-stage-row .custom-select-wrap {
  flex: 1; min-width: 0;
}
.bowtie-stage-row .custom-select-wrap.cs-wide { flex: 2; }
.bowtie-stage-row .custom-select-trigger {
  font-size: .75rem; padding: .25rem .5rem; padding-right: 1.4rem;
  background: var(--bg); border-radius: .25rem;
  background-position: right .3rem center;
}
.bowtie-stage-row .custom-select-dropdown { font-size: .75rem; }
.bowtie-stage-row .custom-select-option { padding: .25rem .5rem; font-size: .75rem; }

.admin-usage-filter .custom-select-trigger {
  font-size: .875rem; padding: .3rem .6rem; padding-right: 1.8rem;
  background: #fff; border-radius: 6px;
  background-position: right .5rem center;
}
.admin-usage-filter .custom-select-dropdown { font-size: .875rem; }
.admin-usage-filter .custom-select-option { padding: .35rem .65rem; font-size: .875rem; }

.admin-menu-tool-item .custom-select-trigger {
  font-size: .75rem; padding: .15rem .35rem; padding-right: 1.4rem;
  background-position: right .25rem center;
}
.admin-menu-tool-item .custom-select-dropdown { font-size: .75rem; min-width: 120px; }
.admin-menu-tool-item .custom-select-option { padding: .25rem .5rem; font-size: .75rem; }

/* Utilities ────────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
