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

:root {
  --navy: #0B1D3A;
  --navy-mid: #122348;
  --navy-light: #1a3260;
  --cyan: #00A3C4;
  --cyan-dark: #007a95;
  --cyan-light: #33b8d4;
  --white: #ffffff;
  --off-white: #f4f6fa;
  --text: #1a2340;
  --text-muted: #5a6785;
  --border: #dde3ef;
  --card: #ffffff;
  --input-bg: #f9fafd;

  --critical: #D32F2F;
  --high: #F57C00;
  --medium: #FBC02D;
  --low: #388E3C;
  --critical-bg: #fdecea;
  --high-bg: #fff3e0;
  --medium-bg: #fffde7;
  --low-bg: #e8f5e9;

  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 2px 8px rgba(11,29,58,0.08);
  --shadow-lg: 0 4px 20px rgba(11,29,58,0.12);
  --transition: 0.18s ease;
}

@media (prefers-color-scheme: dark) {
  :root {
    --navy: #0d2244;
    --navy-mid: #0a1a36;
    --navy-light: #1a3260;
    --white: #e8edf5;
    --off-white: #111c30;
    --text: #d0d8eb;
    --text-muted: #7a89a8;
    --border: #1e3050;
    --card: #0f2040;
    --input-bg: #0d1a2e;
  }
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--off-white);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ─── HEADER ─── */
header {
  background: var(--navy);
  color: var(--white);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.25);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-brand svg {
  flex-shrink: 0;
}

.brand-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--white);
}

.brand-sub {
  font-size: 11px;
  color: var(--cyan-light);
  font-weight: 400;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.header-badges {
  display: flex;
  gap: 8px;
  align-items: center;
}

.badge {
  background: rgba(0,163,196,0.15);
  border: 1px solid rgba(0,163,196,0.3);
  color: var(--cyan-light);
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ─── MAIN LAYOUT ─── */
.app-shell {
  display: flex;
  height: calc(100vh - 60px);
  overflow: hidden;
}

/* ─── SIDEBAR ─── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--navy);
  overflow-y: auto;
  padding: 16px 10px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-group {
  margin-bottom: 6px;
}

.sidebar-group-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  padding: 8px 10px 4px;
  display: block;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 10px;
  background: none;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.65);
  cursor: pointer;
  text-align: left;
  transition: all var(--transition);
}

.nav-btn:hover {
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.9);
}

.nav-btn.active {
  background: var(--cyan);
  color: white;
  font-weight: 600;
}

.nav-btn .nav-icon { font-size: 15px; flex-shrink: 0; }

/* ─── CONTENT AREA ─── */
.content-area {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--off-white);
}

/* ─── PANELS ─── */
.panel { display: none; flex: 1; overflow: hidden; }
.panel.active {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
  padding: 20px 24px;
  flex: 1;
  overflow: hidden;
  align-items: stretch;
  box-sizing: border-box;
}

@media (max-width: 900px) {
  .panel-grid {
    grid-template-columns: 1fr;
    overflow-y: auto;
    align-items: start;
  }
  .panel-grid > div:first-child { height: auto; overflow: visible; }
  .output-card { min-height: 500px; height: auto; }
}

/* ─── CARDS ─── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.card-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.card-body {
  padding: 16px 20px;
}

/* ─── FRAMEWORK SELECTOR ─── */
.framework-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.fw-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all var(--transition);
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  background: var(--input-bg);
  user-select: none;
}

.fw-check:hover {
  border-color: var(--cyan);
  background: rgba(0,163,196,0.05);
}

.fw-check input[type="checkbox"] {
  accent-color: var(--cyan);
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.fw-check.checked {
  border-color: var(--cyan);
  background: rgba(0,163,196,0.08);
  color: var(--cyan-dark);
}

/* ─── DOMAIN SELECTOR ─── */
.domain-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.domain-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--input-bg);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.domain-btn:hover {
  border-color: var(--cyan);
  color: var(--cyan-dark);
}

.domain-btn.active {
  background: var(--cyan);
  border-color: var(--cyan);
  color: white;
  font-weight: 600;
}

/* ─── INPUTS ─── */
label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

textarea {
  width: 100%;
  min-height: 180px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--input-bg);
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  resize: vertical;
  transition: border-color var(--transition);
  line-height: 1.5;
}

textarea:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(0,163,196,0.1);
}

textarea::placeholder { color: var(--text-muted); }

.input-row { margin-bottom: 14px; }

/* ─── SUBFLOW SELECTOR ─── */
.subflow-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.subflow-btn {
  flex: 1;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--input-bg);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  text-align: center;
  transition: all var(--transition);
}

.subflow-btn.active {
  border-color: var(--navy);
  background: var(--navy);
  color: white;
}

/* ─── CTA BUTTON ─── */
.btn-primary {
  width: 100%;
  padding: 13px;
  background: var(--cyan);
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: white;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

.btn-primary:hover { background: var(--cyan-dark); }
.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ─── LEFT COLUMN (inputs) ─── */
.panel-grid > div:first-child {
  overflow-y: auto;
  height: 100%;
  padding-right: 4px;
}

/* ─── OUTPUT PANEL ─── */
.output-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

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

.output-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.export-row {
  display: flex;
  gap: 8px;
}

.btn-export {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-export:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

.output-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
}

/* ─── PLACEHOLDER STATE ─── */
.output-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  color: var(--text-muted);
  text-align: center;
  gap: 16px;
}

.output-placeholder svg {
  opacity: 0.3;
}

.output-placeholder p {
  font-size: 14px;
  max-width: 280px;
}

/* ─── THINKING INDICATOR ─── */
.thinking-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: rgba(0,163,196,0.06);
  border: 1px solid rgba(0,163,196,0.2);
  border-radius: var(--radius);
  color: var(--cyan-dark);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 20px;
}

.thinking-dots {
  display: flex;
  gap: 4px;
}

.thinking-dots span {
  width: 6px;
  height: 6px;
  background: var(--cyan);
  border-radius: 50%;
  animation: dot-bounce 1.2s infinite ease-in-out;
}

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

@keyframes dot-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* ─── MARKDOWN RENDERED CONTENT ─── */
.md-content {
  font-size: 14px;
  line-height: 1.75;
  color: var(--text);
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
}

.md-content h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--navy);
  margin: 0 0 18px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--cyan);
  line-height: 1.3;
}

.md-content h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--navy);
  margin: 28px 0 8px;
  padding: 8px 12px;
  background: rgba(0,163,196,0.07);
  border-left: 3px solid var(--cyan);
  border-radius: 0 4px 4px 0;
}

.md-content h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin: 20px 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.md-content h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 14px 0 4px;
}

.md-content p {
  margin: 0 0 12px;
}

.md-content ul, .md-content ol {
  margin: 0 0 12px 22px;
  padding: 0;
}

.md-content li {
  margin-bottom: 5px;
  line-height: 1.6;
}

.md-content strong { font-weight: 700; color: var(--text); }

.md-content em { font-style: italic; color: var(--text-muted); }

.md-content code {
  background: #f0f4f8;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
  color: #0055a5;
  word-break: break-all;
}

.md-content pre {
  background: #0f1e35;
  border-radius: var(--radius);
  padding: 16px;
  overflow-x: auto;
  margin: 14px 0;
  max-width: 100%;
}

.md-content pre code {
  background: none;
  border: none;
  padding: 0;
  color: #c8d8f0;
  font-size: 12.5px;
  word-break: normal;
}

/* Tables scroll horizontally within the output area — never bust out */
.md-content .table-wrap {
  overflow-x: auto;
  margin: 14px 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.md-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  min-width: 500px;
}

.md-content th {
  background: var(--navy);
  color: white;
  padding: 9px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.md-content td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  word-wrap: break-word;
  max-width: 280px;
}

.md-content tr:nth-child(even) td { background: #f8fafb; }
.md-content tr:hover td { background: rgba(0,163,196,0.05); }

.md-content blockquote {
  border-left: 3px solid var(--cyan);
  padding: 8px 16px;
  margin: 12px 0;
  background: rgba(0,163,196,0.04);
  color: var(--text-muted);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.md-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* ─── RISK BADGE COLOURS in rendered content ─── */
.md-content :is(p, td, li):has-text("🔴") { }

/* ─── ERROR STATE ─── */
.error-box {
  padding: 14px 18px;
  background: var(--critical-bg);
  border: 1px solid #f5c6c6;
  border-radius: var(--radius);
  color: var(--critical);
  font-size: 13px;
  font-weight: 500;
}

/* ─── DIVIDER ─── */
.section-divider {
  height: 1px;
  background: var(--border);
  margin: 14px 0;
}

/* ─── FILE UPLOAD ─── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 16px 14px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--input-bg);
  position: relative;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--cyan);
  background: rgba(0,163,196,0.05);
}

.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.upload-zone-icon { font-size: 22px; margin-bottom: 4px; }

.upload-zone-label {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.upload-zone-label strong { color: var(--cyan); }

.upload-zone-types {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 3px;
  opacity: 0.7;
}

.attachments-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.attachment-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--off-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text);
}

.attachment-chip .att-icon { font-size: 15px; flex-shrink: 0; }
.attachment-chip .att-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.attachment-chip .att-size { color: var(--text-muted); flex-shrink: 0; font-size: 11px; }

.attachment-chip .att-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
  transition: color var(--transition);
}

.attachment-chip .att-remove:hover { color: var(--critical); }

.attachment-chip.att-image img {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── VALIDATION PANEL ─── */
.validation-panel {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.validation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--off-white);
  border-bottom: 1px solid var(--border);
}

.validation-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.validation-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.3px;
}

.validation-badge.badge-high  { background: #E8F5E9; color: #1B5E20; }
.validation-badge.badge-medium { background: #FFF8E1; color: #5D4037; }
.validation-badge.badge-low   { background: #FFEBEE; color: #B71C1C; }

.validation-body {
  padding: 16px;
  font-size: 13px;
  line-height: 1.65;
  max-height: 400px;
  overflow-y: auto;
  color: var(--text);
}

.validation-body h2 { font-size: 14px; margin: 14px 0 6px; }
.validation-body h3 { font-size: 13px; margin: 10px 0 4px; color: var(--text-muted); }
.validation-body table { width: 100%; border-collapse: collapse; font-size: 12px; margin: 8px 0; }
.validation-body th, .validation-body td { padding: 5px 8px; border: 1px solid var(--border); text-align: left; }
.validation-body th { background: var(--off-white); font-weight: 600; }

.btn-validate {
  padding: 5px 12px;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-validate:hover { background: var(--accent); color: #fff; }
.btn-validate:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── VALIDATION DOWNLOAD BAR ─── */
.validation-download-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: #f0f8fa;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.download-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-right: 4px;
}

.btn-dl {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 13px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: white;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: all var(--transition);
  cursor: pointer;
}

.btn-dl:hover {
  background: var(--accent);
  color: white;
}

/* ─── ARCHIVE PANEL ─── */
.sidebar-group--bottom {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.archive-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.archive-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  flex-shrink: 0;
  gap: 16px;
  flex-wrap: wrap;
}

.archive-toolbar-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.archive-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.archive-count {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.archive-toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.archive-search-wrap {
  position: relative;
}

.archive-search {
  padding: 7px 12px 7px 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--input-bg);
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  width: 220px;
  transition: border-color var(--transition);
}

.archive-search:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(0,163,196,0.1);
}

.archive-search-wrap::before {
  content: '🔍';
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  pointer-events: none;
}

.archive-filter {
  padding: 7px 28px 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--input-bg);
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%235a6785'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  transition: border-color var(--transition);
}

.archive-filter:focus {
  outline: none;
  border-color: var(--cyan);
}

.btn-archive-refresh {
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-archive-refresh:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

.archive-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 32px;
  background: var(--off-white);
}

/* ─── RESULTS GRID ─── */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.results-loading {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 48px 0;
  color: var(--text-muted);
  font-size: 14px;
  justify-content: center;
}

.results-empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 64px 0;
  text-align: center;
  color: var(--text-muted);
}

.results-empty span {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.results-empty p {
  font-size: 13px;
  max-width: 300px;
  line-height: 1.5;
}

/* ─── RESULT CARD ─── */
.result-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow var(--transition), transform var(--transition);
}

.result-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

.result-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 12px;
  border-left: 4px solid var(--cyan);
  border-bottom: 1px solid var(--border);
}

.result-icon {
  font-size: 22px;
  flex-shrink: 0;
  line-height: 1;
}

.result-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.result-mode-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}

.result-date {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-desc {
  padding: 10px 16px 6px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
  font-style: italic;
  border-bottom: 1px solid var(--border);
}

.result-files {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  flex-wrap: wrap;
  margin-top: auto;
}

.btn-dl--disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

/* ─── DRAFT FOR REVIEW DOWNLOAD BUTTONS ─── */
.btn-draft-download {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  letter-spacing: .01em;
}
.btn-draft-word {
  background: #1a3a6e;
  color: #fff;
}
.btn-draft-word:hover { background: #234d94; }
.btn-draft-word:active { background: #122d56; }
.btn-draft-pdf {
  background: #7f1d1d;
  color: #fff;
}
.btn-draft-pdf:hover { background: #991b1b; }
.btn-draft-pdf:active { background: #5f1515; }
.btn-draft-download:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ─── ANALYSIS TIER SELECTOR ─── */
.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.tier-selector {
  display: flex;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 20px;
  padding: 3px;
  gap: 2px;
}

.tier-btn {
  padding: 4px 13px;
  border: none;
  border-radius: 16px;
  background: transparent;
  color: rgba(255,255,255,0.55);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.tier-btn:hover {
  color: rgba(255,255,255,0.85);
  background: rgba(255,255,255,0.08);
}

.tier-btn--active {
  background: var(--cyan);
  color: white !important;
  box-shadow: 0 1px 4px rgba(0,163,196,0.4);
}

/* Cost hint shown below the active tier label */
.tier-cost-hint {
  font-size: 10px;
  color: rgba(255,255,255,0.35);
  text-align: center;
  margin-top: 1px;
  letter-spacing: 0.03em;
}

/* ─── FOLLOW-UP PANEL ─── */
.followup-panel {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card);
}

.followup-header {
  padding: 10px 16px;
  background: var(--off-white);
  border-bottom: 1px solid var(--border);
}

.followup-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.followup-thread {
  max-height: 320px;
  overflow-y: auto;
  padding: 12px 16px;
}

.followup-thread:empty {
  display: none;
}

.followup-question {
  align-self: flex-end;
  background: rgba(0,163,196,0.1);
  border: 1px solid rgba(0,163,196,0.25);
  border-radius: 10px 10px 2px 10px;
  padding: 8px 12px;
  margin: 0 0 6px auto;
  max-width: 85%;
  font-size: 13px;
  color: var(--text);
  width: fit-content;
}

.followup-answer {
  background: var(--off-white);
  border-radius: 10px 10px 10px 2px;
  padding: 10px 14px;
  margin: 0 auto 14px 0;
  max-width: 92%;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
}

.followup-answer .thinking-dots {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.followup-system-note {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  padding: 6px 0;
}

.error-text {
  color: var(--critical);
}

.followup-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
}

.followup-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--input-bg);
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
}

.followup-input:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(0,163,196,0.1);
}

.followup-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-followup-send {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  background: var(--cyan);
  color: white;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
  white-space: nowrap;
}

.btn-followup-send:hover { background: var(--cyan-dark); }
.btn-followup-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── LOGIN PAGE ─── */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  background-image: radial-gradient(circle at 30% 20%, rgba(0,163,196,0.12), transparent 50%);
  padding: 20px;
}

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

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

.login-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.login-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.login-error {
  background: var(--critical-bg);
  color: var(--critical);
  border: 1px solid rgba(211,47,47,0.25);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: 13px;
  margin-bottom: 16px;
}

.login-form input[type="email"],
.login-form input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--input-bg);
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
}

.login-form input:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(0,163,196,0.1);
}

.login-submit {
  width: 100%;
  margin-top: 6px;
}

/* ─── USER MENU (header) ─── */
.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 14px;
  border-left: 1px solid rgba(255,255,255,0.15);
}

.user-name {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  white-space: nowrap;
}

.btn-logout {
  font-size: 12px;
  font-weight: 600;
  color: var(--cyan-light);
  text-decoration: none;
  padding: 5px 10px;
  border: 1px solid rgba(0,163,196,0.35);
  border-radius: var(--radius);
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-logout:hover {
  background: rgba(0,163,196,0.15);
  color: white;
}
