/* ── Variables ─────────────────────────────────────────────────────────────── */
/* PharmaGPT Design System v3.0 — "Premium Enterprise" palette. Executive
   business-attire tones (warm neutrals + walnut brown), refining the earlier
   "Executive Office" redesign to a Stripe / Linear / Notion-Enterprise-grade
   precision palette. See docs/DESIGN_SYSTEM.md and
   PROJECT_MEMORY/DECISIONS.md DEC-018 / DEC-019. */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* Brand — Walnut Brown (primary interactive), kept under the historical
     --navy/--blue names so every existing var() consumer repaints for free */
  --navy:          #2D2A28;   /* heading / strong-emphasis text (Primary Text) */
  --navy-light:    #3A3532;
  --blue:          #9D7B60;   /* Primary Hover (brightens on hover) */
  --blue-light:    #8A6B52;   /* Primary Button (default shade) */
  --accent:        #6E8FA5;   /* Information — distinct accent, never a primary CTA */

  /* Sidebar */
  --sidebar-bg:    #5B4C43;
  --sidebar-hover: #6D5B52;
  --sidebar-active:#8A6B52;

  /* Status */
  --success:       #5F8A61;
  --warning:       #C59A41;
  --info:          #6E8FA5;

  /* Soft semantic tints (badges, banners) */
  --soft-blue:     #E7EEF6;
  --soft-green:    #E8F2EA;
  --soft-amber:    #FFF4E5;

  /* Backgrounds */
  --bg:            #F7F5F2;   /* Primary Background */
  --bg-secondary:  #F1ECE6;   /* Secondary Background */
  --surface:       #FFFFFF;   /* Card Background */

  /* Borders */
  --border:        #E6DED6;
  --divider:       #EEE7E1;

  /* Text */
  --text:          #2D2A28;   /* Primary Text */
  --text-muted:    #66615B;   /* Secondary Text */
  --text-disabled: #9A948C;   /* Muted Text */

  /* Legacy aliases */
  --user-bg:       #8A6B52;
  --user-text:     #FFFFFF;
  --ai-bg:         #FFFFFF;
  --ai-text:       #2D2A28;
  --error:         #C35F5B;   /* Danger */

  --radius:        8px;
  --radius-lg:     14px;      /* Cards */
  --radius-input:  10px;      /* Inputs */
  --content-max:   1280px;    /* Maximum content width */
  --shadow:        0 1px 3px rgba(45,42,40,0.06), 0 1px 2px rgba(45,42,40,0.04);
  --shadow-lg:     0 4px 16px rgba(45,42,40,0.09), 0 8px 28px rgba(45,42,40,0.07);
}

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

/* ── Accessibility: consistent keyboard-focus ring (Phase 5, §13) ────────────
   Applies app-wide to every interactive element via :focus-visible (mouse
   clicks don't trigger it, so this never fights the many components' own
   hover/click states — only Tab-key and other non-pointer focus do). Kept
   as one rule rather than per-component overrides so every button, link,
   input, and custom control (sidebar items, tabs, table rows, chips) gets
   the same treatment without hunting down every existing focus style. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible,
.sidebar-item:focus-visible,
.hdr-chip-clickable:focus-visible,
.ws-card:focus-visible {
  outline: 2px solid var(--blue-light);
  outline-offset: 2px;
  border-radius: 4px;
}

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.5;
}

/* ── Header ────────────────────────────────────────────────────────────────── */
header {
  background: #FFFFFF;
  color: var(--text);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  flex-shrink: 0;
}

.header-context {
  font-size: 11px;
  color: var(--text-disabled);
  font-weight: 400;
  letter-spacing: 0.2px;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--blue-light);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #FFF;
  letter-spacing: -0.5px;
  flex-shrink: 0;
}

.header-titles h1 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--text);
}

.header-titles p {
  font-size: 10px;
  color: var(--text-disabled);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-top: 1px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.3px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s infinite;
}

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

.btn-clear {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-family: inherit;
}

.btn-clear:hover {
  background: var(--bg-secondary);
  border-color: var(--text-disabled);
  color: var(--text);
}

/* ── Header: logged-in user badge ──────────────────────────────────────────── */
.user-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 10px;
  margin-left: 2px;
  border-left: 1px solid var(--border);
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
}

.user-badge .icon { width: 16px; height: 16px; color: var(--text-muted); }

.btn-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-disabled);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

.btn-logout:hover { background: var(--bg-secondary); color: var(--error); }
.btn-logout .icon { width: 15px; height: 15px; }

/* ── Login screen (Phase 2 step 2.6) ───────────────────────────────────────── */
.login-view {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px 28px;
}

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

.login-form .form-group { margin-bottom: 14px; }

.login-form input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text);
  background: #FFF;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.login-form input:focus {
  border-color: var(--blue-light);
  box-shadow: 0 0 0 2px rgba(123,91,69,0.12);
}

.login-remember {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
  cursor: pointer;
  user-select: none;
}

.login-remember input { accent-color: var(--blue-light); cursor: pointer; }

.login-error {
  background: #FBEEEC;
  border: 1px solid rgba(195,95,91,0.35);
  color: var(--error);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 12px;
  margin-bottom: 14px;
}

.login-submit {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 13px;
}

.login-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #FFF;
  border-radius: 50%;
  animation: login-spin 0.7s linear infinite;
}

.session-check-view {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 13px;
}

.login-spinner-lg {
  width: 28px;
  height: 28px;
  border-width: 3px;
  border-color: var(--border);
  border-top-color: var(--blue-light);
}

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

/* ── Layout ─────────────────────────────────────────────────────────────────── */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────────────────────────────── */
.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  color: rgba(255,255,255,0.75);
  display: flex;
  flex-direction: column;
  padding: 12px 0;
  flex-shrink: 0;
  overflow-y: auto;
  border-right: 1px solid rgba(255,255,255,0.04);
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 2px; }

.sidebar-section {
  padding: 0 10px 8px;
}

.sidebar-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.28);
  margin-bottom: 4px;
  padding: 4px 8px 2px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px 7px 13px;
  border-radius: var(--radius);
  border-left: 3px solid transparent;
  font-size: 12px;
  font-weight: 400;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  color: rgba(255,255,255,0.65);
  margin-bottom: 1px;
}

.sidebar-item:hover {
  background: var(--sidebar-hover);
  color: rgba(255,255,255,0.92);
}

.sidebar-item.active {
  background: var(--sidebar-active);
  border-left-color: rgba(255,255,255,0.75);
  color: #FFF;
  font-weight: 500;
}

.sidebar-item .icon {
  font-size: 13px;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.75;
}

.sidebar-item.active .icon { opacity: 1; }

/* ── Lucide icon system (replaces legacy Unicode/emoji glyphs) ───────────────── */
.icon svg,
svg.lucide {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 1.75;
  fill: none;
  flex-shrink: 0;
}

/* Any button/pill containing an icon lays it out inline with its label */
button:has(> svg.lucide),
button:has(> .icon) {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sidebar-item .icon svg { width: 15px; height: 15px; }
.val-collapse-btn .icon svg { width: 11px; height: 11px; }
.dash-stat-icon svg,
.dash-card-icon svg { width: 18px; height: 18px; stroke-width: 1.6; }

.sidebar-divider {
  height: 1px;
  background: rgba(255,255,255,0.06);
  margin: 4px 10px 10px;
}

.expertise-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0 10px;
}

.tag {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: var(--radius);
  padding: 2px 6px;
  font-size: 9px;
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.2px;
}

/* ── Chat area ──────────────────────────────────────────────────────────────── */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* Welcome banner */
.welcome-banner {
  background: #F1ECE6;
  border-bottom: 1px solid var(--divider);
  border-left: 3px solid var(--blue-light);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  font-size: 12px;
}

.welcome-banner .icon { font-size: 22px; }

.welcome-banner p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.welcome-banner strong { color: var(--navy); }

/* Messages */
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

#messages::-webkit-scrollbar { width: 5px; }
#messages::-webkit-scrollbar-track { background: transparent; }
#messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--radius); }

/* Message rows */
.message-row {
  display: flex;
  gap: 12px;
  max-width: 900px;
  animation: fadeUp 0.25s ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.message-row.user { flex-direction: row-reverse; align-self: flex-end; }
.message-row.ai   { align-self: flex-start; }

/* Avatars */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}

.message-row.user .avatar {
  background: var(--blue);
  color: #FFF;
}

.message-row.ai .avatar {
  background: var(--blue);
  color: #FFF;
}

/* Bubbles */
.bubble {
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 14px;
  line-height: 1.65;
  box-shadow: var(--shadow);
  max-width: 720px;
}

.message-row.user .bubble {
  background: var(--user-bg);
  color: var(--user-text);
  border-bottom-right-radius: 4px;
}

.message-row.ai .bubble {
  background: var(--ai-bg);
  color: var(--ai-text);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border);
}

/* Markdown rendering inside AI bubbles */
.bubble h1, .bubble h2, .bubble h3, .bubble h4 {
  color: var(--navy);
  margin: 16px 0 8px;
  line-height: 1.3;
}

.bubble h1 { font-size: 18px; }
.bubble h2 { font-size: 16px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.bubble h3 { font-size: 14px; }
.bubble h4 { font-size: 13px; }

.bubble p { margin: 8px 0; }
.bubble p:first-child { margin-top: 0; }
.bubble p:last-child  { margin-bottom: 0; }

.bubble ul, .bubble ol {
  padding-left: 20px;
  margin: 8px 0;
}

.bubble li { margin: 4px 0; }

.bubble strong { color: var(--navy); }
.bubble em { color: var(--text-muted); }

.bubble code {
  background: #F1ECE6;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1px 6px;
  font-size: 12px;
  font-family: 'Consolas', 'Courier New', monospace;
}

.bubble pre {
  background: #F7F5F2;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  overflow-x: auto;
  margin: 10px 0;
}

.bubble pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
}

/* Tables */
.bubble table {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0;
  font-size: 13px;
}

.bubble th {
  background: var(--bg-secondary);
  color: var(--text);
  padding: 9px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.bubble th:first-child { border-top-left-radius: var(--radius); }
.bubble th:last-child  { border-top-right-radius: var(--radius); }

.bubble td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
}

.bubble tr:nth-child(even) td { background: var(--bg-secondary); }
.bubble tr:hover td           { background: #F1ECE6; }

.bubble blockquote {
  border-left: 3px solid var(--accent);
  padding: 8px 14px;
  margin: 10px 0;
  background: #E8F2EA;
  border-radius: 0 6px 6px 0;
  color: var(--text-muted);
  font-style: italic;
}

/* Timestamp */
.message-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 4px;
}

.message-row.user .message-meta { text-align: right; }

/* ── Thinking label (shown before first token) ──────────────────────────────── */
.thinking-label {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
  padding: 2px 0;
}

.thinking-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.thinking-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--blue-light);
  animation: bounce 1.2s infinite;
}

.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%            { transform: translateY(-7px); }
}

/* ── Streaming cursor (blinking | after the last character) ─────────────────── */
.bubble.streaming.has-content #stream-content::after {
  content: "▍";
  display: inline-block;
  color: var(--blue-light);
  animation: blink 0.8s step-end infinite;
  margin-left: 1px;
  vertical-align: baseline;
  font-size: 13px;
}

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

/* ── Input bar ──────────────────────────────────────────────────────────────── */
.input-bar {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 16px 28px;
  flex-shrink: 0;
  box-shadow: 0 -2px 12px rgba(63,58,54,0.06);
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: #FFF;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input-wrapper:focus-within {
  border-color: var(--blue-light);
  box-shadow: 0 0 0 2px rgba(123,91,69,0.10);
}

#user-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  color: var(--text);
  resize: none;
  outline: none;
  font-family: inherit;
  max-height: 140px;
  min-height: 24px;
  line-height: 1.5;
}

#user-input::placeholder { color: var(--text-muted); }

#send-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  background: var(--blue-light);
  border: none;
  color: #FFF;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: background 0.15s;
  flex-shrink: 0;
}

#send-btn:hover:not(:disabled) { background: var(--blue); }
#send-btn:active { opacity: 0.9; }

#send-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.input-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
  text-align: center;
}

/* ── Error toast ────────────────────────────────────────────────────────────── */
.error-bubble {
  background: #F7E8E7;
  border: 1px solid #F2D8D6;
  color: var(--error);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  align-self: center;
  max-width: 600px;
  animation: fadeUp 0.25s ease;
}

/* ── Sidebar label row (label + "＋ New" button side by side) ───────────────── */
.sidebar-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 0 4px;
}

.btn-new-project {
  background: var(--blue-light);
  border: none;
  color: #FFF;
  border-radius: var(--radius);
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s;
  white-space: nowrap;
  font-family: inherit;
}

.btn-new-project:hover { background: var(--blue); }

/* ── Project list items in sidebar ─────────────────────────────────────────── */
.project-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.12s;
  margin-bottom: 1px;
  gap: 8px;
}

.project-item:hover   { background: var(--sidebar-hover); }
.project-item.active  { background: var(--sidebar-active); }

.proj-item-left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;          /* allows text truncation */
}

.proj-icon { width: 15px; height: 15px; flex-shrink: 0; color: rgba(255,255,255,0.55); display: flex; align-items: center; }

.proj-item-info { min-width: 0; }

.proj-item-name {
  font-size: 13px;
  color: rgba(255,255,255,0.88);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.proj-item-sub {
  font-size: 10px;
  color: rgba(255,255,255,0.38);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.proj-item-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.proj-badge {
  background: rgba(127,160,141,0.25);
  border: 1px solid rgba(127,160,141,0.40);
  color: #C7D6DE;
  border-radius: var(--radius);
  padding: 2px 6px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.proj-delete-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.25);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: var(--radius);
  line-height: 1;
  transition: color 0.15s, background 0.15s;
  display: inline-flex;
  align-items: center;
}
.proj-delete-btn .icon svg { width: 12px; height: 12px; }

.proj-delete-btn:hover {
  color: #D89A96;
  background: rgba(198,99,95,0.15);
}

.proj-fav-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.25);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: var(--radius);
}
.proj-fav-btn .icon svg { width: 12px; height: 12px; }
.proj-fav-btn:hover { color: #E8C77A; background: rgba(232,199,122,0.15); }
.proj-fav-btn.is-fav { color: #E8C77A; }
.proj-fav-btn.is-fav .icon svg { fill: #E8C77A; }

/* ── Active project banner (above chat, below welcome) ──────────────────────── */
.active-project-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #F1ECE6;
  border-bottom: 1px solid var(--divider);
  padding: 8px 24px;
  flex-shrink: 0;
}

.apb-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.apb-icon { width: 20px; height: 20px; opacity: 0.7; }

.apb-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
}

.apb-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.apb-right {}

.apb-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  background: var(--blue-light);
  color: #FFF;
  padding: 3px 8px;
  border-radius: var(--radius);
}

/* ── Modal overlay ──────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(63,58,54,0.55);
  z-index: 100;
  backdrop-filter: blur(2px);
}

.modal-overlay.open { display: block; }

/* ── Modal panel ────────────────────────────────────────────────────────────── */
.modal {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.98);
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 4px 24px rgba(45,42,40,0.18);
  width: 560px;
  max-width: calc(100vw - 32px);
  /* Baseline height cap so every modal (not just .eq-modal/.kb-upload-modal,
     which already redeclared this individually) stays reachable when its
     content is taller than the viewport, instead of overflowing off-screen
     top/bottom with no way to scroll to the rest of the form. */
  max-height: 90vh;
  overflow-y: auto;
  z-index: 101;
  opacity: 0;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.modal.open {
  display: block;
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.modal-close:hover { background: var(--bg); color: var(--text); }

/* ── Modal form ─────────────────────────────────────────────────────────────── */
.modal-body { padding: 20px 24px 0; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

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

.form-group label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.2px;
}

.form-group .required { color: var(--error); }

.form-group input,
.form-group select {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 10px;
  font-size: 12px;
  color: var(--text);
  background: #FFF;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--blue-light);
  box-shadow: 0 0 0 2px rgba(123,91,69,0.12);
}

.form-group input::placeholder { color: var(--border); }

/* ── Modal footer ───────────────────────────────────────────────────────────── */
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

.btn-primary {
  background: var(--blue-light);
  color: #FFF;
  border: none;
  border-radius: var(--radius);
  padding: 8px 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}

.btn-primary:hover:not(:disabled) { background: var(--blue); }
.btn-primary:disabled { opacity: 0.50; cursor: not-allowed; }

.btn-secondary {
  background: #FFF;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 18px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  font-family: inherit;
}

.btn-secondary:hover { background: var(--bg); border-color: #E6DED6; }

.btn-danger {
  background: var(--error);
  color: #FFF;
  border: none;
  border-radius: var(--radius);
  padding: 8px 18px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}

.btn-danger:hover { background: #A8544F; }

.btn-success {
  background: var(--success);
  color: #FFF;
  border: none;
  border-radius: var(--radius);
  padding: 8px 18px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}

.btn-success:hover { background: #4C7A4E; }

/* ══════════════════════════════════════════════════════════════════════════════
   DOCUMENTS VIEW
   ══════════════════════════════════════════════════════════════════════════════ */

/* ── Container ──────────────────────────────────────────────────────────────── */
.documents-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* ── Documents header bar ───────────────────────────────────────────────────── */
.doc-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 18px 28px;
  flex-shrink: 0;
}

.doc-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
}

.doc-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ── Upload section ─────────────────────────────────────────────────────────── */
.doc-upload-section {
  padding: 20px 28px 0;
  flex-shrink: 0;
}

.doc-drop-zone {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  gap: 6px;
}

.doc-drop-zone:hover,
.doc-drop-zone.drag-over {
  border-color: var(--blue-light);
  background: #F1ECE6;
}

.doc-drop-zone .drop-icon { width: 34px; height: 34px; margin: 0 auto 4px; stroke-width: 1.4; color: var(--blue-light); opacity: 0.8; }

.doc-drop-zone .drop-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.doc-drop-zone .drop-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.btn-upload {
  background: var(--blue-light);
  color: #FFF;
  border: none;
  border-radius: var(--radius);
  padding: 7px 18px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}

.btn-upload:hover:not(:disabled) { background: var(--blue); }

.btn-upload:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Status message ─────────────────────────────────────────────────────────── */
.doc-status {
  margin-top: 10px;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  animation: fadeUp 0.2s ease;
}

.doc-status-info    { background: #F1ECE6; color: #8A6B52; border: 1px solid #E8DFD5; }
.doc-status-success { background: #E8F2EA; color: #5F8A61; border: 1px solid #E8F2EA; }
.doc-status-error   { background: #F7E8E7; color: #C35F5B; border: 1px solid #F2D8D6; }

/* ── Document list section ──────────────────────────────────────────────────── */
.doc-list-section {
  flex: 1;
  overflow-y: auto;
  padding: 16px 28px 24px;
}

.doc-list-section::-webkit-scrollbar { width: 5px; }
.doc-list-section::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--radius); }

.doc-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.doc-count {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Empty state ────────────────────────────────────────────────────────────── */
.doc-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
}

/* ── Document rows ──────────────────────────────────────────────────────────── */
.doc-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 4px;
  transition: background 0.12s, border-color 0.12s;
}

.doc-row:hover {
  box-shadow: var(--shadow);
  border-color: #E6DED6;
}

.doc-icon {
  font-size: 26px;
  flex-shrink: 0;
  width: 36px;
  text-align: center;
}

.doc-info {
  flex: 1;
  min-width: 0;   /* enables text truncation inside flex children */
}

.doc-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 420px;
}

.doc-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.doc-type-badge {
  border: 1px solid;
  border-radius: var(--radius);
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* ── Document action buttons ────────────────────────────────────────────────── */
.doc-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.doc-btn {
  border-radius: var(--radius);
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  transition: background 0.12s;
  white-space: nowrap;
  font-family: inherit;
}

.doc-btn-view {
  background: #F1ECE6;
  color: #8A6B52;
}

.doc-btn-view:hover:not(.doc-btn-disabled) {
  background: #E8DFD5;
}

.doc-btn-disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.doc-btn-download {
  background: #E8F2EA;
  color: #5F8A61;
}

.doc-btn-download:hover { background: #E8F2EA; }

.doc-btn-delete {
  background: #F7E8E7;
  color: #C35F5B;
  font-family: inherit;
}

.doc-btn-delete:hover {
  background: #F2D8D6;
  transform: scale(1.03);
}

.doc-btn-retry {
  background: #FFF4E5;
  color: #A97D2E;
}

.doc-btn-retry:hover {
  background: #FFF4E5;
}

/* ── Extraction status badges (document rows + KB detail panel) ────────────── */
.doc-extract-badge {
  border-radius: var(--radius);
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 600;
}

.doc-extract-pending {
  background: #F1ECE6;
  color: #8A6B52;
}

.doc-extract-empty {
  background: #FFF4E5;
  color: #A97D2E;
}

.doc-extract-partial {
  background: #FFF4E5;
  color: #C59A41;
}

.doc-extract-failed {
  background: #F7E8E7;
  color: #C35F5B;
}

/* ── Use Project Documents toggle ───────────────────────────────────────────── */
.use-docs-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  padding: 6px 2px;
  flex-wrap: wrap;
}

.use-docs-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
}

.use-docs-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.use-docs-checkmark {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: #FFF;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.use-docs-label input:checked + .use-docs-checkmark {
  background: var(--blue);
  border-color: var(--blue);
}

.use-docs-label input:checked + .use-docs-checkmark::after {
  content: "✓";
  color: #FFF;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.use-docs-label:hover .use-docs-checkmark {
  border-color: var(--blue-light);
}

.use-docs-label input:checked ~ span.use-docs-text,
.use-docs-label:has(input:checked) {
  color: var(--blue);
}

.use-docs-hint {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2px 8px;
}

/* ── Sources strip (below AI bubble when docs were used) ─────────────────────── */
.sources-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
  padding: 6px 12px;
  background: #F1ECE6;
  border: 1px solid #E8DFD5;
  border-radius: 8px;
  animation: fadeUp 0.2s ease;
}

.sources-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--blue);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.sources-pill {
  font-size: 11px;
  background: #E8DFD5;
  color: #5B4C43;
  border-radius: 10px;
  padding: 2px 8px;
  font-weight: 600;
}

/* ══════════════════════════════════════════════════════════════════════════════
   INSIGHTS VIEW
   ══════════════════════════════════════════════════════════════════════════════ */

.insights-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--bg);
  padding: 28px;
}

#insights-panel {
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
}

.insights-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  color: var(--text-muted);
  text-align: center;
  gap: 12px;
}

.insights-empty-icon { width: 44px; height: 44px; stroke-width: 1.3; opacity: 0.4; }
.insights-empty p    { font-size: 14px; }

.insights-loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ── Insights header ────────────────────────────────────────────────────────── */
.insights-header {
  margin-bottom: 24px;
}

.insights-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
}

.insights-project-name {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Stats grid ─────────────────────────────────────────────────────────────── */
.insights-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.insights-stat-card {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius-lg);
  padding: 20px 18px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s;
}

.insights-stat-card:hover { box-shadow: var(--shadow-lg); }

.stat-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--navy);
  line-height: 1;
  margin-bottom: 6px;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Insights sections ──────────────────────────────────────────────────────── */
.insights-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.insights-section h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 14px;
}

/* ── File type badges ───────────────────────────────────────────────────────── */
.insights-types {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.type-badge {
  color: #FFF;
  border-radius: var(--radius);
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.insights-none {
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Extraction progress bar ────────────────────────────────────────────────── */
.insights-progress-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
}

.insights-progress-bar {
  flex: 1;
  height: 10px;
  background: var(--bg);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.insights-progress-fill {
  height: 100%;
  background: var(--blue-light);
  border-radius: 2px;
  transition: width 0.4s ease;
  min-width: 4px;
}

.insights-progress-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--blue);
  white-space: nowrap;
}

.insights-hint {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.btn-refresh-insights {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 7px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s;
}

.btn-refresh-insights:hover {
  background: var(--border);
  color: var(--text);
}

/* ══════════════════════════════════════════════════════════════════════════════
   VALIDATION DOCUMENT GENERATOR  (v0.6)
   ══════════════════════════════════════════════════════════════════════════════ */

/* ── Sidebar: validation nav items ─────────────────────────────────────────── */
.val-nav-item {
  padding: 7px 12px;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 1px;
}

.val-nav-item:hover  { background: rgba(255,255,255,0.08); }
.val-nav-item.active { background: rgba(123,91,69,0.45); }

.val-nav-item .icon { font-size: 12px; margin-bottom: 0; }

.val-nav-label {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  display: flex;
  align-items: center;
  gap: 7px;
}

.val-nav-sub {
  font-size: 9.5px;
  color: rgba(255,255,255,0.35);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  margin-top: 1px;
  padding-left: 19px;
}

.val-nav-item { flex-direction: row !important; align-items: center !important; gap: 8px !important; }
.val-nav-item .val-nav-label { display: inline; }
.val-nav-item .val-nav-sub   { display: none; }   /* keep sidebar compact */

.risk-sub-item, .qual-sub-item, .report-sub-item { padding-left: 24px !important; }

.val-collapse-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  color: rgba(255,255,255,0.40);
  border-radius: var(--radius);
  padding: 1px 6px;
  font-size: 9px;
  cursor: pointer;
  transition: background 0.12s;
  line-height: 1.8;
  font-family: inherit;
}
.val-collapse-btn:hover { background: rgba(255,255,255,0.12); color: rgba(255,255,255,0.75); }

/* ── Validation main container ──────────────────────────────────────────────── */
.validation-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* ── Validation header ──────────────────────────────────────────────────────── */
.val-header {
  background: var(--sidebar-bg);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.val-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.val-doc-badge {
  background: var(--blue-light);
  color: #FFF;
  border-radius: var(--radius);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}

.val-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: #FFF;
  margin: 0;
}

.val-header p {
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  margin-top: 2px;
}

.val-project-tag {
  font-size: 10px;
  font-weight: 500;
  color: rgba(255,255,255,0.60);
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  padding: 3px 10px;
}

/* ── Progress stepper ───────────────────────────────────────────────────────── */
.val-progress-bar {
  display: flex;
  align-items: center;
  padding: 14px 36px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 0;
}

.val-step-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--border);
  border: 2px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  transition: all 0.2s;
}

.val-step-dot.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #FFF;
  box-shadow: 0 0 0 4px rgba(123,91,69,0.18);
}

.val-step-dot.done {
  background: #5F8A61;
  border-color: #5F8A61;
  color: #FFF;
}
.val-step-dot.done::after { content: "✓"; font-size: 13px; }

.val-step-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 10px;
  white-space: nowrap;
  transition: color 0.2s;
}

.val-step-label.active { color: var(--blue); }
.val-step-label.done   { color: #5F8A61; }

.val-step-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  transition: background 0.2s;
}

.val-step-line.done { background: #5F8A61; }

/* ── Wizard panel ───────────────────────────────────────────────────────────── */
.val-panel {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.val-step-content {
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 28px 40px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.val-step-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 6px;
}

.val-step-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.5;
}

/* ── Form grid (2-column) ───────────────────────────────────────────────────── */
.val-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 20px;
  margin-bottom: 28px;
}

.val-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.val-full-width { grid-column: 1 / -1; }

.val-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.val-input {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.val-input:focus {
  border-color: var(--blue-light);
  box-shadow: 0 0 0 3px rgba(123,91,69,0.10);
  background: #FFF;
}

.val-input::placeholder { color: #9A948C; }

.val-textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

/* ── Navigation row ─────────────────────────────────────────────────────────── */
.val-nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

.val-btn-primary {
  background: var(--blue-light);
  color: #FFF;
  border: none;
  border-radius: var(--radius);
  padding: 8px 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
  font-family: inherit;
}
.val-btn-primary:hover {
  box-shadow: 0 4px 16px rgba(123,91,69,0.35);
  transform: translateY(-1px);
}

.val-btn-secondary {
  background: var(--bg);
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  border-radius: 9px;
  padding: 10px 20px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}
.val-btn-secondary:hover { background: var(--border); color: var(--text); }

.val-btn-generate {
  background: var(--blue);
  color: #FFF;
  border: none;
  border-radius: var(--radius);
  padding: 10px 28px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.3px;
  transition: all 0.3s;
  box-shadow: 0 4px 18px rgba(123,91,69,0.30);
}
.val-btn-generate:hover:not(:disabled) {
  background-position: right center;
  box-shadow: 0 6px 24px rgba(123,91,69,0.45);
  transform: translateY(-2px);
}
.val-btn-generate:disabled { opacity: 0.50; cursor: not-allowed; transform: none; }

/* ── Step 3: document selection ─────────────────────────────────────────────── */
.val-doc-select-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.val-chip {
  background: rgba(123,91,69,0.08);
  border: 1px solid rgba(123,91,69,0.20);
  color: var(--blue);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}
.val-chip:hover { background: rgba(123,91,69,0.15); }

.val-doc-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  margin-bottom: 6px;
  cursor: pointer;
  background: var(--surface);
  transition: border-color 0.15s, background 0.15s;
}
.val-doc-row:hover { border-color: var(--blue-light); background: #F1ECE6; }
.val-doc-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--blue); cursor: pointer; }

.val-doc-icon { font-size: 18px; }

.val-doc-name {
  flex: 1;
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}

.val-doc-type-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px 6px;
}

/* ── Step 4: summary card ───────────────────────────────────────────────────── */
.val-summary-card {
  background: #F1ECE6;
  border: 1px solid #E8DFD5;
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 20px;
}

.val-summary-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid rgba(123,91,69,0.08);
  font-size: 13px;
}
.val-summary-row:last-child { border-bottom: none; }
.val-summary-row span { color: var(--text-muted); }
.val-summary-row strong { color: var(--navy); }

/* ── Generation progress indicator ──────────────────────────────────────────── */
.val-gen-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 600;
  padding: 12px 16px;
  background: #F1ECE6;
  border: 1px solid #E8DFD5;
  border-radius: 9px;
  margin-bottom: 16px;
}

.val-gen-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.val-gen-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--blue);
  animation: bounce 1.2s infinite;
}
.val-gen-dots span:nth-child(2) { animation-delay: 0.2s; }
.val-gen-dots span:nth-child(3) { animation-delay: 0.4s; }

.val-gen-error {
  background: #F7E8E7;
  border: 1px solid #F2D8D6;
  color: var(--error);
  border-radius: 9px;
  padding: 12px 16px;
  font-size: 13px;
}

.val-loading { color: var(--text-muted); font-size: 13px; padding: 12px 0; }
.val-note    { color: var(--text-muted); font-size: 13px; padding: 8px 0; line-height: 1.6; }

/* ── Document Viewer toolbar ─────────────────────────────────────────────────── */
.val-viewer-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(63,58,54,0.06);
  flex-wrap: wrap;
}

.val-tool-btn {
  border-radius: 7px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  background: var(--bg);
  color: var(--text-muted);
  border: 1.5px solid var(--border);
}
.val-tool-btn:hover:not(:disabled) { background: var(--border); color: var(--text); }
.val-tool-btn:disabled { opacity: 0.40; cursor: not-allowed; }

.val-tool-primary {
  background: #F1ECE6;
  color: #8A6B52;
  border-color: #E8DFD5;
}
.val-tool-primary:hover:not(:disabled) { background: #E8DFD5; }

.val-tool-save {
  background: #E8F2EA;
  color: #5F8A61;
  border-color: #E8F2EA;
}
.val-tool-save:hover:not(:disabled) { background: #E8F2EA; }

.val-tool-sep {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 4px;
}

.val-tool-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
}
.val-tool-label.done { color: #5F8A61; }

.val-gen-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue);
  animation: pulse 1.4s infinite;
}
.val-done-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #5F8A61;
}

/* ── Document Viewer page (Word-like) ────────────────────────────────────────── */
.val-doc-scroll {
  flex: 1;
  overflow-y: auto;
  background: #F1ECE6;
  padding: 32px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.val-doc-scroll::-webkit-scrollbar { width: 6px; }
.val-doc-scroll::-webkit-scrollbar-thumb { background: #E6DED6; border-radius: var(--radius); }

.val-doc-page {
  background: #FFFFFF;
  width: 794px;     /* A4 at 96dpi */
  max-width: calc(100vw - 280px - 64px);
  min-height: 1123px;
  padding: 64px 72px 80px;
  box-shadow: 0 4px 28px rgba(63,58,54,0.18);
  border-radius: 2px;
  position: relative;
}

/* ── Document content typography (GMP document style) ───────────────────────── */
.val-doc-content {
  font-family: Calibri, "Segoe UI", sans-serif;
  font-size: 11pt;
  line-height: 1.60;
  color: #5B4C43;
}

.val-doc-content h1 {
  font-size: 18pt;
  font-weight: 800;
  color: #5B4C43;
  text-align: center;
  margin: 0 0 20px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.val-doc-content h2 {
  font-size: 13pt;
  font-weight: 700;
  color: #5B4C43;
  margin: 22px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1.5px solid #8A6B52;
  text-transform: uppercase;
  letter-spacing: 0.2px;
}

.val-doc-content h3 {
  font-size: 11pt;
  font-weight: 700;
  color: #8A6B52;
  margin: 16px 0 6px;
}

.val-doc-content h4 {
  font-size: 10.5pt;
  font-weight: 700;
  color: #5B4C43;
  margin: 12px 0 4px;
}

.val-doc-content p {
  margin: 6px 0;
}

.val-doc-content ul, .val-doc-content ol {
  padding-left: 22px;
  margin: 6px 0;
}
.val-doc-content li { margin: 3px 0; }

.val-doc-content strong { color: #5B4C43; font-weight: 700; }
.val-doc-content em     { color: #9A948C; }

.val-doc-content hr {
  border: none;
  border-top: 1px solid #EEE7E1;
  margin: 16px 0;
}

/* Tables */
.val-doc-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0;
  font-size: 9.5pt;
}
.val-doc-content th {
  background: #5B4C43;
  color: #FFFFFF;
  padding: 7px 12px;
  text-align: left;
  font-weight: 700;
  font-size: 9pt;
  letter-spacing: 0.2px;
}
.val-doc-content td {
  padding: 6px 12px;
  border-bottom: 0.5px solid #EEE7E1;
  vertical-align: top;
}
.val-doc-content tr:nth-child(even) td { background: #F1ECE6; }
.val-doc-content tr:hover td           { background: #F1ECE6; }

/* Code blocks (rare in pharma docs but handle gracefully) */
.val-doc-content code {
  font-family: "Consolas", monospace;
  font-size: 9pt;
  background: #F1ECE6;
  border: 1px solid #EEE7E1;
  border-radius: var(--radius);
  padding: 1px 5px;
}
.val-doc-content pre {
  background: #F7F5F2;
  border: 1px solid #EEE7E1;
  border-radius: var(--radius);
  padding: 12px 16px;
  overflow-x: auto;
  margin: 8px 0;
}
.val-doc-content pre code { background: none; border: none; }

/* Blockquote (used for regulatory citations) */
.val-doc-content blockquote {
  border-left: 3px solid #5F8A61;
  background: #E8F2EA;
  padding: 8px 14px;
  margin: 8px 0;
  border-radius: 0 6px 6px 0;
  color: #9A948C;
  font-style: italic;
}

/* Streaming cursor in viewer */
.val-cursor-blink {
  display: inline-block;
  color: #8A6B52;
  animation: blink 0.8s step-end infinite;
  font-size: 12pt;
}

/* ══════════════════════════════════════════════════════════════════════════════
   KNOWLEDGE BASE  (v0.7)
   ══════════════════════════════════════════════════════════════════════════════ */

.kb-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* ── Header ──────────────────────────────────────────────────────────────────── */
.kb-header {
  background: var(--sidebar-bg);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  border-bottom: 2px solid rgba(255,255,255,0.08);
}

.kb-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.kb-header-icon {
  width: 26px;
  height: 26px;
  color: rgba(255,255,255,0.85);
  flex-shrink: 0;
}

.kb-header-title {
  font-size: 18px;
  font-weight: 700;
  color: #FFF;
  margin: 0;
}

.kb-header-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  margin-top: 2px;
}

.kb-btn-upload {
  background: var(--blue-light);
  color: #FFF;
  border: none;
  border-radius: var(--radius);
  padding: 7px 16px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: box-shadow 0.15s, transform 0.15s;
  white-space: nowrap;
}
.kb-btn-upload:hover {
  box-shadow: 0 4px 16px rgba(123,91,69,0.40);
  transform: translateY(-1px);
}

/* ── Search bar ──────────────────────────────────────────────────────────────── */
.kb-search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.kb-search-field {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  flex: 1;
  min-width: 140px;
}

.kb-search-field:focus-within {
  border-color: var(--blue-light);
  box-shadow: 0 0 0 3px rgba(123,91,69,0.10);
}

.kb-search-keyword { flex: 1.5; }

.kb-search-icon { width: 14px; height: 14px; flex-shrink: 0; opacity: 0.6; }

.kb-search-input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 13px;
  color: var(--text);
  width: 100%;
  font-family: inherit;
}
.kb-search-input::placeholder { color: #9A948C; }

.kb-search-select {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  outline: none;
  font-family: inherit;
  cursor: pointer;
  min-width: 130px;
}
.kb-search-select:focus { border-color: var(--blue-light); }

.kb-btn-search {
  background: var(--blue-light);
  color: #FFF;
  border: none;
  border-radius: var(--radius);
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: box-shadow 0.15s;
}
.kb-btn-search:hover { box-shadow: 0 3px 12px rgba(123,91,69,0.35); }

.kb-btn-clear-search {
  background: var(--bg);
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: background 0.15s;
}
.kb-btn-clear-search:hover { background: var(--border); color: var(--text); }

/* ── KB body layout ──────────────────────────────────────────────────────────── */
.kb-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Folder sidebar ──────────────────────────────────────────────────────────── */
.kb-folder-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px 10px;
}

.kb-folder-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 8px 8px;
}

.kb-folder-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  transition: background 0.15s;
  margin-bottom: 2px;
}
.kb-folder-item:hover  { background: var(--bg); }
.kb-folder-item.active { background: #F1ECE6; color: var(--blue); font-weight: 600; }

.kb-folder-icon { font-size: 15px; flex-shrink: 0; }
.kb-folder-name { flex: 1; }

.kb-folder-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 7px;
  min-width: 22px;
  text-align: center;
}
.kb-folder-item.active .kb-folder-count {
  background: rgba(123,91,69,0.12);
  border-color: rgba(123,91,69,0.25);
  color: var(--blue);
}

/* ── Document list area ──────────────────────────────────────────────────────── */
.kb-list-area {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.kb-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.kb-doc-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 8px;
  text-transform: none;
  letter-spacing: 0;
}

.kb-doc-empty {
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
  color: var(--text-muted);
  gap: 8px;
}

.kb-empty-icon { width: 44px; height: 44px; margin: 0 auto 12px; stroke-width: 1.3; opacity: 0.5; }
.kb-empty-sub  { font-size: 12px; margin-top: 4px; line-height: 1.6; }

/* ── KB document row ─────────────────────────────────────────────────────────── */
.kb-doc-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  background: var(--surface);
  transition: background 0.12s;
}
.kb-doc-row:hover    { background: #F1ECE6; }
.kb-doc-row.selected { background: #F1ECE6; border-left: 3px solid var(--blue); padding-left: 15px; }

.kb-doc-type-icon { font-size: 22px; flex-shrink: 0; }

.kb-doc-info { flex: 1; min-width: 0; }

.kb-doc-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.kb-doc-meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.kb-folder-pill {
  font-size: 10px;
  font-weight: 600;
  color: var(--blue);
  background: rgba(123,91,69,0.08);
  border: 1px solid rgba(123,91,69,0.18);
  border-radius: 10px;
  padding: 1px 7px;
}

.kb-version-pill {
  font-size: 10px;
  font-weight: 700;
  color: #9A948C;
  background: #F1ECE6;
  border-radius: 10px;
  padding: 1px 7px;
}

.kb-type-pill {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1px 6px;
}

.kb-date-pill {
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: 10px;
  padding: 1px 7px;
}

.kb-review-pill { color: #A97D2E; background: #FFF4E5; }

.kb-tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}

.kb-tag {
  font-size: 10px;
  font-weight: 600;
  color: #5F8A61;
  background: #E8F2EA;
  border: 1px solid #E8F2EA;
  border-radius: 10px;
  padding: 1px 7px;
}

.kb-doc-row-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
}
.kb-doc-row:hover .kb-doc-row-actions { opacity: 1; }

.kb-row-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 30px;
  height: 30px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s;
}
.kb-row-btn:hover     { background: var(--border); }
.kb-row-btn-del:hover { background: #F7E8E7; border-color: #F2D8D6; }
.kb-row-btn-fav.is-fav { color: #C79B3B; border-color: rgba(199,155,59,0.35); }
.kb-row-btn-fav.is-fav .icon svg { fill: #C79B3B; width: 13px; height: 13px; }
.kb-row-btn-fav .icon svg { width: 13px; height: 13px; }

/* ── Detail / preview panel ──────────────────────────────────────────────────── */
.kb-detail-panel {
  width: 360px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--surface);
  overflow-y: auto;
  flex-direction: column;
}

.kb-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.kb-detail-title-wrap {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.kb-detail-file-icon { font-size: 24px; flex-shrink: 0; margin-top: 2px; }

.kb-detail-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.4;
  word-break: break-word;
}

.kb-detail-fname {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
  word-break: break-all;
}

.kb-close-detail-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.12s;
}
.kb-close-detail-btn:hover { background: var(--border); color: var(--text); }

.kb-detail-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.kb-dtool-btn {
  border-radius: 7px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s;
  background: var(--bg);
  color: var(--text-muted);
  border: 1.5px solid var(--border);
}
.kb-dtool-btn:hover  { background: var(--border); color: var(--text); }
.kb-dtool-view { background: #F1ECE6; color: #8A6B52; border-color: #E8DFD5; }
.kb-dtool-view:hover { background: #E8DFD5; }
.kb-dtool-dl   { background: #E8F2EA; color: #5F8A61; border-color: #E8F2EA; }
.kb-dtool-dl:hover   { background: #E8F2EA; }
.kb-dtool-del  { margin-left: auto; }
.kb-dtool-del:hover  { background: #F7E8E7; color: #C35F5B; border-color: #F2D8D6; }
.kb-dtool-retry { background: #FFF4E5; color: #A97D2E; border-color: #FFF4E5; }
.kb-dtool-retry:hover { background: #FFF4E5; }
.kb-dtool-sep  { flex: 1; }

/* ── Metadata grid ───────────────────────────────────────────────────────────── */
.kb-meta-section {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.kb-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
  margin-bottom: 10px;
}

.kb-meta-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kb-meta-label {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.kb-meta-val {
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
}

.kb-ext-ok         { color: #5F8A61; }
.kb-ext-empty      { color: #A97D2E; }
.kb-ext-error      { color: var(--error); }
.kb-ext-failed     { color: var(--error); }
.kb-ext-partial    { color: #C59A41; }
.kb-ext-pending,
.kb-ext-processing { color: #8A6B52; }
.kb-overdue   { color: #C35F5B; font-weight: 700; }

.kb-ext-badge-pending, .kb-ext-badge-empty, .kb-ext-badge-partial, .kb-ext-badge-failed {
  font-weight: 600;
  border: none;
}
.kb-ext-badge-pending { background: #F1ECE6; color: #8A6B52; }
.kb-ext-badge-empty   { background: #FFF4E5; color: #A97D2E; }
.kb-ext-badge-partial { background: #FFF4E5; color: #C59A41; }
.kb-ext-badge-failed  { background: #F7E8E7; color: #C35F5B; }

.kb-meta-tags-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kb-no-tags {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Preview section ─────────────────────────────────────────────────────────── */
.kb-preview-section {
  padding: 12px 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kb-preview-header {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kb-preview-text {
  font-size: 11px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  max-height: 360px;
  font-family: 'Segoe UI', system-ui, sans-serif;
}

.kb-preview-empty {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  padding: 16px 0;
}

/* ── KB upload modal ─────────────────────────────────────────────────────────── */
.kb-upload-modal { max-height: 92vh; overflow-y: auto; }

.kb-file-pick {
  display: flex;
  align-items: center;
  gap: 10px;
}

.kb-file-btn {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 7px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
  white-space: nowrap;
}
.kb-file-btn:hover { background: var(--border); }

.kb-file-name {
  font-size: 12px;
  color: var(--text-muted);
  word-break: break-all;
  flex: 1;
}

.kb-field-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
  display: block;
}

.kb-upload-status {
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  margin-top: 4px;
}
.kb-status-uploading { background: #F1ECE6; color: var(--blue); border: 1px solid #E8DFD5; }
.kb-status-success   { background: #E8F2EA; color: #5F8A61;      border: 1px solid #E8F2EA; }
.kb-status-error     { background: #F7E8E7; color: var(--error);  border: 1px solid #F2D8D6; }

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar              { display: none; }
  #messages             { padding: 16px; }
  .input-bar            { padding: 12px 16px; }
  .bubble               { max-width: 90vw; }
  .welcome-banner       { padding: 12px 16px; }
  .form-row             { grid-template-columns: 1fr; }
  .modal                { width: calc(100vw - 32px); }
  .doc-upload-section   { padding: 16px; }
  .doc-list-section     { padding: 12px 16px; }
  .doc-header           { padding: 14px 16px; }
  .doc-actions          { flex-direction: column; gap: 4px; }
  .doc-name             { max-width: 160px; }
  .insights-stats-grid  { grid-template-columns: repeat(2, 1fr); }
  .insights-container   { padding: 16px; }
  .val-form-grid        { grid-template-columns: 1fr; }
  .val-doc-page         { width: 100%; padding: 24px; min-height: unset; }
  .val-doc-scroll       { padding: 12px 0; }
  .val-viewer-toolbar   { padding: 8px 12px; }
  .kb-folder-sidebar    { display: none; }
  .kb-detail-panel      { display: none !important; }
  .kb-search-bar        { flex-wrap: wrap; gap: 6px; }
  .kb-meta-grid         { grid-template-columns: 1fr; }
}


/* ══════════════════════════════════════════════════════════════════════════════
   HOME DASHBOARD  (v0.8)
   ══════════════════════════════════════════════════════════════════════════════ */

.dash-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--bg);
  padding: 20px 24px 32px;
  gap: 16px;
}

/* ── Header ──────────────────────────────────────────────────────────────────── */
.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--divider);
}
.dash-header-left { display: flex; align-items: center; gap: 12px; }
.dash-icon { width: 22px; height: 22px; opacity: 0.75; color: var(--blue-light); }
.dash-title { font-size: 16px; font-weight: 600; color: var(--text); margin: 0; }
.dash-subtitle { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.dash-refresh-btn {
  background: #FFF;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 14px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.12s, color 0.12s;
}
.dash-refresh-btn:hover { border-color: var(--blue-light); color: var(--blue-light); }

/* ── Stat cards ──────────────────────────────────────────────────────────────── */
.dash-stats-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  flex-shrink: 0;
}

.dash-stat-card {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius-lg);
  padding: 16px 14px 14px;
  text-align: center;
  box-shadow: var(--shadow);
  border-top: 3px solid var(--border);
  transition: box-shadow 0.15s, transform 0.15s;
}
.dash-stat-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }

.dash-stat-projects { border-top-color: var(--blue-light); }
.dash-stat-val      { border-top-color: #8A6B52; }
.dash-stat-kb       { border-top-color: var(--info); }
.dash-stat-proto    { border-top-color: var(--success); }
.dash-stat-capa     { border-top-color: var(--warning); }
.dash-stat-dev      { border-top-color: var(--error); }
.dash-stat-score    { border-top-color: var(--blue); }

/* ── Suite Overview (Batch 2) ───────────────────────────────────────────────── */
.dash-suite-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  flex-shrink: 0;
}
.dash-stat-equipment         { border-top-color: #8A6B52; }
.dash-stat-documents         { border-top-color: var(--info); }
.dash-stat-changes           { border-top-color: var(--warning); }
.dash-stat-validation-status { border-top-color: var(--blue-light); }

/* ── Quick Actions ────────────────────────────────────────────────────────────── */
.dash-quick-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.dash-qa-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-align: left;
}
.dash-qa-btn:hover { background: var(--bg-secondary); border-color: var(--blue-light); }
.dash-qa-btn .icon svg { width: 14px; height: 14px; stroke-width: 1.8; color: var(--blue-light); }

/* ── Validation Review Badge ──────────────────────────────────────────────────── */
#val-review-banner { padding: 0 24px 16px; }
.val-review-loading {
  font-size: 12px;
  color: var(--text-muted);
  padding: 8px 0;
}
.val-review-banner-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.val-review-score-wrap {
  display: flex;
  align-items: baseline;
  gap: 4px;
  min-width: 80px;
  padding: 6px 14px;
  border-radius: var(--radius);
  color: #FFF;
}
.val-review-badge-green  { background: #5F8A61; }
.val-review-badge-yellow { background: #C59A41; }
.val-review-badge-red    { background: #A8544F; }

.val-review-score-num   { font-size: 26px; font-weight: 700; line-height: 1; }
.val-review-score-label { font-size: 12px; font-weight: 500; }
.val-review-meta        { flex: 1; }
.val-review-readiness   { font-size: 14px; font-weight: 600; color: var(--navy); margin-bottom: 4px; }
.val-review-counts      { display: flex; gap: 10px; font-size: 11px; font-weight: 600; }
.vrc-critical { color: #A8544F; }
.vrc-major    { color: #A97D2E; }
.vrc-minor    { color: #8A6B52; }
.vrc-obs      { color: #66615B; }
.val-review-hint { font-size: 11px; color: var(--text-muted); }

.dash-stat-icon { font-size: 16px; margin-bottom: 6px; line-height: 1; opacity: 0.65; }
.dash-stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin-bottom: 4px;
}
.dash-stat-label {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  line-height: 1.3;
}

.dash-stat-sub {
  font-size: 10.5px;
  color: var(--text-disabled);
  margin-top: 5px;
  line-height: 1.3;
}

.dash-stat-sub.is-attention { color: var(--warning); font-weight: 600; }

.dash-refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ── Main grid ───────────────────────────────────────────────────────────────── */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: auto auto;
  gap: 20px;
}

/* Health card spans full width of last row */
.dash-card-health {
  grid-column: 1 / -1;
}

/* ── Card ────────────────────────────────────────────────────────────────────── */
.dash-card {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.dash-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--divider);
  background: var(--surface);
  flex-shrink: 0;
}
.dash-card-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text);
}
.dash-card-icon { font-size: 16px; }

.dash-card-body {
  padding: 12px 16px;
  flex: 1;
  overflow-y: auto;
  max-height: 280px;
}
.dash-card-health .dash-card-body { max-height: none; }

/* ── Loading / empty ─────────────────────────────────────────────────────────── */
.dash-loading {
  font-size: 12px;
  color: var(--text-muted);
  padding: 20px 0;
  text-align: center;
}
.dash-empty {
  font-size: 12px;
  color: var(--text-muted);
  padding: 24px 0;
  text-align: center;
  font-style: italic;
}

/* ── Activity feed ───────────────────────────────────────────────────────────── */
.dash-activity-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.dash-activity-item:last-child { border-bottom: none; }

.dash-activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}
.dash-dot-audit    { background: var(--accent); }
.dash-dot-document { background: var(--blue); }
.dash-dot-kb       { background: #8A6B52; }
.dash-dot-protocol { background: #5F8A61; }

.dash-activity-body { flex: 1; min-width: 0; }
.dash-activity-title {
  font-weight: 600;
  color: var(--navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-activity-ctx  { color: var(--text-muted); font-size: 11px; margin-top: 1px; }
.dash-activity-time { color: var(--text-muted); font-size: 10px; flex-shrink: 0; white-space: nowrap; }

/* ── Project rows ────────────────────────────────────────────────────────────── */
.dash-proj-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.12s;
  border-radius: var(--radius);
  margin: 0 -4px;
  padding-left: 4px;
  padding-right: 4px;
}
.dash-proj-row:last-child { border-bottom: none; }
.dash-proj-row:hover { background: #F1ECE6; }

.dash-proj-icon { font-size: 18px; flex-shrink: 0; }
.dash-proj-info { flex: 1; min-width: 0; }
.dash-proj-name {
  font-weight: 600;
  color: var(--navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-proj-meta { color: var(--text-muted); font-size: 11px; margin-top: 1px; }
.dash-proj-badge {
  font-size: 10px;
  font-weight: 700;
  background: rgba(123,91,69,0.10);
  color: var(--blue);
  border: 1px solid rgba(123,91,69,0.18);
  border-radius: var(--radius);
  padding: 2px 7px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Upcoming reviews ────────────────────────────────────────────────────────── */
.dash-review-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.dash-review-row:last-child { border-bottom: none; }
.dash-review-info { flex: 1; min-width: 0; }
.dash-review-title {
  font-weight: 600;
  color: var(--navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-review-meta { color: var(--text-muted); font-size: 11px; margin-top: 1px; }
.dash-review-date {
  font-size: 11px;
  font-weight: 700;
  color: #A97D2E;
  background: #FFF4E5;
  border-radius: var(--radius);
  padding: 2px 8px;
  white-space: nowrap;
  flex-shrink: 0;
}
.dash-review-date.soon { color: #C35F5B; background: #F7E8E7; }
.dash-val-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.dash-val-row:last-child { border-bottom: none; }
.dash-val-info { flex: 1; min-width: 0; }
.dash-val-name {
  font-weight: 600;
  color: var(--navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-val-meta { color: var(--text-muted); font-size: 11px; margin-top: 1px; }
.dash-val-date {
  font-size: 11px;
  font-weight: 700;
  color: var(--blue);
  background: #F1ECE6;
  border-radius: var(--radius);
  padding: 2px 8px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Conversations ───────────────────────────────────────────────────────────── */
.dash-conv-row {
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  cursor: pointer;
}
.dash-conv-row:last-child { border-bottom: none; }
.dash-conv-proj {
  font-size: 10px;
  font-weight: 700;
  color: var(--blue);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 3px;
}
.dash-conv-snippet {
  color: var(--text);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.dash-conv-time { color: var(--text-muted); font-size: 10px; margin-top: 3px; }

/* ── System health ───────────────────────────────────────────────────────────── */
.dash-health-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
}
.dash-health-cell {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 12px;
  text-align: center;
}
.dash-health-val {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
  margin-bottom: 5px;
}
.dash-health-val.ok    { color: #5F8A61; }
.dash-health-val.warn  { color: #A97D2E; }
.dash-health-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  line-height: 1.3;
}

@media (max-width: 1400px) {
  .dash-stats-grid  { grid-template-columns: repeat(4, 1fr); }
  .dash-suite-grid  { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 1100px) {
  .dash-stats-grid  { grid-template-columns: repeat(4, 1fr); }
  .dash-suite-grid  { grid-template-columns: repeat(2, 1fr); }
  .dash-grid        { grid-template-columns: repeat(2, 1fr); }
  .dash-card-health { grid-column: 1 / -1; }
  .dash-health-grid { grid-template-columns: repeat(3, 1fr); }
  .dash-quick-actions { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .dash-container   { padding: 16px; gap: 12px; }
  .dash-stats-grid  { grid-template-columns: repeat(2, 1fr); }
  .dash-suite-grid  { grid-template-columns: repeat(2, 1fr); }
  .dash-grid        { grid-template-columns: 1fr; }
  .dash-health-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ══════════════════════════════════════════════════════════════════════════════
   GENERATE DOCUMENT  (v0.9) — wizard body content
   ──────────────────────────────────────────────────────────────────────────────
   The workspace shell (outer container, dark header, breadcrumb/action toolbar,
   step-progress bar) is the reusable Enterprise Workspace pattern — see
   workspace.css (.ent-workspace / .ent-ws-header / .ent-ws-toolbar /
   .ent-ws-progress). Only the wizard's own step content (panels, form fields,
   nav buttons) lives here, since that part is specific to Generate Document.
   ══════════════════════════════════════════════════════════════════════════════ */

.gd-panel { flex: 1; flex-direction: column; overflow-y: auto; }
.gd-step-content {
  /* Matches the 1100px column width already used for .vw-panel-inner —
     820px left roughly half the screen empty on standard desktop widths. */
  max-width: 1100px; width: 100%; margin: 0 auto;
  padding: 28px 24px; display: flex; flex-direction: column; gap: 20px;
}
.gd-step-title { font-size: 17px; font-weight: 700; color: var(--navy); margin: 0; }
.gd-step-sub   { font-size: 13px; color: var(--text-muted); margin: 0; }
.gd-nav-row {
  display: flex; justify-content: space-between; align-items: center;
  padding-top: 8px; border-top: 1.5px solid var(--border); margin-top: 8px;
}
.gd-btn-primary {
  background: var(--blue-light);
  color: #FFF; border: none; border-radius: var(--radius); padding: 8px 20px;
  font-size: 12px; font-weight: 500; cursor: pointer; font-family: inherit;
  transition: background 0.15s;
}
.gd-btn-primary:hover { background: var(--blue); }
.gd-btn-secondary {
  background: #FFF; color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 16px;
  font-size: 12px; font-weight: 500; cursor: pointer; transition: background 0.12s;
  font-family: inherit;
}
.gd-btn-secondary:hover { background: var(--bg); }
.gd-btn-generate {
  background: var(--blue);
  color: #FFF; border: none; border-radius: var(--radius); padding: 8px 22px;
  font-size: 12px; font-weight: 600; cursor: pointer; letter-spacing: 0.2px;
  transition: background 0.15s; font-family: inherit;
}
.gd-btn-generate:hover { box-shadow: 0 4px 16px rgba(138,110,94,0.4); transform: translateY(-1px); }
.gd-btn-generate:disabled { opacity: 0.6; cursor: default; transform: none; box-shadow: none; }

/* Step 1 */
.gd-proj-list { display: flex; flex-direction: column; gap: 8px; }
.gd-proj-card {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-radius: 10px;
  border: 1.5px solid var(--border); background: #FFF; cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.gd-proj-card:hover  { border-color: var(--blue-light); box-shadow: 0 2px 8px rgba(123,91,69,0.1); }
.gd-proj-card.selected { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(123,91,69,0.12); }
.gd-proj-card-left { display: flex; align-items: center; gap: 12px; }
.gd-proj-icon  { font-size: 22px; }
.gd-proj-name  { font-size: 13px; font-weight: 600; color: var(--navy); }
.gd-proj-meta  { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.gd-sel-badge  {
  font-size: 11px; font-weight: 600; color: #5F8A61;
  background: #E8F2EA; border-radius: 20px; padding: 3px 10px;
}

/* Step 2 */
.gd-doctype-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px;
}
.gd-doctype-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 16px 10px; border-radius: 10px;
  border: 1.5px solid var(--border); background: #FFF;
  cursor: pointer; text-align: center;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.gd-doctype-card:hover { border-color: var(--blue-light); box-shadow: 0 3px 10px rgba(123,91,69,0.1); transform: translateY(-2px); }
.gd-doctype-icon  { font-size: 26px; }
.gd-doctype-short { font-size: 13px; font-weight: 800; }
.gd-doctype-label { font-size: 10px; color: var(--text-muted); line-height: 1.35; }

/* Step 3 */
.gd-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.gd-form-group { display: flex; flex-direction: column; gap: 5px; }
.gd-label { font-size: 12px; font-weight: 600; color: var(--navy); }
.gd-input {
  border: 1.5px solid var(--border); border-radius: 8px;
  padding: 8px 11px; font-size: 13px; color: var(--text);
  background: #FFF; transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}
.gd-input:focus { outline: none; border-color: var(--blue-light); box-shadow: 0 0 0 3px rgba(123,91,69,0.10); }
select.gd-input { cursor: pointer; }

/* Step 4 */
.gd-q-list { display: flex; flex-direction: column; gap: 16px; }
.gd-q-item { display: flex; gap: 14px; align-items: flex-start; }
.gd-q-num {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  background: var(--blue); color: #FFF; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; margin-top: 2px;
}
.gd-q-body  { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.gd-q-label { font-size: 12px; font-weight: 600; color: var(--navy); }
.gd-textarea { resize: vertical; min-height: 72px; line-height: 1.55; }

/* Step 5 */
.gd-review-section { display: flex; flex-direction: column; gap: 0; }
.gd-review-section-title {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
  font-size: 13px; font-weight: 600; color: var(--navy);
}
.gd-review-badge {
  font-size: 11px; font-weight: 700; color: #FFF; border-radius: 5px; padding: 2px 8px;
}
.gd-review-project { margin-left: auto; font-size: 11px; color: var(--text-muted); font-weight: 400; }
.gd-review-header {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-muted); padding-bottom: 6px;
  border-bottom: 1.5px solid var(--border); margin-bottom: 2px;
}
.gd-review-row {
  display: flex; align-items: flex-start; gap: 0;
  border-bottom: 1px solid #F1ECE6; padding: 8px 0;
}
.gd-review-key {
  width: 200px; flex-shrink: 0; font-size: 12px; font-weight: 600;
  color: var(--text-muted); padding-top: 2px;
}
.gd-review-val {
  flex: 1; font-size: 13px; color: var(--navy);
  border-radius: 5px; padding: 2px 6px; margin: -2px -6px;
  outline: none; white-space: pre-wrap; word-break: break-word;
  transition: background 0.15s;
}
.gd-review-val:focus { background: rgba(123,91,69,0.06); }
.gd-review-val:hover { background: #F1ECE6; cursor: text; }
.gd-review-empty { font-size: 13px; color: var(--text-muted); padding: 8px 0; }
.gd-review-hint {
  font-size: 12px; color: var(--text-muted);
  background: #FFF4E5; border: 1px solid #FFF4E5;
  border-radius: 8px; padding: 8px 12px;
}

/* Step 6 */
.gd-gen-step  { gap: 16px; }
.gd-draft-result { display: flex; flex-direction: column; gap: 16px; }
.gd-draft-success {
  display: flex; align-items: center; gap: 14px;
  background: #E8F2EA; border: 1.5px solid #E8F2EA;
  border-radius: 10px; padding: 14px 18px;
}
.gd-draft-check {
  width: 36px; height: 36px; border-radius: 50%;
  background: #5F8A61; color: #FFF;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; flex-shrink: 0;
}
.gd-draft-success strong { font-size: 14px; color: #4C7A4E; }
.gd-draft-sub  { font-size: 12px; color: #5F8A61; margin-top: 2px; }
.gd-draft-summary {
  border: 1.5px solid var(--border); border-radius: 10px; background: #FFF; overflow: hidden;
}
.gd-draft-sum-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 16px; border-bottom: 1px solid #F1ECE6; font-size: 13px;
}
.gd-draft-sum-row:last-child { border-bottom: none; }
.gd-draft-sum-row span { color: var(--text-muted); }
.gd-draft-json-section {
  border: 1.5px solid var(--border); border-radius: 10px; background: #FFF; overflow: hidden;
}
.gd-draft-json-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1.5px solid var(--border);
  font-size: 12px; font-weight: 600; color: var(--navy); background: #F1ECE6;
}
.gd-draft-json {
  font-family: "Consolas", "Courier New", monospace;
  font-size: 11.5px; line-height: 1.55; color: #6D5B52;
  background: #F1ECE6; padding: 14px 16px; margin: 0;
  overflow-x: auto; max-height: 340px; overflow-y: auto; white-space: pre;
}
.gd-ai-teaser {
  display: flex; align-items: flex-start; gap: 14px;
  background: #F1ECE6;
  border: 1px solid var(--border); border-left: 3px solid var(--blue-light);
  border-radius: var(--radius); padding: 12px 16px;
}
.gd-teaser-icon { font-size: 18px; flex-shrink: 0; margin-top: 2px; }
.gd-ai-teaser strong { font-size: 12px; color: var(--blue); display: block; margin-bottom: 4px; }
.gd-ai-teaser p { font-size: 12px; color: #66615B; margin: 0; line-height: 1.5; }

/* Shared */
.gd-loading { font-size: 13px; color: var(--text-muted); padding: 24px 0; }
.gd-empty-note {
  font-size: 13px; color: var(--text-muted); background: #F1ECE6;
  border: 1px solid var(--border); border-radius: 8px; padding: 16px; text-align: center;
}
.gd-chip {
  font-size: 11px; font-weight: 600; padding: 4px 10px;
  border: 1.5px solid var(--border); border-radius: 20px;
  background: #FFF; color: var(--navy); cursor: pointer; transition: background 0.15s;
}
.gd-chip:hover { background: #F1ECE6; }
.gd-error-toast {
  position: fixed; bottom: 32px; left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: #C35F5B; color: #FFF; padding: 10px 22px;
  border-radius: 8px; font-size: 13px; font-weight: 600;
  box-shadow: 0 4px 16px rgba(45,42,40,0.25); opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none; z-index: 9999;
}
.gd-error-toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.gd-error-toast.success { background: #5F8A61; }
