/**
 * Savage Design System - Theme CSS
 * Centralized styling for all frontend tools
 */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700;800&family=Geist+Mono:wght@400;500;600;700&family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  /* Backgrounds */
  --bg-primary: #0f0f11;
  --bg-secondary: #161618;
  --bg-card: #1c1c1e;
  --bg-input: rgba(13, 15, 19, 0.96);
  --portal-glass-bg:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.07) 0%,
      rgba(255, 255, 255, 0.038) 42%,
      rgba(255, 255, 255, 0.018) 100%
    ),
    linear-gradient(120deg, rgba(255, 255, 255, 0.028) 0%, transparent 34%),
    radial-gradient(920px 420px at 16% -14%, rgba(99, 102, 241, 0.08), transparent 62%),
    radial-gradient(820px 380px at 84% -16%, rgba(14, 165, 233, 0.07), transparent 64%),
    linear-gradient(180deg, rgba(15, 15, 17, 0.96) 0%, rgba(13, 13, 15, 0.99) 100%);

  /* Text */
  --text-primary: #f1f3f5;
  --text-secondary: #d0d6de;
  --text-muted: #a1aab5;
  --text-dim: #757e89;

  /* Borders */
  --border-primary: rgba(255, 255, 255, 0.11);
  --border-secondary: rgba(255, 255, 255, 0.16);
  --border-subtle: rgba(255, 255, 255, 0.09);
  --border-input: rgba(255, 255, 255, 0.2);
  --border-hover: rgba(255, 255, 255, 0.3);

  /* Accents */
  --accent-success: #34d399;
  --accent-danger: #f87171;
  --accent-info: #60a5fa;
  --accent-blue: #60a5fa;
  --accent-warning: #fbbf24;
  --accent-purple: #a78bfa;
  --accent-cyan: #22d3ee;

  /* Semantic aliases (backward-compat shims — prefer canonical names above) */
  --card-bg: var(--bg-card);
  --text-accent: var(--accent-blue);

  /* Header (deprecated — kept for backward compat) */
  --header-height: 48px;
  --header-bg: rgba(23, 24, 26, 0.74);
  --header-border: rgba(255, 255, 255, 0.12);

  /* Layout */
  --content-max-width: 1240px;
  --content-padding: 28px;
  --border-radius: 8px;
  --border-radius-lg: 12px;
  --border-radius-sm: 6px;
  --control-height: 34px;
  --control-height-sm: 30px;
  --control-radius: 8px;

  /* Sidebar Layout (primary layout system) */
  --sidebar-width-collapsed: 48px;
  --sidebar-width-expanded: 240px;
  --topbar-height: 48px;

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

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(2, 3, 6, 0.45);
  --shadow-md: 0 8px 24px rgba(2, 3, 6, 0.42);
  --shadow-lg: 0 16px 42px rgba(2, 3, 6, 0.55);

  /* Portal header copy visibility controls */
  --portal-header-title-display: block;
  --portal-header-subtitle-display: none;
}

/* Desktop shell (Electron): allow macOS vibrancy to show through */
:root.is-desktop-shell {
  --bg-primary: rgba(8, 10, 12, 0.14);
  --bg-secondary: rgba(14, 16, 18, 0.55);
}

/* ── Light Mode (Apple-inspired) ──────────────────── */
html[data-theme='light'] {
  /* Warm off-white backgrounds — softer than clinical white */
  --bg-primary: #f2f1f6;
  --bg-secondary: #e8e7ed;
  --bg-card: #ffffff;
  --bg-input: rgba(120, 120, 128, 0.08);

  /* Apple typography hierarchy */
  --text-primary: #1d1d1f;
  --text-secondary: rgba(60, 60, 67, 0.85);
  --text-muted: rgba(60, 60, 67, 0.6);
  --text-dim: rgba(60, 60, 67, 0.36);

  /* Minimal borders — Apple prefers shadow separation over lines */
  --border-primary: rgba(0, 0, 0, 0.06);
  --border-secondary: rgba(0, 0, 0, 0.1);
  --border-subtle: rgba(0, 0, 0, 0.04);
  --border-input: rgba(0, 0, 0, 0.12);
  --border-hover: rgba(0, 0, 0, 0.2);

  /* Soft, diffused shadows — the Apple signature */
  --shadow-sm: 0 0.5px 1px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 20px rgba(0, 0, 0, 0.06), 0 20px 48px rgba(0, 0, 0, 0.08);

  /* Apple system accents — slightly deeper for light backgrounds */
  --accent-info: #007aff;
  --accent-blue: #007aff;
  --accent-success: #34c759;
  --accent-danger: #ff3b30;
  --accent-warning: #ff9500;
  --accent-purple: #af52de;
  --accent-cyan: #5ac8fa;

  /* Warm tinted background */
  --portal-glass-bg: #f2f1f6;

  /* Header overrides */
  --header-bg: rgba(242, 241, 246, 0.8);
  --header-border: rgba(0, 0, 0, 0.08);
}

/* Light mode: Apple-style element refinements */
html[data-theme='light'] ::selection {
  color: #fff;
  background: rgba(0, 122, 255, 0.3);
}

html[data-theme='light'] .card {
  border-color: rgba(0, 0, 0, 0.04);
  box-shadow:
    0 0.5px 0 rgba(0, 0, 0, 0.04),
    0 2px 8px rgba(0, 0, 0, 0.04),
    0 6px 20px rgba(0, 0, 0, 0.03);
}

html[data-theme='light'] .btn-primary {
  background: linear-gradient(180deg, #3d8c5c 0%, #2d7a4a 100%);
  border: none;
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.12),
    0 4px 12px rgba(45, 122, 74, 0.2);
  color: #fff;
}

html[data-theme='light'] .btn-secondary {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-primary);
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 0.5px 1px rgba(0, 0, 0, 0.06);
}

html[data-theme='light'] .btn-secondary:hover {
  background: rgba(0, 0, 0, 0.07);
  border-color: rgba(0, 0, 0, 0.16);
}

html[data-theme='light'] tr:hover td {
  background: rgba(0, 0, 0, 0.02);
}

html[data-theme='light'] .result-link:hover {
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.14);
}

html[data-theme='light'] .toggle-group {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.06);
}

html[data-theme='light'] .clear-logs:hover {
  background: rgba(0, 0, 0, 0.04);
}

html[data-theme='light'] .form-input:focus,
html[data-theme='light'] .form-select:focus {
  border-color: #007aff;
  box-shadow: 0 0 0 3.5px rgba(0, 122, 255, 0.16);
}

html[data-theme='light'] .badge-success {
  background: rgba(52, 199, 89, 0.12);
}
html[data-theme='light'] .badge-danger {
  background: rgba(255, 59, 48, 0.1);
}
html[data-theme='light'] .badge-warning {
  background: rgba(255, 149, 0, 0.1);
}
html[data-theme='light'] .badge-info {
  background: rgba(0, 122, 255, 0.1);
}

html[data-theme='light'] .status.success {
  background: rgba(52, 199, 89, 0.1);
  border-color: rgba(52, 199, 89, 0.2);
}
html[data-theme='light'] .status.error {
  background: rgba(255, 59, 48, 0.08);
  border-color: rgba(255, 59, 48, 0.18);
}
html[data-theme='light'] .status.info {
  background: rgba(0, 122, 255, 0.08);
  border-color: rgba(0, 122, 255, 0.16);
}

/* ── Savage Mode — pure black, no glass, vivid accents ── */
html[data-theme='savage'] {
  --bg-primary: #000000;
  --bg-secondary: #0a0a0a;
  --bg-card: #000000;
  --bg-input: rgba(0, 0, 0, 0.98);
  --portal-glass-bg: #000000;
  --border-primary: rgba(255, 255, 255, 0.09);
  --border-secondary: rgba(255, 255, 255, 0.14);
  --border-subtle: rgba(255, 255, 255, 0.07);

  /* Maximum contrast text */
  --text-primary: #ffffff;
  --text-secondary: #e5e7eb;

  /* Full-saturation accents (dark mode uses softened pastels) */
  --accent-purple: #a855f7;
  --accent-success: #22c55e;
  --accent-danger: #ef4444;
  --accent-info: #3b82f6;
  --accent-blue: #3b82f6;
  --accent-warning: #f59e0b;
  --accent-cyan: #06b6d4;
}

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

/* Guardrail: locks the viewport height baseline so fixed overlays (e.g. the
   typeform wizard) always get a stable 100dvh reference, including on mobile
   where address-bar chrome can otherwise shift the layout. */
html {
  height: 100%;
  background: var(--portal-glass-bg, var(--bg-primary));
  background-color: var(--bg-primary);
  overscroll-behavior: none;
}

body {
  font-family: var(--font-family);
  background: var(--portal-glass-bg, var(--bg-primary));
  background-color: var(--bg-primary);
  background-repeat: no-repeat;
  background-size: cover;
  color: var(--text-secondary);
  min-height: 100vh;
  line-height: 1.5;
  letter-spacing: 0.005em;
  overscroll-behavior: none;
}

:root.is-desktop-shell,
:root.is-desktop-shell body,
:root.is-desktop-shell .app-shell,
:root.is-desktop-shell .app-body,
:root.is-desktop-shell .main-content,
:root.is-desktop-shell .main-content .container,
:root.is-desktop-shell .app-shell .main {
  background: transparent !important;
  background-image: none !important;
}

:root.is-desktop-shell body::before {
  content: none;
}

::selection {
  color: #f5f5f5;
  background: rgba(255, 255, 255, 0.22);
}

/* ── DEPRECATED: Old top-header styles (kept for backward compat) ── */
/* These are overridden by layout.css when the sidebar layout is active */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--content-padding);
  z-index: 100;
}

.header-inner {
  width: 100%;
  max-width: var(--content-max-width);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-logo {
  height: 112px;
  width: auto;
  display: block;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 32px;
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.875rem;
  padding-bottom: 4px;
  border-bottom: 2px solid transparent;
  transition:
    color 0.2s,
    border-color 0.2s;
}

.nav-link:hover {
  color: var(--text-secondary);
}

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

/* Mode Toggle (deprecated) */
.mode-toggle {
  display: none;
}

.mode-toggle-btn {
  display: none;
}

/* Submenu (deprecated) */
:root {
  --submenu-height: 48px;
}

.submenu {
  display: none;
}

/* Main Content — works with both old and new layout */
.main {
  min-height: 100vh;
  padding: var(--content-padding);
}

/* When in app-shell (new layout), .main has no extra top padding */
.app-shell .main {
  padding-top: 0;
  min-height: auto;
}

.container {
  width: 100%;
  max-width: var(--content-max-width);
  margin: 0 auto;
}

/* Page Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 14px;
}

.page-title {
  color: var(--text-primary);
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 4px;
  letter-spacing: -0.012em;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.page-header .page-title,
.tool-header .page-title {
  display: var(--portal-header-title-display);
}

.page-header .page-subtitle,
.tool-header .page-subtitle {
  display: var(--portal-header-subtitle-display);
}

.header-badge {
  padding: 8px 16px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.header-badge.blue {
  background: linear-gradient(135deg, var(--accent-info), var(--accent-purple));
  color: var(--bg-primary);
}

.header-badge.green {
  background: linear-gradient(135deg, var(--accent-success), var(--accent-cyan));
  color: var(--bg-primary);
}

.header-badge.orange {
  background: linear-gradient(135deg, var(--accent-warning), var(--accent-danger));
  color: var(--bg-primary);
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle, var(--border-secondary));
  border-radius: var(--border-radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
}

.card-header {
  margin-bottom: 20px;
}

.card-title {
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 600;
}

.card-subtitle {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 4px;
}

/* Form Elements */
.form-group {
  margin-bottom: 20px;
}

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

.form-input,
.form-select {
  width: 100%;
  min-height: var(--control-height);
  padding: 0 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--control-radius);
  color: var(--text-secondary);
  font-size: 0.84rem;
  font-weight: 450;
  line-height: 1.2;
  font-family: var(--font-family);
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--accent-info);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.18);
}

.form-input::placeholder {
  color: var(--text-dim);
}

.form-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23737373'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 18px;
  padding-right: 34px;
}

.form-select option {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--control-height);
  padding: 0 14px;
  border-radius: var(--control-radius);
  font-size: 0.84rem;
  font-weight: 560;
  letter-spacing: -0.005em;
  font-family: var(--font-family);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  border: none;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(90deg, rgba(89, 148, 110, 0.95), rgba(58, 104, 93, 0.95));
  border: 1px solid rgba(151, 203, 175, 0.35);
  color: #ecfff6;
  box-shadow:
    0 6px 16px rgba(29, 49, 38, 0.4),
    inset 0 1px 0 rgba(228, 255, 242, 0.2);
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: rgba(13, 19, 27, 0.72);
  color: var(--text-secondary);
  border: 1px solid var(--border-secondary);
  box-shadow: inset 0 1px 0 rgba(214, 232, 255, 0.06);
}

.btn-secondary:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.btn-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(10, 10, 10, 0.3);
  border-top-color: var(--bg-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Status Messages */
.status {
  padding: 12px 16px;
  border-radius: var(--border-radius);
  font-size: 0.85rem;
  margin-bottom: 20px;
  display: none;
}

.status.active {
  display: block;
}

.status.success {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: var(--accent-success);
}

.status.error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--accent-danger);
}

.status.info {
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: var(--accent-info);
}

.status a {
  color: inherit;
  font-weight: 500;
}

/* Toggle Switch */
.toggle-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-secondary);
  border-radius: var(--border-radius);
}

.toggle-info {
  flex: 1;
}

.toggle-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
}

.toggle-desc {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 2px;
}

.toggle-switch {
  position: relative;
  width: 48px;
  height: 26px;
}

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

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-secondary);
  transition: 0.3s;
  border-radius: 26px;
}

.toggle-slider:before {
  position: absolute;
  content: '';
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-primary);
  transition: 0.3s;
  border-radius: 50%;
}

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

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

/* Activity Log */
.logs-card {
  margin-top: 24px;
}

.logs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.logs-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

.error-badge {
  background: var(--accent-danger);
  color: white;
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 9999px;
  font-weight: 600;
}

.error-badge.hidden {
  display: none;
}

.clear-logs {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition:
    color 0.2s,
    background-color 0.2s;
}

.clear-logs:hover {
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
}

.logs-list {
  max-height: 200px;
  overflow-y: auto;
  font-size: 0.75rem;
}

.logs-list::-webkit-scrollbar {
  width: 6px;
}

.logs-list::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

.logs-list::-webkit-scrollbar-thumb {
  background: var(--border-secondary);
  border-radius: 3px;
}

.logs-empty {
  color: var(--text-dim);
  font-style: italic;
  padding: 16px;
  text-align: center;
}

.log-entry {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-primary);
}

.log-entry:last-child {
  border-bottom: none;
}

.log-time {
  color: var(--text-dim);
  font-family: var(--font-family-mono);
  flex-shrink: 0;
}

.log-level {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

.log-level.info {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-info);
}

.log-level.success {
  background: rgba(34, 197, 94, 0.15);
  color: var(--accent-success);
}

.log-level.warn {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-warning);
}

.log-level.error {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-danger);
}

.log-message {
  color: var(--text-secondary);
  flex: 1;
}

/* Progress Bar */
.progress-container {
  margin-top: 20px;
  display: none;
}

.progress-container.active {
  display: block;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.progress-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.progress-percent {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.progress-bar {
  width: 100%;
  height: 8px;
  background-color: var(--border-secondary);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-info), var(--accent-purple));
  border-radius: 4px;
  transition: width 0.3s ease;
  width: 0%;
}

.progress-stage {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.stage-icon {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: pulse 1.5s ease-in-out infinite;
}

.stage-icon.crawling {
  background-color: var(--accent-info);
}
.stage-icon.exporting {
  background-color: var(--accent-purple);
}
.stage-icon.uploading {
  background-color: var(--accent-success);
}
.stage-icon.complete {
  background-color: var(--accent-success);
  animation: none;
}

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

.progress-details {
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.progress-details span {
  display: inline-block;
  margin-right: 16px;
}

/* Results */
.results-panel {
  display: none;
}

.results-panel.active {
  display: block;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.result-item {
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: var(--border-radius-sm);
}

.result-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.result-value {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.result-value.blue {
  color: var(--accent-info);
}
.result-value.purple {
  color: var(--accent-purple);
}
.result-value.green {
  color: var(--accent-success);
}
.result-value.orange {
  color: var(--accent-warning);
}

.result-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-secondary);
  border-radius: var(--border-radius);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  transition:
    border-color 0.2s,
    background-color 0.2s;
}

.result-link:hover {
  border-color: var(--border-hover);
  background: rgba(255, 255, 255, 0.02);
}

.result-link svg {
  width: 18px;
  height: 18px;
  color: var(--text-dim);
}

/* Divider */
.divider {
  display: flex;
  align-items: center;
  margin: 24px 0;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background-color: var(--border-secondary);
}

.divider span {
  padding: 0 16px;
  color: var(--text-dim);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Section Header */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.section-title {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Layout Grid */
.layout-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
}

.layout-grid.single {
  grid-template-columns: 1fr;
  max-width: 600px;
  margin: 0 auto;
}

/* Client Dropdown (header) */
.client-dropdown {
  background: var(--bg-secondary);
  border: 1px solid var(--border-input);
  border-radius: var(--border-radius);
  padding: 8px 16px;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-family: var(--font-family);
  cursor: pointer;
  transition: border-color 0.2s;
}

.client-dropdown:hover,
.client-dropdown:focus {
  border-color: var(--border-hover);
  outline: none;
}

/* Metric Cards (dashboards) */
.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-secondary);
  border-radius: var(--border-radius);
  padding: 20px;
}

.metric-value {
  color: var(--text-primary);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
}

.metric-label {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 4px;
}

.metric-change {
  font-size: 0.75rem;
  font-weight: 500;
  margin-top: 8px;
}

.metric-change.positive {
  color: var(--accent-success);
}

.metric-change.negative {
  color: var(--accent-danger);
}

/* Grid Layout (dashboards) */
.grid {
  display: grid;
  gap: 16px;
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}
.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}
.grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1200px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Tables */
.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: 12px 16px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-secondary);
}

td {
  padding: 12px 16px;
  color: var(--text-secondary);
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border-primary);
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-success {
  background: rgba(34, 197, 94, 0.15);
  color: var(--accent-success);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-danger);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-warning);
}

.badge-info {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-info);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border-secondary);
  margin-bottom: 24px;
}

.tab {
  padding: 12px 16px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition:
    color 0.2s,
    border-color 0.2s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.tab:hover {
  color: var(--text-secondary);
}

.tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--text-primary);
}

/* Chart Container */
.chart-container {
  position: relative;
  height: 300px;
}

/* Loading State */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  color: var(--text-muted);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state-title {
  color: var(--text-secondary);
  font-size: 1.125rem;
  font-weight: 500;
  margin-bottom: 8px;
}

/* Utility Classes */
.text-success {
  color: var(--accent-success);
}
.text-danger {
  color: var(--accent-danger);
}
.text-warning {
  color: var(--accent-warning);
}
.text-info {
  color: var(--accent-info);
}
.text-muted {
  color: var(--text-muted);
}
.text-primary {
  color: var(--text-primary);
}

.mt-1 {
  margin-top: 4px;
}
.mt-2 {
  margin-top: 8px;
}
.mt-3 {
  margin-top: 16px;
}
.mt-4 {
  margin-top: 24px;
}

.mb-1 {
  margin-bottom: 4px;
}
.mb-2 {
  margin-bottom: 8px;
}
.mb-3 {
  margin-bottom: 16px;
}
.mb-4 {
  margin-bottom: 24px;
}

.flex {
  display: flex;
}
.flex-col {
  flex-direction: column;
}
.items-center {
  align-items: center;
}
.justify-between {
  justify-content: space-between;
}
.gap-2 {
  gap: 8px;
}
.gap-3 {
  gap: 16px;
}
.gap-4 {
  gap: 24px;
}

/* Client context — wider container for dashboards */
body.mode-client .container,
body.mode-client .header-inner,
body.has-client .container {
  max-width: 1500px;
}

/* Responsive */
@media (max-width: 1024px) {
  .layout-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .header {
    padding: 0 16px;
  }

  .header-nav {
    gap: 16px;
  }

  .nav-link {
    font-size: 0.8rem;
  }

  .form-row,
  .results-grid {
    grid-template-columns: 1fr;
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .main {
    padding: calc(var(--header-height) + 16px) 16px 16px;
  }
}
