:root {
  --bg: #0c0e14;
  --bg-elevated: #131720;
  --bg-hover: #1a1f2e;
  --bg-input: #0f131c;
  --border: #252d3d;
  --border-light: #323d52;
  --text: #edf0f7;
  --text-muted: #7d879a;
  --text-dim: #555f73;
  --accent: #6c7bf7;
  --accent-hover: #8490ff;
  --accent-soft: rgba(108, 123, 247, 0.12);
  --accent-glow: rgba(108, 123, 247, 0.25);
  --success: #34d399;
  --warning: #fbbf24;
  --error: #f87171;
  --info: #38bdf8;
  --radius: 14px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --sidebar-width: 252px;
  --font: 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

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

.hidden { display: none !important; }

html { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 60% at 10% -10%, rgba(108, 123, 247, 0.08), transparent),
    radial-gradient(ellipse 60% 50% at 90% 100%, rgba(168, 85, 247, 0.05), transparent);
  color: var(--text);
  line-height: 1.5;
  height: 100%;
  overflow: hidden;
}

code, .mono { font-family: var(--mono); font-size: 0.875em; }

.app {
  display: flex;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

/* ─── Sidebar ─── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 26px 22px;
  border-bottom: 1px solid var(--border);
}

.brand-icon {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.brand-title { font-weight: 700; font-size: 1.08rem; letter-spacing: -0.02em; }
.brand-sub { font-size: 0.72rem; color: var(--text-muted); margin-top: 1px; }

.nav { padding: 18px 14px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 11px 14px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.18s;
  margin-bottom: 3px;
  text-align: left;
  position: relative;
}

.nav-item:hover { background: var(--bg-hover); color: var(--text); }

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 20px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.sidebar-footer { padding: 18px 14px; border-top: 1px solid var(--border); }

.stat-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.stat-label { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: 1.6rem; font-weight: 700; margin-top: 2px; letter-spacing: -0.03em; }
.stat-sub { font-size: 0.72rem; color: var(--text-muted); margin-top: 4px; line-height: 1.3; }

.cache-info {
  margin-top: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.74rem;
}

.cache-info-title {
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.68rem;
  margin-bottom: 8px;
}

.cache-info-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
  line-height: 1.35;
}

.cache-reset-stats {
  width: 100%;
  margin-top: 10px;
  padding: 7px 10px;
  font-size: 0.72rem;
}

.cache-info-label { color: var(--text-muted); flex-shrink: 0; }
.cache-info-value { color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }

/* ─── Content ─── */
.content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 16px 24px;
  width: calc(100% - var(--sidebar-width));
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.page {
  display: none;
  min-width: 0;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}
.page.active {
  display: flex;
  flex-direction: column;
}

/* ─── Cards ─── */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}

.card.full-height {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.card h2 { font-size: 1.05rem; font-weight: 600; letter-spacing: -0.01em; }
.card h3 { font-size: 0.92rem; margin-bottom: 12px; color: var(--text-muted); font-weight: 600; }
.card h3.mt { margin-top: 28px; }
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-shrink: 0;
}
.card-header h2 { margin-bottom: 0; }

.card-section-title {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 28px;
}

.card-section-title.compact { margin-bottom: 0; }

.section-icon {
  width: 36px; height: 36px;
  background: var(--accent-soft);
  border-radius: var(--radius-xs);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.section-desc { font-size: 0.82rem; color: var(--text-muted); margin-top: 3px; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

/* ─── Export layout ─── */
.export-layout {
  display: grid;
  grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
  gap: 24px;
  align-items: stretch;
  flex: 1;
  min-height: 0;
  min-width: 0;
  max-width: 100%;
}

.export-filters,
.export-preview {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}

.export-filters { overflow: auto; }

.export-preview { overflow: hidden; }

.export-preview .card-header,
.export-preview .preview-tabs { flex-shrink: 0; }

.export-preview .preview-panel { width: 100%; max-width: 100%; }

.preview-tabs {
  display: flex;
  gap: 6px;
  padding: 0 4px 12px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.preview-tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
}

.preview-tab:hover { color: var(--text); background: var(--bg-hover); }

.preview-tab.active {
  color: var(--text);
  background: var(--accent-soft);
  border-color: rgba(108, 123, 247, 0.35);
}

.preview-panel { display: none; flex: 1; min-height: 0; flex-direction: column; overflow: hidden; }
.preview-panel.active { display: flex; }

.preview-panel[data-preview-panel="coverage"] #coverage-body:not(.hidden) {
  flex: 1;
  min-height: 0;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.coverage-placeholder:not(.hidden) {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.coverage-loading:not(.hidden) {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.coverage-loading-inner {
  width: min(420px, 100%);
  text-align: center;
}

.coverage-spinner {
  width: 28px;
  height: 28px;
  margin: 0 auto 16px;
  display: block;
}

.coverage-loading-inner > p {
  color: var(--text);
  font-size: 0.92rem;
  margin-bottom: 14px;
}

.coverage-progress-track {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 10px;
}

.coverage-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: 999px;
  transition: width 0.35s ease;
}

.coverage-loading-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.preview-panel .file-list {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow: auto;
}

.coverage-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 14px;
  flex-shrink: 0;
}

.coverage-metric {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.coverage-metric select,
.coverage-metric input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  padding: 7px 10px;
  font-size: 0.84rem;
  min-width: 120px;
}

.coverage-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
  flex-shrink: 0;
  min-width: 0;
}

.coverage-stat {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.coverage-stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.coverage-stat-value {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.coverage-stat-range {
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.35;
}

.coverage-suggest {
  display: none;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 14px;
  background: var(--accent-soft);
  border: 1px solid rgba(108, 123, 247, 0.25);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  flex-shrink: 0;
}

.coverage-suggest.visible { display: flex; }

.coverage-chart-wrap {
  position: relative;
  flex: 1;
  min-height: 220px;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 8px 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.coverage-chart-scroll {
  flex: 1;
  min-height: 0;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
}

.coverage-chart-scroll canvas {
  display: block;
  cursor: crosshair;
  height: 100%;
  min-height: 200px;
  max-width: none;
}

.coverage-legend {
  margin-top: 8px;
  font-size: 0.72rem;
  color: var(--text-dim);
  flex-shrink: 0;
  text-align: center;
}

.coverage-meta {
  margin-top: 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.coverage-tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 5;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xs);
  padding: 8px 10px;
  font-size: 0.78rem;
  box-shadow: var(--shadow);
  display: none;
  white-space: nowrap;
}

.filter-block { margin-bottom: 22px; }

.export-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
}

.export-source-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.export-source-option input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent, #3b82f6);
}

.field-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.date-range {
  display: flex;
  align-items: center;
  gap: 10px;
}

.date-field { flex: 1; }

.date-field-label {
  display: block;
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-bottom: 5px;
}

.date-field input[type="date"] {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.875rem;
  color-scheme: dark;
  transition: border-color 0.15s;
}

.date-field input[type="date"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.date-separator { color: var(--text-dim); font-size: 1.1rem; margin-top: 18px; }

.export-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.export-actions .btn { width: 100%; }

.export-actions .btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.export-status {
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.export-status.hidden { display: none; }

.export-status.error {
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.35);
}

.export-status.ready {
  background: rgba(52, 211, 153, 0.1);
  border-color: rgba(52, 211, 153, 0.35);
}

.export-status-badge {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: lowercase;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.export-status-badge[data-status="building"] {
  color: var(--warning);
  border-color: rgba(251, 191, 36, 0.4);
}

.export-status-badge[data-status="ready"] {
  color: var(--success);
  border-color: rgba(52, 211, 153, 0.4);
}

.export-status-badge[data-status="error"] {
  color: var(--error);
  border-color: rgba(248, 113, 113, 0.4);
}

.export-status-spinner.hidden { display: none; }

.export-ready-actions,
.export-error-actions {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.export-ready-actions.hidden,
.export-error-actions.hidden { display: none; }

.export-ready-actions .btn,
.export-error-actions .btn {
  width: 100%;
  text-align: center;
  text-decoration: none;
}

.export-ready-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0;
}

.btn.is-loading {
  opacity: 0.85;
  pointer-events: none;
}

.btn-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: -2px;
  margin-right: 6px;
}

.btn.secondary .btn-spinner {
  border-color: rgba(125, 135, 154, 0.3);
  border-top-color: var(--text);
}

.queues-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 18px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.queues-meta strong { color: var(--text); font-weight: 600; }

#page-queues > .card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.queues-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.queue-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  flex-wrap: wrap;
}

.queue-item.status-ready { border-color: rgba(52, 211, 153, 0.35); }
.queue-item.status-error { border-color: rgba(248, 113, 113, 0.35); }
.queue-item.status-building { border-color: rgba(251, 191, 36, 0.35); }

.queue-item-main { flex: 1; min-width: 220px; }

.queue-item-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.queue-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.queue-item-error {
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--error);
}

.queue-item-actions { flex-shrink: 0; }
.queue-item-actions .btn { min-width: 120px; text-align: center; text-decoration: none; }

.export-status-header {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}

.export-status-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-light);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

.export-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.export-progress.hidden { display: none; }

.export-progress-track {
  flex: 1;
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
}

.export-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #a855f7);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.export-progress-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 36px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.export-preview .file-list {
  max-height: none;
  flex: 1;
  min-height: 0;
}

/* ─── Multi-select dropdown ─── */
.multiselect {
  position: relative;
}

.multiselect-empty {
  padding: 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--bg-input);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
}

.multiselect-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  padding: 11px 14px;
  font-family: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}

.multiselect-trigger:hover { border-color: var(--border-light); }

.multiselect.open .multiselect-trigger {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.multiselect-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  margin-right: 8px;
}

.multiselect-value.has-selection { color: var(--text); font-weight: 500; }

.multiselect-chevron {
  flex-shrink: 0;
  color: var(--text-dim);
  transition: transform 0.2s;
}

.multiselect.open .multiselect-chevron { transform: rotate(180deg); }

.multiselect-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  z-index: 100;
  overflow: hidden;
}

.multiselect.open .multiselect-dropdown { display: block; }

.multiselect-search-wrap {
  padding: 10px 10px 0;
}

.multiselect-search {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  padding: 8px 12px;
  font-family: inherit;
  font-size: 0.85rem;
}

.multiselect-search:focus {
  outline: none;
  border-color: var(--accent);
}

.multiselect-actions {
  display: flex;
  gap: 12px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent-hover);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  transition: opacity 0.15s;
}

.link-btn:hover { opacity: 0.75; }

.multiselect-options {
  max-height: 220px;
  overflow-y: auto;
  padding: 6px;
}

.multiselect-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: background 0.1s;
  user-select: none;
}

.multiselect-option:hover { background: var(--bg-hover); }

.multiselect-option input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0; height: 0;
}

.option-check {
  width: 18px; height: 18px;
  border: 2px solid var(--border-light);
  border-radius: 4px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  background: var(--bg-input);
}

.multiselect-option input:checked ~ .option-check {
  background: var(--accent);
  border-color: var(--accent);
}

.multiselect-option input:checked ~ .option-check::after {
  content: '';
  width: 5px; height: 9px;
  border: 2px solid white;
  border-top: none; border-left: none;
  transform: rotate(45deg) translateY(-1px);
}

.option-label {
  font-size: 0.875rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multiselect-option.network-parent .option-label {
  font-weight: 600;
}

.multiselect-option.network-child {
  padding-left: 28px;
}

.multiselect-option.network-child .option-label {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.multiselect-option input:indeterminate ~ .option-check {
  background: var(--accent);
  border-color: var(--accent);
  opacity: 0.65;
}

.multiselect-option input:indeterminate ~ .option-check::after {
  content: '';
  width: 8px;
  height: 2px;
  background: white;
  border: none;
  transform: none;
}

.multiselect-no-results {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ─── Forms ─── */
.form-group { margin-bottom: 18px; }

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  margin-bottom: 7px;
  color: var(--text-muted);
}

.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 13px;
  font-family: inherit;
  font-size: 0.875rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group textarea { font-family: var(--mono); font-size: 0.82rem; resize: vertical; }

.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 6px; }
.desc { color: var(--text-muted); margin-bottom: 22px; font-size: 0.875rem; line-height: 1.6; }

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
}

.btn.primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 2px 12px var(--accent-glow);
}

.btn.primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--accent-glow);
}

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

.btn.secondary:hover { background: var(--bg-hover); border-color: var(--border-light); }
.btn.large { width: 100%; padding: 14px; margin-top: 18px; }
.btn.small { padding: 7px 14px; font-size: 0.8rem; }
.btn-row { display: flex; gap: 10px; }

.badge {
  background: var(--accent-soft);
  color: var(--accent-hover);
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid rgba(108, 123, 247, 0.2);
}

/* ─── File list ─── */
.file-list {
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
}

.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  transition: background 0.1s;
}

.file-item:last-child { border-bottom: none; }
.file-item:hover { background: var(--bg-hover); }

.file-item-icon { font-size: 1rem; opacity: 0.6; flex-shrink: 0; }

.file-item-info { flex: 1; min-width: 0; }

.file-item-name {
  display: block;
  font-weight: 500;
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-item-path {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-item-size {
  color: var(--text-muted);
  font-size: 0.78rem;
  flex-shrink: 0;
  font-family: var(--mono);
}

.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.empty-icon { font-size: 2rem; margin-bottom: 12px; opacity: 0.5; }
.empty-state p { max-width: 280px; margin: 0 auto; line-height: 1.6; }

/* ─── Files browser ─── */
.files-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.files-toolbar-actions {
  margin-left: auto;
}

.files-download-status {
  margin-bottom: 16px;
}

.file-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.file-preview-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.tabs-inline { display: flex; gap: 6px; }

.tab, .settings-tab {
  padding: 8px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  transition: all 0.15s;
}

.tab.active, .settings-tab.active {
  background: var(--accent-soft);
  border-color: rgba(108, 123, 247, 0.4);
  color: var(--accent-hover);
}

.breadcrumb { font-size: 0.82rem; color: var(--text-muted); font-family: var(--mono); }
.breadcrumb span { cursor: pointer; color: var(--accent-hover); }
.breadcrumb span:hover { text-decoration: underline; }

.files-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.file-tree {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  overflow-y: auto;
  min-height: 0;
  height: 100%;
}

.tree-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px;
  cursor: pointer;
  font-size: 0.84rem;
  border-bottom: 1px solid rgba(37, 45, 61, 0.6);
  transition: background 0.1s;
}

.tree-item:hover { background: var(--bg-hover); }
.tree-item.active { background: var(--accent-soft); }
.tree-icon { opacity: 0.65; font-size: 0.9rem; }

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

.tree-item-download {
  flex-shrink: 0;
  margin-left: auto;
  padding: 2px 8px;
  font-size: 0.72rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}

.tree-item:hover .tree-item-download { opacity: 1; }

.tree-item-download:hover {
  color: var(--accent-hover);
  border-color: rgba(108, 123, 247, 0.4);
}

.file-preview {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.file-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  font-weight: 500;
}

.file-meta { color: var(--text-muted); font-size: 0.78rem; font-family: var(--mono); }

.code-view {
  flex: 1;
  overflow: auto;
  padding: 18px;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  color: #b8c0cc;
}

/* ─── Process ─── */
#page-process > .grid-2 {
  flex: 1;
  min-height: 0;
  overflow: auto;
  align-content: start;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 10px;
}

.info-item {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
}

.info-label {
  display: block;
  font-size: 0.68rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.info-value { display: block; margin-top: 5px; font-size: 0.875rem; word-break: break-all; }

.steps { padding-left: 20px; color: var(--text-muted); font-size: 0.875rem; line-height: 1.7; }
.steps li { margin-bottom: 10px; }
.steps strong { color: var(--text); }

/* ─── Settings ─── */
#page-settings > .card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.settings-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.settings-panel { display: none; }
.settings-panel.active {
  display: block;
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.field-hint {
  margin: 6px 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.45;
}
.field-hint code {
  font-size: 0.76rem;
  background: var(--bg-input);
  padding: 1px 5px;
  border-radius: 3px;
}

.day-split-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: none;
}
.day-split-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  cursor: pointer;
}
.day-split-name {
  font-weight: 600;
  font-size: 0.9rem;
}
.day-split-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.day-split-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent, #3b82f6);
}

.stack-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.stack-stat {
  min-width: 76px;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stack-stat b { font-size: 1.05rem; line-height: 1.2; }
.stack-stat span { font-size: 0.72rem; color: var(--text-muted); }
.stack-filters { margin-bottom: 8px; }
.table-scroll {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
}
#stack-table .mono,
.stack-table .mono {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#page-stack > .stack-page-card,
#page-ggconv > .stack-page-card {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.stack-page-card { display: flex; flex-direction: column; gap: 0; }
.stack-page-header { margin-bottom: 0.5rem; flex-shrink: 0; }
.stack-tabs {
  margin: 0 0 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.stack-panel { display: none; }
.stack-panel.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.stack-panel.active[data-stack-panel="results"],
.stack-panel.active[data-ggconv-panel="files"] {
  overflow: hidden;
}
.stack-panel-lead { margin-bottom: 1.25rem; max-width: 52rem; }

.ggconv-queue-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 0.5rem;
}
.ggconv-q-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--card-bg, transparent);
}
.ggconv-q-card .q-label {
  font-size: 0.8rem;
  opacity: 0.7;
  margin-bottom: 4px;
}
.ggconv-q-card .q-value {
  font-size: 1.35rem;
  font-weight: 600;
}
.ggconv-q-card.q-warn .q-value { color: #c07800; }
.ggconv-q-card.q-bad .q-value { color: #c44; }
.ggconv-q-card.q-ok .q-value { color: #2a8; }
.ggconv-scanner-box {
  margin-top: 1rem;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.stack-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  flex-shrink: 0;
}

.stack-filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px 14px;
  margin-bottom: 0.75rem;
  align-items: end;
  flex-shrink: 0;
}
.stack-filters-grid .form-group { margin: 0; }
.stack-filter-check { display: flex; align-items: flex-end; padding-bottom: 6px; }
.stack-filters-actions {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
  flex-shrink: 0;
}

.stack-table-shell {
  position: relative;
  flex: 1;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.stack-table-loading {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 12, 0.55);
  backdrop-filter: blur(1px);
  border-radius: 8px;
}
.stack-table-loading[hidden] { display: none !important; }
.stack-table-loading-inner {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--bg-card, #151515);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.9rem;
}
.stack-table-loading-inner .btn-spinner {
  width: 18px;
  height: 18px;
  margin-right: 0;
}

.stack-table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 0.75rem;
  flex-shrink: 0;
}
.stack-page-size-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.stack-page-size-group label {
  margin: 0;
  white-space: nowrap;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.stack-page-size-group select {
  min-width: 72px;
}

.stack-table { table-layout: fixed; width: 100%; }
.stack-table th {
  position: relative;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stack-table th.sortable { cursor: pointer; }
.stack-table th.sortable:hover { color: var(--accent, #60a5fa); }
.stack-table th.sort-asc::after,
.stack-table th.sort-desc::after {
  content: '';
  display: inline-block;
  margin-left: 6px;
  border: 4px solid transparent;
  vertical-align: middle;
}
.stack-table th.sort-asc::after {
  border-bottom-color: currentColor;
  margin-top: -4px;
}
.stack-table th.sort-desc::after {
  border-top-color: currentColor;
  margin-bottom: -4px;
}
.stack-table .col-resizer {
  position: absolute;
  top: 0;
  right: 0;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
  z-index: 2;
}
.stack-table .col-resizer:hover,
.stack-table.resizing .col-resizer { background: rgba(96, 165, 250, 0.35); }
.stack-table td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stack-table .stack-col-dl {
  text-align: center;
  width: 56px;
}
.stack-dl-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  padding: 4px 8px;
}
.stack-dl-btn:hover {
  color: var(--accent, #60a5fa);
  border-color: var(--accent, #60a5fa);
}

.stack-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.stack-switch input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent, #3b82f6);
}
.stack-switch-lg {
  font-size: 0.95rem;
  color: var(--text);
  font-weight: 600;
  margin-bottom: 1rem;
}

.stack-settings-grid {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(260px, 1.1fr);
  gap: 1.5rem 2rem;
  align-items: start;
}
@media (max-width: 900px) {
  .stack-settings-grid { grid-template-columns: 1fr; }
}
.stack-settings-rooms h3 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
}
.stack-room-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 420px;
  overflow: auto;
  padding-right: 4px;
  margin-top: 0.75rem;
  width: 100%;
}
.stack-room-list .day-split-row {
  margin: 0;
  width: 100%;
}

.stack-help {
  max-width: 44rem;
}
.stack-help h3 {
  margin: 1.25rem 0 0.5rem;
  font-size: 1rem;
}
.stack-help h3:first-child { margin-top: 0; }
.stack-help .steps { margin-bottom: 0.25rem; }

.export-danger-modal {
  max-width: 420px;
  padding: 20px 22px 18px;
}
.export-danger-text {
  margin: 12px 0 18px;
  color: var(--text-secondary, #6b7280);
  font-size: 0.92rem;
  line-height: 1.45;
}
.export-danger-actions {
  justify-content: flex-end;
  gap: 10px;
}
#export-danger-reasons {
  white-space: pre-line;
  margin-top: 6px;
}

.file-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
}
.file-modal-overlay[hidden] { display: none !important; }
.file-modal {
  width: min(960px, 100%);
  max-height: min(86vh, 900px);
  display: flex;
  flex-direction: column;
  background: var(--bg-card, #151515);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
.file-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.file-modal-title {
  font-weight: 600;
  font-size: 0.95rem;
  word-break: break-all;
}
.file-modal-meta {
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.file-modal-body {
  margin: 0;
  padding: 16px 18px;
  overflow: auto;
  flex: 1;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg-input, #0f0f0f);
  color: var(--text);
}
.stack-path-link {
  color: var(--accent, #60a5fa);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  text-align: left;
  max-width: 100%;
}
.stack-path-link:hover { opacity: 0.85; }

.rule-row {
  display: grid;
  grid-template-columns: 1fr 140px 1fr 40px;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}

.rule-row input, .rule-row select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  padding: 9px 11px;
  font-size: 0.84rem;
}

.rule-row button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--error);
  border-radius: var(--radius-xs);
  cursor: pointer;
  padding: 8px;
  font-size: 1rem;
  transition: background 0.15s;
}

.rule-row button:hover { background: rgba(248, 113, 113, 0.1); }

.network-row {
  display: grid;
  grid-template-columns: minmax(140px, 200px) 1fr 40px;
  gap: 8px;
  margin-bottom: 12px;
  align-items: start;
}

.network-row > .network-name {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  padding: 9px 11px;
  font-size: 0.84rem;
  width: 100%;
}

.network-row .network-rooms-select {
  position: relative;
  min-width: 0;
}

.network-row .network-rooms-select .multiselect-trigger {
  width: 100%;
  min-height: 38px;
}

.network-row .rule-remove {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--error);
  border-radius: var(--radius-xs);
  cursor: pointer;
  padding: 8px;
  font-size: 1rem;
  transition: background 0.15s;
  height: 38px;
}

.network-row .rule-remove:hover { background: rgba(248, 113, 113, 0.1); }

.network-rooms-hint {
  grid-column: 1 / -1;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: -4px;
}

/* ─── Logs ─── */
.logs-toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.logs-toolbar select, .logs-toolbar input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 13px;
  font-size: 0.84rem;
}

.logs-toolbar input { flex: 1; min-width: 160px; }

.log-view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: none;
  font-family: var(--mono);
  font-size: 0.77rem;
}

.log-line {
  padding: 7px 14px;
  border-bottom: 1px solid rgba(37, 45, 61, 0.5);
  line-height: 1.55;
  word-break: break-word;
}

.log-line.level-ERROR, .log-line.level-EXCEPT { background: rgba(248, 113, 113, 0.07); }
.log-line.level-WARN { background: rgba(251, 191, 36, 0.05); }
.log-line.level-DEBUG { opacity: 0.7; }

.logs-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.logs-pagination-info {
  font-size: 0.84rem;
  color: var(--text-muted);
}

.logs-pagination-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logs-page-label {
  font-size: 0.84rem;
  color: var(--text-muted);
  min-width: 90px;
  text-align: center;
}

/* ─── Toast ─── */
.toast-container {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 22px;
  box-shadow: var(--shadow);
  font-size: 0.875rem;
  animation: slideIn 0.3s ease;
  max-width: 380px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--error); }
.toast.info { border-left: 3px solid var(--info); }

@keyframes slideIn {
  from { transform: translateX(110%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ─── Login ─── */
.login-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(8, 10, 16, 0.85);
  backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-overlay.visible { display: flex; }

.app.blurred { filter: blur(6px); pointer-events: none; user-select: none; }

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.login-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 24px;
  letter-spacing: -0.02em;
}

.login-error {
  color: var(--error);
  font-size: 0.85rem;
  min-height: 20px;
  margin-bottom: 8px;
}

.login-docs-link {
  display: block;
  text-align: center;
  margin-top: 20px;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}

.login-docs-link:hover { color: var(--accent-hover); }

.sidebar-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.sidebar-user-name {
  font-size: 0.82rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-xs);
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 0.9rem;
  flex-shrink: 0;
  transition: all 0.15s;
}

.btn-logout:hover {
  border-color: var(--error);
  color: var(--error);
  background: rgba(248, 113, 113, 0.08);
}

.sidebar-docs {
  display: block;
  text-align: center;
  margin-top: 10px;
  font-size: 0.75rem;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.15s;
}

.sidebar-docs:hover { color: var(--accent-hover); }

.lk-unmatched-meta {
  flex-shrink: 0;
  margin: 0 0 10px;
  padding: 0 4px;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.lk-match-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.lk-match-tab {
  background: transparent;
  border: 1px solid var(--border, #333);
  color: var(--text-dim);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.82rem;
  cursor: pointer;
}
.lk-match-tab.active {
  border-color: var(--accent, #3b82f6);
  color: var(--text);
  background: rgba(59, 130, 246, 0.12);
}
.lk-match-hint {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin: 0 0 10px;
  flex-shrink: 0;
}
.preview-panel[data-preview-panel="lk-unmatched"] {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  padding: 12px 16px 16px;
}
.preview-panel[data-preview-panel="lk-unmatched"].active {
  display: flex;
}
.lk-unmatched-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.lk-unmatched-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.lk-unmatched-table th,
.lk-unmatched-table td {
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border, #333);
}
.lk-unmatched-table th { opacity: 0.7; font-weight: 600; position: sticky; top: 0; background: var(--card, #1a1a1a); }
.lk-unmatched-table tr.lk-row-bad td { color: #f87171; }
.lk-unmatched-table tr.lk-row-warn td { color: #fbbf24; }
.lk-unmatched-table tr.lk-row-ok td { color: #4ade80; }
.lk-unmatched-table tr.lk-row-info td { color: #60a5fa; }

/* ─── Responsive ─── */
@media (max-width: 1200px) {
  .export-layout { grid-template-columns: 1fr; }
  .export-filters { position: static; }
}

@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .files-layout { grid-template-columns: 1fr; }
}

/* ─── Мобильное меню (off-canvas) ─── */
.nav-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 25;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.nav-toggle:hover { background: var(--bg-hover); }
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 19;
  background: rgba(5, 7, 12, 0.6);
  backdrop-filter: blur(2px);
}
.sidebar-backdrop[hidden] { display: none; }

@media (max-width: 900px) {
  .sidebar {
    width: min(86vw, var(--sidebar-width));
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    z-index: 20;
    overflow-y: auto;
  }
  body.nav-open .sidebar { transform: translateX(0); box-shadow: var(--shadow); }
  body.nav-open { overflow: hidden; }
  .content { margin-left: 0; width: 100%; padding: 56px 14px 16px; }
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
}

@media (max-width: 560px) {
  .content { padding: 52px 10px 12px; }
  .btn { padding-left: 12px; padding-right: 12px; }
  .files-toolbar-actions { width: 100%; }
}

/* Широкие таблицы прокручиваются внутри блока, а не ломают страницу */
.stack-table-wrap, .table-wrap, .ggconv-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.stack-table, .ggconv-table, .lk-unmatched-table { min-width: 100%; }

/* ─── Очереди: фильтр по сервису, бейджи, предупреждение ─── */
.queue-filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 14px; }
.chip {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.chip:hover { background: var(--bg-hover); color: var(--text); }
.chip.active {
  background: var(--accent-soft);
  border-color: rgba(108, 123, 247, 0.5);
  color: var(--accent-hover);
}
.queues-warn {
  margin: 0 0 12px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.08);
  color: var(--warning);
  font-size: 0.82rem;
}
.svc-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  background: var(--bg-input);
}
.svc-badge.svc-sorter { color: #93c5fd; border-color: rgba(147, 197, 253, 0.35); }
.svc-badge.svc-ggconv { color: #c4b5fd; border-color: rgba(196, 181, 253, 0.35); }
.svc-badge.svc-stack_bb { color: #6ee7b7; border-color: rgba(110, 231, 183, 0.35); }

/* ─── Файловый браузер: чекбоксы выбора ─── */
.files-toolbar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.files-select-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.files-selected-count { font-size: 0.8rem; color: var(--accent-hover); font-variant-numeric: tabular-nums; }
.tree-check {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}
.tree-item.selected { background: var(--accent-soft); }
@media (hover: none) {
  .tree-item-download { opacity: 1; }
}
