/* National Bank of Egypt UI — Soft UI + NBE brand tokens (ui-ux-pro-max) */
:root {
  --color-primary: #004b23;
  --color-on-primary: #ffffff;
  --color-secondary: #0a3d1f;
  --color-accent: #ffcc00;
  --color-accent-hover: #e0a800;
  --color-background: #f4f7f5;
  --color-foreground: #0b1a12;
  --color-muted: #e4ebe6;
  --color-muted-fg: #3d5346;
  --color-border: #d3ddd7;
  --color-destructive: #b42318;
  --color-success: #0f766e;
  --color-ring: #004b23;
  --color-surface: #ffffff;
  --color-sidebar: #003d1c;
  --color-sidebar-fg: #eef5f0;
  --color-sidebar-muted: #a7c0b2;

  /* Legacy aliases used by charts / older rules */
  --ink: var(--color-primary);
  --ink-2: #1e293b;
  --paper: var(--color-background);
  --surface: var(--color-surface);
  --muted: var(--color-muted-fg);
  --line: var(--color-border);
  --brass: var(--color-accent);
  --brass-dark: var(--color-accent-hover);
  --forest: var(--color-success);
  --red: var(--color-destructive);
  --focus: #0369a1;

  --radius: 10px;
  --radius-sm: 8px;
  --radius-lg: 12px;
  --duration: 220ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 2px 4px rgba(15, 23, 42, 0.06), 0 8px 20px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 10px 28px rgba(15, 23, 42, 0.14);
  --shadow: var(--shadow-lg);
  --viz-radius: var(--radius);
  --viz-duration: var(--duration);
  --viz-shadow: var(--shadow-md);
  --viz-surface: #f1f5f9;
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
  --z-drawer: 40;
  --z-sidebar: 50;
  --z-modal: 60;
  --z-notice: 70;
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--color-background);
  color: var(--color-foreground);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: 0.65; }

:focus-visible {
  outline: 3px solid rgba(3, 105, 161, 0.45);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: var(--space-md);
  top: -48px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--color-primary);
  color: var(--color-on-primary);
  font-weight: 600;
  text-decoration: none;
  transition: top var(--duration) var(--ease);
}
.skip-link:focus { top: var(--space-md); }

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

.icon {
  display: inline-block;
  width: 1.1em;
  height: 1.1em;
  vertical-align: -0.15em;
  flex-shrink: 0;
}
.icon-lg { width: 1.35em; height: 1.35em; }

.eyebrow {
  margin: 0;
  color: var(--color-accent-hover);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.institution-mark {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--color-accent);
  color: var(--color-primary);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow-sm);
}

.institution-logo {
  display: block;
  width: auto;
  max-width: 156px;
  height: 44px;
  object-fit: contain;
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  box-shadow: var(--shadow-sm);
}

/* —— Shell —— */
.app-shell {
  min-height: 100vh;
  display: flex;
  background:
    radial-gradient(1200px 500px at 8% -12%, rgba(255, 204, 0, 0.12), transparent 55%),
    radial-gradient(900px 420px at 100% 0%, rgba(0, 75, 35, 0.06), transparent 50%),
    linear-gradient(160deg, #f4f7f5 0%, #e8efea 100%);
}

.sidebar {
  width: 280px;
  flex: 0 0 280px;
  display: flex;
  flex-direction: column;
  padding: var(--space-lg) var(--space-md);
  background: var(--color-sidebar);
  color: var(--color-sidebar-fg);
  z-index: var(--z-sidebar);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 28px;
}
.brand-lockup strong {
  display: block;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: #fff;
}
.brand-lockup small {
  display: block;
  margin-top: 4px;
  color: var(--color-sidebar-muted);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.new-chat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 11px 14px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: var(--radius);
  background: transparent;
  color: #fff;
  font-weight: 600;
  text-align: left;
  transition: background-color var(--duration) var(--ease), border-color var(--duration) var(--ease), transform var(--duration) var(--ease);
}
.new-chat:hover { background: rgba(255, 255, 255, 0.06); border-color: rgba(226, 232, 240, 0.55); }
.new-chat:active { transform: scale(0.98); }
.new-chat .icon { color: var(--color-accent); }

.nav-label {
  margin: 28px 8px 10px;
  color: var(--color-sidebar-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.recents-search-wrap { margin: 0 8px 10px; }
#recents-search {
  width: 100%;
  min-height: 34px;
  padding: 7px 9px 7px 30px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.72) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 10px center;
  color: #e2e8f0;
  font: inherit;
  font-size: 12px;
}
#recents-search::placeholder { color: var(--color-sidebar-muted); }
#recents-search:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px var(--focus-ring); }

.recents { overflow: auto; flex: 1; min-height: 0; }

.recent {
  display: block;
  width: 100%;
  min-height: 40px;
  padding: 10px 12px;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: transparent;
  color: #cbd5e1;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background-color var(--duration) var(--ease), color var(--duration) var(--ease), border-color var(--duration) var(--ease);
}
.recent:hover,
.recent.active {
  border-left-color: var(--color-accent);
  background: rgba(30, 41, 59, 0.85);
  color: #fff;
}
.recent.active { font-weight: 600; }

.sidebar-foot {
  margin-top: auto;
  padding: 18px 8px 0;
  border-top: 1px solid rgba(148, 163, 184, 0.25);
  color: var(--color-sidebar-muted);
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.security-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.2);
}

.workspace {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  max-height: 100vh;
}

.app-header {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--color-border);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
  z-index: 5;
}

.header-title { display: flex; align-items: center; gap: 12px; }
.header-title h1 {
  margin: 2px 0 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--color-primary);
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.health,
.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.role-picker select {
  min-height: 40px;
  min-width: 11.5rem;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-foreground);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.role-picker select:hover {
  border-color: var(--color-primary);
}
.role-picker select:focus-visible {
  outline: 3px solid rgba(0, 75, 35, 0.35);
  outline-offset: 2px;
}
.role-picker select:disabled {
  opacity: 0.65;
  cursor: wait;
}
.health {
  border: 1px solid #a7f3d0;
  color: var(--color-success);
  background: #ecfdf5;
}
.health.is-issue {
  border-color: #fecaca;
  color: var(--color-destructive);
  background: #fef2f2;
}
.health::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.role-badge {
  background: var(--color-muted);
  color: var(--color-primary);
}
.user-label { font-size: 13px; font-weight: 600; color: var(--ink-2); }

.header-button {
  min-height: 36px;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 6px 4px;
  background: none;
  color: var(--color-primary);
  font-size: 12px;
  font-weight: 700;
  transition: color var(--duration) var(--ease), border-color var(--duration) var(--ease);
}
.header-button:hover { border-bottom-color: var(--color-accent); color: var(--color-accent-hover); }
.header-button.logout { color: var(--color-destructive); }
.header-button.logout:hover { border-bottom-color: var(--color-destructive); }

.icon-button {
  display: none;
  min-width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  padding: 10px;
  color: var(--color-primary);
}
.icon-button:hover { background: var(--color-muted); }
.icon-button span {
  display: block;
  width: 20px;
  height: 2px;
  margin: 4px auto;
  background: currentColor;
  border-radius: 1px;
}

#chat {
  flex: 1;
  overflow: auto;
  padding: 36px max(28px, calc((100% - 1060px) / 2));
}

.empty-state {
  max-width: 780px;
  margin: clamp(48px, 12vh, 120px) auto;
  padding: var(--space-xl);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-accent);
  background: rgba(255, 255, 255, 0.85);
  box-shadow: var(--shadow-md);
}
.empty-state h2 {
  margin: 8px 0 12px;
  font-size: clamp(26px, 4vw, 34px);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--color-primary);
}
.empty-state > p:not(.eyebrow) {
  max-width: 620px;
  margin: 0;
  color: var(--color-muted-fg);
  line-height: 1.6;
}

.example-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 28px;
}
.example-prompt {
  min-height: 72px;
  padding: 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--color-primary);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--duration) var(--ease), background-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease), transform var(--duration) var(--ease);
}
.example-prompt:hover {
  border-color: #d4a574;
  background: #fffbeb;
  box-shadow: var(--shadow-md);
}
.example-prompt:active { transform: scale(0.98); }

.message { max-width: 950px; margin: 0 auto 28px; }
.message.user { display: flex; justify-content: flex-end; }
.bubble { max-width: 100%; line-height: 1.5; }

.user .bubble {
  max-width: 76%;
  padding: 12px 16px;
  border-radius: var(--radius) var(--radius) 4px var(--radius);
  background: var(--ink-2);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.assistant .bubble {
  padding: 20px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  border-top: 3px solid var(--color-accent);
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
}

.label {
  margin-bottom: 10px;
  color: var(--color-accent-hover);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}
.answer-copy { font-size: 16px; font-weight: 600; }
.error { color: var(--color-destructive); font-weight: 600; }

.typing {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--color-muted-fg);
  font-style: normal;
}
.typing-copy { font-size: 14px; font-weight: 500; }
.typing-dots {
  display: inline-flex;
  gap: 5px;
}
.typing-dots i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-accent);
  opacity: 0.45;
  animation: typing-pulse 1.1s ease-in-out infinite;
}
.typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.typing-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-pulse {
  0%, 100% { opacity: 0.35; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-2px); }
}

.table-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  position: sticky;
  left: 0;
  margin-top: 13px;
}
.copy-table {
  cursor: pointer;
  min-height: 44px;
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 700;
  transition: background-color var(--duration) var(--ease), border-color var(--duration) var(--ease);
}
.copy-table:hover { border-color: var(--color-success); background: #f0fdfa; }
.copy-table:focus-visible, .preset-item:focus-visible, .anchor-card:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.wide-table-hint { margin-left: auto; color: var(--color-muted-fg); font-size: 11px; }
.table-row-count { margin-right: auto; color: var(--color-muted-fg); font-size: 12px; font-weight: 700; }

.table-shell {
  max-width: 100%;
  margin-top: 8px;
  overflow: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: #fff;
}
table {
  width: 100%;
  min-width: 610px;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
  white-space: nowrap;
}
.table-shell.is-compact th, .table-shell.is-compact td { padding: 5px 8px; font-size: 12px; }
th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f1f5f9;
  color: var(--color-primary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.sort-column { appearance: none; width: 100%; padding: 0; border: 0; background: transparent; color: inherit; cursor: pointer; font: inherit; font-weight: inherit; letter-spacing: inherit; text-align: inherit; }
.sort-column::after { content: ' ↕'; color: var(--color-muted-fg); }
th[aria-sort="ascending"] .sort-column::after { content: ' ↑'; color: var(--color-primary); }
th[aria-sort="descending"] .sort-column::after { content: ' ↓'; color: var(--color-primary); }
.sort-column:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
tbody tr:nth-child(even) { background: #f8fafc; }
tbody tr:hover { background: #ecfdf5; }
.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.table-shell.is-wide .sticky-column {
  position: sticky;
  z-index: 2;
  background: #fff;
  box-shadow: 1px 0 0 var(--color-border);
}
.table-shell.is-wide th.sticky-column { z-index: 4; background: #f1f5f9; }
.table-shell.is-wide tbody tr:nth-child(even) .sticky-column { background: #f8fafc; }
.table-shell.is-wide tbody tr:hover .sticky-column { background: #ecfdf5; }
.table-shell.is-wide .sticky-column-1 { left: 0; min-width: 140px; }
.table-shell.is-wide .sticky-column-2 { left: 140px; min-width: 140px; }

.composer-area {
  padding: 12px max(28px, calc((100% - 1060px) / 2)) 22px;
  border-top: 1px solid var(--color-border);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
}
.rolebar {
  min-height: 18px;
  margin-bottom: 8px;
  color: var(--color-muted-fg);
  font-size: 11px;
  line-height: 1.4;
}
.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 10px 10px 16px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.composer:focus-within {
  border-color: #94a3b8;
  box-shadow: 0 0 0 3px rgba(3, 105, 161, 0.15);
}
textarea {
  width: 100%;
  min-height: 36px;
  max-height: 130px;
  padding: 8px 0;
  border: 0;
  resize: none;
  color: var(--color-foreground);
  outline: 0;
  background: transparent;
}
.question-mode { display: flex; flex-shrink: 0; align-items: center; gap: 2px; padding: 3px; border: 1px solid #cbd5e1; border-radius: var(--radius-sm); background: #f8fafc; }
.mode-button { border: 0; border-radius: 4px; padding: 8px 12px; min-height: 44px; color: var(--color-secondary); background: transparent; font-size: 12px; font-weight: 700; white-space: nowrap; cursor: pointer; }
.mode-button:hover { background: #e2e8f0; }
.mode-button.active { color: var(--color-on-primary); background: var(--color-primary); }
.button {
  border: 0;
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  min-height: 44px;
  font-weight: 700;
  transition: background-color var(--duration) var(--ease), transform var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.primary {
  background: var(--color-primary);
  color: var(--color-on-primary);
  box-shadow: 0 1px 0 rgba(0, 75, 35, 0.18);
}
.primary:hover { background: var(--color-secondary); }
.primary:active { transform: scale(0.98); }
.primary.is-loading { position: relative; }
.clarify-copy { font-size: 16px; font-weight: 600; color: var(--color-primary); }
.clarification-options { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.clarification-option {
  min-height: 44px;
  padding: 8px 14px;
  background: var(--color-accent-soft, var(--color-muted));
  color: var(--color-accent, var(--color-secondary));
  border: 1px solid var(--color-accent, transparent);
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.clarification-option:hover:not(:disabled) { background: var(--color-accent); color: #fff; }
.clarification-option:active:not(:disabled) { transform: scale(0.97); }
.clarification-option:disabled { opacity: 0.55; cursor: default; }
.anchor-card { display: grid; width: min(100%, 420px); text-align: left; gap: 5px; border-radius: var(--radius); }
.anchor-preview { color: var(--color-muted-fg); font-size: 11px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* —— Login —— */
.login {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background:
    radial-gradient(800px 400px at 80% 10%, rgba(161, 98, 7, 0.18), transparent 50%),
    linear-gradient(145deg, #0f172a 0%, #1e293b 55%, #0f172a 100%);
}
.login::before {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(120deg, transparent 0 44px, rgba(255, 255, 255, 0.02) 45px 46px);
  content: "";
  pointer-events: none;
}
.login-card {
  position: relative;
  width: min(430px, 100%);
  padding: 40px;
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow-lg);
}
.login-card .institution-mark { margin-bottom: 20px; }
.login-card h1 {
  margin: 6px 0 10px;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--color-primary);
}
.login-intro {
  margin: 0 0 24px;
  color: var(--color-muted-fg);
  line-height: 1.55;
}
.login-card label,
.modal-panel label {
  display: block;
  margin: 16px 0 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--color-primary);
}
.login-card input,
.modal input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--color-foreground);
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.login-card input:focus,
.modal input:focus {
  border-color: #64748b;
  box-shadow: 0 0 0 3px rgba(3, 105, 161, 0.18);
  outline: none;
}
.form-error {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--color-destructive);
  font-size: 13px;
  font-weight: 600;
}
.login-card .button { width: 100%; margin-top: 8px; }
.text-button {
  display: block;
  margin: 14px auto 0;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.text-button:hover { color: var(--color-accent-hover); }
.login-footnote {
  margin: 24px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--color-border);
  color: var(--color-muted-fg);
  font-size: 11px;
  line-height: 1.45;
}

/* —— Modal / notice —— */
.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.55);
}
.modal-panel {
  position: relative;
  width: min(470px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 30px;
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow-lg);
}
.modal-panel h2 {
  margin: 0 36px 8px 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.modal-panel p { color: var(--color-muted-fg); line-height: 1.5; }
.modal-panel .button { margin-top: 20px; }
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-primary);
  font-size: 22px;
  line-height: 1;
}
.modal-close:hover { background: var(--color-muted); }
.modal-secret {
  display: block;
  overflow: auto;
  margin: 12px 0;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: #f1f5f9;
  color: var(--color-primary);
  font-size: 13px;
  font-family: ui-monospace, "Cascadia Code", monospace;
}

.notice {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: var(--z-notice);
  max-width: 370px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border-left: 4px solid var(--color-success);
  background: #fff;
  box-shadow: var(--shadow-lg);
  color: var(--color-primary);
  font-weight: 600;
}
.notice.error { border-left-color: var(--color-destructive); }
.result-freshness { margin: -5px 0 10px; color: var(--color-muted-fg); font-size: 12px; font-variant-numeric: tabular-nums; }
.timeline-item { display: block; width: 100%; margin: 8px 0; text-align: left; white-space: normal; }

.drawer-backdrop { display: none; }

/* —— Response / viz (Soft UI Evolution) —— */
.response-summary { margin: 0 0 12px; font-size: 16px; font-weight: 600; line-height: 1.45; color: var(--color-primary); }
.response-title { margin: 0 0 5px; color: var(--color-muted-fg); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.viz-panel {
  margin: 14px 0 16px;
  padding: 14px 14px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: linear-gradient(165deg, #fff 0%, var(--viz-surface) 100%);
  box-shadow: var(--viz-shadow);
}
.viz-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.viz-type-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 6px;
  background: rgba(15, 118, 110, 0.1);
  color: var(--color-success);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.viz-hint { color: var(--color-muted-fg); font-size: 11px; line-height: 1.35; }
.response-actions { display: flex; justify-content: flex-end; gap: 8px; margin: 8px 0; }
.visualize-button {
  cursor: pointer;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-accent-hover);
  font-size: 12px;
  font-weight: 700;
  transition: background-color var(--duration) var(--ease), color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.visualize-button:hover { background: #fffbeb; box-shadow: var(--shadow-sm); }
.visualize-button[aria-pressed="true"] { background: var(--color-accent); color: #fff; }
.visualize-button[aria-pressed="true"]:hover { background: var(--color-accent-hover); }

.response-chart { position: relative; width: 100%; margin: 4px 0 8px; overflow: visible; }
.chart-canvas { position: relative; width: 100%; overflow: hidden; border-radius: var(--radius-sm); background: rgba(255, 255, 255, 0.7); }
.plotly-canvas { min-height: 340px; width: 100%; border-radius: var(--radius-sm); background: rgba(255, 255, 255, 0.7); }
.response-chart svg { display: block; width: 100%; height: auto; min-height: 190px; }
.chart-enter { animation: chart-fade-in var(--duration) var(--ease); }
@keyframes chart-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
.chart-grid { stroke: rgba(71, 85, 105, 0.18); stroke-width: 1; }
.chart-axis { stroke: rgba(15, 23, 42, 0.35); stroke-width: 1.25; }
.chart-label { fill: var(--color-muted-fg); font-size: 11px; }
.chart-label-start { text-anchor: start; }
.chart-label-end { text-anchor: end; }
.chart-label-center { text-anchor: middle; }
.chart-value { fill: var(--color-primary); font-size: 11px; text-anchor: end; font-variant-numeric: tabular-nums; font-weight: 600; }
.chart-value-center { text-anchor: middle; }
.chart-value-start { text-anchor: start; }
.chart-value-end { text-anchor: end; }
.chart-bar { fill: var(--color-success); cursor: pointer; transition: opacity var(--duration) var(--ease); }
.chart-bar:hover, .chart-bar:focus { opacity: 0.88; outline: none; }
.chart-bar:focus-visible { stroke: var(--focus); stroke-width: 2; }
.chart-bar-alt { fill: var(--color-accent); }
.chart-bar-pattern { fill: url(#chart-hatch); pointer-events: none; }
.chart-area { fill: rgba(15, 118, 110, 0.16); }
.chart-area-alt { fill: rgba(161, 98, 7, 0.14); }
.chart-line { fill: none; stroke: var(--color-success); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.chart-line-alt { stroke: var(--color-accent); }
.chart-point { fill: var(--color-success); stroke: var(--color-surface); stroke-width: 2; cursor: pointer; }
.chart-point-alt { fill: var(--color-accent); }
.chart-point:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.chart-tooltip {
  position: absolute;
  z-index: 2;
  max-width: 220px;
  padding: 7px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--color-primary);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  box-shadow: var(--viz-shadow);
  pointer-events: none;
}
.chart-kpi-card {
  display: grid;
  gap: 6px;
  padding: 22px 24px;
  border-radius: var(--radius);
  background: linear-gradient(145deg, #fff, #f8fafc);
  border: 1px solid var(--color-border);
  box-shadow: var(--viz-shadow);
}
.chart-kpi-eyebrow { color: var(--color-accent-hover); font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.chart-kpi-label { color: var(--color-muted-fg); font-size: 13px; font-weight: 600; }
.chart-kpi-value {
  color: var(--color-primary);
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  letter-spacing: -0.03em;
}
.chart-empty {
  padding: 18px;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-muted-fg);
  font-size: 13px;
  background: #fff;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 12px 0;
}
.metric-card {
  padding: 14px 15px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--duration) var(--ease);
}
.metric-card:hover { box-shadow: var(--shadow-md); }
.metric-card-action { width: 100%; text-align: left; cursor: pointer; font: inherit; }
.metric-card-action:hover { border-color: var(--color-accent); transform: translateY(-1px); }
.metric-card-action:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.metric-card-action:disabled { cursor: default; opacity: 0.72; box-shadow: none; transform: none; }
.metric-action-hint { display: inline-block; margin-top: 9px; color: var(--color-accent-hover); font-size: 11px; font-weight: 700; }
.metric-label {
  color: var(--color-muted-fg);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.metric-value {
  margin-top: 6px;
  color: var(--color-primary);
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.empty-result {
  margin-top: 10px;
  padding: 16px 18px;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  color: var(--color-muted-fg);
  background: #f8fafc;
}
.empty-result strong { display: block; margin-bottom: 6px; color: var(--color-primary); font-size: 14px; }
.empty-result p { margin: 0; font-size: 13px; line-height: 1.45; }
.result-kind { display: inline-flex; margin: 4px 0 8px; padding: 4px 8px; border: 1px solid var(--color-border); border-radius: 999px; background: #f8fafc; color: var(--color-secondary); font-size: 11px; font-weight: 700; }
.result-kind-summary_grouped { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.result-kind-filtered_prior, .result-kind-enriched { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.result-scope { margin-top: 5px; color: var(--color-muted-fg); font-size: 12px; font-weight: 600; }
.active-filter-strip, .context-suggestions, .guided-flow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.active-filter-chip { padding: 6px 10px; border-radius: 999px; background: #ecfdf5; color: #065f46; font-size: 12px; font-weight: 700; }
.clear-filters { min-height: 44px; border: 0; background: transparent; color: var(--color-accent-hover); font-weight: 700; cursor: pointer; text-decoration: underline; }
.orphan-tip { margin-top: 12px; padding: 12px 14px; border-left: 3px solid var(--color-accent); background: #f8fafc; color: var(--color-secondary); }
.modal-panel dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 14px; margin: 18px 0; }
.modal-panel dt { color: var(--color-muted-fg); font-size: 12px; font-weight: 700; }
.modal-panel dd { margin: 0; overflow-wrap: anywhere; }
.preset-item { display: block; width: 100%; min-height: 44px; margin-top: 8px; text-align: left; }
.error-access_denied, .error-access-denied { border-left-color: #b91c1c; background: #fef2f2; }
.error-unsupported { border-left-color: #b45309; background: #fffbeb; }
.guided-flow { margin: 20px 0; }
.guided-flow > span { display: grid; width: 26px; height: 26px; place-items: center; border-radius: 50%; background: var(--color-primary); color: white; font-size: 12px; font-weight: 700; }
.guided-flow .example-prompt { min-height: 44px; }

/* —— Breakpoints —— */
@media (max-width: 1024px) {
  .example-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 850px) {
  .header-actions .header-button { font-size: 11px; }
  .header-actions { gap: 6px; }
}

@media (max-width: 768px) {
  .example-grid { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 700px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: var(--z-sidebar);
    width: min(280px, 84vw);
    transform: translateX(-101%);
    transition: transform var(--duration) var(--ease);
  }
  .sidebar.is-open { transform: translateX(0); }
  .drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: var(--z-drawer);
    background: rgba(15, 23, 42, 0.48);
  }
  .drawer-backdrop[hidden] { display: none; }
  .drawer-backdrop:not([hidden]) { display: block; }
  .icon-button { display: grid; place-items: center; }
  .workspace { width: 100%; max-height: none; min-height: 100vh; }
  .app-header { align-items: flex-start; padding: 12px 16px; }
  .header-title h1 { font-size: 19px; }
  .header-actions { justify-content: flex-start; padding-left: 0; width: 100%; }
  .health { font-size: 10px; }
  .user-label { font-size: 12px; }
  #chat { padding: 24px 16px; min-height: 0; }
  .empty-state { margin: 32px 0; padding: 22px; }
  .empty-state h2 { font-size: 26px; }
  .assistant .bubble { padding: 15px; }
  .user .bubble { max-width: 90%; }
  .composer-area { position: sticky; bottom: 0; padding: 9px 16px 14px; }
  .rolebar { font-size: 10px; }
  .composer { padding-left: 12px; }
  .question-mode { order: 3; width: 100%; }
  .composer { flex-wrap: wrap; }
  .mode-button { width: 100%; min-height: 44px; }
  .composer .button { padding: 10px 14px; }
  .login-card { padding: 28px 22px; }
  .viz-panel { padding: 12px; }
  .viz-hint { width: 100%; }
  .chart-kpi-value { font-size: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  .metric-card-action:hover { transform: none; }
}

@media (max-width: 375px) {
  .metric-grid { grid-template-columns: 1fr; }
  .header-title h1 { font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .chart-enter { animation: none !important; }
  .typing-dots i { animation: none !important; opacity: 0.7; }
}
