/*
 * RagGo Web UI - Branding Stylesheet
 *
 * Implements the RagGo brand design language:
 * - Warm cream palette (#f2ece0 background, #bf4217 rust accent)
 * - Cormorant Garamond (serif display) / Archivo (body) / JetBrains Mono
 * - Grain texture overlay, warm shadows, clean tile-grid layouts
 * - Component styles for cards, buttons, forms, code blocks
 *
 * Design Philosophy: Warm, professional, accessible — private AI for humans
 */

/* ============================================================================
   CSS VARIABLES - RagGo Brand Palette & Design Tokens
   ============================================================================ */

:root {
  /* Light Theme Colors (Default) — Warm Cream */
  --ink: #1a1611;
  --ink-rgb: 26, 22, 17;
  --ink-soft: #5a5045;
  --ink-muted: #8a7e6e;
  --paper: #f2ece0;
  --paper-rgb: 242, 236, 224;
  --paper-soft: #ede7d7;
  --paper-elevated: #e8e1d2;

  /* Accent Colors - RagGo Brand */
  --accent: #bf4217;               /* Rust/Burnt Orange - Primary */
  --accent-rgb: 191, 66, 23;       /* RGB for alpha variants */
  --accent-2: #4caf7d;             /* Sage Green - Secondary */
  --accent-2-rgb: 76, 175, 125;    /* RGB for alpha variants */
  --accent-3: #f5e0d8;             /* Light rust tint */
  --accent-batch: #5b9eff;              /* Batch job blue */
  --accent-glow: rgba(191, 66, 23, 0.18);
  --accent-2-glow: rgba(76, 175, 125, 0.18);

  /* Navy for dark sections */
  --navy: #1b3454;

  /* Status Colors */
  --danger: #d94040;               /* Error/destructive actions */
  --danger-rgb: 217, 64, 64;
  --warning: #e8921a;              /* Warning messages */
  --warning-rgb: 232, 146, 26;
  --success: #4caf7d;              /* Success = sage green */
  --info: #5a7fbf;                 /* Info = muted blue */

  /* Shadows & Effects */
  --shadow-ink: rgba(26, 22, 17, 0.1);
  --shadow-heavy: rgba(26, 22, 17, 0.18);
  --shadow-card: 0 4px 12px var(--shadow-ink);
  --shadow-card-hover: 0 8px 28px var(--shadow-heavy);
  --grid-line: transparent;
  --noise-opacity: 0.028;
  --overlay-rgb: 26, 22, 17;
  --noise-asset: none;
  --text-primary: var(--ink);
  --border: rgba(26, 22, 17, 0.12);
  --border-hover: rgba(26, 22, 17, 0.22);

  /* Code + Terminal */
  --code-text-shadow: none;
  --terminal-bg: #e8e1d2;
  --terminal-text: #1a1611;
  --terminal-muted: #8a7e6e;
  --terminal-message: #1a1611;
  --terminal-header-bg: rgba(26, 22, 17, 0.04);
  --terminal-scrollbar-track: rgba(26, 22, 17, 0.06);
  --terminal-scrollbar-thumb: rgba(26, 22, 17, 0.2);
  --terminal-scrollbar-thumb-hover: rgba(26, 22, 17, 0.3);

  /* Typography Scale */
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'Archivo', 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;

  --font-size-xs: 0.75rem;         /* 12px */
  --font-size-sm: 0.875rem;        /* 14px */
  --font-size-base: 1rem;          /* 16px */
  --font-size-lg: 1.125rem;        /* 18px */
  --font-size-xl: 1.25rem;         /* 20px */
  --font-size-2xl: 1.5rem;         /* 24px */
  --font-size-3xl: 1.875rem;       /* 30px */
  --font-size-4xl: 2.25rem;        /* 36px */

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

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);

  /* Z-Index Scale */
  --z-base: 0;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-fixed: 300;
  --z-modal-backdrop: 400;
  --z-modal: 500;
  --z-tooltip: 600;
}
/* Dark Theme Overrides (explicit opt-in) */
:root[data-theme="dark"] {
  --ink: #e8ddd0;
  --ink-rgb: 232, 221, 208;
  --ink-soft: #b8aa9a;
  --ink-muted: #7a6e62;
  --paper: #0c0e14;
  --paper-rgb: 12, 14, 20;
  --paper-soft: #13151e;
  --paper-elevated: #1a1d28;
  --accent-3: rgba(191, 66, 23, 0.12);
  --accent-batch: #7db4ff;
  --accent-glow: rgba(191, 66, 23, 0.28);
  --accent-2-glow: rgba(76, 175, 125, 0.28);
  --shadow-ink: rgba(0, 0, 0, 0.4);
  --shadow-heavy: rgba(0, 0, 0, 0.6);
  --overlay-rgb: 255, 255, 255;
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);
  --code-text-shadow: none;
  --terminal-bg: #0c0e14;
  --terminal-text: #c9bfaf;
  --terminal-muted: #5a5e72;
  --terminal-message: #e0d8cc;
  --terminal-header-bg: rgba(255, 255, 255, 0.03);
  --terminal-scrollbar-track: rgba(255, 255, 255, 0.05);
  --terminal-scrollbar-thumb: rgba(255, 255, 255, 0.15);
  --terminal-scrollbar-thumb-hover: rgba(255, 255, 255, 0.25);
}

/* ============================================================================
   BASE STYLES & RESET
   ============================================================================ */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  line-height: 1.6;
  color: var(--ink);
  background-color: var(--paper);
  transition: background-color 0.25s ease, color 0.25s ease;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Subtle grain overlay — matches branding aesthetic */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  opacity: 0.028;
  pointer-events: none;
  z-index: 9999;
}

/* ============================================================================
   TYPOGRAPHY
   ============================================================================ */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  color: var(--ink);
  margin-bottom: var(--space-4);
  letter-spacing: -0.015em;
}

h1 {
  font-size: var(--font-size-4xl);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.025em;
}

h2 {
  font-size: var(--font-size-3xl);
}

h3 {
  font-size: var(--font-size-2xl);
}

h4 {
  font-size: var(--font-size-xl);
}

h5 {
  font-size: var(--font-size-lg);
}

h6 {
  font-size: var(--font-size-base);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
}

p {
  margin-bottom: var(--space-4);
  color: var(--ink-soft);
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition-fast);
  cursor: pointer;
}

a:hover {
  color: var(--accent-2);
  text-decoration: underline;
}

a:active {
  color: var(--ink);
}

strong, b {
  font-weight: 600;
  color: var(--ink);
}

em, i {
  font-style: italic;
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--paper-elevated);
  border: 1px solid var(--accent-3);
  padding: 0.2em 0.4em;
  border-radius: var(--radius-sm);
  color: var(--accent);
}

.monospace {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  letter-spacing: -0.02em;
}

.text-gradient {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ============================================================================
   LOGO & BRANDING
   ============================================================================ */

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

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

.logo-wrap {
  position: relative;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  position: relative;
  z-index: 2;
  transition: transform var(--transition-base);
}

.logo:hover {
  transform: scale(1.05);
}

.logo-glow {
  display: none;
}

.title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--font-size-2xl);
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1;
}

.title-accent {
  color: var(--accent);
  font-weight: 600;
}

.subtitle {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  color: var(--ink-muted);
  letter-spacing: 0.06em;
  margin-top: var(--space-1);
  font-weight: 500;
}

.blink {
  animation: blink 1.5s step-start infinite;
  color: var(--accent);
  font-weight: bold;
}

.logo-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.08em;
  padding: 2px 7px;
  border-radius: 3px;
  background: var(--accent);
  color: #fff;
  vertical-align: middle;
  margin-left: 4px;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

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

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.container-narrow {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.container-wide {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.section {
  padding: var(--space-12) 0;
}

.section-sm {
  padding: var(--space-8) 0;
}

.section-lg {
  padding: var(--space-16) 0;
}

/* ============================================================================
   NAVIGATION
   ============================================================================ */

.navbar {
  background: rgba(var(--paper-rgb), 0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  box-shadow: 0 1px 4px var(--shadow-ink);
  animation: fade-in-down 0.5s ease-out;
}

.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  max-width: 1200px;
  margin: 0 auto;
  min-height: 62px;
}

.nav-links {
  display: flex;
  gap: var(--space-2);
  list-style: none;
  align-items: center;
}

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

.nav-link {
  position: relative;
  color: var(--ink-soft);
  font-weight: 500;
  font-size: var(--font-size-sm);
  font-family: var(--font-body);
  letter-spacing: 0.015em;
  transition: color var(--transition-fast);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  text-decoration: none;
}

.nav-link:hover {
  color: var(--ink);
  text-decoration: none;
}

.nav-link.active {
  color: var(--accent);
  font-weight: 600;
  border-bottom: 2px solid var(--accent);
  border-radius: 0;
}

/* ============================================================================
   MAIN CONTENT & FOOTER
   ============================================================================ */

.main-content {
  min-height: calc(100vh - 72px - 120px); /* Viewport - navbar - footer */
  padding: var(--space-12) 0;
  animation: fade-in-up 0.6s ease-out;
}

.footer {
  background: var(--paper-elevated);
  border-top: 1px solid var(--border);
  padding: var(--space-8) 0;
  margin-top: var(--space-16);
  transition: background-color 0.25s ease;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
}

.footer-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.footer-text {
  color: var(--ink-muted);
  font-size: var(--font-size-sm);
  margin: 0;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

.footer-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.footer-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: rgba(var(--ink-rgb, 26, 22, 17), 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  color: var(--ink-soft);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.footer-badge-accent {
  color: var(--accent);
  font-weight: 700;
}

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

.card {
  background: var(--paper-soft);
  border: 1px solid rgba(var(--overlay-rgb), 0.1);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-card);
  transition: all var(--transition-base);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
  border-color: rgba(var(--ink-rgb), 0.2);
  background: var(--paper-elevated);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid rgba(var(--overlay-rgb), 0.08);
}

.card-title {
  font-family: var(--font-display);
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--ink);
  margin: 0;
}

.card-body {
  color: var(--ink-soft);
  line-height: 1.7;
}

.card-footer {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid rgba(var(--overlay-rgb), 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-elevated {
  background: var(--paper-elevated);
  border-color: rgba(var(--overlay-rgb), 0.15);
}

.card-accent {
  border: 2px solid var(--accent);
  box-shadow: 0 0 20px var(--accent-glow);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-6);
  margin-bottom: var(--space-8);
}

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

.button,
button.button,
input[type="submit"].button,
input[type="button"].button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  font-weight: 600;
  line-height: 1.5;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  border: none;
  border-radius: var(--radius-md);
  transition: all var(--transition-base);
  white-space: nowrap;
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary Button - Rust solid */
.button-primary {
  background: var(--accent);
  color: #fff;
}

.button-primary:hover {
  background: #a8361a;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(191, 66, 23, 0.25);
}

.button-primary:active {
  transform: translateY(0);
}

/* Secondary Button - Outline */
.button-secondary {
  background: transparent;
  color: var(--ink);
  border: 1.5px solid var(--border);
}

.button-secondary:hover {
  border-color: var(--ink);
  background: rgba(var(--ink-rgb), 0.04);
}

/* Ghost Button - Minimal */
.button-ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--border);
}

.button-ghost:hover {
  background: var(--paper-elevated);
  color: var(--ink);
  border-color: var(--border-hover);
}

/* Danger Button */
.button-danger {
  background: var(--danger);
  color: white;
  box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
}

.button-danger:hover {
  background: #ff5252;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(255, 107, 107, 0.4);
}

/* Button Sizes */
.button-sm {
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-sm);
}

.button-lg {
  padding: var(--space-4) var(--space-8);
  font-size: var(--font-size-lg);
}

.button-icon {
  padding: var(--space-3);
  aspect-ratio: 1;
}

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

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

.form-label {
  display: block;
  font-family: var(--font-display);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--ink);
  margin-bottom: var(--space-2);
  letter-spacing: 0.02em;
}

.form-label-required::after {
  content: " *";
  color: var(--danger);
}

.form-input,
.form-textarea,
.form-select,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="url"],
input[type="tel"],
input[type="file"],
textarea,
select {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper-elevated);
  border: 1px solid rgba(var(--overlay-rgb), 0.2);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

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

.form-input:disabled,
.form-textarea:disabled,
.form-select:disabled,
input:disabled,
textarea:disabled,
select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--paper);
}

.form-textarea,
textarea {
  min-height: 120px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
}

.form-select,
select {
  appearance: none;
  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='%23bf4217' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-8);
  cursor: pointer;
}

.form-hint {
  display: block;
  margin-top: var(--space-2);
  font-size: var(--font-size-xs);
  color: var(--ink-muted);
  font-style: italic;
}

.form-error {
  display: block;
  margin-top: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--danger);
  font-weight: 500;
}

/* Checkbox & Radio */
input[type="checkbox"],
input[type="radio"] {
  width: auto;
  margin-right: var(--space-2);
  accent-color: var(--accent);
  cursor: pointer;
}

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

.form-check-label {
  font-size: var(--font-size-sm);
  color: var(--ink-soft);
  cursor: pointer;
}

/* File Upload */
input[type="file"] {
  padding: var(--space-4);
  border: 2px dashed rgba(var(--overlay-rgb), 0.2);
  cursor: pointer;
}

input[type="file"]:hover {
  border-color: var(--accent);
  background: rgba(191, 66, 23, 0.04);
}

/* ============================================================================
   CODE BLOCKS
   ============================================================================ */

pre {
  margin: var(--space-5) 0;
  border-radius: var(--radius-md);
  overflow: hidden;
}

pre[class*="language-"] {
  background: var(--paper-elevated);
}

code[class*="language-"] {
  color: var(--ink);
}

pre code {
  display: block;
  background: var(--paper-elevated);
  border: 1px solid var(--border);
  border-top: 2px solid var(--accent);
  padding: var(--space-6);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  line-height: 1.7;
  overflow-x: auto;
  color: var(--ink);
  text-shadow: var(--code-text-shadow);
}

pre code::-webkit-scrollbar {
  height: 8px;
}

pre code::-webkit-scrollbar-track {
  background: var(--paper);
}

pre code::-webkit-scrollbar-thumb {
  background: var(--accent-3);
  border-radius: var(--radius-full);
}

pre code::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* Syntax Highlighting (Prism.js integration) */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: var(--ink-muted);
  font-style: italic;
}

.token.punctuation {
  color: var(--ink-soft);
}

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
  color: var(--accent-2);
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
  color: var(--accent);
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
  color: var(--accent-2);
}

.token.atrule,
.token.attr-value,
.token.keyword {
  color: var(--info);
  font-weight: 600;
}

.token.function,
.token.class-name {
  color: var(--accent);
  font-weight: 600;
}

.token.regex,
.token.important,
.token.variable {
  color: var(--warning);
}

/* ============================================================================
   ALERTS & MESSAGES
   ============================================================================ */

.alert {
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  border-left: 4px solid;
  margin-bottom: var(--space-5);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  background: var(--paper-elevated);
}

.alert-success {
  border-left-color: var(--success);
  background: rgba(76, 175, 125, 0.1);
  color: var(--success);
}

.alert-info {
  border-left-color: var(--info);
  background: rgba(90, 127, 191, 0.1);
  color: var(--info);
}

.alert-warning {
  border-left-color: var(--warning);
  background: rgba(255, 169, 77, 0.1);
  color: var(--warning);
}

.alert-danger {
  border-left-color: var(--danger);
  background: rgba(255, 107, 107, 0.1);
  color: var(--danger);
}

.alert-icon {
  font-size: var(--font-size-xl);
  line-height: 1;
  flex-shrink: 0;
}

.alert-content {
  flex: 1;
}

.alert-title {
  font-weight: 600;
  font-size: var(--font-size-base);
  margin-bottom: var(--space-2);
  color: inherit;
}

.alert-message {
  font-size: var(--font-size-sm);
  color: var(--ink-soft);
  line-height: 1.6;
}

/* ============================================================================
   PROGRESS BARS
   ============================================================================ */

.progress-bar {
  position: relative;
  width: 100%;
  height: 24px;
  background: var(--paper-elevated);
  border: 1px solid rgba(var(--overlay-rgb), 0.1);
  border-radius: var(--radius-full);
  overflow: hidden;
  box-shadow: inset 0 2px 4px var(--shadow-ink);
}

.progress {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-full);
  transition: width var(--transition-base);
  position: relative;
  overflow: hidden;
}

.progress::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(var(--overlay-rgb), 0.3),
    transparent
  );
  animation: progress-shine 2s infinite;
}

@keyframes progress-shine {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

.progress-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: var(--paper);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  z-index: 1;
}

/* Progress Component for Ingestion Jobs */
.progress-container {
  background: var(--paper-soft);
  border: 1px solid rgba(var(--overlay-rgb), 0.1);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
  transition: all var(--transition-base);
}

.progress-container:hover {
  border-color: rgba(var(--overlay-rgb), 0.2);
  box-shadow: var(--shadow-card);
}

.progress-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.job-type-badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  font-size: var(--font-size-xs);
  font-weight: 600;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: var(--radius-full);
  border: 1px solid;
}

.job-type-file {
  background: rgba(191, 66, 23, 0.08);
  border-color: var(--accent);
  color: var(--accent);
}

.job-type-directory {
  background: rgba(76, 175, 125, 0.08);
  border-color: var(--accent-2);
  color: var(--accent-2);
}

.job-type-batch {
  background: rgba(91, 158, 255, 0.08);
  border-color: var(--accent-batch);
  color: var(--accent-batch);
}

.batch-file-panel {
  margin-bottom: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.batch-file-summary {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--paper-elevated);
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.batch-file-summary::-webkit-details-marker {
  display: none;
}

.batch-file-summary::marker {
  display: none;
}

.batch-chevron {
  color: var(--ink-muted);
  transition: transform 0.18s ease;
  flex-shrink: 0;
}

details.batch-file-panel[open] .batch-chevron {
  transform: rotate(90deg);
}

.batch-file-items {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 128px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
}

.batch-file-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  color: var(--ink-soft);
  border-bottom: 1px solid var(--border);
}

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

.batch-file-item svg {
  color: var(--accent-batch);
  flex-shrink: 0;
}

.job-filename {
  flex: 1;
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  color: var(--ink);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-duration {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  color: var(--ink-muted);
  font-weight: 500;
  margin-left: auto;
}

.progress-bar-track {
  position: relative;
  width: 100%;
  height: 20px;
  background: var(--paper-elevated);
  border: 1px solid rgba(var(--overlay-rgb), 0.1);
  border-radius: var(--radius-full);
  overflow: hidden;
  box-shadow: inset 0 2px 4px var(--shadow-ink);
  margin-bottom: var(--space-4);
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.8s ease;
  position: relative;
  overflow: hidden;
}

.progress-fill-processing {
  background: var(--accent);
}

.progress-fill-completed {
  background: var(--success);
}

.progress-fill-failed {
  background: var(--danger);
  box-shadow: 0 0 12px rgba(255, 107, 107, 0.4);
}

.progress-shimmer {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(var(--overlay-rgb), 0.3),
    transparent
  );
  animation: progress-shine 2s infinite;
}

.progress-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.status-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
}

.status-right {
  display: flex;
  align-items: center;
}

.status-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.status-icon-processing {
  color: var(--accent);
}

.status-icon-success {
  color: var(--success);
}

.status-icon-error {
  color: var(--danger);
}

.icon-spin {
  animation: spin 0.8s linear infinite;
}

.status-message {
  font-size: var(--font-size-sm);
  font-weight: 500;
  line-height: 1.4;
}

.status-message-processing {
  color: var(--ink-soft);
}

.status-message-success {
  color: var(--success);
}

.status-message-error {
  color: var(--danger);
}

.progress-percentage {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  font-weight: 700;
  margin-left: var(--space-3);
}

.progress-percentage-processing {
  color: var(--accent);
}

.progress-percentage-success {
  color: var(--success);
}

.progress-percentage-error {
  color: var(--danger);
}

.progress-error {
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid var(--danger);
  border-left: 4px solid var(--danger);
  border-radius: var(--radius-md);
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  color: var(--danger);
  font-size: var(--font-size-sm);
  line-height: 1.5;
}

.progress-error svg {
  flex-shrink: 0;
  margin-top: 2px;
}

.progress-completion {
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: rgba(76, 175, 125, 0.1);
  border: 1px solid var(--success);
  border-left: 4px solid var(--success);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.completion-text {
  color: var(--success);
  font-size: var(--font-size-sm);
  font-weight: 500;
}

.completion-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--accent);
  font-size: var(--font-size-sm);
  font-weight: 600;
  text-decoration: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.completion-link:hover {
  color: var(--accent-2);
  text-decoration: underline;
}

/* ============================================================================
   TABLES
   ============================================================================ */

.table-container {
  overflow-x: auto;
  margin-bottom: var(--space-6);
  border-radius: var(--radius-md);
  border: 1px solid rgba(var(--overlay-rgb), 0.1);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--paper-soft);
}

thead {
  background: var(--paper-elevated);
  border-bottom: 1px solid var(--border);
}

th {
  padding: var(--space-4) var(--space-5);
  text-align: left;
  font-family: var(--font-display);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

td {
  padding: var(--space-4) var(--space-5);
  font-size: var(--font-size-sm);
  color: var(--ink-soft);
  border-bottom: 1px solid rgba(var(--overlay-rgb), 0.05);
}

tbody tr {
  transition: background var(--transition-fast);
}

tbody tr:hover {
  background: var(--paper-elevated);
}

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

.table-monospace td {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
}

/* ============================================================================
   BADGES & TAGS
   ============================================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  font-size: var(--font-size-xs);
  font-weight: 600;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: var(--radius-full);
  background: var(--paper-elevated);
  border: 1px solid rgba(var(--overlay-rgb), 0.2);
  color: var(--ink-soft);
}

.badge-accent {
  background: rgba(191, 66, 23, 0.1);
  border-color: var(--accent);
  color: var(--accent);
}

.badge-success {
  background: rgba(76, 175, 125, 0.12);
  border-color: var(--success);
  color: var(--success);
}

.badge-warning {
  background: rgba(255, 169, 77, 0.15);
  border-color: var(--warning);
  color: var(--warning);
}

.badge-danger {
  background: rgba(255, 107, 107, 0.15);
  border-color: var(--danger);
  color: var(--danger);
}

/* ============================================================================
   STATUS INDICATORS
   ============================================================================ */

.status-live {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: var(--radius-full);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(0.95);
  }
}

.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  margin-right: var(--space-2);
}

.status-success {
  background: var(--success);
}

.status-warning {
  background: var(--warning);
  box-shadow: 0 0 6px rgba(255, 169, 77, 0.5);
}

.status-danger {
  background: var(--danger);
  box-shadow: 0 0 6px rgba(255, 107, 107, 0.5);
}

/* ============================================================================
   LOADING STATES
   ============================================================================ */

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(191, 66, 23, 0.2);
  border-top-color: var(--accent);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
}

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

.spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 4px;
}

.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator {
  display: inline-block;
}

.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* Skeleton Loading */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--paper-elevated) 25%,
    var(--paper-soft) 50%,
    var(--paper-elevated) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.skeleton-text {
  height: 1em;
  margin-bottom: var(--space-2);
}

.skeleton-heading {
  height: 1.5em;
  width: 60%;
  margin-bottom: var(--space-3);
}

.skeleton-card {
  height: 120px;
  border-radius: var(--radius-lg);
}

.skeleton-row {
  height: 2.5em;
  margin-bottom: var(--space-3);
}

/* ============================================================================
   PAGE-SPECIFIC COMPONENTS
   ============================================================================ */

/* Page Header */
.page-header {
  margin-bottom: var(--space-10);
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--border);
  animation: fade-in-down 0.5s ease-out;
}

.page-title {
  font-family: var(--font-display);
  font-size: var(--font-size-4xl);
  font-weight: 600;
  margin-bottom: var(--space-2);
  color: var(--ink);
  letter-spacing: -0.025em;
}

.page-subtitle {
  font-size: var(--font-size-base);
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Dashboard Components */
.dashboard-section {
  margin-bottom: var(--space-12);
}

.section-title {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  margin-bottom: var(--space-6);
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.section-title::before {
  content: '';
  width: 4px;
  height: 24px;
  background: var(--accent);
  border-radius: var(--radius-sm);
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-6);
  margin-bottom: var(--space-8);
}

.stat-card {
  background: var(--paper-soft);
  border: 1px solid rgba(var(--overlay-rgb), 0.1);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
  animation: scale-in 0.4s ease-out backwards;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  opacity: 0;
  transition: opacity var(--transition-base);
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: rgba(var(--ink-rgb), 0.2);
  box-shadow: var(--shadow-card-hover);
}

.stat-card:hover::before {
  opacity: 1;
}

.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.1s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.2s; }
.stat-card:nth-child(5) { animation-delay: 0.25s; }

.stat-card-wide {
  grid-column: span 2;
}

.stat-icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(191, 66, 23, 0.08);
  border: 1px solid rgba(191, 66, 23, 0.2);
  border-radius: var(--radius-md);
  color: var(--accent);
  transition: all var(--transition-base);
}

.stat-card:hover .stat-icon {
  background: rgba(191, 66, 23, 0.12);
  border-color: var(--accent);
}

.stat-content {
  flex: 1;
  min-width: 0;
}

.stat-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-2);
}

.stat-value {
  font-family: var(--font-display);
  font-size: var(--font-size-3xl);
  font-weight: 600;
  color: var(--ink);
  line-height: 1;
  letter-spacing: -0.02em;
}

.stat-value-model {
  font-family: var(--font-mono);
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--accent);
  margin-bottom: var(--space-2);
}

.stat-sublabel {
  font-size: var(--font-size-xs);
  color: var(--ink-soft);
  margin-top: var(--space-2);
}

.stat-dim {
  color: var(--accent-2);
  font-weight: 600;
}

/* Actions Grid */
.actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-6);
}

.action-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-6);
  background: var(--paper-soft);
  border: 1px solid rgba(var(--overlay-rgb), 0.1);
  border-radius: var(--radius-lg);
  text-decoration: none;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  animation: fade-in-up 0.5s ease-out backwards;
}

.action-card:nth-child(1) { animation-delay: 0.1s; }
.action-card:nth-child(2) { animation-delay: 0.2s; }
.action-card:nth-child(3) { animation-delay: 0.3s; }
.action-card:nth-child(4) { animation-delay: 0.4s; }

.action-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: var(--accent);
  opacity: 0;
  transition: opacity var(--transition-base);
}

.action-card:hover {
  transform: translateX(6px);
  border-color: rgba(var(--ink-rgb), 0.2);
  box-shadow: var(--shadow-card-hover);
  background: var(--paper-elevated);
}

.action-card:hover::before {
  opacity: 1;
}

.action-icon {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  transition: all var(--transition-base);
}

.action-icon-search {
  background: rgba(191, 66, 23, 0.08);
  border: 1px solid rgba(191, 66, 23, 0.2);
  color: var(--accent);
}

.action-icon-ingest {
  background: rgba(76, 175, 125, 0.08);
  border: 1px solid rgba(76, 175, 125, 0.2);
  color: var(--accent-2);
}

.action-icon-metrics {
  background: rgba(232, 146, 26, 0.08);
  border: 1px solid rgba(232, 146, 26, 0.2);
  color: var(--warning);
}

.action-icon-sources {
  background: rgba(191, 66, 23, 0.08);
  border: 1px solid rgba(191, 66, 23, 0.2);
  color: var(--accent);
}

.action-card:hover .action-icon {
  transform: scale(1.08);
}

.action-content {
  flex: 1;
  min-width: 0;
}

.action-title {
  font-family: var(--font-display);
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--ink);
  margin-bottom: var(--space-2);
}

.action-description {
  font-size: var(--font-size-sm);
  color: var(--ink-soft);
  line-height: 1.5;
}

.action-arrow {
  flex-shrink: 0;
  color: var(--ink-muted);
  transition: all var(--transition-base);
}

.action-card:hover .action-arrow {
  color: var(--accent);
  transform: translateX(3px);
}

/* Status Indicator */
.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.pulse-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: var(--radius-full);
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(1.2);
  }
}

.pulse-dot-amber {
  background: #f0ad4e;
}

.pulse-dot-red {
  background: #ff6b6b;
  animation: none;
}

.status-text {
  color: var(--accent);
  font-weight: 600;
}

/* Dashboard health badges */
.health-badges {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-2);
  flex-wrap: wrap;
}

.status-badge-ok {
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent);
  border: 1px solid rgba(var(--accent-rgb), 0.35);
}

.status-badge-err {
  background: rgba(255, 107, 107, 0.12);
  color: #ff6b6b;
  border: 1px solid rgba(255, 107, 107, 0.35);
}

/* ============================================================================
   ANIMATIONS
   ============================================================================ */

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-in-down {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scale-in {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.fade-in {
  animation: fade-in 0.5s ease-out;
}

.fade-in-up {
  animation: fade-in-up 0.6s ease-out;
}

.fade-in-down {
  animation: fade-in-down 0.6s ease-out;
}

.scale-in {
  animation: scale-in 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Glow Animation */
@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 20px var(--accent-glow);
  }
  50% {
    box-shadow: 0 0 30px var(--accent-2-glow);
  }
}

.glow {
  animation: glow 3s ease-in-out infinite;
}

/* ============================================================================
   UTILITY CLASSES
   ============================================================================ */

/* Display */
.hidden { display: none !important; }
.block { display: block !important; }
.inline-block { display: inline-block !important; }
.flex { display: flex !important; }
.inline-flex { display: inline-flex !important; }
.grid { display: grid !important; }

/* Flex Utilities */
.flex-row { flex-direction: row; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-around { justify-content: space-around; }
.justify-start { justify-content: flex-start; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

/* Spacing */
.m-0 { margin: 0 !important; }
.m-1 { margin: var(--space-1); }
.m-2 { margin: var(--space-2); }
.m-4 { margin: var(--space-4); }
.m-6 { margin: var(--space-6); }
.m-8 { margin: var(--space-8); }
.mt-0 { margin-top: 0 !important; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-0 { margin-bottom: 0 !important; }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.ml-auto { margin-left: auto; }
.mr-auto { margin-right: auto; }
.mx-auto { margin-left: auto; margin-right: auto; }

.p-0 { padding: 0 !important; }
.p-2 { padding: var(--space-2); }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.p-8 { padding: var(--space-8); }
.pt-4 { padding-top: var(--space-4); }
.pt-6 { padding-top: var(--space-6); }
.pb-4 { padding-bottom: var(--space-4); }
.pb-6 { padding-bottom: var(--space-6); }
.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }
.px-6 { padding-left: var(--space-6); padding-right: var(--space-6); }
.py-4 { padding-top: var(--space-4); padding-bottom: var(--space-4); }
.py-6 { padding-top: var(--space-6); padding-bottom: var(--space-6); }

/* Text Alignment */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* Text Colors */
.text-ink { color: var(--ink) !important; }
.text-ink-soft { color: var(--ink-soft) !important; }
.text-ink-muted { color: var(--ink-muted) !important; }
.text-accent { color: var(--accent) !important; }
.text-accent-2 { color: var(--accent-2) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger { color: var(--danger) !important; }

/* Font Weight */
.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-extrabold { font-weight: 800; }

/* Font Size */
.text-xs { font-size: var(--font-size-xs); }
.text-sm { font-size: var(--font-size-sm); }
.text-base { font-size: var(--font-size-base); }
.text-lg { font-size: var(--font-size-lg); }
.text-xl { font-size: var(--font-size-xl); }
.text-2xl { font-size: var(--font-size-2xl); }

/* Border Radius */
.rounded-sm { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }

/* Width */
.w-full { width: 100%; }
.w-auto { width: auto; }
.w-fit { width: fit-content; }

/* Overflow */
.overflow-auto { overflow: auto; }
.overflow-hidden { overflow: hidden; }
.overflow-scroll { overflow: scroll; }

/* Cursor */
.cursor-pointer { cursor: pointer; }
.cursor-not-allowed { cursor: not-allowed; }

/* Pointer Events */
.pointer-events-none { pointer-events: none; }
.pointer-events-auto { pointer-events: auto; }

/* Opacity */
.opacity-0 { opacity: 0; }
.opacity-50 { opacity: 0.5; }
.opacity-75 { opacity: 0.75; }
.opacity-100 { opacity: 1; }

/* ============================================================================
   KEYWORD HIGHLIGHTING
   ============================================================================ */

.highlight,
mark.highlight {
  background: rgba(191, 66, 23, 0.15);
  color: var(--accent);
  padding: 2px 4px;
  border-radius: 3px;
  font-weight: 600;
}

/* ============================================================================
   RECENT SEARCHES
   ============================================================================ */

.recent-searches-container {
  background: var(--paper-soft);
  border: 1px solid rgba(var(--overlay-rgb), 0.1);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-6);
  animation: fade-in-up 0.4s ease-out;
}

.recent-searches-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
  gap: var(--space-3);
}

.recent-searches-title {
  font-family: var(--font-display);
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--ink-soft);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.recent-searches-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.recent-search-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: var(--paper-elevated);
  border: 1px solid rgba(var(--overlay-rgb), 0.15);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.recent-search-pill:hover {
  background: rgba(191, 66, 23, 0.08);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.pill-query {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pill-type {
  padding: var(--space-1) var(--space-2);
  background: rgba(76, 175, 125, 0.15);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ============================================================================
   EXPORT BUTTONS
   ============================================================================ */

.results-header-content {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-6);
  width: 100%;
  flex-wrap: wrap;
}

.export-buttons {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
}

.export-buttons .button {
  white-space: nowrap;
}

/* ============================================================================
   LOG VIEWER FILTERS
   ============================================================================ */

.log-filter-select {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 4px 8px;
  font-size: var(--font-size-xs);
  font-family: var(--font-mono);
}

.log-filter-input {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 4px 8px;
  font-size: var(--font-size-xs);
  font-family: var(--font-mono);
  width: 140px;
}

.log-filter-input::placeholder {
  color: var(--ink-muted);
}

/* ============================================================================
   INGESTION HISTORY TABLE
   ============================================================================ */

.history-table-wrapper {
  overflow-x: auto;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.history-table th {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  color: var(--ink-muted);
  font-weight: 600;
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
}

.history-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border-subtle, rgba(255,255,255,0.04));
  color: var(--ink-soft);
}

.history-name {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 700;
}

.history-status-ok {
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent);
}

.history-status-err {
  background: rgba(255, 107, 107, 0.12);
  color: #ff6b6b;
}

.batch-history-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  padding: 0;
  font-family: var(--font-mono);
  font-size: inherit;
  color: var(--accent-3, #5b9eff);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(91, 158, 255, 0.4);
  transition: color var(--transition-fast);
}

.batch-history-btn:hover {
  color: #7fb3ff;
  text-decoration-color: rgba(91, 158, 255, 0.8);
}

.batch-history-btn svg {
  opacity: 0.7;
  flex-shrink: 0;
}

/* Batch modal */
.batch-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.batch-modal-card {
  background: var(--paper-soft);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  width: min(480px, 92vw);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.batch-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  background: var(--paper-elevated);
  flex-shrink: 0;
}

.batch-modal-title {
  font-family: var(--font-display);
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--ink);
}

.batch-modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--ink-muted);
  transition: all var(--transition-fast);
  padding: 0;
}

.batch-modal-close:hover {
  background: rgba(224, 90, 90, 0.12);
  color: #e05a5a;
}

.batch-modal-list {
  list-style: none;
  margin: 0;
  padding: var(--space-2) 0;
  overflow-y: auto;
  flex: 1;
}

.batch-modal-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-5);
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  color: var(--ink-soft);
  border-bottom: 1px solid var(--border-subtle, rgba(255,255,255,0.03));
}

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

.batch-modal-enter { transition: opacity 0.15s ease, transform 0.15s ease; }
.batch-modal-enter-start { opacity: 0; transform: scale(0.97); }
.batch-modal-enter-end { opacity: 1; transform: scale(1); }

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

@media (max-width: 768px) {
  /* Typography */
  h1 { font-size: var(--font-size-3xl); }
  h2 { font-size: var(--font-size-2xl); }
  h3 { font-size: var(--font-size-xl); }

  /* Container */
  .container,
  .container-narrow,
  .container-wide {
    padding: 0 var(--space-4);
  }

  /* Section */
  .section { padding: var(--space-8) 0; }
  .section-lg { padding: var(--space-12) 0; }

  /* Navigation */
  .navbar-inner {
    flex-direction: column;
    gap: var(--space-4);
    padding: var(--space-4);
  }

  .brand {
    width: 100%;
    justify-content: center;
  }

  .nav-links {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-2);
  }

  .nav-actions {
    width: 100%;
    justify-content: center;
  }

  .nav-actions .button {
    width: auto;
  }

  .nav-link {
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-size-xs);
  }

  /* Footer */
  .footer-inner {
    flex-direction: column;
    text-align: center;
    padding: 0 var(--space-4);
  }

  .footer-left,
  .footer-right {
    justify-content: center;
  }

  /* Cards */
  .card { padding: var(--space-4); }
  .card-grid {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  /* Dashboard Stats */
  .stats-grid {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  .stat-card-wide {
    grid-column: span 1;
  }

  .stat-value {
    font-size: var(--font-size-2xl);
  }

  /* Actions Grid */
  .actions-grid {
    grid-template-columns: 1fr;
  }

  /* Buttons */
  .button {
    width: 100%;
    justify-content: center;
  }

  .button-group {
    flex-direction: column;
  }

  /* Tables */
  .table-container {
    font-size: var(--font-size-xs);
  }

  th, td {
    padding: var(--space-2) var(--space-3);
  }

  /* Recent Searches */
  .recent-searches-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .recent-search-pill .pill-query {
    max-width: 150px;
  }

  /* Export Buttons */
  .results-header-content {
    flex-direction: column;
    align-items: flex-start;
  }

  .export-buttons {
    width: 100%;
  }

  .export-buttons .button {
    flex: 1;
  }
}

@media (max-width: 480px) {
  /* Typography */
  h1 { font-size: var(--font-size-2xl); }
  h2 { font-size: var(--font-size-xl); }

  /* Logo */
  .logo-wrap {
    width: 32px;
    height: 32px;
  }

  .title {
    font-size: var(--font-size-base);
  }

  /* Cards */
  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }
}

/* ============================================================================
   PRINT STYLES
   ============================================================================ */

@media print {
  body {
    background: white;
    color: black;
  }

  .navbar,
  .button,
  .card:hover {
    transform: none;
    box-shadow: none;
  }

  a {
    text-decoration: underline;
  }

  .no-print {
    display: none !important;
  }
}

/* ============================================
   SERVICES CONSOLE STYLES
   ============================================ */

/* Services Status Grid */
.services-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.service-status-card {
  background: var(--paper-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: all var(--transition-base);
}

.service-status-card:hover {
  border-color: rgba(var(--ink-rgb), 0.2);
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
}

.service-status-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
}

.service-status-header h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--ink);
}

.service-status-details {
  margin-bottom: var(--space-3);
}

.service-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-2) 0;
  font-size: var(--font-size-sm);
  border-bottom: 1px solid rgba(var(--overlay-rgb), 0.04);
}

.service-stat:last-child {
  border-bottom: none;
}

.service-stat .stat-label {
  font-weight: 500;
  color: var(--ink-muted);
}

.service-stat .stat-value {
  font-weight: 600;
  color: var(--ink);
  font-family: var(--font-mono);
}

.service-error {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: rgba(255, 107, 107, 0.08);
  border: 1px solid rgba(255, 107, 107, 0.25);
  border-radius: var(--radius-md);
  margin-top: var(--space-3);
}

.service-error .error-icon {
  flex-shrink: 0;
  margin-top: 2px;
}

.service-error .error-text {
  flex: 1;
  font-size: var(--font-size-xs);
  color: var(--danger);
  font-family: var(--font-mono);
  word-break: break-word;
  line-height: 1.5;
}

.service-controls {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

/* ============================================
   BTN-* ALIASES (used in services template)
   ============================================ */

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  font-weight: 600;
  line-height: 1.5;
  cursor: pointer;
  border: none;
  border-radius: var(--radius-md);
  transition: all var(--transition-base);
  white-space: nowrap;
  text-decoration: none;
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: #a8361a;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(191, 66, 23, 0.25);
  text-decoration: none;
  color: #fff;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  font-weight: 600;
  line-height: 1.5;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all var(--transition-base);
  white-space: nowrap;
  text-decoration: none;
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
}

.btn-secondary:hover {
  background: rgba(var(--accent-rgb), 0.1);
  box-shadow: 0 0 14px var(--accent-glow);
  text-decoration: none;
  color: var(--accent);
}

.btn-sm {
  padding: var(--space-2) var(--space-3) !important;
  font-size: var(--font-size-xs) !important;
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.status-running {
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent);
  border: 1px solid rgba(var(--accent-rgb), 0.35);
}

.status-starting {
  background: rgba(255, 193, 7, 0.12);
  color: #f59e0b;
  border: 1px solid rgba(255, 193, 7, 0.35);
}

.status-stopping {
  background: rgba(255, 193, 7, 0.12);
  color: #f59e0b;
  border: 1px solid rgba(255, 193, 7, 0.35);
}

.status-stopped {
  background: rgba(var(--overlay-rgb), 0.06);
  color: var(--ink-muted);
  border: 1px solid rgba(var(--overlay-rgb), 0.18);
}

.status-failed {
  background: rgba(255, 107, 107, 0.12);
  color: var(--danger);
  border: 1px solid rgba(255, 107, 107, 0.35);
}

.status-restarting {
  background: rgba(var(--accent-2-rgb), 0.12);
  color: var(--accent-2);
  border: 1px solid rgba(var(--accent-2-rgb), 0.35);
}

.status-unknown {
  background: rgba(var(--overlay-rgb), 0.06);
  color: var(--ink-muted);
  border: 1px solid rgba(var(--overlay-rgb), 0.18);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.status-dot-pulse {
  animation: pulse 2s ease-in-out infinite;
}

.status-dot-blink {
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* Log Terminals */
.log-terminals-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
  margin-top: var(--space-6);
}

.log-terminal {
  background: var(--terminal-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 4px 12px var(--shadow-ink);
  display: flex;
  flex-direction: column;
}

.log-terminal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) var(--space-5);
  background: var(--terminal-header-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.log-terminal-header h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--ink);
}

.log-terminal-controls {
  display: flex;
  gap: var(--space-2);
}

.log-terminal-body {
  padding: var(--space-3) var(--space-4);
  height: 460px;
  max-height: 460px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.65;
  color: var(--terminal-text);
  background: var(--terminal-bg);
}

.log-line {
  display: flex;
  gap: var(--space-3);
  padding: 1px 0;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.log-line:hover {
  background: rgba(var(--overlay-rgb), 0.03);
  border-radius: var(--radius-sm);
}

.log-timestamp {
  color: var(--terminal-muted);
  flex-shrink: 0;
  min-width: 72px;
  font-weight: 500;
  opacity: 0.7;
}

.log-level {
  flex-shrink: 0;
  min-width: 58px;
  font-weight: 700;
  text-align: left;
}

.log-message {
  flex: 1;
  word-break: break-word;
  color: var(--terminal-message);
}

/* ANSI Color Classes */
.ansi-green  { color: #7ee787; }
.ansi-yellow { color: #ffc107; }
.ansi-red    { color: #ff6b6b; }
.ansi-cyan   { color: #79c0ff; }
.ansi-gray   { color: var(--terminal-muted); }

/* Scrollbar styling for terminals */
.log-terminal-body::-webkit-scrollbar { width: 6px; }
.log-terminal-body::-webkit-scrollbar-track { background: var(--terminal-scrollbar-track); }
.log-terminal-body::-webkit-scrollbar-thumb {
  background: var(--terminal-scrollbar-thumb);
  border-radius: var(--radius-full);
}
.log-terminal-body::-webkit-scrollbar-thumb:hover {
  background: var(--terminal-scrollbar-thumb-hover);
}

/* Global scrollbar styling */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(var(--overlay-rgb), 0.18);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(var(--overlay-rgb), 0.3);
}

/* Responsive adjustments for services console */
@media (max-width: 1024px) {
  .services-status-grid   { grid-template-columns: 1fr; }
  .log-terminals-container { grid-template-columns: 1fr; }
  .log-terminal-body       { height: 380px; max-height: 380px; }
}

/* ============================================
   LIGHT-MODE POLISH
   ============================================ */

/* Improve card visibility in light mode */
:root:not([data-theme="dark"]) .card,
[data-theme="light"] .card {
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08), 0 0 1px rgba(15, 23, 42, 0.06);
}

:root:not([data-theme="dark"]) .card:hover,
[data-theme="light"] .card:hover {
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12), 0 0 1px rgba(15, 23, 42, 0.08);
}

/* Ensure smooth transitions on theme-sensitive elements */
.card, .stat-card, .action-card, .metric-card, .result-card,
.service-status-card, .log-terminal, .navbar, .footer,
input, textarea, select, .form-input {
  transition:
    background-color 0.25s ease,
    border-color 0.25s ease,
    box-shadow 0.25s ease,
    color 0.25s ease;
}

/* ============================================================================
   HTMX SWAP TRANSITIONS
   ============================================================================ */

.htmx-swapping {
  opacity: 0;
  transition: opacity 0.15s ease-out;
}

.htmx-settling {
  opacity: 1;
  transition: opacity 0.2s ease-in;
}

/* ============================================================================
   TOAST NOTIFICATION SYSTEM
   ============================================================================ */

#toast-container {
  position: fixed;
  top: 76px; /* Below navbar */
  right: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  z-index: var(--z-tooltip);
  pointer-events: none;
  max-width: 400px;
  width: 100%;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--paper-soft);
  border: 1px solid var(--border);
  border-left: 4px solid var(--info);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card-hover);
  font-size: var(--font-size-sm);
  color: var(--ink);
  pointer-events: auto;
  opacity: 0;
  transform: translateX(100%);
  backdrop-filter: blur(8px);
}

.toast-enter {
  animation: toast-slide-in 0.3s ease-out forwards;
}

.toast-exit {
  animation: toast-slide-out 0.25s ease-in forwards;
}

@keyframes toast-slide-in {
  from { opacity: 0; transform: translateX(100%); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toast-slide-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(100%); }
}

.toast-success { border-left-color: var(--success); }
.toast-error   { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
.toast-info    { border-left-color: var(--info); }

.toast-icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon   { color: var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info .toast-icon    { color: var(--info); }

.toast-message {
  flex: 1;
  line-height: 1.4;
  font-weight: 500;
}

.toast-close {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  background: none;
  color: var(--ink-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.toast-close:hover {
  background: rgba(var(--ink-rgb), 0.08);
  color: var(--ink);
}

/* Toast countdown bar for auto-dismiss toasts */
.toast-countdown {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  transition: width 4s linear;
}
.toast {
  position: relative;
  overflow: hidden;
}
.toast-success .toast-countdown { background: var(--success); }
.toast-info .toast-countdown    { background: var(--info); }

/* ============================================================================
   MOBILE HAMBURGER MENU
   ============================================================================ */

.nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  padding: 6px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  z-index: calc(var(--z-sticky) + 1);
}

.hamburger-line {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
  transition: all 0.25s ease;
  transform-origin: center;
}

.nav-hamburger.active .hamburger-line:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-hamburger.active .hamburger-line:nth-child(2) {
  opacity: 0;
}

.nav-hamburger.active .hamburger-line:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

@media (max-width: 768px) {
  .nav-hamburger {
    display: flex;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    background: rgba(var(--paper-rgb), 0.97);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
    padding: var(--space-4) var(--space-6);
    box-shadow: 0 8px 24px var(--shadow-heavy);
    z-index: var(--z-sticky);
  }

  .nav-links.nav-open {
    display: flex;
  }

  .nav-links .nav-link {
    padding: var(--space-3) var(--space-4);
    width: 100%;
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
  }

  .nav-links .nav-link:hover {
    background: rgba(var(--ink-rgb), 0.04);
  }

  .nav-links .nav-link.active {
    border-bottom: none;
    background: rgba(var(--accent-rgb), 0.08);
  }

  .nav-actions {
    margin-left: auto;
    margin-right: var(--space-2);
  }

  #toast-container {
    right: var(--space-3);
    left: var(--space-3);
    max-width: none;
  }
}

/* ============================================================================
   ONBOARDING STEPS (Dashboard)
   ============================================================================ */

.onboarding-steps {
  display: flex;
  gap: var(--space-6);
  margin-bottom: var(--space-8);
  flex-wrap: wrap;
}

.onboarding-step {
  flex: 1;
  min-width: 260px;
  background: var(--paper-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  text-decoration: none;
  transition: all var(--transition-base);
  position: relative;
}

.onboarding-step:hover {
  border-color: rgba(var(--accent-rgb), 0.3);
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
  text-decoration: none;
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: #fff;
  font-family: var(--font-display);
  font-size: var(--font-size-base);
  font-weight: 700;
  flex-shrink: 0;
}

.step-title {
  font-family: var(--font-display);
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--ink);
  margin: 0;
}

.step-desc {
  font-size: var(--font-size-sm);
  color: var(--ink-soft);
  line-height: 1.6;
  margin: 0;
}

/* ============================================================================
   DRAG-AND-DROP FILE UPLOAD
   ============================================================================ */

.file-input-dragging {
  border-color: var(--accent) !important;
  background: rgba(var(--accent-rgb), 0.04) !important;
  box-shadow: 0 0 24px rgba(var(--accent-rgb), 0.12) !important;
}

.drop-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  background: rgba(var(--accent-rgb), 0.06);
  border-radius: var(--radius-md);
  color: var(--accent);
  font-family: var(--font-display);
  font-size: var(--font-size-base);
  font-weight: 600;
  pointer-events: none;
  z-index: 2;
}

/* File queue size warning */
.fq-size-warning {
  color: var(--warning);
}

.fq-warning-icon {
  color: var(--warning);
  flex-shrink: 0;
}

/* ============================================================================
   ERROR CATEGORIZATION (Progress Bar)
   ============================================================================ */

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

.error-category-label {
  font-weight: 700;
  font-size: var(--font-size-sm);
  color: var(--danger);
}

.error-suggestion {
  font-size: var(--font-size-xs);
  color: var(--ink-soft);
  font-weight: 400;
}

/* Retry button */
.retry-button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-display);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.08);
  border: 1px solid rgba(var(--accent-rgb), 0.2);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.retry-button:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ============================================================================
   SEARCH THRESHOLD HELPER
   ============================================================================ */

.threshold-hint {
  font-size: var(--font-size-xs);
  color: var(--ink-muted);
  font-style: italic;
  margin-top: var(--space-1);
  transition: color var(--transition-fast);
}

/* ============================================================================
   BULK ACTIONS BAR (Documents)
   ============================================================================ */

.bulk-action-bar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  margin-bottom: var(--space-4);
  background: rgba(var(--accent-rgb), 0.06);
  border: 1px solid rgba(var(--accent-rgb), 0.15);
  border-radius: var(--radius-md);
  animation: fade-in 0.2s ease-out;
}

.bulk-count {
  font-family: var(--font-display);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--accent);
}

.bulk-btn-delete {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: #fff;
  background: var(--danger);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.bulk-btn-delete:hover {
  background: #c53030;
}

.bulk-btn-clear {
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--ink-soft);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.bulk-btn-clear:hover {
  border-color: var(--ink-soft);
}

/* Checkbox column */
.doc-th-check,
.doc-td-check {
  width: 36px;
  text-align: center;
}

.doc-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ============================================================================
   DOCUMENT PREVIEW MODAL
   ============================================================================ */

.preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(var(--overlay-rgb), 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: var(--space-6);
}

.preview-card {
  background: var(--paper-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card-hover);
  max-width: 800px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.preview-title {
  font-family: var(--font-display);
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  margin: 0;
}

.preview-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.preview-close:hover {
  background: rgba(var(--ink-rgb), 0.05);
  color: var(--ink);
}

.preview-body {
  padding: var(--space-5);
  overflow-y: auto;
  flex: 1;
}

.preview-content {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  line-height: 1.7;
  color: var(--ink-soft);
  white-space: pre-wrap;
  word-break: break-word;
}

.preview-meta {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  font-size: var(--font-size-xs);
  color: var(--ink-muted);
  flex-shrink: 0;
}

/* ============================================================================
   DELETE CONFIRMATION MODAL
   ============================================================================ */

.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(var(--overlay-rgb), 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: var(--space-6);
}

.confirm-card {
  background: var(--paper-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card-hover);
  max-width: 440px;
  width: 100%;
  padding: var(--space-6);
}

.confirm-title {
  font-family: var(--font-display);
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 var(--space-4);
}

.confirm-text {
  font-size: var(--font-size-sm);
  color: var(--ink-soft);
  line-height: 1.6;
  margin: 0 0 var(--space-2);
}

.confirm-warn {
  font-size: var(--font-size-sm);
  color: var(--danger);
  font-weight: 500;
  margin: 0 0 var(--space-6);
}

.confirm-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
}

/* ============================================================================
   CLICKABLE SOURCE CARDS
   ============================================================================ */

.source-card-body-link {
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
}

.source-card-body-link:hover {
  text-decoration: none;
}

/* ============================================================================
   COPY-TO-CLIPBOARD BUTTONS
   ============================================================================ */

.code-block-wrapper {
  position: relative;
}

.copy-trigger {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--paper-soft);
  color: var(--ink-muted);
  cursor: pointer;
  opacity: 0;
  transition: all var(--transition-fast);
  z-index: 2;
}

.code-block-wrapper:hover .copy-trigger,
.mcp-ref-row:hover .copy-trigger,
.result-card:hover .copy-trigger,
.log-line:hover .copy-trigger {
  opacity: 1;
}

.copy-trigger:hover {
  background: var(--paper-elevated);
  color: var(--ink);
  border-color: var(--border-hover);
}

.copy-trigger.copied {
  color: var(--success);
  border-color: var(--success);
}

/* ============================================================================
   PROGRESS STAGE INDICATOR
   ============================================================================ */

.progress-stages {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: var(--space-3);
  padding: 0 var(--space-1);
  overflow-x: auto;
}

.progress-stage {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  white-space: nowrap;
}

.progress-stage-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--paper-elevated);
  border: 2px solid var(--border);
  flex-shrink: 0;
  transition: all var(--transition-base);
}

.progress-stage-completed .progress-stage-dot {
  background: var(--accent);
  border-color: var(--accent);
}

.progress-stage-active .progress-stage-dot {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.2);
  animation: stage-pulse 1.5s ease-in-out infinite;
}

.progress-stage-pending .progress-stage-dot {
  background: var(--paper-elevated);
  border-color: var(--border);
}

@keyframes stage-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.2); }
  50% { box-shadow: 0 0 0 5px rgba(var(--accent-rgb), 0.1); }
}

.progress-stage-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.progress-stage-completed .progress-stage-label {
  color: var(--accent);
}

.progress-stage-active .progress-stage-label {
  color: var(--ink);
  font-weight: 600;
}

.progress-stage-connector {
  width: 16px;
  height: 2px;
  background: var(--border);
  flex-shrink: 0;
  margin: 0 2px;
}

.progress-stage-connector-done {
  background: var(--accent);
}

/* ============================================================================
   SKELETON LOADING PLACEHOLDERS
   ============================================================================ */

.skeleton {
  background: linear-gradient(90deg,
    var(--paper-elevated) 25%,
    var(--paper-soft) 50%,
    var(--paper-elevated) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-card {
  height: 120px;
  border-radius: var(--radius-lg);
}

.skeleton-row {
  height: 40px;
  margin-bottom: var(--space-2);
}

.skeleton-text {
  height: 14px;
  width: 60%;
  margin-bottom: var(--space-2);
}

/* ============================================================================
   BUTTON LOADING STATES
   ============================================================================ */

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

.btn-spinner {
  display: none;
  align-items: center;
  gap: var(--space-2);
}

.htmx-request .btn-text { display: none; }
.htmx-request .btn-spinner { display: inline-flex; }
.htmx-request.button { pointer-events: none; opacity: 0.7; }

.btn-spinner-icon {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ============================================================================
   HTMX SWAP TRANSITIONS
   ============================================================================ */

.htmx-swapping {
  opacity: 0;
  transition: opacity 0.15s ease-out;
}

.htmx-settling {
  transition: opacity 0.25s ease-in;
}

/* ============================================================================
   FULL-PAGE DRAG OVERLAY
   ============================================================================ */

.drop-overlay-fullpage {
  position: fixed;
  inset: 0;
  background: rgba(var(--accent-rgb), 0.08);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  border: 3px dashed var(--accent);
  gap: var(--space-4);
  pointer-events: none;
}

.drop-overlay-fullpage svg {
  color: var(--accent);
  opacity: 0.6;
}

.drop-overlay-fullpage span {
  font-family: var(--font-display);
  font-size: var(--font-size-2xl);
  font-weight: 600;
  color: var(--accent);
}

/* ============================================================================
   ONBOARDING WIZARD (ENHANCED)
   ============================================================================ */

.onboarding-wizard {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.onboarding-wizard-steps {
  display: flex;
  align-items: flex-start;
  gap: 0;
  position: relative;
}

.onboarding-step-enhanced {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  text-decoration: none;
  color: inherit;
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  transition: all var(--transition-base);
  position: relative;
}

.onboarding-step-enhanced:hover {
  background: var(--paper-elevated);
  transform: translateY(-2px);
}

.step-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: var(--font-size-xl);
  font-weight: 700;
  margin-bottom: var(--space-3);
  transition: all var(--transition-base);
}

.step-circle-pending {
  background: var(--paper-elevated);
  border: 2px solid var(--border);
  color: var(--ink-muted);
}

.step-circle-active {
  background: var(--accent);
  border: 2px solid var(--accent);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.15);
}

.step-circle-done {
  background: var(--success);
  border: 2px solid var(--success);
  color: #fff;
}

.step-connector {
  position: absolute;
  top: 48px;
  height: 2px;
  background: var(--border);
  z-index: 0;
}

.step-connector-done {
  background: var(--success);
}

.onboarding-explainer {
  background: var(--paper-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-top: var(--space-4);
}

.onboarding-explainer h4 {
  font-family: var(--font-display);
  font-size: var(--font-size-base);
  font-weight: 700;
  color: var(--ink);
  margin-bottom: var(--space-2);
}

.onboarding-explainer p {
  font-size: var(--font-size-sm);
  color: var(--ink-soft);
  line-height: 1.6;
  margin: 0;
}

/* ============================================================================
   STATUS PAGE TAB LAYOUT
   ============================================================================ */

.status-tab-bar {
  display: flex;
  gap: var(--space-1);
  border-bottom: 2px solid var(--border);
  margin-bottom: var(--space-6);
  overflow-x: auto;
}

.status-tab-button {
  padding: var(--space-3) var(--space-5);
  font-family: var(--font-display);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--ink-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.status-tab-button:hover {
  color: var(--ink);
}

.status-tab-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ============================================================================
   STICKY BULK ACTION BAR
   ============================================================================ */

.bulk-action-bar-sticky {
  position: sticky;
  bottom: 0;
  z-index: var(--z-sticky);
  backdrop-filter: blur(8px);
  background: rgba(var(--paper-rgb), 0.9);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px var(--shadow-ink);
  padding: var(--space-3) var(--space-5);
  margin: 0 calc(-1 * var(--space-5));
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

/* ============================================================================
   ENHANCED PREVIEW MODAL METADATA
   ============================================================================ */

.preview-meta-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-1) var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  font-size: var(--font-size-xs);
  flex-shrink: 0;
}

.preview-meta-label {
  color: var(--ink-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.preview-meta-value {
  color: var(--ink-soft);
  font-family: var(--font-mono);
  word-break: break-all;
}

/* ============================================================================
   ENHANCED EMPTY STATES
   ============================================================================ */

.empty-state-enhanced {
  text-align: center;
  padding: var(--space-12) var(--space-8);
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  background: var(--paper-soft);
}

.empty-state-enhanced svg {
  color: var(--ink-muted);
  margin-bottom: var(--space-4);
  opacity: 0.5;
}

.empty-state-enhanced h3 {
  font-family: var(--font-display);
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--ink);
  margin-bottom: var(--space-2);
}

.empty-state-enhanced p {
  font-size: var(--font-size-sm);
  color: var(--ink-soft);
  margin-bottom: var(--space-6);
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}

.empty-state-enhanced .button {
  display: inline-flex;
}

/* Source delete confirmation modal */
.source-confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(var(--overlay-rgb), 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: var(--space-6);
}

.source-confirm-card {
  background: var(--paper-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card-hover);
  max-width: 440px;
  width: 100%;
  padding: var(--space-6);
}

/* Format badges */
.format-badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: center;
  margin-top: var(--space-4);
}

.format-badge {
  padding: var(--space-1) var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.08);
  border: 1px solid rgba(var(--accent-rgb), 0.15);
  border-radius: var(--radius-full);
}
