/* ── Glassmorphism UI — Garnier Alliance Group palette ── */

:root {
  /* GAG Brand palette */
  --gold-50:  #fdf8e8;
  --gold-100: #f9eeb8;
  --gold-200: #f4df85;
  --gold-300: #ecc84a;
  --gold-400: #d9b02a;
  --gold-500: #C5941A;       /* Brand primary (WCAG AA: 4.52:1 on white) */
  --gold-600: #A67A16;
  --gold-700: #8B6914;
  --gold-800: #6d530f;
  --gold-900: #4f3c0b;

  --brand:       var(--gold-500);
  --brand-light: var(--gold-300);
  --brand-dark:  var(--gold-700);
  --brand-rgb:   197, 148, 26;   /* RGB components for rgba() */

  /* Neutral scale (Apple-like) */
  --gray-50:  #f9f9fb;
  --gray-100: #f0f0f3;
  --gray-200: #e1e1e8;
  --gray-300: #c7c7d1;
  --gray-400: #a0a0ab;
  --gray-500: #7c7c86;
  --gray-600: #5c5c66;
  --gray-700: #40404a;
  --gray-800: #2c2c35;
  --gray-900: #1a1a22;
  --gray-950: #0f0f15;

  /* Glass / Surface */
  --glass-bg:      rgba(255,255,255,0.72);
  --glass-border:  rgba(255,255,255,0.30);
  --glass-shadow:  0 8px 32px rgba(0,0,0,0.08);
  --glass-blur:    12px;

  /* Dark glass */
  --glass-bg-dark:      rgba(26,26,34,0.78);
  --glass-border-dark:  rgba(255,255,255,0.08);
  --glass-shadow-dark:  0 8px 32px rgba(0,0,0,0.40);

  /* Typography */
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
  --font-heading: 'SF Pro Display', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:    'SF Mono', 'Cascadia Code', 'Fira Code', monospace;

  /* Spacing (8px grid — Apple) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.02);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.04);

  /* Transitions */
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.22, 1, 0.36, 1);

  /* Semantic text aliases */
  --color-text: var(--gray-900);
  --color-text-muted: var(--gray-500);
  --color-accent: var(--brand);
  --color-bg: rgba(0,0,0,0.03);
  --color-border: rgba(0,0,0,0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --glass-bg:     var(--glass-bg-dark);
    --glass-border: var(--glass-border-dark);
    --glass-shadow: var(--glass-shadow-dark);
  }
}

/* html.dark-mode overrides for manual toggle (theme.js adds this class) */
/* Values tuned for readability on gray-950 background: contrast >= 4.5:1 ✓ */
html.dark-mode {
  --glass-bg:     rgba(20, 20, 30, 0.55);
  --glass-border: rgba(255, 255, 255, 0.06);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

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

body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  color: var(--gray-900);
  background: var(--gray-50);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-text: var(--gray-100);
    --color-text-muted: var(--gray-400);
    --color-accent: var(--brand);
    --color-bg: rgba(255,255,255,0.04);
    --color-border: rgba(255,255,255,0.10);
    --gold-500: #E6A817;       /* Brighter gold for dark mode (WCAG AA) */
    --brand:    var(--gold-500);
    --brand-rgb: 230, 168, 23;  /* RGB of dark mode gold */
  }
  body {
    color: var(--gray-100);
    background: var(--gray-950);
  }
  .chat-msg.assistant .chat-msg-content {
    background: var(--gray-800);
  }
  .chat-msg-content code {
    background: rgba(255,255,255,0.12);
  }
  .chat-msg-content pre {
    background: rgba(0,0,0,0.3);
  }
}

/* ── Scrollbar ──────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
@media (prefers-color-scheme: dark) {
  ::-webkit-scrollbar-thumb { background: var(--gray-600); }
}

/* ── Selection ──────────────────────────────────────── */
::selection { background: var(--brand); color: #fff; }

/* ── Buttons ────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s var(--ease-smooth);
  -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--gold-400), var(--gold-600));
  color: #fff;
  box-shadow: 0 2px 12px rgba(var(--brand-rgb),0.30);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(var(--brand-rgb),0.40);
}

.btn-outline {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--gray-700);
  box-shadow: var(--glass-shadow);
}
.btn-outline:hover {
  border-color: var(--brand);
  color: var(--brand);
}

/* ── Empty State ────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--space-16) var(--space-6);
  color: var(--gray-400);
}
.empty-state .icon {
  margin-bottom: var(--space-4);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.empty-state .icon svg { display: block; opacity: 0.5; }
.empty-state h3 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: var(--space-2);
  color: var(--gray-600);
}
.empty-state p {
  font-size: 0.9rem;
  max-width: 400px;
  margin: 0 auto var(--space-5);
  color: var(--gray-400);
}
@media (prefers-color-scheme: dark) {
  .empty-state h3 { color: var(--gray-300); }
  .empty-state p { color: var(--gray-400); }
}

/* ── Breadcrumbs ────────────────────────────────────── */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.85rem;
  color: var(--gray-400);
}
.breadcrumbs a { color: var(--brand); text-decoration: none; }
.breadcrumbs a:hover { text-decoration: underline; }

/* ── Markdown content ───────────────────────────────── */
.article-content { line-height: 1.8; font-size: 0.95rem; }
.article-content h1, .article-content h2, .article-content h3 {
  font-family: var(--font-heading);
  color: var(--brand);
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.article-content h1 { font-size: 1.6rem; border-bottom: 1px solid var(--gray-200); padding-bottom: var(--space-2); }
.article-content h2 { font-size: 1.3rem; }
.article-content h3 { font-size: 1.1rem; }
.article-content p { margin-bottom: 1em; }
.article-content a { color: var(--brand); text-decoration: underline; transition: color 0.15s; }
.article-content a:hover { filter: brightness(1.2); }
.article-content a[href^="http"]::after { content: " ↗"; font-size: 0.75em; }
.article-content blockquote {
  border-left: 3px solid var(--brand);
  padding-left: var(--space-4);
  margin: 1em 0;
  color: var(--gray-500);
  font-style: italic;
}
.article-content code {
  background: var(--gray-100);
  padding: 2px 6px;
  border-radius: var(--space-1);
  font-size: 0.85em;
  font-family: var(--font-mono);
}
@media (prefers-color-scheme: dark) {
  .article-content code { background: var(--gray-800); }
}
.article-content pre {
  background: var(--gray-900);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  overflow-x: auto;
  margin: 1em 0;
}
.article-content pre code { background: none; padding: 0; color: var(--gray-100); }
.article-content img { max-width: 100%; border-radius: var(--radius-md); margin: 1em 0; }

/* ── Tables ─────────────────────────────────────────── */
.article-content table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 1.2em 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  font-size: 0.9rem;
}
.article-content thead th {
  background: linear-gradient(135deg, var(--gold-400), var(--gold-600));
  color: #fff;
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: none;
}
.article-content thead th:not(:last-child) { border-right: 1px solid rgba(255,255,255,0.15); }
.article-content tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--gray-200);
  border-right: 1px solid var(--gray-200);
  vertical-align: top;
}
.article-content tbody td:first-child { border-left: 1px solid var(--gray-200); }
.article-content tbody tr:last-child td { border-bottom: none; }
.article-content tbody tr:last-child td:first-child { border-radius: 0 0 0 var(--radius-md); }
.article-content tbody tr:last-child td:last-child { border-radius: 0 0 var(--radius-md) 0; }
.article-content tbody tr:nth-child(even) { background: var(--gray-50); }
.article-content tbody tr:hover { background: rgba(var(--brand-rgb),0.06); }
.article-content tbody td:first-child { font-weight: 500; }
@media (prefers-color-scheme: dark) {
  .article-content tbody td { border-color: var(--gray-700); }
  .article-content tbody tr:nth-child(even) { background: rgba(255,255,255,0.02); }
}
.article-content ul, .article-content ol { padding-left: var(--space-6); margin-bottom: 1em; }
.article-content li { margin-bottom: var(--space-1); }

/* ── Notification ───────────────────────────────────── */
.notification {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 200;
  padding: var(--space-4) var(--space-6);
  border-radius: var(--radius-lg);
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  font-size: 14px;
  transform: translateY(var(--space-5));
  opacity: 0;
  transition: all 0.3s var(--ease-smooth);
  max-width: 400px;
  pointer-events: none;
}
.notification.show { transform: translateY(0); opacity: 1; }
.notification.success { border-left: 4px solid #34c759; }
.notification.error { border-left: 4px solid #ff3b30; }
.notification.info { border-left-color: var(--brand); }

/* ══ Background gradient ══════════════════════════ */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 0% 0%, rgba(var(--brand-rgb),0.08) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 100% 100%, rgba(var(--brand-rgb),0.06) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}
@media (prefers-color-scheme: dark) {
  body::before {
    background:
      radial-gradient(ellipse 80% 60% at 0% 0%, rgba(var(--brand-rgb),0.15) 0%, transparent 60%),
      radial-gradient(ellipse 60% 50% at 100% 100%, rgba(var(--brand-rgb),0.10) 0%, transparent 50%);
  }
}

/* ══ Layout ══════════════════════════════════════ */

/* ── Glass utility class ────────────────────────────── */
/* Reusable glassmorphism surface. Drop this on any container
   that needs the frosted-glass look. Dark mode is handled
   by the --glass-* variable overrides above (both @media and html.dark-mode). */
.glass {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow);
}

body { display: flex; min-height: 100vh; }
.main-wrap, .sidebar { position: relative; z-index: 1; }

/* ══ Sidebar ════════════════════════════════════ */
.sidebar {
  width: 240px;
  min-width: 240px;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--glass-border);
  box-shadow: 4px 0 24px rgba(0,0,0,0.03);
  transition: width 0.3s var(--ease-smooth), min-width 0.3s var(--ease-smooth);
  overflow: hidden;
}
.sidebar.collapsed { width: 60px; min-width: 60px; }

.sidebar-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4);
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
}
.sidebar-toggle {
  width: 34px; height: 34px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
  color: var(--gray-500);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}
.sidebar-toggle:hover { border-color: var(--brand); color: var(--brand); }
.sidebar-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gray-800);
  white-space: nowrap;
  overflow: hidden;
  opacity: 1;
  transition: opacity 0.2s;
}
.collapsed .sidebar-title { opacity: 0; pointer-events: none; }

/* Sidebar sections */
.sidebar-section { padding: var(--space-2) 0; border-bottom: 1px solid var(--glass-border); flex-shrink: 0; }
.sidebar-section-label {
  padding: var(--space-1) var(--space-4);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--gray-400);
  white-space: nowrap;
  overflow: hidden;
}
.collapsed .sidebar-section-label { opacity: 0; height: 0; padding: 0; overflow: hidden; }

.sidebar-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  text-decoration: none;
  color: var(--gray-600);
  font-size: 0.85rem;
  white-space: nowrap;
  transition: all 0.15s var(--ease-smooth);
  border-left: 3px solid transparent;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 1px 0;
}
.sidebar-item:hover { color: var(--brand); background: rgba(var(--brand-rgb),0.06); }
.sidebar-item.active { background: rgba(var(--brand-rgb),0.10); border-left-color: var(--brand); color: var(--brand); font-weight: 500; }
.sidebar-item .icon {
  width: 24px; text-align: center; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.sidebar-item .icon svg { display: block; }
.sidebar-item .label { overflow: hidden; opacity: 1; transition: opacity 0.2s; }
.collapsed .sidebar-item .label { opacity: 0; width: 0; }

/* Sidebar projects */
.sidebar-projects { flex: 1; overflow-y: auto; padding: var(--space-1) 0; }
.sidebar-projects .sidebar-item { padding-left: var(--space-4); font-size: 0.82rem; }

/* Env links */
.sidebar-env-links {
  display: flex;
  gap: 2px;
  padding: 0 var(--space-4) var(--space-2) 44px;
}
.env-link {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border-radius: var(--space-1);
  font-size: 0.68rem;
  text-decoration: none;
  color: var(--gray-400);
  transition: all 0.15s;
  white-space: nowrap;
}
.env-link svg { display: block; }
.env-link:hover { color: var(--brand); background: rgba(var(--brand-rgb),0.06); }
.env-link.disabled { opacity: 0.3; cursor: default; pointer-events: none; }
.collapsed .sidebar-env-links { display: none; }

/* Env status dot */
.env-status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--gray-300);
  transition: background-color 0.3s ease;
}
.env-status-dot.grey { background: var(--gray-400); }
.env-status-dot.green { background: #22c55e; box-shadow: 0 0 4px rgba(34,197,94,0.5); }
.env-status-dot.orange { background: #f59e0b; box-shadow: 0 0 4px rgba(245,158,11,0.5); }
.env-status-dot.red { background: #ef4444; box-shadow: 0 0 4px rgba(239,68,68,0.5); }

/* Sidebar search */
.sidebar-search {
  display: flex;
  align-items: center;
  gap: 0;
  padding: var(--space-1) var(--space-4);
}
.sidebar-search input {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--glass-border);
  border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  background: var(--glass-bg);
  color: var(--gray-700);
  font-size: 0.8rem;
  font-family: var(--font-body);
  outline: none;
  min-width: 0;
  transition: border-color 0.15s;
}
.sidebar-search input:focus { border-color: var(--brand); }
.sidebar-search input::placeholder { color: var(--gray-400); }
.sidebar-search button {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--brand);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: linear-gradient(135deg, var(--gold-400), var(--gold-600));
  color: #fff;
  cursor: pointer;
  transition: filter 0.15s;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar-search button:hover { filter: brightness(1.1); }
.sidebar-search button svg { display: block; }
.collapsed .sidebar-search input { display: none; }
.collapsed .sidebar-search button { border-radius: var(--radius-sm); }

/* Sidebar footer */
.sidebar-footer {
  padding: var(--space-2);
  border-top: 1px solid var(--glass-border);
  flex-shrink: 0;
  margin-top: auto;
}
.btn-install-app {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3); width: 100%;
  border: 1px dashed var(--gray-300);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--gray-400);
  font-size: 0.82rem; font-family: var(--font-body);
  cursor: pointer; transition: all 0.15s;
  white-space: nowrap; overflow: hidden;
}
.btn-install-app:hover { border-color: var(--brand); color: var(--brand); background: rgba(var(--brand-rgb),0.06); }
.btn-install-app .icon { flex-shrink: 0; }
.collapsed .btn-install-app .label { opacity: 0; width: 0; overflow: hidden; }

/* ══ Chat Panel (right slide-in) ═════════════════ */
.chat-panel {
  position: fixed;
  top: 0;
  right: -400px;
  width: 400px;
  height: 100vh;
  background: var(--bg);
  border-left: 1px solid var(--glass-border);
  box-shadow: -8px 0 32px rgba(0,0,0,0.08);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: right 0.3s var(--ease-smooth);
}
.chat-panel.open { right: 0; }

.chat-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gray-800);
}
.chat-panel-header .icon { vertical-align: middle; margin-right: var(--space-2); }

.chat-panel-close {
  width: 30px; height: 30px;
  border: none; border-radius: var(--radius-sm);
  background: transparent;
  color: var(--gray-400);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.chat-panel-close:hover { background: var(--gray-100); color: var(--gray-800); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.chat-msg {
  display: flex;
  max-width: 85%;
  animation: msgIn 0.25s var(--ease-smooth);
}
.chat-msg.user { align-self: flex-end; }
.chat-msg.assistant { align-self: flex-start; }

.chat-msg-content {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-msg.user .chat-msg-content {
  background: var(--brand);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg.assistant .chat-msg-content {
  background: var(--gray-100);
  color: var(--color-text);
  border-bottom-left-radius: 4px;
}
.chat-msg.assistant.error .chat-msg-content {
  background: #fef2f2;
  color: #b91c1c;
}

/* Markdown rendering inside chat messages */
.chat-msg-content p { margin: 0 0 0.4em; }
.chat-msg-content p:last-child { margin-bottom: 0; }
.chat-msg-content code {
  background: rgba(0,0,0,0.08);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.82rem;
  font-family: 'SFMono-Regular', Consolas, monospace;
}
.chat-msg-content pre {
  background: rgba(0,0,0,0.06);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 0.4em 0;
}
.chat-msg-content pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}
.chat-msg-content a {
  color: var(--brand);
  text-decoration: underline;
}
.chat-msg-content ul, .chat-msg-content ol {
  margin: 0.3em 0;
  padding-left: 1.4em;
}
.chat-msg-content li { margin-bottom: 0.2em; }
.chat-msg-content strong { font-weight: 600; }

/* Typing indicator */
.chat-msg.typing .chat-msg-content {
  display: flex;
  gap: 4px;
  padding: var(--space-3) var(--space-4);
  min-height: 36px;
  align-items: center;
}
.typing-dot {
  font-size: 0.6rem;
  color: var(--gray-400);
  animation: typingBounce 1.4s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-input-wrap {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5) var(--space-5);
  border-top: 1px solid var(--glass-border);
  flex-shrink: 0;
}
.chat-input-wrap input {
  flex: 1;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  background: var(--glass-bg);
  color: var(--color-text);
  font-size: 0.88rem;
  font-family: var(--font-body);
  outline: none;
  transition: border-color 0.15s;
}
.chat-input-wrap input::placeholder { color: var(--color-text-muted); }
.chat-input-wrap input:focus { border-color: var(--brand); }
.chat-send-btn {
  width: 40px; height: 40px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}
.chat-send-btn:hover { filter: brightness(1.1); }
.chat-send-btn .icon { display: block; }

/* Collapsed sidebar: hide label */
.collapsed .chat-toggle-btn .label { opacity: 0; width: 0; overflow: hidden; }

/* Dark mode overrides for chat panel (must come AFTER base rules) */
@media (prefers-color-scheme: dark) {
  .chat-panel { background: var(--gray-900); border-left-color: rgba(255,255,255,0.06); }
  .chat-panel-header { color: var(--gray-100); border-bottom-color: rgba(255,255,255,0.06); }
  .chat-panel-close:hover { background: rgba(255,255,255,0.08); color: var(--gray-100); }
  .chat-msg.assistant .chat-msg-content { background: var(--gray-800); }
  .chat-msg-content code { background: rgba(255,255,255,0.12); }
  .chat-msg-content pre { background: rgba(0,0,0,0.3); }
  .chat-input-wrap { border-top-color: rgba(255,255,255,0.06); }
  .chat-input-wrap input { border-color: rgba(255,255,255,0.10); background: var(--gray-800); }
  .chat-input-wrap input:focus { border-color: var(--brand); }
}

/* ── Main content ────────────────────────────────── */
.main-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; }
main {
  flex: 1;
  padding: var(--space-8) var(--space-10) var(--space-12);
  max-width: 1200px;
  width: 100%;
}

/* Mobile burger */
.mobile-burger {
  display: none;
  position: fixed;
  top: var(--space-3);
  left: var(--space-3);
  z-index: 45;
  width: 36px; height: 36px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  color: var(--gray-600);
  cursor: pointer;
  font-size: 18px;
  transition: all 0.2s;
}
.mobile-burger:hover { border-color: var(--brand); color: var(--brand); }

/* ── Dark mode sidebar overrides ────────────────── */
@media (prefers-color-scheme: dark) {
  .sidebar-title { color: var(--gray-200); }
  .sidebar-item { color: var(--gray-300); }
  .sidebar-item:hover { color: var(--brand); background: rgba(var(--brand-rgb),0.12); }
  .sidebar-item.active { color: var(--brand); }
  .sidebar-section-label { color: var(--gray-500); }
  .sidebar-footer { border-top-color: rgba(255,255,255,0.06); }
  .env-link { color: var(--gray-500); }
  .env-link:hover { color: var(--brand); background: rgba(var(--brand-rgb),0.12); }
  .env-link.disabled { color: var(--gray-600); }
  .sidebar-search input { color: var(--gray-200); background: rgba(255,255,255,0.05); }
  .sidebar-search input::placeholder { color: var(--gray-500); }
  .mobile-burger { color: var(--gray-300); background: rgba(26,26,34,0.85); border-color: rgba(255,255,255,0.08); }
  .page-header h1 { color: var(--gray-100); }
}

/* ── Page header ────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-header h1 { font-family: var(--font-heading); font-size: 1.6rem; color: var(--gray-800); font-weight: 700; letter-spacing: -0.02em; }

/* ── Project table (portal) ─────────────────────── */
.project-table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--glass-bg); -webkit-backdrop-filter: blur(var(--glass-blur)); backdrop-filter: blur(var(--glass-blur)); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--glass-shadow); border: 1px solid var(--glass-border); }
.project-table th { text-align: left; padding: 12px 16px; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.8px; color: var(--gray-400); background: transparent; border-bottom: 1px solid var(--glass-border); font-weight: 600; }
.project-table td { padding: 12px 16px; border-bottom: 1px solid var(--glass-border); vertical-align: middle; background: transparent; }
.project-table tr:last-child td { border-bottom: none; }
.project-table tr:hover td { background: rgba(var(--brand-rgb),0.04); }
.project-table .proj-icon { font-size: 1.4rem; width: 48px; text-align: center; vertical-align: middle; }
.project-table .proj-name { font-weight: 500; vertical-align: middle; }
.project-table .proj-name a { color: var(--color-text); text-decoration: none; }
.project-table .proj-name a:hover { color: var(--color-accent); }
.project-table .proj-desc { color: var(--color-text-muted); font-size: 0.85rem; max-width: 300px; vertical-align: middle; }
.project-table .proj-slug { font-size: 0.8rem; color: var(--color-text-muted); font-family: 'Cascadia Code', 'Fira Code', monospace; vertical-align: middle; }
.project-table .actions { white-space: nowrap; vertical-align: middle; }
.project-table .actions .btn-sm + .btn-sm { margin-left: 6px; }
.btn-sm { padding: 5px 10px; font-size: 0.8rem; border-radius: 6px; border: none; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; transition: all 0.15s; }
.btn-sm svg { display: block; color: inherit; }
.btn-edit { background: var(--color-bg); border: 1px solid var(--color-border); color: var(--color-text); }
.btn-edit:hover { border-color: var(--color-accent); color: var(--color-accent); }
.btn-delete { background: #fef2f2; border: 1px solid #fecaca; color: #dc2626; }
.btn-delete:hover { background: #fee2e2; }
.project-stats { display: flex; gap: 8px; flex-wrap: wrap; }
.stat-tag { padding: 2px 8px; border-radius: 10px; font-size: 0.75rem; background: var(--color-bg); color: var(--color-text-muted); }

/* ── Resource bars (project list) ── */
.proj-stats { min-width: 180px; }
.res-bar { display: inline-flex; align-items: center; gap: 4px; margin-right: 10px; font-size: 0.78rem; }
.res-icon { display: inline-flex; align-items: center; color: var(--color-text-muted); flex-shrink: 0; }
.res-track { width: 40px; height: 5px; background: var(--glass-border); border-radius: 3px; overflow: hidden; }
.res-fill { height: 100%; border-radius: 3px; transition: width 0.3s; }
.res-pct { color: var(--color-text-muted); font-size: 0.72rem; font-weight: 500; min-width: 28px; text-align: right; }
.res-na { color: var(--color-text-muted); font-size: 0.78rem; }

/* ── Monitoring dashboard ───────────────────────── */
.monitor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-4);
}
.monitor-card {
  background: var(--card-bg, var(--glass-bg));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  backdrop-filter: blur(10px);
}
.monitor-card h2 {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gray-400);
  margin: 0 0 var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.monitor-card h2 svg { display: block; }
.monitor-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--glass-border);
  font-size: 0.85rem;
}
.monitor-stat:last-child { border-bottom: none; }
.monitor-stat .label { color: var(--gray-500); }
.monitor-stat .value { font-weight: 600; color: var(--gray-800); }
@media (prefers-color-scheme: dark) {
  .monitor-stat .value { color: var(--gray-200); }
}
.container-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--glass-border);
  font-size: 0.85rem;
}
.container-row:last-child { border-bottom: none; }
.container-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.container-dot.up { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,0.5); }
.container-dot.paused { background: #f59e0b; box-shadow: 0 0 6px rgba(245,158,11,0.5); }
.container-dot.down { background: #ef4444; box-shadow: 0 0 6px rgba(239,68,68,0.5); }
.container-info { flex: 1; min-width: 0; }
.container-name {
  font-weight: 600;
  color: var(--gray-800);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (prefers-color-scheme: dark) {
  .container-name { color: var(--gray-200); }
}
.container-meta {
  font-size: 0.75rem;
  color: var(--gray-400);
  margin-top: 2px;
}
.container-cpu-mem {
  text-align: right;
  white-space: nowrap;
  font-size: 0.78rem;
  color: var(--gray-500);
}
.bar-track {
  width: 100%;
  height: 8px;
  background: var(--gray-200);
  border-radius: 4px;
  overflow: hidden;
  margin-top: var(--space-2);
}
@media (prefers-color-scheme: dark) {
  .bar-track { background: var(--gray-700); }
}
.bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}
.bar-fill.green { background: linear-gradient(90deg, #22c55e, #16a34a); }
.bar-fill.orange { background: linear-gradient(90deg, #f59e0b, #d97706); }
.bar-fill.red { background: linear-gradient(90deg, #ef4444, #dc2626); }
.bar-fill.blue { background: linear-gradient(90deg, #3b82f6, #2563eb); }
.refresh-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}
.refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--gray-500);
  cursor: pointer;
  font-size: 0.78rem;
  font-family: var(--font-body);
  transition: all 0.15s;
}
.refresh-btn:hover { border-color: var(--brand); color: var(--brand); }
.refresh-btn svg { display: block; }
.last-updated {
  font-size: 0.72rem;
  color: var(--gray-400);
}

/* ── Sparkline monitoring ───────────────────────── */
.sparkline-wrap {
  position: relative;
  margin-top: var(--space-3);
  min-height: 34px;
}
.sparkline-svg {
  display: flex;
  align-items: center;
  justify-content: center;
}
.sparkline-svg-element {
  display: block;
  cursor: crosshair;
}
.sparkline-fallback {
  font-size: 0.72rem;
  color: var(--gray-400);
  font-style: italic;
  padding: 6px 0;
  display: block;
  text-align: center;
  line-height: 30px;
}
.sparkline-loading {
  font-size: 0.72rem;
  color: var(--gray-400);
  display: block;
  text-align: center;
  line-height: 30px;
}
.sparkline-tooltip {
  display: none;
  position: absolute;
  top: -28px;
  left: 0;
  background: var(--gray-800);
  color: #fff;
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.sparkline-tooltip strong {
  color: #fff;
  font-weight: 600;
}
html.dark-mode .sparkline-tooltip {
  background: var(--gray-700);
}

/* ── Alert threshold colors (P1-10) ─────────────── */
:root {
  --alert-ok: #22c55e;
  --alert-warning: #f59e0b;
  --alert-critical: #ef4444;
}
.alert-ok { color: var(--alert-ok); }
.alert-warning { color: var(--alert-warning); }
.alert-critical {
  color: var(--alert-critical);
  animation: alertPulse 2s ease-in-out infinite;
}
@keyframes alertPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}


/* ── Project page ────────────────────────── */
.project-header { display: flex; align-items: flex-start; gap: 20px; margin-bottom: 32px; flex-wrap: wrap; }
.project-icon { font-size: 3rem; line-height: 1; }
.project-info { flex: 1; }
.project-info h1 { font-family: var(--font-heading); font-size: 1.8rem; color: var(--gray-800); font-weight: 700; letter-spacing: -0.02em; margin-bottom: 8px; }
@media (prefers-color-scheme: dark) {
  .project-info h1 { color: var(--gray-100); }
}
.project-info .desc { color: var(--color-text-muted); font-size: 0.95rem; max-width: 600px; }
.project-info .meta { font-size: 0.8rem; color: var(--color-text-muted); margin-top: 8px; }
.project-info .meta span { display: inline-flex; align-items: center; gap: 4px; }
.color-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

.section-title { font-family: var(--font-heading); font-size: 1.2rem; margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--glass-border); display: flex; align-items: center; gap: 8px; color: var(--gray-700); font-weight: 600; letter-spacing: -0.01em; }
@media (prefers-color-scheme: dark) {
  .section-title { color: var(--gray-300); }
}
.section-title svg { display: block; color: var(--brand); }

.cat-table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--glass-bg); -webkit-backdrop-filter: blur(var(--glass-blur)); backdrop-filter: blur(var(--glass-blur)); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--glass-shadow); border: 1px solid var(--glass-border); }
.cat-table th { text-align: left; padding: 12px 16px; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.8px; color: var(--gray-400); background: transparent; border-bottom: 1px solid var(--glass-border); font-weight: 600; }
.cat-table td { padding: 12px 16px; border-bottom: 1px solid var(--glass-border); vertical-align: middle; background: transparent; }
.cat-table tr:last-child td { border-bottom: none; }
.cat-table tr:hover td { background: rgba(var(--brand-rgb),0.04); }
.cat-icon { width: 48px; text-align: center; color: var(--color-text); vertical-align: middle; }
.cat-icon svg { display: inline-block; vertical-align: middle; }
.cat-name { font-weight: 500; }
.cat-name a { color: var(--color-text); text-decoration: none; }
.cat-name a:hover { color: var(--color-accent); }
.cat-count { font-size: 0.85rem; color: var(--color-text-muted); }
.cat-pub { font-size: 0.75rem; padding: 2px 8px; border-radius: 10px; background: #d1fae5; color: #059669; white-space: nowrap; }
@media (prefers-color-scheme: dark) { .cat-pub { background: #064e3b; color: #6ee7b7; } }

/* ── Content list page ────────────────────── */
.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--glass-border);
}
.list-header .heading {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.list-header .heading .icon {
  font-size: 2rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}
.list-header .heading h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}
.list-header .heading h1 .project-name {
  color: var(--brand);
}
.list-header .btn-add {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.4rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid var(--brand);
  background: linear-gradient(135deg, var(--gold-400), var(--gold-600));
  color: #fff;
  text-decoration: none;
}
.list-header .btn-add:hover {
  filter: brightness(1.1);
  text-decoration: none;
  color: #fff;
}
.content-table-wrap {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  backdrop-filter: blur(var(--glass-blur));
  box-shadow: var(--glass-shadow);
}
.content-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.93rem;
}
.content-table th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 600;
  color: var(--gray-400);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border-bottom: 1px solid var(--glass-border);
  background: transparent;
}
.content-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--glass-border);
  color: var(--color-text);
  vertical-align: middle;
  background: transparent;
}
.content-table tbody tr:last-child td { border-bottom: none; }
.content-table tbody tr:hover td { background: rgba(var(--brand-rgb),0.04); }
.item-title-link {
  color: var(--color-text);
  font-weight: 600;
  text-decoration: none;
  transition: color 0.15s;
}
.item-title-link:hover {
  color: var(--color-accent);
  text-decoration: none;
}
.badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  line-height: 1.5;
}
.badge-draft {
  background: rgba(139,148,158,0.15);
  color: var(--color-text-muted);
  border: 1px solid rgba(139,148,158,0.25);
}
.badge-published,
.badge-ok,
.badge-ready,
.badge-done {
  background: rgba(46,160,67,0.12);
  color: #3fb950;
  border: 1px solid rgba(46,160,67,0.3);
}
.badge-review,
.badge-wip {
  background: rgba(var(--brand-rgb),0.12);
  color: var(--brand);
  border: 1px solid rgba(var(--brand-rgb),0.3);
}
.badge-archived,
.badge-deprecated {
  background: rgba(248,81,73,0.1);
  color: #f85149;
  border: 1px solid rgba(248,81,73,0.25);
}
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}
.tag {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--color-text-muted);
  background: transparent;
  white-space: nowrap;
}
.item-date {
  color: var(--color-text-muted);
  font-size: 0.83rem;
  white-space: nowrap;
}
.text-muted { color: var(--color-text-muted); }

@media (max-width: 768px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); width: 260px; min-width: 260px; }
  .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 45; }
  .sidebar-overlay.open { display: block; }
  main { padding: var(--space-5); padding-top: calc(var(--space-5) + 40px); }
  .mobile-burger { display: flex; }
  .page-header { margin-bottom: 16px; }
  .project-table .proj-desc { display: none; }
  .project-table th:nth-child(3), .project-table td:nth-child(3) { display: none; }
  .monitor-grid { grid-template-columns: 1fr; }
  .list-header { flex-direction: column; align-items: flex-start; }
  .content-table { font-size: 0.85rem; }
  .content-table th,
  .content-table td { padding: 0.65rem 0.8rem; }
  .col-version { display: none; }
}

/* ══ Loading / Empty / Error States ═══════════════════ */

/* Screen-reader only utility */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ── Skeleton loader ─────────────────────────────── */
.skeleton-wrap {
  background: var(--glass-bg);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(var(--glass-blur));
  box-shadow: var(--glass-shadow);
}

.skeleton-table {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.skeleton-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--glass-border);
}

.skeleton-row:last-child {
  border-bottom: none;
}

.skeleton-cell {
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(90deg,
    var(--gray-200) 25%,
    var(--gray-300) 50%,
    var(--gray-200) 75%
  );
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s ease-in-out infinite;
}

.skeleton-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex-shrink: 0;
}

.skeleton-text.w-20 { width: 20%; }
.skeleton-text.w-30 { width: 30%; }
.skeleton-text.w-40 { width: 40%; }
.skeleton-text.w-50 { width: 50%; }
.skeleton-text.w-60 { width: 60%; }
.skeleton-text.w-70 { width: 70%; }
.skeleton-text.w-80 { width: 80%; }

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

@media (prefers-color-scheme: dark) {
  .skeleton-cell {
    background: linear-gradient(90deg,
      var(--gray-700) 25%,
      var(--gray-600) 50%,
      var(--gray-700) 75%
    );
    background-size: 200% 100%;
  }
}

/* Skeleton for card content (monitoring) */
.skeleton-card-loading {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-2) 0;
}

.skeleton-line {
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(90deg,
    var(--gray-200) 25%,
    var(--gray-300) 50%,
    var(--gray-200) 75%
  );
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s ease-in-out infinite;
}

.skeleton-line.w-30 { width: 30%; }
.skeleton-line.w-40 { width: 40%; }
.skeleton-line.w-50 { width: 50%; }
.skeleton-line.w-60 { width: 60%; }
.skeleton-line.w-70 { width: 70%; }
.skeleton-line.w-80 { width: 80%; }

@media (prefers-color-scheme: dark) {
  .skeleton-line {
    background: linear-gradient(90deg,
      var(--gray-700) 25%,
      var(--gray-600) 50%,
      var(--gray-700) 75%
    );
    background-size: 200% 100%;
  }
}

/* ── Loading spinner ─────────────────────────────── */
.loading-spinner-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-8) var(--space-4);
  color: var(--color-text-muted);
}

.loading-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spinnerRotate 0.7s linear infinite;
  flex-shrink: 0;
}

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

.loading-spinner-text {
  font-size: 0.88rem;
  color: var(--color-text-muted);
}

@media (prefers-color-scheme: dark) {
  .loading-spinner {
    border-color: var(--gray-700);
    border-top-color: var(--brand);
  }
}

/* ── Empty state (improved) ──────────────────────── */
.empty-state-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-4);
  color: var(--gray-300);
  opacity: 0.6;
}

.empty-state-icon svg { display: block; }

.empty-state-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: var(--space-2);
  color: var(--gray-500);
}

.empty-state-desc {
  font-size: 0.9rem;
  max-width: 400px;
  margin: 0 auto var(--space-5);
  color: var(--gray-400);
  line-height: 1.5;
}

.empty-state-cta {
  margin-top: var(--space-2);
}

@media (prefers-color-scheme: dark) {
  .empty-state-icon { color: var(--gray-600); }
  .empty-state-title { color: var(--gray-400); }
  .empty-state-desc { color: var(--gray-500); }
}

/* ── Error state ─────────────────────────────────── */
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-12) var(--space-6);
}

.error-state-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-4);
  color: var(--res-danger, #ef4444);
  opacity: 0.7;
}

.error-state-icon svg { display: block; }

.error-state-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: var(--space-2);
  color: var(--res-danger, #dc2626);
}

.error-state-desc {
  font-size: 0.9rem;
  max-width: 420px;
  margin: 0 auto var(--space-5);
  color: var(--color-text-muted);
  line-height: 1.5;
}

.error-state-retry {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.error-state-retry svg { display: block; }

@media (prefers-color-scheme: dark) {
  .error-state-title { color: #fca5a5; }
  .error-state-icon { color: #fca5a5; }
}

/* ══ Score donut gauge (SVG) ═══════════════════════ */
.score-gauge-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 4px 0 12px;
}
.score-gauge {
  width: 100px;
  height: 100px;
  display: block;
}
.score-gauge .gauge-track {
  fill: none;
  stroke: var(--gray-200);
  stroke-width: 8;
}
@media (prefers-color-scheme: dark) {
  .score-gauge .gauge-track { stroke: var(--gray-700); }
}
.score-gauge .gauge-arc {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s ease, stroke 0.3s ease;
}
.score-gauge .gauge-arc.green { stroke: #22c55e; }
.score-gauge .gauge-arc.yellow { stroke: #f59e0b; }
.score-gauge .gauge-arc.red { stroke: #ef4444; }
.score-gauge .gauge-text {
  font-size: 22px;
  font-weight: 700;
  fill: var(--color-text);
  dominant-baseline: central;
  text-anchor: middle;
}
.score-gauge .gauge-label {
  font-size: 9px;
  fill: var(--color-text-muted);
  dominant-baseline: central;
  text-anchor: middle;
}

/* ══ Dimension bars ════════════════════════════════ */
.dim-bars { margin: 8px 0 4px; }
.dim-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.dim-bar-row:last-child { margin-bottom: 0; }
.dim-bar-label {
  width: 80px;
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dim-bar-track {
  flex: 1;
  height: 8px;
  background: var(--gray-200);
  border-radius: 4px;
  overflow: hidden;
}
@media (prefers-color-scheme: dark) {
  .dim-bar-track { background: var(--gray-700); }
}
.dim-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 1s ease;
}
.dim-bar-fill.green { background: linear-gradient(90deg, #22c55e, #16a34a); }
.dim-bar-fill.yellow { background: linear-gradient(90deg, #f59e0b, #d97706); }
.dim-bar-fill.red { background: linear-gradient(90deg, #ef4444, #dc2626); }
.dim-bar-score {
  width: 28px;
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-align: right;
}

/* ══ Client-side table filters ════════════════════════ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--glass-border);
  background: rgba(0,0,0,0.02);
  min-height: 36px;
}
@media (prefers-color-scheme: dark) {
  .filter-bar { background: rgba(255,255,255,0.03); }
}
.filter-count {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  flex: 1;
}
.filter-reset {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  background: transparent;
  color: var(--color-text);
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}
.filter-reset:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: rgba(var(--brand-rgb),0.06);
}
.filter-th {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.filter-th-label {
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.filter-dropdown {
  position: relative;
  display: inline-flex;
}
.filter-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.15s;
  padding: 0;
}
.filter-trigger:hover {
  border-color: var(--glass-border);
  background: rgba(0,0,0,0.04);
}
.filter-trigger[aria-expanded="true"] {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: rgba(var(--brand-rgb),0.08);
}
@media (prefers-color-scheme: dark) {
  .filter-trigger:hover { background: rgba(255,255,255,0.06); }
}
.filter-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 180px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  box-shadow: var(--glass-shadow);
  z-index: 50;
  padding: 6px;
  backdrop-filter: blur(var(--glass-blur));
}
@media (prefers-color-scheme: dark) {
  .filter-menu { background: var(--glass-bg-dark); border-color: var(--glass-border-dark); }
}
.filter-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--color-text);
  transition: background 0.1s;
  white-space: nowrap;
  user-select: none;
}
.filter-option:hover {
  background: rgba(var(--brand-rgb),0.06);
}
.filter-option[aria-selected="true"] {
  background: rgba(var(--brand-rgb),0.08);
  font-weight: 500;
}
.filter-option input[type="checkbox"] {
  margin: 0;
  accent-color: var(--color-accent);
}
.filter-date {
  width: 0;
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 2px 4px;
}

/* ── Side Tabs (Research / Legal) ── */
.side-tabs {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.side-action-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--glass-border);
  background: var(--glass-bg);
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  z-index: 2;
}
.side-action-bar .btn {
  gap: 6px;
}
.side-tablist {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
  overflow-x: auto;
  padding: 0 16px;
}
.side-tab {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  font-size: 0.72rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--color-text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}
.side-tab:hover { color: var(--color-text); }
.side-tab[aria-selected="true"] {
  color: var(--brand);
  border-bottom-color: var(--brand);
}
.side-panels {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}
.side-tabpanel {
  display: none;
}
.side-tabpanel[aria-hidden="false"] {
  display: block;
}
@media (prefers-color-scheme: dark) {
  .side-tab[aria-selected="true"] { color: var(--brand); }
}

