:root {
  --brand-primary: #0B1220;
  --brand-secondary: #4B5054;
  --brand-accent: #FF002B;
  --surface: #FFFFFF;
  --surface-2: #F5F5F5;
  --surface-3: #EFEFEF;
  --border: #E0E0E0;
  --text-primary: #0B1220;
  --text-secondary: #4B5054;
  --text-muted: #888;
  --success: #2E7D32;
  --warning: #E65100;
  --info: #1565C0;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow: 0 1px 4px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.10);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px;
  color: var(--text-primary);
  background: var(--surface-2);
  line-height: 1.55;
}

section.page { display: none; min-height: 100vh; }
section.page.active { display: flex; flex-direction: column; }

/* ── NAV ── */
nav {
  background: var(--brand-primary);
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}
.nav-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; margin-right: 32px; }
.nav-logo img { height: 28px; width: auto; }
.nav-logo .cama-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--brand-accent);
  letter-spacing: 0.08em;
  border: 1px solid var(--brand-accent);
  border-radius: 3px;
  padding: 1px 6px;
  line-height: 1.4;
}
.nav-links { display: flex; gap: 2px; flex: 1; }
.nav-link {
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
  cursor: pointer;
  border: none;
  background: none;
  letter-spacing: 0.01em;
}
.nav-link:hover { color: #fff; background: rgba(255,255,255,0.08); }
.nav-link.active { color: #fff; background: rgba(255, 0, 43,0.18); }
.nav-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.nav-tenant {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.5);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 3px;
  padding: 2px 8px;
}
.nav-user {
  width: 32px; height: 32px;
  background: var(--brand-accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  cursor: pointer;
}
.nav-new-btn {
  background: var(--brand-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 700;
  padding: 6px 14px;
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  transition: opacity 0.15s;
}
.nav-new-btn:hover { opacity: 0.88; }

/* ── LAYOUT ── */
.app-shell { display: flex; flex: 1; overflow: hidden; height: calc(100vh - 56px); }
.sidebar {
  width: 240px;
  background: var(--brand-primary);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  border-right: 1px solid rgba(255,255,255,0.06);
}
.sidebar-section { padding: 16px 12px 8px; }
.sidebar-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.3);
  text-transform: uppercase;
  padding: 0 8px;
  margin-bottom: 6px;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: rgba(255,255,255,0.6);
  font-size: 13.5px;
  font-weight: 400;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  text-decoration: none;
}
.sidebar-item:hover { background: rgba(255,255,255,0.07); color: #fff; }
.sidebar-item.active { background: rgba(255, 0, 43,0.15); color: #fff; font-weight: 600; }
.sidebar-item svg { flex-shrink: 0; opacity: 0.7; }
.sidebar-item.active svg { opacity: 1; color: var(--brand-accent); }
.sidebar-divider { height: 1px; background: rgba(255,255,255,0.07); margin: 8px 12px; }
.doc-status-dot {
  width: 7px; height: 7px; border-radius: 50%; margin-left: auto; flex-shrink: 0;
}
.dot-draft { background: #888; }
.dot-review { background: #F59E0B; }
.dot-approved { background: #22C55E; }
.dot-rejected { background: #EF4444; }

.main-content { flex: 1; overflow-y: auto; background: var(--surface-2); }

/* ── SKELETON ── */
.skeleton-card {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── HOME PAGE ── */
.home-hero {
  background: var(--brand-primary);
  padding: 48px 40px 40px;
  position: relative;
  overflow: hidden;
}
.home-hero::after {
  content: '';
  position: absolute;
  right: -40px; top: -40px;
  width: 320px; height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 0, 43,0.12) 0%, transparent 70%);
  pointer-events: none;
}
.home-hero h1 {
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
  line-height: 1.25;
}
.home-hero h1 span { color: var(--brand-accent); }
.home-hero p {
  color: rgba(255,255,255,0.55);
  font-size: 14px;
  max-width: 480px;
  font-weight: 300;
}
.hero-stats { display: flex; gap: 32px; margin-top: 28px; }
.hero-stat-num { font-size: 22px; font-weight: 700; color: #fff; line-height: 1; }
.hero-stat-label { font-size: 11px; color: rgba(255,255,255,0.4); margin-top: 3px; font-weight: 300; }

.home-body { padding: 28px 32px; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--text-secondary); letter-spacing: 0.06em; text-transform: uppercase; }
.text-link { font-size: 13px; color: var(--brand-accent); font-weight: 600; cursor: pointer; text-decoration: none; }
.text-link:hover { text-decoration: underline; }

.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin-bottom: 28px; }
.doc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
  position: relative;
}
.doc-card:hover { box-shadow: var(--shadow-md); border-color: #ccc; }
.doc-card-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 10px; }
.doc-card-type {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 2px 7px;
}
.doc-status-pill {
  font-size: 10px;
  font-weight: 700;
  border-radius: 20px;
  padding: 2px 9px;
  letter-spacing: 0.04em;
}
.pill-draft { background: #F3F4F6; color: #6B7280; }
.pill-pending { background: #FFF7ED; color: #C2410C; }
.pill-approved { background: #F0FDF4; color: #166534; }
.pill-review { background: #EFF6FF; color: #1D4ED8; }
.pill-rejected { background: #FEF2F2; color: #991B1B; }
.doc-card h3 { font-size: 14px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; line-height: 1.35; }
.doc-card-meta { font-size: 12px; color: var(--text-muted); }
.doc-card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--surface-3); }
.doc-card-client { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.doc-card-date { font-size: 11px; color: var(--text-muted); }

.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 28px; }
@media (max-width: 1100px) { .quick-actions { grid-template-columns: repeat(4, 1fr); } }
.qa-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  transition: box-shadow 0.15s, border-color 0.15s;
  text-align: left;
}
.qa-btn:hover { box-shadow: var(--shadow-md); border-color: #ccc; }
.qa-icon {
  width: 34px; height: 34px;
  background: var(--surface-2);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: var(--brand-accent);
}
.qa-btn-label { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.qa-btn-sub { font-size: 11px; color: var(--text-muted); }

/* ── EDITOR PAGE ── */
.editor-layout { display: flex; flex: 1; height: 100%; overflow: hidden; }
.editor-sidebar {
  width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}
.editor-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.editor-toolbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 20px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.tb-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex; align-items: center; gap: 4px;
  transition: background 0.12s, border-color 0.12s;
  font-family: inherit;
}
.tb-btn:hover { background: var(--surface-2); border-color: var(--border); }
.tb-btn.accent { background: var(--brand-accent); color: #fff; border-color: var(--brand-accent); }
.tb-btn.accent:hover { opacity: 0.88; }
.tb-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.tb-status {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.status-badge {
  font-size: 11px;
  font-weight: 700;
  border-radius: 4px;
  padding: 3px 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.sb-draft { background: #F3F4F6; color: #6B7280; border: 1px solid #E5E7EB; }
.sb-brand { background: #EFF6FF; color: #1D4ED8; border: 1px solid #BFDBFE; }
.sb-approved { background: #F0FDF4; color: #166534; border: 1px solid #BBF7D0; }
.sb-pending { background: #FFF7ED; color: #C2410C; border: 1px solid #FED7AA; }
.sb-rejected { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }

.editor-body { flex: 1; display: flex; overflow: hidden; }
.editor-canvas { flex: 1; overflow-y: auto; padding: 32px 40px; background: var(--surface-2); }
.doc-paper {
  max-width: 720px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 52px;
  position: relative;
  min-height: 600px;
  box-shadow: var(--shadow);
}
.doc-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-30deg);
  font-size: 72px;
  font-weight: 900;
  color: rgba(0,0,0,0.04);
  pointer-events: none;
  letter-spacing: 0.1em;
  white-space: nowrap;
  user-select: none;
}
.doc-paper h1 { font-size: 22px; font-weight: 700; color: var(--text-primary); margin-bottom: 6px; }
.doc-paper .doc-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 24px; padding-bottom: 16px; border-bottom: 2px solid var(--brand-accent); display: flex; gap: 16px; flex-wrap: wrap; }
.doc-paper h2 { font-size: 15px; font-weight: 700; color: var(--text-primary); margin: 20px 0 8px; }
.doc-paper p { font-size: 14px; line-height: 1.7; color: var(--text-primary); margin-bottom: 12px; }
.claim-cite {
  display: inline;
  background: rgba(255, 0, 43,0.08);
  border-bottom: 1px solid var(--brand-accent);
  border-radius: 2px;
  padding: 0 2px;
  font-size: 12px;
  color: var(--brand-accent);
  cursor: pointer;
  font-weight: 600;
}
.flag-inline {
  background: #FFF7ED;
  border: 1px solid #FED7AA;
  border-radius: 3px;
  padding: 2px 8px;
  font-size: 12px;
  color: #C2410C;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.tracked-add { background: #DCFCE7; text-decoration: none; border-radius: 2px; padding: 0 2px; }
.tracked-del { background: #FEE2E2; text-decoration: line-through; border-radius: 2px; padding: 0 2px; color: #991B1B; }

.editor-right-panel {
  width: 280px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}
.panel-tabs { display: flex; border-bottom: 1px solid var(--border); }
.panel-tab {
  flex: 1;
  padding: 10px 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.12s;
}
.panel-tab.active { color: var(--brand-accent); border-bottom-color: var(--brand-accent); }
.panel-content { padding: 14px; flex: 1; }
.panel-section-title { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; }
.flag-item {
  background: #FFF7ED;
  border: 1px solid #FED7AA;
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
}
.flag-item-type { font-size: 10px; font-weight: 700; color: #C2410C; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 3px; }
.flag-item-desc { font-size: 12px; color: var(--text-primary); line-height: 1.45; }
.flag-item-actions { display: flex; gap: 6px; margin-top: 8px; }
.review-panel { min-width: 0; overflow-wrap: anywhere; }
.review-panel > h3 { margin: 16px 0 8px; font-size: 14px; }
.review-flag-list { display: grid; gap: 10px; margin: 10px 0 14px; }
.review-flag { min-width: 0; padding: 12px; border: 1px solid var(--border); border-left: 3px solid var(--warning); border-radius: var(--radius); background: var(--surface); }
.review-flag.is-resolved { border-left-color: var(--success); background: #FAFFFA; }
.review-flag.is-historical { border-left-color: var(--text-muted); background: var(--surface-2); }
.review-flag-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 7px; }
.review-flag-kind { color: var(--text-secondary); font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.review-flag-status { flex: 0 0 auto; color: var(--text-muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.review-flag-description { font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.review-flag-resolution { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); color: var(--text-secondary); font-size: 12px; white-space: pre-wrap; }
.review-flag-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.review-checklist { padding: 12px; margin: 12px 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); font-size: 13px; }
.review-checklist.has-open { border-color: #FED7AA; background: #FFFBEB; }
.flag-resolve-btn {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid;
  font-family: inherit;
}
.flag-resolve-btn.resolve { background: #F0FDF4; color: #166534; border-color: #BBF7D0; }
.flag-resolve-btn.override { background: #F9FAFB; color: #6B7280; border-color: #E5E7EB; }
.tracked-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--surface);
}
.tracked-item-label { font-size: 10px; font-weight: 700; color: var(--text-muted); letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 4px; }
.tracked-item-text { font-size: 12px; color: var(--text-primary); line-height: 1.45; margin-bottom: 8px; }
.tracked-actions { display: flex; gap: 6px; }
.tracked-accept { background: #F0FDF4; color: #166534; border: 1px solid #BBF7D0; font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 4px; cursor: pointer; font-family: inherit; }
.tracked-reject { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 4px; cursor: pointer; font-family: inherit; }

.editor-sidebar-section { padding: 14px; border-bottom: 1px solid var(--border); }
.editor-sidebar-title { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 10px; }
.step-list { list-style: none; }
.step-item { display: flex; align-items: flex-start; gap: 8px; padding: 6px 0; }
.step-num {
  width: 20px; height: 20px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.step-done { background: #22C55E; color: #fff; }
.step-active { background: var(--brand-accent); color: #fff; }
.step-todo { background: var(--surface-3); color: var(--text-muted); }
.step-text { font-size: 12.5px; color: var(--text-secondary); line-height: 1.4; }
.step-text.done { color: var(--text-muted); text-decoration: line-through; }
.step-text.active { color: var(--text-primary); font-weight: 600; }

/* ── CHAT / BRIEF PAGE ── */
.chat-layout { display: flex; flex: 1; height: 100%; overflow: hidden; }
.chat-left {
  width: 320px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.chat-left-header { padding: 16px 18px; border-bottom: 1px solid var(--border); }
.chat-left-header h2 { font-size: 14px; font-weight: 700; color: var(--text-primary); margin-bottom: 12px; }
.form-row { margin-bottom: 10px; }
.form-label { font-size: 11px; font-weight: 700; color: var(--text-secondary); letter-spacing: 0.05em; text-transform: uppercase; margin-bottom: 4px; display: block; }
.form-select, .form-input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--surface);
  appearance: none;
  outline: none;
  transition: border-color 0.12s;
}
.form-select:focus, .form-input:focus { border-color: var(--brand-accent); }
.intel-brief {
  padding: 14px 16px;
  margin: 12px;
  background: #F0F9FF;
  border: 1px solid #BAE6FD;
  border-radius: var(--radius);
}
.intel-brief-title { font-size: 11px; font-weight: 700; color: #0369A1; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 8px; }
.intel-item { font-size: 12px; color: var(--text-secondary); padding: 4px 0; border-bottom: 1px solid #E0F2FE; display: flex; gap: 6px; }
.intel-item:last-child { border-bottom: none; }
.intel-label { font-weight: 600; color: var(--text-primary); min-width: 70px; }

.chat-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.chat-messages { flex: 1; overflow-y: auto; padding: 20px 24px; display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; gap: 10px; max-width: 90%; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.avatar-agent { background: var(--brand-primary); color: var(--brand-accent); }
.avatar-user { background: var(--brand-accent); color: #fff; }
.msg-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-primary);
}
.msg.user .msg-bubble { background: var(--brand-primary); color: rgba(255,255,255,0.9); border-color: transparent; }
.msg-time { font-size: 10px; color: var(--text-muted); margin-top: 4px; text-align: right; }
.outline-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-top: 4px;
}
.outline-card-title { font-size: 12px; font-weight: 700; color: var(--text-primary); margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.outline-section { display: flex; align-items: flex-start; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--surface-3); }
.outline-section:last-child { border-bottom: none; }
.outline-num { font-size: 11px; font-weight: 700; color: var(--brand-accent); min-width: 18px; }
.outline-sec-title { font-size: 12.5px; font-weight: 600; color: var(--text-primary); }
.outline-sec-src { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.outline-actions { display: flex; gap: 8px; margin-top: 12px; }
.btn-approve {
  background: var(--brand-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 700;
  padding: 7px 16px;
  cursor: pointer;
  transition: opacity 0.15s;
  font-family: inherit;
}
.btn-approve:hover { opacity: 0.88; }
.btn-approve:disabled, .btn-secondary:disabled { opacity: .5; cursor: not-allowed; }
.btn-revise {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 16px;
  cursor: pointer;
  font-family: inherit;
}
.btn-revise:hover { background: var(--surface-2); }

.chat-input-area {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.chat-textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 14px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text-primary);
  outline: none;
  min-height: 44px;
  max-height: 120px;
  transition: border-color 0.12s;
  line-height: 1.5;
}
.chat-textarea:focus { border-color: var(--brand-accent); }
.chat-send-btn {
  background: var(--brand-accent);
  border: none;
  border-radius: var(--radius);
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: #fff;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.chat-send-btn:hover { opacity: 0.88; }

/* ── LIBRARY PAGE ── */
.library-layout { padding: 28px 32px; }
.library-header { margin-bottom: 24px; }
.library-header h1 { font-size: 20px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.library-header p { font-size: 13.5px; color: var(--text-secondary); }
.studio-page-content { min-width: 0; }
.studio-layout { width: 100%; max-width: 1320px; margin: 0 auto; padding: 38px clamp(20px, 3vw, 44px) 48px; }
.studio-header { margin-bottom: 22px; padding: 0 0 22px; border-bottom: 1px solid #D9D6D3; }
.studio-header h1 { margin: 0 0 6px; color: var(--brand-primary); font-size: clamp(27px, 3vw, 34px); line-height: 1.13; letter-spacing: -.035em; }
.studio-header p { max-width: 680px; color: var(--text-secondary); font-size: 14px; line-height: 1.55; }
.studio-toolbar { display: grid; grid-template-columns: minmax(280px, 2.2fr) minmax(150px, 1fr) minmax(150px, 1fr) minmax(126px, .85fr) minmax(126px, .85fr) auto; align-items: end; gap: 10px; margin: 18px 0 12px; }
/* The filters are a semantic grouping; their controls participate directly in the toolbar grid. */
.studio-filters { display: contents; }
#studio .studio-filters .form-select { min-width: 0; width: 100%; height: 38px; border-color: #DAD7D4; border-radius: 7px; background-color: #fff; }
#studio .studio-search { min-width: 0; width: 100%; height: 38px; border-color: #DAD7D4; border-radius: 7px; }
.studio-date-filter { display: grid; gap: 4px; min-width: 0; color: #746E69; font-size: 10px; font-weight: 700; letter-spacing: .055em; text-transform: uppercase; }
.studio-date-filter .form-input { width: 100%; min-width: 0; height: 38px; padding: 6px 8px; border-color: #DAD7D4; border-radius: 7px; color: var(--text-secondary); font-size: 12px; }
.studio-refresh { min-height: 38px; padding: 7px 13px; white-space: nowrap; border-radius: 7px; }
.studio-count { min-height: 20px; margin: 0 0 13px; color: #817B76; font-size: 11px; letter-spacing: .015em; }
.studio-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 285px), 1fr)); gap: 13px; }
.studio-card { width: 100%; min-width: 0; min-height: 0; padding: 16px 17px 13px; text-align: left; font: inherit; color: inherit; background: #FFFEFD; border-color: #E1DDDA; border-radius: 9px; box-shadow: 0 2px 7px rgba(38,35,36,.035); }
.studio-card:hover { transform: translateY(-1px); border-color: #C9BFB8; box-shadow: 0 7px 18px rgba(38,35,36,.075); }
.studio-card .doc-card-top { align-items: center; gap: 8px; margin-bottom: 12px; }
.studio-card .doc-card-type { max-width: 60%; padding: 3px 7px; border: 0; border-radius: 4px; background: #F3F0ED; color: #746E69; font-size: 9px; letter-spacing: .085em; }
.studio-card h3 { margin: 0 0 7px; font-size: 16px; font-weight: 650; line-height: 1.35; letter-spacing: -.018em; overflow-wrap: anywhere; }
.studio-card .doc-card-meta { min-height: 18px; color: #817B76; font-size: 11.5px; }
.studio-card .doc-card-footer { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; margin-top: 13px; padding-top: 11px; border-color: #EEEAE7; }
.studio-card .doc-card-footer span { min-width: 0; color: #817B76; font-size: 10.5px; line-height: 1.45; overflow-wrap: anywhere; }
.studio-card .doc-card-footer span:last-child { text-align: right; }
.studio-card:focus-visible, .studio-action:focus-visible, .studio-detail-close:focus-visible { outline: 3px solid rgba(255, 0, 43,.45); outline-offset: 2px; }
.studio-status { display: inline-flex; flex: 0 1 auto; align-items: center; max-width: 58%; padding: 4px 9px; border: 1px solid #E3DED9; border-radius: 99px; background: #F7F5F3; color: #68615C; font-size: 9px; font-weight: 700; line-height: 1.3; letter-spacing: .055em; overflow-wrap: anywhere; text-transform: uppercase; }
.studio-status.is-approved { background: #EFF6F0; border-color: #D3E4D5; color: #356342; }
.studio-status.is-review { background: #FFF4E9; border-color: #F2D6BC; color: #94501D; }
.studio-status.is-rejected { background: #FAEEEE; border-color: #EBCFCF; color: #923F3F; }
.studio-detail { margin-top: 22px; padding: clamp(16px, 2.5vw, 28px); background: #FFFEFD; border: 1px solid #DED9D5; border-top: 3px solid var(--brand-accent); border-radius: 10px; box-shadow: 0 8px 24px rgba(38,35,36,.07); scroll-margin-top: 72px; }
.studio-detail[hidden] { display: none; }
.studio-detail-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; padding-bottom: 16px; border-bottom: 1px solid #EAE6E2; }
.studio-detail-title { min-width: 0; overflow-wrap: anywhere; }
.studio-detail-title h2 { font-size: 22px; line-height: 1.3; letter-spacing: -.025em; margin: 6px 0; }
.studio-detail-meta { color: #817B76; font-size: 11.5px; }
.studio-detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 4px; }
.studio-detail-actions > button, .studio-inline-actions > button, .review-flag-actions > button { max-width: 100%; white-space: normal; }
.studio-download-section { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin: 16px 0 4px; padding: 16px 18px; border: 1px solid #E7DED7; border-left: 3px solid var(--brand-accent); border-radius: 9px; background: #FAF7F4; }
.studio-download-section h3 { margin: 0 0 4px; font-size: 14px; }
.studio-download-section p { margin: 0; color: #817B76; font-size: 12px; line-height: 1.5; }
.studio-download-actions { display: flex; flex: 0 0 auto; flex-wrap: wrap; gap: 9px; }
.studio-download-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; }
.studio-download-button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.studio-download-unavailable { padding: 9px 12px; border: 1px solid #E6DDD5; border-radius: 7px; background: #FFFDFC; color: #6E6259 !important; font-size: 12px !important; }
.studio-section { padding: 18px 0; border-top: 1px solid #EAE6E2; overflow-wrap: anywhere; }
.studio-section h3 { font-size: 15px; font-weight: 700; letter-spacing: -.01em; margin-bottom: 8px; }
.studio-section h4 { margin: 14px 0 6px; color: #68615C; font-size: 10px; font-weight: 700; letter-spacing: .075em; text-transform: uppercase; }
.studio-section p { margin: 5px 0; color: var(--text-secondary); }
.studio-version-list, .studio-review-list { display: grid; gap: 8px; }
.studio-history-row { min-width: 0; padding: 12px 14px; border: 1px solid #E5E0DC; border-radius: 8px; background: #FAF8F6; }
.studio-history-row p { margin: 4px 0 0; }
.studio-inline-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.campaign-asset-edit { display: block; width: 100%; min-height: 180px; margin-top: 6px; font: inherit; line-height: 1.6; }
.studio-version-compare { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin: 12px 0; }
.studio-version-compare label { display: grid; gap: 4px; font-size: 12px; color: var(--text-secondary); }
.studio-version-diff { max-width: 100%; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }
.studio-detail input { max-width: 100%; }
.studio-detail .studio-date-filter { max-width: 500px; margin-bottom: 8px; }
.studio-detail .studio-date-filter .form-input { text-transform: none; }
.review-flag { padding: 15px; border-radius: 8px; }
.review-flag-heading { align-items: center; }
.review-flag-kind { color: #756B63; letter-spacing: .08em; }
.review-flag-status { padding: 3px 8px; border: 1px solid #E4DED9; border-radius: 99px; background: #F7F4F1; }
.review-flag-description { margin-top: 8px; color: #332F2D; }
.review-flag-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; gap: 10px; }
.review-flag-actions > .studio-date-filter { min-width: 0; }
.review-flag-note { width: 100%; min-height: 74px; resize: vertical; padding: 9px 10px; border: 1px solid #DAD5D0; border-radius: 7px; font: inherit; font-size: 13px; }
.review-flag-note:focus-visible, .studio-filters :focus-visible, .studio-detail :focus-visible { outline: 3px solid rgba(255, 0, 43,.28); outline-offset: 2px; border-color: var(--brand-accent); }
.review-flag-actions > button { justify-self: start; }
.library-controls { display: flex; gap: 10px; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 12px;
  flex: 1;
  min-width: 200px;
}
.search-box input {
  border: none;
  outline: none;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text-primary);
  background: transparent;
  flex: 1;
}
.filter-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  font-family: inherit;
}
.filter-pill.active { background: var(--brand-primary); color: #fff; border-color: var(--brand-primary); }
.upload-btn {
  background: var(--brand-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 700;
  padding: 7px 16px;
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  transition: opacity 0.15s;
  font-family: inherit;
}
.upload-btn:hover { opacity: 0.88; }
.library-tabs { display: flex; gap: 2px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.lib-tab {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 8px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.12s;
}
.lib-tab.active { color: var(--brand-accent); border-bottom-color: var(--brand-accent); }
.lib-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}
.lib-table th {
  background: var(--surface-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.lib-table td {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--surface-3);
  vertical-align: middle;
}
.lib-table tr:last-child td { border-bottom: none; }
.lib-table tr:hover td { background: var(--surface-2); }
.content-type-badge {
  font-size: 10px;
  font-weight: 700;
  border-radius: 3px;
  padding: 2px 7px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.ct-past_proposal, .ct-proposal { background: #EDE9FE; color: #5B21B6; }
.ct-case_study, .ct-case { background: #DCFCE7; color: #166534; }
.ct-messaging_framework, .ct-messaging { background: #FFF7ED; color: #C2410C; }
.ct-approved_claims, .ct-claim { background: #F0F9FF; color: #0369A1; }
.ct-price_book, .ct-price { background: #F0FDF4; color: #166534; }
.ct-template { background: #FDF4FF; color: #7E22CE; }
.ct-reference { background: #F3F4F6; color: #4B5563; }
.expiry-warn { color: #C2410C; font-weight: 600; }
.expiry-ok { color: var(--text-muted); }

/* ── AUDIT PAGE ── */
.audit-layout { padding: 28px 32px; }
.audit-header { margin-bottom: 24px; }
.audit-header h1 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.audit-header p { font-size: 13.5px; color: var(--text-secondary); }
.audit-filters { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.audit-timeline { display: flex; flex-direction: column; gap: 0; }
.audit-event {
  display: flex;
  gap: 14px;
  padding: 12px 0;
  position: relative;
}
.audit-event::before {
  content: '';
  position: absolute;
  left: 14px;
  top: 36px;
  bottom: -12px;
  width: 1px;
  background: var(--border);
}
.audit-event:last-child::before { display: none; }
.audit-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  margin-top: 4px;
  z-index: 1;
}
.ad-session { background: #EDE9FE; color: #5B21B6; }
.ad-brief { background: #F0F9FF; color: #0369A1; }
.ad-outline { background: #FFF7ED; color: #C2410C; }
.ad-draft { background: #F0FDF4; color: #166534; }
.ad-edit { background: #F3F4F6; color: #4B5563; }
.ad-flag { background: #FEF3C7; color: #92400E; }
.ad-brand { background: #EFF6FF; color: #1D4ED8; }
.ad-approval { background: #F0FDF4; color: #166534; }
.ad-export { background: #0B1220; color: #FF002B; }
.ad-default { background: #F3F4F6; color: #4B5563; }
.audit-content { flex: 1; }
.audit-event-type { font-size: 12px; font-weight: 700; color: var(--text-primary); margin-bottom: 2px; }
.audit-event-detail { font-size: 12px; color: var(--text-secondary); line-height: 1.45; }
.audit-event-meta { font-size: 11px; color: var(--text-muted); margin-top: 3px; display: flex; gap: 12px; }
.audit-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 20px;
}
.audit-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.audit-doc-title { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.audit-doc-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── APPROVALS PAGE ── */
.approvals-layout { padding: 28px 32px; }
.approvals-header { margin-bottom: 24px; }
.approvals-header h1 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.approvals-header p { font-size: 13.5px; color: var(--text-secondary); }
.approval-queue { display: flex; flex-direction: column; gap: 12px; }
.approval-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.approval-card:hover { box-shadow: var(--shadow-md); }
.approval-tier {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  border-radius: 4px;
  padding: 3px 9px;
  flex-shrink: 0;
  margin-top: 2px;
}
.tier-low { background: #F0FDF4; color: #166534; border: 1px solid #BBF7D0; }
.tier-medium { background: #FFF7ED; color: #C2410C; border: 1px solid #FED7AA; }
.tier-high { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }
.approval-body { flex: 1; }
.approval-title { font-size: 14px; font-weight: 700; color: var(--text-primary); margin-bottom: 3px; }
.approval-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.approval-tokens { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.token-badge {
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  padding: 3px 9px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.token-ok { background: #F0FDF4; color: #166534; border: 1px solid #BBF7D0; }
.token-pending { background: #F3F4F6; color: #6B7280; border: 1px solid #E5E7EB; }
.approval-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn-approve-action {
  background: var(--brand-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 700;
  padding: 7px 16px;
  cursor: pointer;
  transition: opacity 0.15s;
  font-family: inherit;
}
.btn-approve-action:hover { opacity: 0.88; }
.btn-approve-action:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-reject-action {
  background: var(--surface);
  color: #991B1B;
  border: 1px solid #FECACA;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 16px;
  cursor: pointer;
  font-family: inherit;
}
.btn-changes-action {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 16px;
  cursor: pointer;
  font-family: inherit;
}
.sla-chip {
  font-size: 11px;
  font-weight: 600;
  color: #C2410C;
  background: #FFF7ED;
  border-radius: 4px;
  padding: 2px 8px;
  margin-left: auto;
  flex-shrink: 0;
}

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  overflow: hidden;
}
.modal-header {
  background: var(--brand-primary);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h2 { font-size: 15px; font-weight: 700; color: #fff; }
.modal-close { background: none; border: none; color: rgba(255,255,255,0.5); cursor: pointer; font-size: 20px; line-height: 1; }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }
.btn-primary {
  background: var(--brand-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 700;
  padding: 8px 20px;
  cursor: pointer;
  transition: opacity 0.15s;
  font-family: inherit;
}
.btn-primary:hover { opacity: 0.88; }
.btn-secondary {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 20px;
  cursor: pointer;
  font-family: inherit;
}

/* Library document reader and review actions */
.library-review-overlay { z-index: 220; padding: clamp(8px, 2vw, 28px); background: rgba(19, 18, 18, .72); backdrop-filter: blur(3px); }
.library-review-modal { width: min(1120px, 100%); height: min(92vh, 980px); display: flex; flex-direction: column; overflow: hidden; background: #f0efed; border: 1px solid rgba(255,255,255,.45); border-radius: 14px; box-shadow: 0 24px 80px rgba(0,0,0,.35); }
.library-review-header { flex: 0 0 auto; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 20px 28px 17px; color: #fff; background: var(--brand-primary); }
.library-review-kicker { margin: 0 0 4px; color: #ff9868; font-size: 10px; font-weight: 700; letter-spacing: .12em; }
.library-review-header h2 { font-size: clamp(19px, 2vw, 24px); line-height: 1.2; }
.library-review-meta { margin-top: 6px; color: rgba(255,255,255,.68); font-size: 12px; overflow-wrap: anywhere; }
.library-review-header .modal-close { color: #fff; padding: 4px 8px; border-radius: 6px; }
.library-review-header .modal-close:hover { background: rgba(255,255,255,.12); }
.library-review-notice, .library-placeholder-notice { flex: 0 0 auto; margin: 12px auto 0; width: min(860px, calc(100% - 32px)); padding: 10px 14px; border-radius: 7px; color: #394047; background: #fff; border: 1px solid #dedbd7; font-size: 12px; }
.library-placeholder-notice { color: #7a3d00; background: #fff4e6; border-color: #f2c27d; }
.library-reader-scroll { flex: 1 1 auto; min-height: 120px; overflow: auto; padding: 18px 18px 24px; overscroll-behavior: contain; }
.library-reader-page { width: min(860px, 100%); min-height: 100%; margin: 0 auto; padding: clamp(24px, 5vw, 58px) clamp(22px, 6vw, 76px); color: #242628; background: #fff; border: 1px solid #e1dfdc; border-radius: 3px; box-shadow: 0 5px 22px rgba(40,35,30,.09); font-family: 'Source Sans 3', system-ui, sans-serif; font-size: 16px; line-height: 1.8; overflow-wrap: anywhere; }
.library-reader-page h1, .library-reader-page h2, .library-reader-page h3, .library-reader-page h4 { margin: 1.55em 0 .58em; color: #242324; line-height: 1.28; }
.library-reader-page h1 { margin-top: 0; font-size: 1.75em; }
.library-reader-page h2 { font-size: 1.48em; border-bottom: 1px solid #ece9e5; padding-bottom: .25em; }
.library-reader-page h3 { font-size: 1.2em; }
.library-reader-page p { margin: 0 0 1em; white-space: pre-wrap; }
.library-reader-page ul, .library-reader-page ol { margin: 0 0 1.1em 1.5em; }
.library-reader-page li { padding-left: .2em; margin: .25em 0; }
.library-reader-table-wrap { overflow-x: auto; margin: 1.2em 0; }
.library-reader-page table { width: 100%; border-collapse: collapse; font-size: .92em; line-height: 1.5; }
.library-reader-page th { text-align: left; color: #fff; background: #393638; font-weight: 700; }
.library-reader-page th, .library-reader-page td { padding: 9px 11px; border: 1px solid #d9d6d2; vertical-align: top; }
.library-reader-page tr:nth-child(even) td { background: #faf9f7; }
.library-original-inspection { flex: 0 0 auto; max-height: 44vh; overflow: auto; margin: 12px 20px 0; padding: 14px 16px; background: #fff; border: 1px solid #dedbd7; border-radius: 10px; }
.library-original-inspection h3 { margin: 0 0 8px; color: #28272a; font-size: 15px; }
.library-original-inspection > label { display: block; margin: 0 0 5px; color: #5d5a57; font-size: 12px; font-weight: 600; }
.library-original-inspection select { max-width: 420px; }
.library-original-view { margin-top: 10px; }
.library-original-view iframe { display: block; width: 100%; height: 38vh; min-height: 220px; border: 1px solid #d9d6d2; background: white; }
.library-original-block { margin: 8px 0; color: #29282a; line-height: 1.6; white-space: pre-wrap; }
.library-original-block.is-heading { font-weight: 700; font-size: 1.08em; }
.library-original-block table { border-collapse: collapse; width: 100%; }
.library-original-block th, .library-original-block td { border: 1px solid #d9d6d2; padding: 7px; text-align: left; vertical-align: top; }
.library-original-note { margin: 8px 0 0; color: #716c67; font-size: 11px; line-height: 1.5; }
.library-evidence-heading { margin: 18px auto 10px; max-width: 860px; color: #5a5652; font-size: 13px; letter-spacing: .02em; }
.library-extraction-warning { max-width: 860px; margin: 8px auto; padding: 10px 12px; border: 1px solid #f0ca86; border-radius: 7px; background: #fff8e9; color: #79520b; font-size: 12px; }
.template-placeholder { display: inline-block; padding: 0 .22em; color: #7a3200; background: #ffe0c2; border: 1px solid #f2ad73; border-radius: 3px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; font-weight: 650; }
.library-analysis { flex: 0 0 auto; max-height: 150px; overflow: auto; margin: 0 auto 10px; width: min(860px, calc(100% - 32px)); padding: 12px 16px; background: #fff; border: 1px solid var(--border); border-radius: 8px; font-size: 12px; }
.library-analysis h3 { margin-bottom: 5px; font-size: 13px; }
.library-review-actions { flex: 0 0 auto; max-height: 36vh; overflow: auto; padding: 14px clamp(16px, 3vw, 28px) 16px; background: #fff; border-top: 1px solid #dedbd7; box-shadow: 0 -5px 18px rgba(20,18,18,.06); }
.library-review-fields { display: grid; grid-template-columns: minmax(210px, .7fr) minmax(280px, 1.5fr); gap: 14px; align-items: start; }
.library-review-field { display: grid; gap: 5px; color: var(--text-secondary); font-size: 11px; font-weight: 700; }
.library-review-field small { color: var(--text-muted); font-weight: 400; }
.library-review-field textarea { resize: vertical; min-height: 56px; font-size: 12px; }
.library-review-identity-note { margin-top: 7px; color: var(--text-muted); font-size: 10.5px; }
.library-review-buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 10px; }
.library-review-buttons .btn-primary, .library-review-buttons .btn-secondary { min-height: 38px; }
.library-review-error { min-height: 0; color: #a12222; font-size: 12px; margin-top: 5px; }
.library-review-error:empty { display: none; }
.library-review-overlay :focus-visible { outline: 3px solid rgba(255, 0, 43,.55); outline-offset: 2px; }
.hidden { display: none !important; }
.compliance-matrix { width: 100%; border-collapse: collapse; margin-top: 12px; }
.compliance-matrix th { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.compliance-matrix td { font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--surface-3); color: var(--text-primary); }
.cm-addressed { color: #166534; font-weight: 700; }
.cm-partial { color: #C2410C; font-weight: 700; }
.cm-open { color: #991B1B; font-weight: 700; }

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--brand-primary);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateY(80px);
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
  max-width: 340px;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* ── MISC ── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state p { font-size: 14px; }
.price-book-table { width: 100%; border-collapse: collapse; }
.price-book-table th { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: left; }
.price-book-table td { font-size: 13px; padding: 10px 12px; border-bottom: 1px solid var(--surface-3); color: var(--text-primary); }
.price-book-table tr:last-child td { border-bottom: none; }
.price-highlight { font-weight: 700; color: var(--brand-primary); }

@media (max-width: 900px) {
  .quick-actions { grid-template-columns: repeat(2, 1fr) !important; }
  .editor-right-panel { display: none; }
  .sidebar { width: 200px; }
}
@media (max-width: 1180px) {
  #studio .studio-toolbar { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
  #studio .studio-search { grid-column: span 2; }
  #studio .studio-refresh { grid-column: 4; justify-self: end; }
}
@media (max-width: 680px) {
  .library-review-overlay { padding: 0; align-items: stretch; }
  .library-review-modal { width: 100%; height: 100dvh; max-height: 100dvh; border-radius: 0; }
  .library-review-header { padding: 15px 16px 13px; }
  .library-reader-scroll { padding: 10px 8px 14px; }
  .library-reader-page { padding: 24px 19px; font-size: 15px; }
  .library-original-inspection { max-height: 42vh; margin: 10px 12px 0; padding: 12px; }
  .library-original-view iframe { height: 32vh; }
  .library-review-fields { grid-template-columns: minmax(0, 1fr); gap: 9px; }
  .library-review-actions { max-height: 44vh; padding: 11px 14px calc(12px + env(safe-area-inset-bottom)); }
  .library-review-buttons { justify-content: stretch; }
  .library-review-buttons > button { flex: 1 1 auto; }
  nav { height: auto; min-height: 56px; padding: 8px 12px; flex-wrap: wrap; }
  .nav-logo { margin-right: 12px; }
  .nav-links { order: 3; flex: 1 0 100%; overflow-x: auto; padding: 4px 0; }
  .nav-link { flex: 0 0 auto; padding: 7px 10px; }
  .nav-right { gap: 7px; }
  .sidebar { display: none; }
  .home-body { padding: 20px 16px; }
  .library-layout { padding: 20px 16px; }
  .studio-layout { padding: 22px 16px 36px; }
  .studio-header { margin-bottom: 17px; padding-bottom: 17px; }
  .studio-header h1 { font-size: 27px; }
  #studio .studio-toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 14px 0 10px; }
  #studio .studio-search { grid-column: 1 / -1; }
  #studio .studio-refresh { grid-column: 2; justify-self: end; align-self: start; }
  .studio-detail { padding: 14px; }
  .studio-detail-header { flex-direction: column; }
  .studio-detail-title h2 { font-size: 20px; }
  .studio-download-section { align-items: stretch; flex-direction: column; gap: 12px; padding: 14px; }
  .studio-download-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .studio-download-button { min-width: 0; padding-inline: 8px; }
  .review-flag-actions { grid-template-columns: minmax(0, 1fr); }
  .studio-detail-actions > button, .studio-inline-actions > button, .review-flag-actions > button { min-height: 40px; }
  .audit-layout { padding: 20px 16px; }
  .approvals-layout { padding: 20px 16px; }
}
@media (max-width: 380px) {
  .studio-layout { padding-right: 12px; padding-left: 12px; }
  .studio-filters { gap: 7px; }
  .studio-filters .form-select, .studio-date-filter .form-input { padding-right: 6px; padding-left: 7px; font-size: 11px; }
  .studio-card { padding: 14px 13px 12px; }
}
@media (max-width: 340px) {
  #studio .studio-toolbar { grid-template-columns: minmax(0, 1fr); }
  #studio .studio-search, #studio .studio-refresh { grid-column: 1; }
  #studio .studio-refresh { justify-self: start; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; }
}
.library-record-id{display:block;margin-top:3px;color:var(--text-muted);font-size:.76rem;font-weight:400;letter-spacing:.015em}
.studio-evidence-warning {
  margin: 1rem 0;
  padding: 0.9rem 1rem;
  border: 1px solid #d18a2b;
  border-left: 4px solid var(--accent, #e87524);
  border-radius: 8px;
  background: #fff7ed;
  color: #49321f;
  line-height: 1.5;
}

/* Account Managers (proposals only): no library writes, no studio re-index (the server refuses them too). */
body.proposals-only [onclick*="showUploadModal"],
body.proposals-only [onclick*="backfillStudio"],
body.proposals-only [onclick*="createStudioTemplate"] { display: none !important; }
