/* ══════════════════════════════════════════════════════════════════
   Daleel AI — Gemini-inspired dark theme
   ══════════════════════════════════════════════════════════════════ */

:root {
  --bg:        #131314;
  --surface:   #1E1F20;
  --surface-2: #28292B;
  --surface-3: #303134;
  --text:      #E3E3E3;
  --text-2:    #BDC1C6;
  --muted:     #9AA0A6;
  --line:      #3C4043;
  --brand:     #00B2EC;
  --brand-dim: #1D3166;
  --accent:    #F9A01B;
  --danger:    #EF4123;
  --warn:      #F9A01B;
  --ok:        #81C995;
  --header-bg: rgba(19,19,20,.85);
  --nav-active-bg: #1D3166;
  --card-bg: var(--surface);
  --border: var(--line);
  --bg-secondary: var(--surface-2);
  --text-primary: var(--text);
  --text-secondary: var(--text-2);
  --text-muted: var(--muted);
  --hover-bg: var(--surface-3);
  --success: var(--ok);
  --warning: var(--warn);
  --text-on-brand: #ffffff;
  --brand-hover: #009bd4;
  --danger-rgb: 242, 139, 130;
  --ok-rgb: 129, 201, 149;
  --warn-rgb: 253, 214, 99;
  --radius:    16px;
  --sidebar-w: 240px;
  --nav-rail-w: 56px;
  --max-chat:  760px;
}

html[data-theme="light"] {
  --bg:        #f5f7fb;
  --surface:   #ffffff;
  --surface-2: #eef2f8;
  --surface-3: #e3eaf5;
  --text:      #17202f;
  --text-2:    #344154;
  --muted:     #5d6a7c;
  --line:      #cfd9e8;
  --brand:     #00B2EC;
  --brand-dim: #1D3166;
  --accent:    #F9A01B;
  --danger:    #EF4123;
  --warn:      #F9A01B;
  --ok:        #16a34a;
  --header-bg: rgba(245,247,251,.85);
  --nav-active-bg: #d4f0fc;
  --brand-hover: #009bd4;
  --text-on-brand: #ffffff;
  --danger-rgb: 220, 38, 38;
  --ok-rgb: 22, 163, 74;
  --warn-rgb: 217, 119, 6;
}

/* ── Reset & base ───────────────────────────────────────────────── */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: "Google Sans", "Nunito Sans", "IBM Plex Sans", sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: "Google Sans", "Nunito Sans", "Space Grotesk", sans-serif; margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }

.skip-link {
  position: absolute; left: 8px; top: -44px;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--text); padding: 8px 12px; border-radius: 8px; z-index: 200;
}
.skip-link:focus { top: 8px; }
.hidden { display: none !important; }

/* ── Toasts ─────────────────────────────────────────────────────── */
.toast-region {
  position: fixed; right: 16px; bottom: 16px;
  display: grid; gap: 8px; z-index: 50;
}
.toast {
  background: var(--surface-3); color: var(--text);
  border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 12px;
  font-size: 13px; max-width: 360px;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
  animation: toast-in .25s ease-out;
  transition: opacity .4s ease;
}
.toast-error { border-color: #e74c3c; background: rgba(231,76,60,.15); }
.toast-success { border-color: #2ecc71; background: rgba(46,204,113,.15); }
.toast-fade { opacity: 0; }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  border: 1px solid var(--line); background: var(--surface-2);
  color: var(--text); border-radius: 24px; padding: 8px 18px;
  cursor: pointer; transition: background .15s, border-color .15s;
  font-size: 14px; font-weight: 500;
}
.btn:hover { background: var(--surface-3); border-color: var(--brand); }
.btn:focus-visible, .icon-btn:focus-visible,
.nav-btn:focus-visible, .chip:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}
.btn-primary {
  background: var(--brand-dim); color: var(--text-on-brand); border-color: var(--brand-dim);
}
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.icon-btn {
  border: none; background: transparent; color: var(--muted);
  border-radius: 50%; width: 34px; height: 34px;
  cursor: pointer; display: grid; place-items: center;
  font-size: 16px; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

/* ══ App shell ══════════════════════════════════════════════════════ */
.app-shell {
  display: grid;
  grid-template-columns: var(--nav-rail-w) var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ── Nav rail (desktop) ───────────────────────────────────────── */
.nav-rail {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 0 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}
.nav-rail-brand {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 18px;
  font-weight: bold;
  font-family: 'Google Sans', sans-serif;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dim) 100%);
  box-shadow: 0 2px 10px rgba(0,178,236,.35);
  margin-bottom: 8px;
  user-select: none;
}
.nav-rail-spacer { flex: 1; }

/* icon-only rail buttons */
.nav-rail .nav-btn {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  gap: 0;
  font-size: 0;
}
.nav-rail .nav-btn .nav-icon {
  width: 18px;
  height: 18px;
}
.nav-rail .nav-btn::after {
  content: attr(title);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s;
  z-index: 12;
}
.nav-rail .nav-btn:hover::after,
.nav-rail .nav-btn:focus-visible::after {
  opacity: 1;
}

/* ── Sidebar ────────────────────────────────────────────────────── */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 12px 8px; gap: 4px;
  position: sticky; top: 0; height: 100vh; overflow: hidden;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px 14px;
}
.brand-logo { 
  height: 28px; width: auto; 
  background-color: rgba(255, 255, 255, 0.9);
  padding: 4px 10px;
  border-radius: 6px;
}
html[data-theme="light"] .brand-logo {
  background-color: transparent;
  padding: 0;
}
.brand h1 { font-size: 1.05rem; color: var(--text); font-weight: 600; }

.new-chat-btn {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 24px; padding: 10px 16px;
  cursor: pointer; width: 100%; text-align: left;
  font-size: 14px; font-weight: 500; color: var(--text);
  transition: background .15s, border-color .15s;
  margin: 4px 4px 8px;
}
.new-chat-btn:hover { background: var(--surface-3); border-color: var(--brand); }
.new-chat-btn .new-icon { font-size: 18px; color: var(--brand); }

/* ── SVG icon base ── */
.icon {
  display: inline-block;
  width: 1.15em;
  height: 1.15em;
  vertical-align: middle;
  flex-shrink: 0;
  stroke: currentColor;
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-btn {
  display: flex; align-items: center; gap: 12px;
  border: none; background: transparent; color: var(--text-2);
  border-radius: 24px; padding: 10px 14px;
  cursor: pointer; font-size: 14px; font-weight: 500;
  width: 100%; text-align: left;
  transition: background .15s, color .15s;
}
.nav-btn .nav-icon { font-size: 18px; width: 22px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.nav-btn:hover { background: var(--surface-3); color: var(--text); }
.nav-btn[aria-current="page"] {
  background: var(--nav-active-bg); color: var(--brand); font-weight: 600;
}
.nav-rail .nav-btn[aria-current="page"] {
  background: var(--nav-active-bg);
  color: var(--brand);
}

.sidebar-section-label {
  font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .07em;
  padding: 10px 16px 4px;
}

.history-panel {
  flex: 1; min-height: 0; overflow-y: auto; padding: 0 4px;
}
.history-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 10px 6px;
}

.history-list {
  margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 2px;
}
.history-item {
  display: grid; grid-template-columns: 1fr auto;
  gap: 4px; align-items: center;
  border-radius: 12px; padding: 6px 8px 6px 12px;
  transition: background .12s;
}
.history-item:hover { background: var(--surface-2); }
.history-item-title {
  border: 0; background: none; text-align: left; padding: 0;
  cursor: pointer; color: var(--text-2); min-width: 0;
}
.history-item-title strong {
  display: block; font-weight: 500; font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.history-item-title span { color: var(--muted); font-size: 11px; }
.history-item-title[aria-current="true"] strong { color: var(--brand); }

.history-item-actions {
  display: flex; gap: 2px; opacity: 0; transition: opacity .12s;
}
.history-item:hover .history-item-actions { opacity: 1; }

.bookmarks-toggle {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 12px 8px; font-size: 12px; color: var(--muted); cursor: pointer;
}

.user-chip {
  margin-top: auto; border-top: 1px solid var(--line);
  padding: 12px 10px 4px; display: flex; align-items: center; gap: 10px;
}
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg,#4285F4,#9C27B0);
  display: grid; place-items: center; font-size: 14px;
  font-weight: 700; color: #fff; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-info strong { display: block; font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info span { font-size: 11px; color: var(--muted); }

/* ── Main area ──────────────────────────────────────────────────── */
.main {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  background: var(--bg);
}
.main-header {
  border-bottom: 1px solid var(--line);
  background: var(--header-bg);
  backdrop-filter: blur(8px);
  padding: 12px 24px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 10;
}
.main-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.theme-switch {
  display: inline-flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px;
}
.theme-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.theme-btn:hover { color: var(--text); }
.theme-btn.is-active {
  background: var(--brand);
  color: #fff;
}
.main-header h2 { font-size: 1rem; font-weight: 600; color: var(--text); }
.main-content {
  padding: 24px;
  min-width: 0; min-height: 0; overflow: auto;
}

/* ── Auth ───────────────────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh; display: grid; place-items: center;
  padding: 16px; background: var(--bg);
}
.auth-card {
  width: min(480px, 100%);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 24px; padding: 32px 28px;
  box-shadow: 0 8px 40px rgba(0,0,0,.4);
}
.auth-logo {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin-bottom: 24px;
}
.auth-brand-img {
  height: 56px;
  width: auto;
  background-color: rgba(255, 255, 255, 0.9);
  padding: 8px 24px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
}
html[data-theme="light"] .auth-brand-img {
  background-color: transparent;
  box-shadow: none;
  padding: 0;
}
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap;
}
.auth-logo h1 { font-size: 1.4rem; font-weight: 700; }
.auth-card > p, .auth-tagline { color: var(--muted); font-size: 14px; margin: 0 0 20px; text-align: center; }
.auth-tabs { display: flex; gap: 6px; margin: 0 0 20px; }
.auth-tabs .btn { flex: 1; text-align: center; padding: 8px 6px; font-size: 13px; }
.auth-submit-btn { width: 100%; padding: 12px 0; }

/* ── Auth error alerts ─────────────────────────────────────────── */
.auth-status { margin-top: 4px; }
.auth-error-alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: 12px;
  background: rgba(242,139,130,.08);
  border: 1px solid rgba(242,139,130,.3);
  animation: authAlertIn .25s ease-out;
}
.auth-error-icon { flex-shrink: 0; color: var(--danger); margin-top: 1px; }
.auth-error-body { flex: 1; min-width: 0; }
.auth-error-msg { font-size: 13px; font-weight: 600; color: var(--danger); line-height: 1.4; }
.auth-error-suggestion { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.auth-error-suggestion .auth-link { color: var(--brand); }

/* ── Auth success alert ────────────────────────────────────────── */
.auth-success-alert {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: 12px;
  background: rgba(129,201,149,.08);
  border: 1px solid rgba(129,201,149,.3);
  font-size: 13px; font-weight: 600; color: var(--ok);
  animation: authAlertIn .25s ease-out;
}
.auth-success-icon {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--ok); color: #fff; flex-shrink: 0;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
}

/* ── Auth info text ────────────────────────────────────────────── */
.auth-info-text { font-size: 13px; color: var(--muted); text-align: center; padding: 6px 0; }

/* ── Auth footer (links to other modes) ────────────────────────── */
.auth-footer {
  display: flex; align-items: center; justify-content: center;
  gap: 6px; padding-top: 6px; font-size: 12px; color: var(--muted);
  flex-wrap: wrap;
}
.auth-footer-sep { color: var(--line); }
.auth-footer-text { display: inline; }
.auth-link {
  background: none; border: none; padding: 0; margin: 0;
  font-size: inherit; font-family: inherit; cursor: pointer;
  color: var(--brand); font-weight: 600;
  text-decoration: none; transition: color .15s;
}
.auth-link:hover { color: var(--accent); text-decoration: underline; }

/* ── Password field with toggle ────────────────────────────────── */
.pwd-wrap { position: relative; display: flex; align-items: center; }
.pwd-wrap .pwd-input { padding-right: 42px; }
.pwd-toggle {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  color: var(--muted); padding: 4px; border-radius: 6px;
  transition: color .15s, background .15s;
  display: grid; place-items: center;
}
.pwd-toggle:hover { color: var(--text); background: var(--surface-3); }
.pwd-toggle-active { color: var(--brand); }
.pwd-eye-icon { display: block; }

/* ── Password strength meter ───────────────────────────────────── */
.pwd-strength { min-height: 20px; }
.pwd-meter {
  height: 4px; border-radius: 4px; background: var(--surface-3);
  overflow: hidden; margin-bottom: 4px;
}
.pwd-meter-fill {
  height: 100%; border-radius: 4px;
  transition: width .3s ease, background .3s ease;
}
.pwd-meter-label { font-size: 11px; font-weight: 600; }

@keyframes authAlertIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Password-reset multi-step ──────────────────────────────────── */
.rst-steps {
  display: flex; align-items: center; margin: 0 0 20px;
}
.rst-dot {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid var(--line); background: var(--surface-2);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: var(--muted);
  transition: background .2s, border-color .2s, color .2s;
}
.rst-dot.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.rst-dot.done   { background: #22c55e; border-color: #22c55e; color: #fff; }
.rst-line { flex: 1; height: 2px; background: var(--line); transition: background .3s; }
.rst-line.done { background: #22c55e; }
.rst-desc {
  font-size: 13px; color: var(--muted); text-align: center;
  margin: 0 0 18px; line-height: 1.55;
}
.rst-desc strong { color: var(--text); }
.rst-code-input {
  font-size: 1.6rem; letter-spacing: 0.35em; text-align: center;
  font-weight: 700; padding: 10px 14px;
}
.rst-back-btn { width: 100%; margin-top: 8px; }
.rst-success {
  display: flex; flex-direction: column; align-items: center;
  gap: 12px; padding: 8px 0 4px;
}
.rst-success-icon {
  width: 56px; height: 56px; border-radius: 50%;
  background: #22c55e; color: #fff;
  display: grid; place-items: center;
  font-size: 22px; font-weight: 700;
}
.rst-success h3 { font-size: 1.05rem; font-weight: 700; margin: 0; }
.field-grid { display: grid; gap: 12px; }
.field-grid label { font-size: 13px; color: var(--text-2); }
.input, .textarea, .select {
  width: 100%; border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 14px;
  background: var(--surface-2); color: var(--text);
  transition: border-color .15s;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--brand);
}
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.select option { background: var(--surface-2); }

/* ══ Chat layout ════════════════════════════════════════════════════ */
.chat-layout {
  display: flex; flex-direction: column;
  height: calc(100vh - 57px); /* header */
  min-height: 520px;
}

/* messages scroll area */
.messages {
  flex: 1; overflow-y: auto;
  padding: 24px 16px 8px;
  display: flex; flex-direction: column; gap: 0;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
.messages::-webkit-scrollbar { width: 5px; }
.messages::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

/* ── Welcome screen ─────────────────────────────────────────────── */
.gemini-welcome {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; flex: 1; gap: 16px;
  padding: 40px 16px; text-align: center;
  max-width: var(--max-chat); margin: 0 auto; width: 100%;
}
.gemini-welcome-icon {
  width: 72px; height: 72px;
  background: linear-gradient(135deg,#4285F4 0%,#9C27B0 50%,#EA4335 100%);
  border-radius: 50%; display: grid; place-items: center;
  font-size: 36px; box-shadow: 0 4px 24px rgba(66,133,244,.3);
  animation: pulse 3s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 4px 24px rgba(66,133,244,.3); }
  50%       { box-shadow: 0 4px 36px rgba(156,39,176,.5); }
}
.gemini-welcome h2 {
  font-size: 1.8rem; font-weight: 700;
  background: linear-gradient(135deg,#8AB4F8,#C58AF9);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.gemini-welcome p { color: var(--muted); font-size: 15px; margin: 0; }
.suggestion-chips {
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 8px;
}
.suggestion-chip {
  border: 1px solid var(--line); background: var(--surface);
  color: var(--text-2); border-radius: 24px; padding: 10px 20px;
  cursor: pointer; font-size: 13px;
  transition: background .15s, border-color .15s, color .15s;
}
.suggestion-chip:hover {
  background: var(--surface-2); border-color: var(--brand); color: var(--text);
}

/* ── Individual messages ────────────────────────────────────────── */
.message-wrapper {
  display: flex; width: 100%; max-width: var(--max-chat);
  margin: 0 auto; padding: 12px 0;
}
.message-wrapper.user  { justify-content: flex-end; }
.message-wrapper.assistant { justify-content: flex-start; gap: 12px; align-items: flex-start; }

.assistant-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg,#4285F4,#9C27B0);
  display: grid; place-items: center; font-size: 16px;
  flex-shrink: 0; margin-top: 2px;
}
.assistant-avatar--thinking {
  position: relative;
}
.assistant-avatar--thinking::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--brand);
  border-right-color: var(--brand-dim);
  animation: thinking-spin .9s linear infinite;
}

@keyframes thinking-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.message {
  max-width: min(600px, 80%);
}
.message.user .msg-bubble {
  background: var(--surface-3); border-radius: 20px 20px 4px 20px;
  padding: 12px 18px; color: var(--text); font-size: 14px; line-height: 1.6;
  word-break: break-word;
}
.message.assistant .msg-bubble {
  background: transparent; padding: 4px 0;
  font-size: 14px; line-height: 1.7; color: var(--text);
}

.msg-top {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  margin-bottom: 6px;
}
.msg-time { font-size: 11px; color: var(--muted); }
.msg-text { white-space: pre-wrap; }
.msg-sources { margin-top: 8px; font-size: 12px; color: var(--muted); }
.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 20px;
  padding: 2px 0;
}
.typing-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand);
  opacity: .35;
  animation: typing-bounce 1s ease-in-out infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: .15s; }
.typing-indicator span:nth-child(3) { animation-delay: .3s; }
@keyframes typing-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .35; }
  40% { transform: translateY(-4px); opacity: 1; }
}

/* ── Streaming text ────────────────────────────────────────────── */
.streaming-text {
  white-space: pre-wrap; word-break: break-word;
  line-height: 1.6; font-size: 14px; min-height: 0;
}
.streaming-text:not(:empty) {
  min-height: 1.6em;
}
.streaming-text:not(:empty)::after {
  content: "▋"; display: inline;
  animation: stream-cursor .6s steps(2) infinite;
  color: var(--brand); font-weight: 700;
}
@keyframes stream-cursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}
.stream-status {
  transition: opacity .2s;
}
.msg-source-link,
.source-link {
  color: var(--brand);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.msg-source-link:hover,
.source-link:hover {
  color: var(--brand-dim);
}

/* ── Confidence badge ───────────────────────────────────────────── */
.confidence-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; padding: 2px 10px;
  border-radius: 999px; letter-spacing: .02em;
}
.confidence-high   { background: rgba(129,201,149,.15); color: #81C995; border: 1px solid rgba(129,201,149,.3); }
.confidence-medium { background: rgba(253,214,99,.12); color: #FDD663; border: 1px solid rgba(253,214,99,.3); }
.confidence-low    { background: rgba(242,139,130,.12); color: #F28B82; border: 1px solid rgba(242,139,130,.3); }

/* ── Strategy badge ─────────────────────────────────────────────── */
.strategy-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; padding: 2px 10px;
  border-radius: 999px; letter-spacing: .02em;
  border: 1px solid; white-space: nowrap;
}
.strategy-vision  { background: rgba(168,85,247,.12);  color: #c084fc; border-color: rgba(168,85,247,.35); }
.strategy-kb      { background: rgba(59,130,246,.10);  color: #93c5fd; border-color: rgba(59,130,246,.30); }
.strategy-hybrid  { background: rgba(20,184,166,.10);  color: #5eead4; border-color: rgba(20,184,166,.30); }
.strategy-web     { background: rgba(245,158,11,.10);  color: #fcd34d; border-color: rgba(245,158,11,.30); }
.strategy-file    { background: rgba(34,197,94,.10);   color: #86efac; border-color: rgba(34,197,94,.30); }
.strategy-llm     { background: rgba(156,163,175,.10); color: #d1d5db; border-color: rgba(156,163,175,.30); }

/* ── Verification flags ─────────────────────────────────────────── */
.verify-row {
  margin-top: 8px; display: flex; flex-wrap: wrap; gap: 4px; align-items: flex-start;
}
.verify-flag {
  display: inline-block; font-size: 11px; padding: 2px 8px;
  border-radius: 6px;
  background: rgba(253,214,99,.1); color: #FDD663;
  border: 1px solid rgba(253,214,99,.25);
}
.verify-note { width: 100%; font-size: 11px; color: var(--muted); margin-top: 3px; }

/* ── Citations ──────────────────────────────────────────────────── */
.citations-details { margin-top: 10px; font-size: 12px; }
.citations-details summary {
  cursor: pointer; color: var(--brand); font-weight: 600;
  user-select: none; list-style: none;
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 0;
}
.citations-details summary::-webkit-details-marker { display: none; }
.citations-details summary::before {
  content: "▶"; display: inline-block; transition: transform .15s; font-size: 9px;
}
.citations-details[open] summary::before { transform: rotate(90deg); }
.citations-list { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.citation-card {
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px;
  background: var(--surface);
}
.citation-source-wrap {
  display: block;
  margin-bottom: 4px;
  word-break: break-all;
}
.citation-source {
  font-weight: 600; font-size: 12px; display: block;
  color: var(--text-2);
}
.citation-page { font-size: 11px; color: var(--muted); font-weight: 400; }
.citation-snippet {
  margin: 6px 0 0; padding-left: 10px;
  border-left: 3px solid var(--brand);
  color: var(--muted); font-style: italic;
  white-space: pre-wrap; font-size: 11px; line-height: 1.5;
}

/* ── Feedback ───────────────────────────────────────────────────── */
.feedback-row {
  margin-top: 10px; display: flex; gap: 4px; align-items: center; flex-wrap: wrap;
}
.chip {
  border: 1px solid var(--line); background: transparent;
  color: var(--muted); border-radius: 999px; padding: 4px 12px;
  font-size: 12px; cursor: pointer; transition: background .12s, color .12s;
}
.chip:hover { background: var(--surface-2); color: var(--text); }
.chip[aria-pressed="true"] {
  background: rgba(138,180,248,.15); border-color: var(--brand); color: var(--brand);
}

/* ── Chat input bar ─────────────────────────────────────────────── */
.chat-input-wrap {
  padding: 12px 16px 20px; background: var(--bg);
}
.chat-options {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  max-width: var(--max-chat); margin: 0 auto 8px;
}
.chat-options .select {
  width: auto; border-radius: 16px; padding: 5px 12px;
  font-size: 12px; background: var(--surface-2); border-color: var(--line);
}
.chat-options label {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--muted); cursor: pointer;
}

/* ── Mode / Style info tooltips ──────────────────────────────────────────── */
.mode-info {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid var(--muted);
  color: var(--muted);
  font-size: 9px;
  font-style: normal;
  line-height: 1;
  cursor: help;
  vertical-align: middle;
  opacity: 0.65;
  transition: opacity 0.15s, color 0.15s, border-color 0.15s;
  /* The ⓘ character is slightly tall — nudge it */
  padding-bottom: 1px;
}
.mode-info:hover,
.mode-info:focus {
  opacity: 1;
  color: var(--brand);
  border-color: var(--brand);
  outline: none;
}
.mode-info-tip {
  display: none;
  position: absolute;
  bottom: calc(100% + 9px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 250px;
  max-width: 310px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 13px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  z-index: 500;
  pointer-events: none;
  /* caret */
}
.mode-info-tip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--border);
}
.mode-info:hover .mode-info-tip,
.mode-info:focus .mode-info-tip {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.mode-tip-row {
  font-size: 0.73rem;
  color: var(--text-secondary, var(--muted));
  line-height: 1.45;
  white-space: normal;
}
.mode-tip-row strong {
  color: var(--text);
  font-weight: 600;
}
/* ── end mode tooltips ───────────────────────────────────────────────────── */
.chat-form {
  max-width: var(--max-chat); margin: 0 auto;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 28px; padding: 4px 6px 4px 18px;
  display: flex; align-items: flex-end; gap: 8px;
  transition: border-color .15s;
  box-shadow: 0 2px 12px rgba(0,0,0,.25);
}
.chat-form:focus-within { border-color: var(--brand); }
.chat-form textarea {
  flex: 1; background: transparent; border: none; outline: none;
  resize: none; color: var(--text); font-size: 14px; line-height: 1.5;
  padding: 10px 0; max-height: 200px; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
.chat-form textarea::placeholder { color: var(--muted); }
.send-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--brand-dim); border: none; cursor: pointer;
  display: grid; place-items: center; flex-shrink: 0;
  font-size: 18px; color: var(--text-on-brand); margin-bottom: 2px;
  transition: background .15s, transform .1s;
}
.send-btn:hover { background: var(--brand-hover); }
.send-btn:active { transform: scale(.93); }
.send-btn:disabled { background: var(--surface-3); cursor: not-allowed; color: var(--muted); }

/* ── Image attachment bar ───────────────────────────────────────── */
.img-attach-btn {
  position: relative; flex-shrink: 0;
  color: var(--muted); transition: color .15s;
}
.img-attach-btn:hover,
.img-attach-btn[data-has-images] { color: var(--brand); }
.img-attach-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 16px; height: 16px; border-radius: 8px;
  background: var(--brand); color: var(--text-on-brand);
  font-size: 10px; font-weight: 700; line-height: 16px;
  text-align: center; padding: 0 3px; pointer-events: none;
}
.img-preview-strip {
  max-width: var(--max-chat); margin: 0 auto 8px;
  display: flex; flex-wrap: wrap; gap: 8px;
}
.img-preview-pill {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 4px 8px 4px 4px;
  max-width: 200px;
}
.img-preview-thumb {
  width: 36px; height: 36px; object-fit: cover;
  border-radius: 8px; flex-shrink: 0;
}
.img-preview-name {
  font-size: 12px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1;
}
.img-preview-remove {
  background: none; border: none; cursor: pointer; color: var(--muted);
  font-size: 16px; line-height: 1; padding: 0 2px;
  flex-shrink: 0; transition: color .15s;
}
.img-preview-remove:hover { color: var(--danger); }

/* ── User message image thumbnails ─────────────────────────────── */
.msg-img-row {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px;
  justify-content: flex-end;
}
.msg-img-thumb {
  max-width: 200px; max-height: 160px; border-radius: 10px;
  object-fit: cover; border: 1px solid var(--line);
}

/* ── Feedback button active states ──────────────────────────────── */
.fb-vote--active {
  font-weight: 700;
}
.fb-vote--up.fb-vote--active {
  background: rgba(var(--ok-rgb), .18);
  border-color: var(--success); color: var(--success);
}
.fb-vote--down.fb-vote--active {
  background: rgba(var(--danger-rgb), .18);
  border-color: var(--danger); color: var(--danger);
}
.chip--active {
  background: rgba(138,180,248,.22);
  border-color: var(--brand); color: var(--brand);
  font-weight: 700;
}

/* ── Cards / utility (ingest, admin, profile) ───────────────────── */
.muted { color: var(--muted); font-size: 13px; }
.card {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); padding: 16px;
}
.card h3 { font-size: .95rem; margin-bottom: 12px; }

/* ── Health view ────────────────────────────────────────────────── */
.health-view { display: flex; flex-direction: column; gap: 20px; }

.health-topbar {
  display: flex; align-items: center;
  justify-content: space-between; flex-wrap: wrap; gap: 12px;
}
.health-status-bar { display: flex; gap: 20px; flex-wrap: wrap; }
.health-status-item {
  display: flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 500; color: var(--text-2);
}
.health-actions { display: flex; align-items: center; gap: 12px; }

/* Status dots */
.status-dot {
  display: inline-block; width: 10px; height: 10px;
  border-radius: 50%; flex-shrink: 0;
}
.status-dot.ok    { background: var(--ok);     box-shadow: 0 0 6px var(--ok); }
.status-dot.error { background: var(--danger);  box-shadow: 0 0 6px var(--danger); }
.status-dot.warn  { background: var(--warn);    box-shadow: 0 0 6px var(--warn); }
.status-dot.pulse {
  background: var(--muted);
  animation: dot-pulse 1s ease-in-out infinite;
}
@keyframes dot-pulse {
  0%, 100% { opacity: 1; } 50% { opacity: .35; }
}

.health-error-banner {
  padding: 10px 14px; border-radius: var(--radius);
  background: color-mix(in srgb, var(--danger) 15%, transparent);
  border: 1px solid var(--danger); color: var(--danger); font-size: 13px;
}
.health-db-banner {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: var(--radius);
  background: var(--surface-2); font-size: 12px; color: var(--text-2);
}
.health-db-banner.tone-danger { color: var(--danger); }

/* Metrics grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.metric-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 14px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.metric-card.tone-ok     { border-color: color-mix(in srgb, var(--ok)     40%, var(--line)); }
.metric-card.tone-warn   { border-color: color-mix(in srgb, var(--warn)   40%, var(--line)); }
.metric-card.tone-danger { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.metric-value {
  font-size: 1.7rem; font-weight: 700; line-height: 1;
  color: var(--text); letter-spacing: -.03em;
}
.metric-card.tone-ok     .metric-value { color: var(--ok); }
.metric-card.tone-warn   .metric-value { color: var(--warn); }
.metric-card.tone-danger .metric-value { color: var(--danger); }
.metric-unit { font-size: .9rem; font-weight: 400; color: var(--muted); margin-left: 2px; }
.metric-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

/* Detail grid */
.health-detail-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px;
}
.health-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.health-table td { padding: 7px 6px; border-bottom: 1px solid var(--line); }
.health-table tr:last-child td { border-bottom: none; }
.health-table td.hl { color: var(--muted); width: 45%; }

/* Alert table row accents */
.sev-critical td { background: color-mix(in srgb, var(--danger) 6%, transparent); }
.sev-warn     td { background: color-mix(in srgb, var(--warn)   6%, transparent); }

/* Severity badges */
.sev-critical-badge { color: var(--danger); font-weight: 600; font-size: 11px; text-transform: uppercase; }
.sev-warn-badge     { color: var(--warn);   font-weight: 600; font-size: 11px; text-transform: uppercase; }
.sev-info-badge     { color: var(--muted);  font-weight: 600; font-size: 11px; text-transform: uppercase; }
.badge-ok    { background: color-mix(in srgb, var(--ok)     20%, transparent); color: var(--ok);     border-radius: 4px; padding: 2px 7px; font-size: 11px; font-weight: 600; }
.badge-error { background: color-mix(in srgb, var(--danger) 20%, transparent); color: var(--danger); border-radius: 4px; padding: 2px 7px; font-size: 11px; font-weight: 600; }

.health-alerts-card { overflow: hidden; }
.btn-sm { padding: 3px 10px; font-size: 12px; }
.grid-2 {
  display: grid; grid-template-columns: repeat(2, minmax(240px, 1fr)); gap: 16px;
}
.ingest-grid {
  display: grid; grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 16px; align-content: start;
}
.ingest-history-card { grid-column: 1 / -1; }
.table-wrap { overflow: auto; }
/* ── Admin Panel (card-based) ───────────────────────────────────── */
.admin-panel { max-width: 960px; margin: 0 auto; }
.admin-panel-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; flex-wrap: wrap; margin-bottom: 20px;
}
.admin-panel-title { font-size: 20px; font-weight: 700; margin: 0; }

.admin-stats-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px; margin-bottom: 20px;
}
.admin-stat {
  background: var(--surface-2); border-radius: 12px; padding: 14px 16px;
  text-align: center; border: 1px solid var(--line);
}
.admin-stat-value { display: block; font-size: 24px; font-weight: 700; color: var(--text-1); }
.admin-stat-label { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-top: 4px; }
.admin-stat--green { color: #34d399; }
.admin-stat--purple { color: #a78bfa; }
.admin-stat--blue { color: #60a5fa; }

.admin-search-bar {
  position: relative; margin-bottom: 20px;
}
.admin-search-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  font-size: 14px; pointer-events: none;
}
.admin-search-input {
  width: 100%; padding: 10px 14px 10px 40px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2);
  color: var(--text-1); font-size: 14px; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.admin-search-input:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(124,58,237,.15);
}

.admin-card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.admin-user-card {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 14px; padding: 18px; display: flex; flex-direction: column;
  gap: 14px; transition: transform .15s, box-shadow .2s, border-color .2s;
}
.admin-user-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,.15);
  border-color: var(--brand-dim);
}
.admin-user-card--inactive { opacity: .6; }

.admin-card-header {
  display: flex; align-items: center; gap: 10px;
}
.admin-card-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-dim));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; flex-shrink: 0;
}
.admin-card-identity { flex: 1; min-width: 0; }
.admin-card-username {
  display: block; font-size: 14px; font-weight: 600; color: var(--text-1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.admin-card-email {
  display: block; font-size: 11px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.admin-status-badge {
  padding: 3px 10px; border-radius: 20px; font-size: 11px;
  font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  flex-shrink: 0;
}
.admin-status--active { background: rgba(52,211,153,.15); color: #34d399; }
.admin-status--inactive { background: rgba(248,113,113,.12); color: #f87171; }

.admin-card-body { display: flex; flex-direction: column; gap: 6px; }
.admin-card-section-label {
  font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em;
}

.admin-role-group {
  display: flex; flex-direction: column; gap: 6px;
}
.admin-role-option {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-radius: 10px; border: 1px solid var(--line); cursor: pointer;
  transition: background .15s, border-color .15s;
  user-select: none;
}
.admin-role-option:hover { background: var(--surface-3); }
.admin-role-option--selected {
  background: rgba(124,58,237,.1); border-color: var(--brand);
}
.admin-role-option input[type="radio"] {
  accent-color: var(--brand); margin: 0;
}
.admin-role-icon { font-size: 16px; }
.admin-role-text { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.admin-role-label { font-size: 13px; font-weight: 500; color: var(--text-1); }
.admin-role-desc { font-size: 11px; color: var(--muted); font-weight: 400; }

.admin-card-footer {
  display: flex; gap: 8px; margin-top: auto; padding-top: 4px;
}
.admin-card-btn {
  flex: 1; padding: 8px 12px; border-radius: 8px; font-size: 12px;
  font-weight: 600; text-align: center; cursor: pointer;
  transition: background .15s, transform .1s;
}
.admin-card-btn:active { transform: scale(.97); }
.admin-card-btn--save {
  background: var(--brand); color: #fff; border: none;
}
.admin-card-btn--save:hover { background: var(--brand-dim); }
.admin-card-btn--toggle {
  background: transparent; border: 1px solid var(--line); color: var(--text-2);
}
.admin-card-btn--toggle:hover { background: var(--surface-3); }
table { width: 100%; border-collapse: collapse; min-width: 700px; }
th {
  border-bottom: 1px solid var(--line); text-align: left;
  padding: 10px 8px; font-size: 12px; color: var(--muted);
  font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
}
td {
  border-bottom: 1px solid var(--line); text-align: left;
  padding: 10px 8px; font-size: 13px;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); }

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .app-shell { grid-template-columns: 1fr; }
  .nav-rail {
    height: auto; position: static; flex-direction: row;
    border-right: none; border-bottom: 1px solid var(--line);
    padding: 6px 10px; gap: 4px; width: 100%; overflow-x: auto;
  }
  .nav-rail-brand { margin-bottom: 0; width: 30px; height: 30px; font-size: 13px; }
  .nav-rail-spacer { display: none; }
  .nav-rail .nav-btn { width: 36px; height: 36px; }
  .nav-rail .nav-btn::after { display: none; }
  .sidebar {
    height: auto; position: static; flex-direction: row;
    flex-wrap: wrap; border-right: none;
    border-bottom: 1px solid var(--line); padding: 8px 12px;
    gap: 8px;
  }
  .brand { padding: 4px 0; }
  .sidebar-section-label, .history-panel, .bookmarks-toggle { display: none; }
  .user-chip { margin-top: 0; border-top: none; padding: 0; }
  .new-chat-btn { width: auto; margin: 0; }
  .chat-layout { height: calc(100vh - 140px); }
}
@media (max-width: 680px) {
  .main-content { padding: 12px; }
  .grid-2 { grid-template-columns: 1fr; }
  .ingest-grid { grid-template-columns: 1fr; }
  .message { max-width: 100%; }
  .chat-input-wrap { padding: 8px 8px 16px; }
  .health-detail-grid { grid-template-columns: 1fr; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .fb-summary-grid { grid-template-columns: repeat(2, 1fr); }
  .fb-review-stats { flex-wrap: wrap; }
}

/* ── Feedback & Quality view ──────────────────────────────────────────────── */
.fb-view { display: flex; flex-direction: column; gap: 20px; }

.fb-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.fb-topbar h2 { margin: 0; font-size: 1.1rem; color: var(--text-primary); }
.fb-topbar .fb-last-updated { font-size: 0.78rem; color: var(--text-muted); margin-left: auto; }
.fb-topbar .btn-group { display: flex; gap: 8px; }

.fb-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
  flex-wrap: wrap;
}
.fb-tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px 14px;
  font-size: 0.88rem;
  font-weight: 500;
  border-radius: 4px 4px 0 0;
  transition: color .15s, border-color .15s;
}
.fb-tab-btn:hover { color: var(--text-primary); }
.fb-tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.fb-tab-content { animation: fadeIn .2s ease; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes spin   { to { transform: rotate(360deg); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* Summary grid */
.fb-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.fb-tile {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.fb-tile-val { font-size: 1.65rem; font-weight: 700; line-height: 1; }
.fb-tile-sub { font-size: 0.78rem; color: var(--text-muted); }
.fb-tile-lbl { font-size: 0.82rem; color: var(--text-secondary); margin-top: 2px; }
.fb-tile.tone-ok .fb-tile-val  { color: var(--success); }
.fb-tile.tone-warn .fb-tile-val { color: var(--warning); }
.fb-tile.tone-danger .fb-tile-val { color: var(--danger); }

/* Badges */
.fb-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  letter-spacing: .02em;
}
.fb-badge-up      { background: rgba(var(--ok-rgb), .18); color: var(--success); }
.fb-badge-down    { background: rgba(var(--danger-rgb), .18); color: var(--danger); }
.fb-badge-neutral { background: var(--surface-3); color: var(--text-muted); }
.fb-badge-pending   { background: rgba(var(--warn-rgb), .18); color: var(--warning); }
.fb-badge-reviewed  { background: rgba(var(--ok-rgb), .18); color: var(--success); }
.fb-badge-escalated { background: rgba(var(--danger-rgb), .18); color: var(--danger); }
.fb-badge-archived  { background: var(--surface-3); color: var(--text-muted); }

/* Confidence bar */
.conf-bar-wrap { display: flex; align-items: center; gap: 8px; }
.conf-bar-wrap span { font-size: 0.78rem; color: var(--text-muted); min-width: 32px; }
.conf-bar {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-secondary);
  overflow: hidden;
  min-width: 60px;
}
.conf-fill {
  height: 100%;
  border-radius: 3px;
  transition: width .3s;
}
.conf-hi { background: var(--success); }
.conf-mid { background: var(--warning); }
.conf-lo  { background: var(--danger); }

/* Review queue */
.fb-queue-controls { margin-bottom: 12px; }
.fb-filter-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.fb-filter-row select {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  padding: 6px 10px;
  font-size: 0.85rem;
}

.fb-review-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color .15s;
}
.fb-review-card:hover { border-color: var(--accent); }
.fb-review-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.fb-review-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.fb-review-body { display: flex; flex-direction: column; gap: 6px; }
.fb-q-label, .fb-a-label { font-size: 0.73rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.fb-q-text { color: var(--text-primary); font-size: 0.9rem; line-height: 1.4; }
.fb-a-text {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.fb-comment {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-style: italic;
  padding: 6px 10px;
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  border-radius: 0 4px 4px 0;
}
.fb-review-stats {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.fb-review-stats span { display: flex; align-items: center; gap: 4px; }
.fb-review-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.fb-op-note {
  font-size: 0.8rem;
  color: var(--text-secondary);
  padding: 6px 10px;
  background: var(--surface-2);
  border-radius: 4px;
}

.fb-pagination {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin-top: 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.fb-pagination button {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  padding: 5px 12px;
  cursor: pointer;
  font-size: 0.85rem;
}
.fb-pagination button:disabled { opacity: .35; cursor: default; }
.fb-pagination button.active-page { border-color: var(--accent); color: var(--accent); }

/* Trend table */
.fb-trend-wrap { overflow-x: auto; }
.delta-up { color: var(--success); font-size: 0.8rem; }
.delta-dn { color: var(--danger);  font-size: 0.8rem; }

/* Generic fb-table */
.fb-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.fb-table th {
  text-align: left;
  padding: 8px 10px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.fb-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: top;
}
.fb-table tr:hover td { background: var(--surface-2); }

/* Flag modal */
.fb-modal {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  color: var(--text-primary);
  width: min(480px, 96vw);
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
}
.fb-modal::backdrop { background: rgba(0,0,0,.6); }
.fb-modal h3 { margin: 0 0 16px; font-size: 1rem; }
.fb-modal-form { display: flex; flex-direction: column; gap: 12px; }
.fb-modal-form label { font-size: 0.82rem; color: var(--text-muted); display: flex; flex-direction: column; gap: 5px; }
.fb-modal-form select,
.fb-modal-form textarea {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  padding: 8px 10px;
  font-size: 0.88rem;
  font-family: inherit;
  resize: vertical;
}
.fb-modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* Loading / empty */
.fb-loading { display: flex; align-items: center; gap: 12px; color: var(--text-muted); padding: 32px 0; justify-content: center; }
.fb-spinner {
  width: 22px; height: 22px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.fb-empty { text-align: center; color: var(--text-secondary); padding: 40px 0; font-size: 0.92rem; }

/* Progress Bar */
.progress-container { width: 100%; margin-top: 16px; display: none; }
.progress-container.active { display: block; }
.progress-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.progress-track { width: 100%; height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; position: relative; }
.progress-fill {
  position: absolute; top: 0; left: 0; height: 100%; background: var(--brand); border-radius: 3px;
  width: 30%; animation: indeterminate 1.5s infinite ease-in-out;
}
@keyframes indeterminate {
  0% { left: -30%; width: 30%; }
  50% { width: 50%; }
  100% { left: 100%; width: 30%; }
}

/* small danger button */
.btn-danger-sm {
  background: rgba(var(--danger-rgb), .14);
  color: var(--danger);
  border: 1px solid rgba(var(--danger-rgb), .35);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.78rem;
  padding: 4px 10px;
}
.btn-danger-sm:hover { background: rgba(var(--danger-rgb), .22); }

/* ══════════════════════════════════════════════════════════════════════════════
   ENTERPRISE VIEW  (.ent-*)
   ══════════════════════════════════════════════════════════════════════════════ */
.ent-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.ent-topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.ent-tabs {
  display: flex;
  gap: 0.25rem;
  flex: 1;
  flex-wrap: wrap;
}

.ent-tab-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.82rem;
  padding: 5px 14px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.ent-tab-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.ent-tab-btn.active {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
  animation: fadeIn 0.15s ease;
}

.ent-tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
}

/* Section blocks */
.ent-section {
  max-width: 1100px;
}

.ent-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.ent-section-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

/* Forms */
.ent-form {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.ent-form h4 {
  margin: 0 0 0.25rem 0;
  font-size: 0.9rem;
  color: var(--text);
}

.ent-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.ent-form input,
.ent-form select {
  background: var(--bg-input, var(--bg));
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  padding: 6px 10px;
}

.ent-form input:focus,
.ent-form select:focus {
  border-color: var(--accent);
  outline: none;
}

.ent-form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

/* Tables */
.ent-table-wrap {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.ent-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
}

.ent-table th {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.ent-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}

.ent-table tr:last-child td { border-bottom: none; }
.ent-table tr:hover td { background: var(--bg-hover); }

.ent-empty {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
  font-style: italic;
}

.ent-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* Badges */
.ent-badge {
  display: inline-block;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 9px;
  white-space: nowrap;
}

.ent-badge-active   { background: rgba(var(--ok-rgb), .18); color: var(--success); }
.ent-badge-inactive { background: rgba(var(--danger-rgb), .18); color: var(--danger); }
.ent-badge-type     { background: var(--accent-subtle); color: var(--accent); }

/* Key display */
.ent-key-prefix {
  background: var(--bg-secondary);
  border-radius: 4px;
  font-size: 0.78rem;
  padding: 2px 6px;
  letter-spacing: 0.03em;
}

.ent-raw-key {
  display: block;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--accent);
  font-size: 0.8rem;
  margin-top: 0.5rem;
  overflow-x: auto;
  padding: 8px 12px;
  word-break: break-all;
}

.ent-key-result {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  font-size: 0.83rem;
  padding: 0.75rem 1rem;
}

/* ── One-time API Key Reveal Modal ─────────────────────────────────────── */
.key-reveal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(3px);
  padding: 16px;
}

.key-reveal-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  max-width: 540px;
  width: 100%;
  padding: 0;
  overflow: hidden;
  animation: key-reveal-in 0.18s ease;
}
@keyframes key-reveal-in {
  from { opacity: 0; transform: scale(0.95) translateY(-8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.key-reveal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 24px 14px;
  border-bottom: 1px solid var(--border);
}
.key-reveal-header-icon {
  font-size: 1.3rem;
  line-height: 1;
}
.key-reveal-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}
.key-reveal-name {
  margin: 0 0 0 auto;
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.key-reveal-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.key-reveal-warning {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(var(--warn-rgb), 0.12);
  border: 1px solid rgba(var(--warn-rgb), 0.35);
  border-radius: 8px;
  color: var(--warning);
  font-size: 0.82rem;
  line-height: 1.5;
  padding: 10px 14px;
}
.key-reveal-warning-icon {
  font-size: 1rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.key-reveal-key-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
}
.key-reveal-key-value {
  flex: 1;
  font-family: ui-monospace, "Cascadia Code", "SF Mono", monospace;
  font-size: 0.82rem;
  color: var(--brand);
  word-break: break-all;
  user-select: all;
  line-height: 1.6;
}
.key-reveal-copy-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  padding: 5px 12px;
  background: var(--brand);
  color: var(--text-on-brand);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.key-reveal-copy-btn:hover { background: var(--brand-hover); }
.key-reveal-copy-btn.copied {
  background: var(--success);
  color: var(--text-on-brand);
}

.key-reveal-confirm {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.83rem;
  color: var(--text-secondary, var(--muted));
  cursor: pointer;
  user-select: none;
}
.key-reveal-confirm input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 1px;
  accent-color: var(--brand);
  cursor: pointer;
}

.key-reveal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 14px 24px 20px;
  border-top: 1px solid var(--border);
  gap: 10px;
}
.key-reveal-done-btn {
  font-size: 0.85rem;
  padding: 7px 20px;
  background: var(--brand);
  color: var(--text-on-brand);
  border: none;
  border-radius: 7px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
.key-reveal-done-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.key-reveal-done-btn:not(:disabled):hover { background: var(--brand-hover); }
/* ── end key reveal modal ────────────────────────────────────────────────── */

.ent-revoked-note {
  color: var(--text-muted, var(--text-secondary));
  font-size: 0.78rem;
  font-style: italic;
}

/* Side panel (sync history) */
.ent-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-top: 1.5rem;
  overflow: hidden;
}

.ent-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.ent-panel-header h4 { margin: 0; font-size: 0.9rem; }

/* Responsive */
@media (max-width: 680px) {
  .ent-tab-content { padding: 0.75rem; }
  .ent-form { padding: 0.75rem; }
  .ent-table th, .ent-table td { padding: 6px 8px; }
}

/* ═══════════════════════════════════════════════════════════════════
   i18n / Voice styles
   ═══════════════════════════════════════════════════════════════════ */

/* ── Mic button ─────────────────────────────────────────────────── */
.mic-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  font-size: 1.1rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.1s;
  color: var(--text-secondary);
}
.mic-btn:hover { background: var(--hover-bg); }
.mic-btn--active {
  background: rgba(var(--danger-rgb), 0.18);
  color: var(--danger);
  animation: mic-pulse 1s ease-in-out infinite;
}
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(var(--danger-rgb), .45); }
  50%       { box-shadow: 0 0 0 6px rgba(var(--danger-rgb), 0); }
}

/* ── TTS button ─────────────────────────────────────────────────── */
.tts-btn {
  font-size: 0.95rem;
  padding: 2px 6px;
  opacity: 0.55;
  transition: opacity 0.15s;
}
.tts-btn:hover { opacity: 1; }
.tts-btn--active { opacity: 1; color: var(--brand-dim); }

/* ── Language badge ─────────────────────────────────────────────── */
.lang-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(var(--ok-rgb), .14);
  color: var(--brand);
  vertical-align: middle;
  margin-left: 4px;
}
.lang-badge-translated { background: rgba(var(--ok-rgb), .15); color: var(--success); }

.lang-note {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
  font-style: italic;
}

/* ── msg-actions row ─────────────────────────────────────────────── */
.msg-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
}

/* ── Language panel nav button ───────────────────────────────────── */
#langPanelBtn {
  margin-top: auto;
  font-size: 1.1rem;
  color: var(--text-secondary);
  width: 100%;
  text-align: center;
  padding: 8px 0;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s;
}
#langPanelBtn:hover { background: var(--hover-bg); }

/* ── Language panel modal ────────────────────────────────────────── */
.lang-panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.lang-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: min(480px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
}

.lang-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.lang-panel-header h3 { margin: 0; font-size: 1rem; font-weight: 600; }
.lang-close-btn { font-size: 1.4rem; line-height: 1; }

.lang-panel-body {
  overflow-y: auto;
  padding: 0.75rem 1.25rem;
  flex: 1;
}

.lang-section {
  margin-bottom: 1.25rem;
}
.lang-section h4 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-secondary);
  margin: 0 0 0.6rem;
}
.lang-section label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 0.6rem;
  font-size: 0.85rem;
}
.lang-section label span { color: var(--text-secondary); font-size: 0.78rem; }
.lang-toggle-row {
  flex-direction: row !important;
  align-items: center;
  justify-content: space-between;
}
.lang-toggle-row span { flex: 1; }
.lang-select {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: inherit;
  padding: 5px 8px;
  font-size: 0.83rem;
  width: 100%;
}
.lang-tts-settings { padding-top: 0.4rem; }
.lang-section-disabled { opacity: 0.45; pointer-events: none; }
.lang-unsupported { font-size: 0.72rem; color: var(--danger); font-weight: normal; margin-left: 6px; }
.lang-hint { font-size: 0.77rem; color: var(--muted); margin: 0 0 0.6rem; }
.lang-hint-inline { font-size: 0.75rem; color: var(--muted); margin-left: 4px; }

.lang-panel-footer {
  padding: 0.75rem 1.25rem;
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  border-top: 1px solid var(--border);
}
.btn-sm { font-size: 0.82rem; padding: 5px 14px; border-radius: 6px; cursor: pointer; border: none; }
.btn-primary { background: var(--accent); color: var(--text-on-brand); font-weight: 600; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: inherit; }

/* ── Profile form extras ─────────────────────────────────────────── */
.field-hint {
  font-size: 0.76rem; color: var(--brand); margin-top: 2px; min-height: 1.1em;
}
.profile-form-actions {
  display: flex; align-items: center; gap: 12px; padding-top: 4px;
}
.btn-xs {
  font-size: 0.72rem; padding: 2px 8px; border-radius: 4px;
  cursor: pointer; border: 1px solid var(--border);
  background: transparent; color: var(--brand); margin-left: 8px;
  vertical-align: middle;
}
.btn-xs:hover { background: rgba(var(--ok-rgb), .12); }

/* ── RTL support ─────────────────────────────────────────────────── */
[dir="rtl"] .chat-form { flex-direction: row-reverse; }
[dir="rtl"] .message.user { margin-left: 0; margin-right: auto; }
[dir="rtl"] .sidebar { border-right: none; border-left: 1px solid var(--border); }

/* ═══════════════════════════════════════════════════════════════════════════
   REPORTS / ANALYTICS VIEW  (.rpt-*)
   ═══════════════════════════════════════════════════════════════════════════ */

/* Layout */
.rpt-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}
.rpt-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.rpt-topbar h2 { margin: 0; font-size: 1.15rem; font-weight: 600; }
.rpt-period-picker { display: flex; align-items: center; gap: 8px; }
.rpt-period-picker label { font-size: .85rem; color: var(--muted); }

/* Tabs */
.rpt-tabs {
  display: flex;
  gap: 2px;
  padding: 6px 16px 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
}
.rpt-tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: .85rem;
  padding: 6px 14px 8px;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.rpt-tab-btn:hover { color: var(--text); }
.rpt-tab-btn--active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Content area */
.rpt-tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
}

/* Section */
.rpt-section { margin-bottom: 28px; }
.rpt-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.rpt-section-header h3 { margin: 0; font-size: .95rem; font-weight: 600; }
.rpt-export-row { display: flex; gap: 6px; }

/* KPI card grid */
.rpt-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
}
.rpt-kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 11px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.rpt-kpi-icon { font-size: 1.15rem; line-height: 1; }
.rpt-kpi-body { flex: 1; min-width: 0; }
.rpt-kpi-label { font-size: .75rem; color: var(--muted); margin-bottom: 3px; }
.rpt-kpi-value { font-size: 1.15rem; font-weight: 700; line-height: 1.1; }
.rpt-kpi-meta { font-size: .75rem; color: var(--muted); margin-top: 4px; display: flex; align-items: center; gap: 4px; }
.rpt-kpi-target { font-size: .72rem; color: var(--muted); }
.rpt-delta-up   { color: var(--success); }
.rpt-delta-down { color: var(--danger); }

/* Spark bar */
.rpt-bar-wrap { background: var(--border); border-radius: 4px; height: 6px; width: 80px; margin-top: 6px; overflow: hidden; }
.rpt-bar { height: 100%; border-radius: 4px; background: var(--muted); }
.rpt-bar-ok   { background: var(--success); }
.rpt-bar-warn { background: var(--warning); }

/* Status badges */
.rpt-badge {
  display: inline-block;
  font-size: .72rem;
  font-weight: 600;
  border-radius: 10px;
  padding: 2px 8px;
  white-space: nowrap;
}
.rpt-badge-ok    { background: rgba(var(--ok-rgb), .18); color: var(--success); }
.rpt-badge-warn  { background: rgba(var(--warn-rgb), .18);  color: var(--warning); }
.rpt-badge-bad   { background: rgba(var(--danger-rgb), .18);  color: var(--danger); }
.rpt-badge-muted { background: var(--surface); color: var(--muted); border: 1px solid var(--border); }

/* Stat row (usage spark line area) */
.rpt-stat-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.rpt-stat { display: flex; flex-direction: column; align-items: center; }
.rpt-stat-label { font-size: .72rem; color: var(--muted); margin-bottom: 2px; }
.rpt-stat-val { font-size: 1.1rem; font-weight: 700; }
.rpt-stat-warn { color: var(--warning); }
.rpt-stat-spark { font-size: .75rem; color: var(--muted); letter-spacing: .5px; }

/* Latency percentile strip */
.rpt-lat-row { display: flex; gap: 2px; margin-bottom: 16px; flex-wrap: wrap; }
.rpt-lat-cell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 9px;
  text-align: center;
  min-width: 56px;
}
.rpt-lat-label { font-size: .68rem; color: var(--muted); }
.rpt-lat-val   { font-size: .95rem; font-weight: 700; }

/* Tables */
.rpt-table-wrap { overflow-x: auto; }
.rpt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
.rpt-table th {
  text-align: left;
  padding: 6px 9px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  font-size: .78rem;
  border-bottom: 1px solid var(--border);
}
.rpt-table td {
  padding: 6px 9px;
  border-bottom: 1px solid rgba(60,64,67,.4);
}
.rpt-table tr:last-child td { border-bottom: none; }
.rpt-table tr:hover td { background: var(--surface-2); }

/* Two-column grid */
.rpt-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 760px) { .rpt-two-col { grid-template-columns: 1fr; } }

/* ROI cards */
.rpt-roi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.rpt-roi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.rpt-roi-icon { font-size: 1.05rem; }
.rpt-roi-label { font-size: .75rem; color: var(--muted); }
.rpt-roi-val   { font-size: 1rem; font-weight: 700; }
.rpt-roi-sub   { font-size: .72rem; color: var(--muted); }

/* KPI targets section */
.rpt-kpi-summary {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.rpt-kpi-targets-section { margin-top: 20px; }
.rpt-kpi-targets-list { display: flex; flex-direction: column; gap: 8px; }
.rpt-target-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 9px;
}
.rpt-target-label { flex: 1; font-size: .85rem; }
.rpt-target-input {
  width: 80px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-size: .85rem;
  padding: 3px 7px;
}
.rpt-target-input:focus { outline: 2px solid var(--accent); }

/* Custom report form */
.rpt-custom-form { margin-bottom: 16px; }
.rpt-custom-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  align-items: flex-end;
}
.rpt-custom-dates { display: flex; gap: 8px; flex-wrap: wrap; }
.rpt-custom-result { margin-top: 16px; }

/* Form controls */
.rpt-select, .rpt-select-sm, .rpt-date-input, .rpt-text-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: .82rem;
  padding: 5px 8px;
}
.rpt-select:focus, .rpt-select-sm:focus, .rpt-date-input:focus, .rpt-text-input:focus {
  outline: 2px solid var(--accent);
}
.rpt-select { min-width: 140px; height: 82px; }
.rpt-select-sm { min-width: 115px; }
.rpt-date-input { min-width: 115px; }
.rpt-text-input { min-width: 130px; }

/* Keep report controls consistent with Period field size */
.rpt-view .rpt-select-sm,
.rpt-view .rpt-date-input,
.rpt-view .rpt-text-input,
.rpt-view .rpt-target-input,
.rpt-view .btn-sm {
  height: 32px;
}

.rpt-view .rpt-select-sm,
.rpt-view .rpt-date-input,
.rpt-view .rpt-text-input,
.rpt-view .rpt-target-input {
  padding: 4px 8px;
}

.rpt-view .btn-sm {
  padding: 0 10px;
  line-height: 30px;
}

/* Schedule form */
.rpt-schedule-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-end;
}

@media (max-width: 1100px) {
  .rpt-kpi-grid { grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); }
  .rpt-roi-grid { grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); }
}

@media (max-width: 760px) {
  .rpt-topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .rpt-tab-content { padding: 10px; }
  .rpt-kpi-grid,
  .rpt-roi-grid,
  .rpt-two-col {
    grid-template-columns: 1fr;
  }
  .rpt-table { font-size: .8rem; }
}

/* State messages */
.rpt-loading, .rpt-error, .rpt-empty {
  padding: 30px 0;
  text-align: center;
  color: var(--muted);
  font-size: .9rem;
}
.rpt-error { color: var(--danger); }
.rpt-notice     { font-size: 1.05rem; font-weight: 600; margin-bottom: 6px; }
.rpt-notice-sub { font-size: .85rem; color: var(--muted); }
.rpt-muted { color: var(--muted); font-size: .85rem; }

/* ═══════════════════════════════════════════════════════════════════
   ARABIC TYPOGRAPHY  [lang="ar"]
   ═══════════════════════════════════════════════════════════════════ */
[lang="ar"] body {
  font-family: "Noto Naskh Arabic", "Cairo", "Segoe UI", Tahoma, sans-serif;
  font-size: 15px;
  line-height: 1.9;
  letter-spacing: 0;
  word-spacing: 0.05em;
}
[lang="ar"] h1,
[lang="ar"] h2,
[lang="ar"] h3 {
  font-family: "Cairo", "Noto Naskh Arabic", sans-serif;
  line-height: 1.5;
  letter-spacing: 0;
}
[lang="ar"] .btn,
[lang="ar"] .nav-btn,
[lang="ar"] input,
[lang="ar"] textarea,
[lang="ar"] select {
  font-family: "Noto Naskh Arabic", "Cairo", sans-serif;
}
/* Inputs: force RTL for Arabic text entry */
[lang="ar"] input,
[lang="ar"] textarea {
  direction: rtl;
  text-align: right;
}

/* ═══════════════════════════════════════════════════════════════════
   RTL LAYOUT  [dir="rtl"]
   ═══════════════════════════════════════════════════════════════════ */

/* ── Skip link ─── */
[dir="rtl"] .skip-link { left: auto; right: 8px; }

/* ── Toast: flip to left side ─── */
[dir="rtl"] .toast-region { right: auto; left: 16px; }

/* ── Nav rail ─── */
[dir="rtl"] .nav-rail {
  border-right: none;
  border-left: 1px solid var(--line);
}
/* Rail tooltip: show to the RIGHT of icon (which is now on the right) */
[dir="rtl"] .nav-rail .nav-btn::after {
  left: auto;
  right: calc(100% + 10px);
  transform: translateY(-50%);
}

/* ── Sidebar ─── */
[dir="rtl"] .sidebar {
  border-right: none;
  border-left: 1px solid var(--line);
}

/* ── Text alignment ─── */
[dir="rtl"] .nav-btn          { text-align: right; }
[dir="rtl"] .new-chat-btn     { text-align: right; }
[dir="rtl"] .sidebar-section-label { text-align: right; }
[dir="rtl"] .history-item-title  { text-align: right; }
[dir="rtl"] th,
[dir="rtl"] td                { text-align: right; }
[dir="rtl"] .fb-table th,
[dir="rtl"] .fb-table td      { text-align: right; }
[dir="rtl"] .ent-table th,
[dir="rtl"] .ent-table td     { text-align: right; }
[dir="rtl"] .rpt-table th,
[dir="rtl"] .rpt-table td     { text-align: right; }
[dir="rtl"] .health-table td  { text-align: right; }

/* ── Badges / lang badges ─── */
[dir="rtl"] .lang-badge      { margin-left: 0; margin-right: 4px; }
[dir="rtl"] .lang-badge-translated { margin-left: 0; margin-right: 4px; }

/* ── Profile button ─── */
[dir="rtl"] .btn-xs { margin-left: 0; margin-right: 8px; }
[dir="rtl"] .profile-form-actions { flex-direction: row-reverse; }

/* ── Citations: flip left-border to right ─── */
[dir="rtl"] .citation-snippet {
  border-left: none;
  border-right: 3px solid var(--brand);
  padding-left: 0;
  padding-right: 10px;
}

/* ── Feedback comment: flip left-border ─── */
[dir="rtl"] .fb-comment {
  border-left: none;
  border-right: 3px solid var(--accent);
  border-radius: 4px 0 0 4px;
}

/* ── Enterprise key result: flip left-border ─── */
[dir="rtl"] .ent-key-result {
  border-left: none;
  border-right: 3px solid var(--accent);
}

/* ── Tooltips: flip horizontal centering ─── */
[dir="rtl"] .mode-info-tip {
  left: auto;
  right: 50%;
  transform: translateX(50%);
}
[dir="rtl"] .mode-info-tip::after {
  left: auto;
  right: 50%;
  transform: translateX(50%);
}

/* ── Chat form ─── */
[dir="rtl"] .chat-form         { flex-direction: row-reverse; padding: 4px 18px 4px 6px; }
[dir="rtl"] .chat-form textarea { text-align: right; }
[dir="rtl"] .chat-options       { flex-direction: row-reverse; }
[dir="rtl"] .chat-options label { flex-direction: row-reverse; }

/* ── Image attach badge position ─── */
[dir="rtl"] .img-attach-badge { right: auto; left: -4px; }

/* ── Message bubbles ─── */
[dir="rtl"] .message.user .msg-bubble {
  border-radius: 20px 20px 20px 4px;   /* flip notch to left */
}
[dir="rtl"] .message-wrapper.user { justify-content: flex-start; }
[dir="rtl"] .message.user  { margin-left: 0; margin-right: auto; }
[dir="rtl"] .msg-img-row   { justify-content: flex-start; }
[dir="rtl"] .msg-sources   { text-align: right; }
[dir="rtl"] .msg-top       { flex-direction: row-reverse; }
[dir="rtl"] .msg-actions   { flex-direction: row-reverse; }
[dir="rtl"] .feedback-row  { flex-direction: row-reverse; }

/* ── Panel / modal footers ─── */
[dir="rtl"] .lang-panel-footer  { flex-direction: row-reverse; }
[dir="rtl"] .fb-modal-actions   { flex-direction: row-reverse; }
[dir="rtl"] .ent-form-actions   { flex-direction: row-reverse; }
[dir="rtl"] .key-reveal-footer  { flex-direction: row-reverse; }
[dir="rtl"] .health-actions     { flex-direction: row-reverse; }
[dir="rtl"] .fb-topbar-right    { flex-direction: row-reverse; }
[dir="rtl"] .rpt-section-header { flex-direction: row-reverse; }
[dir="rtl"] .rpt-export-row     { flex-direction: row-reverse; }

/* ── Auth card ─── */
[dir="rtl"] .auth-tabs { flex-direction: row-reverse; }

/* ── User chip ─── */
[dir="rtl"] .user-chip { flex-direction: row-reverse; }

/* ── New chat button icon ─── */
[dir="rtl"] .new-chat-btn { flex-direction: row-reverse; }

/* ── Health status bar ─── */
[dir="rtl"] .health-topbar      { flex-direction: row-reverse; }
[dir="rtl"] .health-status-bar  { flex-direction: row-reverse; }
[dir="rtl"] .health-status-item { flex-direction: row-reverse; }

/* ── Admin check grid ─── */
[dir="rtl"] .admin-search-icon { left: auto; right: 14px; }
[dir="rtl"] .admin-search-input { padding: 10px 40px 10px 14px; }
[dir="rtl"] .admin-role-option { flex-direction: row-reverse; }

/* ── Suggestion chips ─── */
[dir="rtl"] .suggestion-chips { flex-direction: row-reverse; }

/* ── Sidebar section label ─── */
[dir="rtl"] .brand { flex-direction: row-reverse; }

