/* MKM AI Assistant Standalone — Light & Dark Theme Stylesheet */
:root {
  --ai-bg: #f6f7fb;
  --ai-surface: #ffffff;
  --ai-sidebar: #f0f2f8;
  --ai-border: rgba(57, 60, 89, 0.14);
  --ai-ink: #111827;
  --ai-muted: #6b7280;

  --ai-brand: #393c59;
  --ai-brand-hover: #2d3048;
  --ai-accent: #6366f1;
  --ai-accent-ink: #4f46e5;
  --ai-accent-soft: rgba(99, 102, 241, 0.10);
  --ai-accent-border: rgba(99, 102, 241, 0.30);
  --ai-gradient: linear-gradient(135deg, #d946ef 0%, #6366f1 52%, #06b6d4 100%);

  --ai-cyan-ink: #0e7490;
  --ai-cyan-bg: rgba(6, 182, 212, 0.14);
  --ai-cyan-border: rgba(6, 182, 212, 0.35);

  --ai-user-bg: #393c59;
  --ai-user-ink: #ffffff;
  --ai-bot-bg: #ffffff;

  --ai-chip-doc-bg: #fff7ed;
  --ai-chip-doc-ink: #9a3412;

  --ai-code-bg: rgba(99, 102, 241, 0.12);
  --ai-pre-bg: rgba(17, 24, 39, 0.06);

  --ai-success-bg: #d1fae5;
  --ai-success-ink: #065f46;
  --ai-warning-bg: #fef3c7;
  --ai-warning-ink: #92400e;
  --ai-danger-bg: #fee2e2;
  --ai-danger-ink: #dc2626;
  --ai-danger-soft: rgba(220, 38, 38, 0.08);
  --ai-danger-border: rgba(220, 38, 38, 0.40);

  --ai-sports-time-bg: rgba(99, 102, 241, 0.12);
  --ai-sports-time-ink: #4f46e5;
  --ai-sports-score-bg: #0f172a;
  --ai-sports-score-ink: #ffffff;
  --ai-curr-ink: #059669;
  --ai-chart-ink: #374151;
  --ai-chart-grid: rgba(156, 163, 175, 0.22);
  --ai-chart-navy: #393c59;
  --ai-kpi-ink: #393c59;

  --ai-shadow: 0 2px 10px rgba(17, 24, 39, 0.06);
  --ai-welcome-glow: 0.34;
  --ai-welcome-glow-peak: 0.56;
  --ai-welcome-sheen: rgba(255, 255, 255, 0.55);
  --ai-welcome-ripple: rgba(99, 102, 241, 0.42);
  --ai-title-gradient: linear-gradient(95deg, #111827 0%, #4f46e5 35%, #0891b2 65%, #111827 100%);
}

[data-theme="dark"] {
  --ai-bg: #1b1d26;
  --ai-surface: #262a36;
  --ai-sidebar: #20232e;
  --ai-border: rgba(148, 163, 184, 0.22);
  --ai-ink: #f3f4f6;
  --ai-muted: #9ca3af;

  --ai-brand: #6366f1;
  --ai-brand-hover: #4f46e5;
  --ai-accent: #818cf8;
  --ai-accent-ink: #a5b4fc;
  --ai-accent-soft: rgba(129, 140, 248, 0.16);
  --ai-accent-border: rgba(129, 140, 248, 0.38);

  --ai-cyan-ink: #67e8f9;
  --ai-cyan-bg: rgba(6, 182, 212, 0.20);
  --ai-cyan-border: rgba(34, 211, 238, 0.42);

  --ai-user-bg: #4338ca;
  --ai-user-ink: #ffffff;
  --ai-bot-bg: #262a36;

  --ai-chip-doc-bg: rgba(251, 146, 60, 0.18);
  --ai-chip-doc-ink: #fdba74;

  --ai-code-bg: rgba(129, 140, 248, 0.20);
  --ai-pre-bg: rgba(15, 23, 42, 0.65);

  --ai-success-bg: rgba(16, 185, 129, 0.20);
  --ai-success-ink: #6ee7b7;
  --ai-warning-bg: rgba(245, 158, 11, 0.20);
  --ai-warning-ink: #fde68a;
  --ai-danger-bg: rgba(239, 68, 68, 0.20);
  --ai-danger-ink: #fca5a5;
  --ai-danger-soft: rgba(239, 68, 68, 0.14);
  --ai-danger-border: rgba(248, 113, 113, 0.45);

  --ai-sports-time-bg: rgba(129, 140, 248, 0.24);
  --ai-sports-time-ink: #c7d2fe;
  --ai-sports-score-bg: #10b981;
  --ai-sports-score-ink: #052e16;
  --ai-curr-ink: #34d399;
  --ai-chart-ink: #e5e7eb;
  --ai-chart-grid: rgba(148, 163, 184, 0.18);
  --ai-chart-navy: #8f94c8;
  --ai-kpi-ink: #a5b4fc;

  --ai-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  --ai-welcome-glow: 0.52;
  --ai-welcome-glow-peak: 0.78;
  --ai-welcome-sheen: rgba(255, 255, 255, 0.20);
  --ai-welcome-ripple: rgba(129, 140, 248, 0.55);
  --ai-title-gradient: linear-gradient(95deg, #f8fafc 0%, #c4b5fd 35%, #67e8f9 65%, #f8fafc 100%);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--ai-bg);
  color: var(--ai-ink);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.ic-sun { display: none; }
[data-theme="dark"] .ic-sun { display: block; }
[data-theme="dark"] .ic-moon { display: none; }

/* Login Page */
.ai-login-body {
  background: radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.14), transparent 45%),
              radial-gradient(circle at 80% 80%, rgba(6, 182, 212, 0.14), transparent 45%),
              var(--ai-bg);
}
.ai-login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
}
.ai-login-theme-btn {
  position: fixed;
  top: 18px;
  right: 18px;
}
.ai-login-card {
  width: 100%;
  max-width: 420px;
  background: var(--ai-surface);
  border: 1px solid var(--ai-border);
  border-radius: 22px;
  padding: 32px 30px 30px;
  box-shadow: 0 20px 50px rgba(17, 24, 39, 0.12);
}
.ai-login-title {
  margin: 6px 0 4px;
  text-align: center;
  font-size: 24px;
  font-weight: 800;
  background: var(--ai-title-gradient);
  background-size: 220% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.ai-login-sub {
  margin: 0 0 22px;
  text-align: center;
  color: var(--ai-muted);
  font-size: 13.5px;
}
.ai-login-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}
.ai-pwd-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.ai-pwd-wrap input {
  width: 100%;
  padding-right: 40px;
}
.ai-pwd-eye {
  position: absolute;
  right: 8px;
  border: none;
  background: transparent;
  color: var(--ai-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
}
.ai-pwd-eye:hover { color: var(--ai-ink); }

/* Form Elements & Buttons */
.ai-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ai-field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ai-ink);
}
.ai-field input[type="text"],
.ai-field input[type="password"],
.ai-field input[type="email"],
.ai-field input[type="number"],
.ai-field input[type="date"],
.ai-field input[type="file"],
.ai-field select,
.ai-field textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--ai-border);
  background: var(--ai-bg);
  color: var(--ai-ink);
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.ai-field input:focus,
.ai-field select:focus,
.ai-field textarea:focus {
  border-color: var(--ai-accent);
  box-shadow: 0 0 0 3px var(--ai-accent-soft);
}
.ai-check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ai-ink);
  cursor: pointer;
}
.ai-check-row input { width: 16px; height: 16px; accent-color: var(--ai-accent); }

.ai-btn-primary,
.ai-btn-secondary,
.ai-btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: none;
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}
.ai-btn-primary {
  background: var(--ai-brand);
  color: #ffffff;
}
.ai-btn-primary:hover { background: var(--ai-brand-hover); }
.ai-btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.ai-btn-block { width: 100%; padding: 11px 16px; }
.ai-btn-secondary {
  background: var(--ai-surface);
  color: var(--ai-ink);
  border: 1px solid var(--ai-border);
}
.ai-btn-secondary:hover { background: var(--ai-accent-soft); border-color: var(--ai-accent-border); }
.ai-btn-danger {
  background: var(--ai-danger-soft);
  color: var(--ai-danger-ink);
  border: 1px solid var(--ai-danger-border);
}
.ai-btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }

.ai-alert {
  padding: 10px 13px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 14px;
}
.ai-alert.is-danger {
  background: var(--ai-danger-bg);
  color: var(--ai-danger-ink);
  border: 1px solid var(--ai-danger-border);
}
.ai-alert.is-success {
  background: var(--ai-success-bg);
  color: var(--ai-success-ink);
}
.ai-alert.is-info {
  background: var(--ai-cyan-bg);
  color: var(--ai-cyan-ink);
  border: 1px solid var(--ai-cyan-border);
}

.ai-lang-bar {
  max-width: 860px;
  margin: 0 auto 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.ai-lang-lbl {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ai-muted);
  margin-inline-end: 2px;
}
.ai-lang-pill {
  border: 1px solid var(--ai-border);
  background: var(--ai-surface);
  color: var(--ai-muted);
  border-radius: 999px;
  padding: 3px 11px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s ease;
}
.ai-lang-pill:hover {
  border-color: var(--ai-accent);
  color: var(--ai-ink);
}
.ai-lang-pill.is-active {
  background: var(--ai-accent);
  border-color: var(--ai-accent);
  color: #ffffff;
}
.ai-toolbar-sep {
  width: 1px;
  height: 18px;
  background: var(--ai-border);
  margin: 0 4px;
}
.ai-upload-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px dashed var(--ai-accent-border);
  background: var(--ai-accent-soft);
  color: var(--ai-accent-ink);
  border-radius: 999px;
  padding: 3px 11px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.ai-upload-pill:hover { background: var(--ai-accent); color: #fff; border-style: solid; }
.ai-ds-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--ai-success-bg);
  color: var(--ai-success-ink);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
}
.ai-ds-chip button {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0 2px;
}

/* KPI Cards, Interactive Chart.js Cards & Data Report Tables (ported from Odoo module) */
.ai-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.ai-kpi-card {
  background: var(--ai-bg);
  border: 1px solid var(--ai-border);
  border-radius: 12px;
  padding: 12px 14px;
  text-align: start;
}
.ai-kpi-label { font-size: 11.5px; color: var(--ai-muted); font-weight: 600; margin-bottom: 4px; }
.ai-kpi-val { font-size: 21px; font-weight: 800; color: var(--ai-kpi-ink); }

.ai-charts-wrap, .ai-tables-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}
.ai-chart-card {
  background: var(--ai-bg);
  border: 1px solid var(--ai-border);
  border-radius: 14px;
  padding: 14px;
}
.ai-chart-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.ai-chart-title { font-weight: 700; font-size: 14px; }
.ai-chart-sub { font-size: 12px; color: var(--ai-muted); margin-top: 2px; }
.ai-chart-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ai-chart-switch {
  display: inline-flex;
  background: var(--ai-surface);
  border: 1px solid var(--ai-border);
  border-radius: 8px;
  overflow: hidden;
}
.ai-chart-switch button {
  border: none;
  background: transparent;
  color: var(--ai-muted);
  padding: 4px 8px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}
.ai-chart-switch button.is-active {
  background: var(--ai-accent);
  color: #ffffff;
}
.ai-tool-btn {
  border: 1px solid var(--ai-border);
  background: var(--ai-surface);
  color: var(--ai-ink);
  border-radius: 7px;
  padding: 4px 9px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}
.ai-tool-btn:hover { border-color: var(--ai-accent); color: var(--ai-accent-ink); }
.ai-chart-canvas-wrap { position: relative; height: 270px; width: 100%; }

.ai-data-table-card {
  background: var(--ai-bg);
  border: 1px solid var(--ai-border);
  border-radius: 14px;
  overflow: hidden;
}
.ai-data-table-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--ai-border);
  flex-wrap: wrap;
}
.ai-col-pills { display: flex; flex-wrap: wrap; gap: 5px; }
.ai-col-pill {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--ai-bg);
  border: 1px solid var(--ai-border);
  color: var(--ai-muted);
}

/* Workspace Layout */
.ai-root {
  display: flex;
  height: 100vh;
  min-height: 0;
  background: var(--ai-bg);
  color: var(--ai-ink);
  overflow: hidden;
}

/* Sidebar */
.ai-sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--ai-sidebar);
  border-inline-end: 1px solid var(--ai-border);
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease, opacity 0.2s ease;
}
.ai-sidebar.is-collapsed {
  width: 0;
  opacity: 0;
  overflow: hidden;
  border-inline-end: none;
}
.ai-sidebar-top {
  padding: 16px;
  border-bottom: 1px solid var(--ai-border);
}
.ai-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.ai-brand-logo {
  width: 38px;
  height: 38px;
  padding: 4px;
  border-radius: 10px;
  background: var(--ai-surface);
  border: 1px solid var(--ai-border);
  object-fit: contain;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.18);
}
.ai-brand-title { font-weight: 700; font-size: 15px; line-height: 1.2; }
.ai-brand-sub { font-size: 12px; color: var(--ai-muted); }

.ai-new-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--ai-brand);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: 9px 14px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.ai-new-btn:hover { background: var(--ai-brand-hover); }

.ai-session-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
}
.ai-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ai-muted);
  padding: 4px 10px 8px;
}
.ai-empty-sessions {
  font-size: 12.5px;
  color: var(--ai-muted);
  padding: 10px;
  line-height: 1.5;
}
.ai-session-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13px;
  color: var(--ai-ink);
  transition: background 0.12s ease;
}
.ai-session-item:hover { background: var(--ai-accent-soft); }
.ai-session-item.is-active {
  background: var(--ai-surface);
  font-weight: 600;
  box-shadow: var(--ai-shadow);
}
.ai-session-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ai-session-del {
  border: none;
  background: transparent;
  color: var(--ai-muted);
  opacity: 0;
  padding: 2px 5px;
  border-radius: 5px;
  cursor: pointer;
}
.ai-session-item:hover .ai-session-del { opacity: 1; }
.ai-session-del:hover { color: var(--ai-danger-ink); }

.ai-sidebar-footer {
  padding: 10px;
  border-top: 1px solid var(--ai-border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ai-footer-link {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ai-ink);
  font-size: 13px;
  font-weight: 500;
  text-align: start;
  cursor: pointer;
}
.ai-footer-link:hover,
.ai-footer-link.is-active { background: var(--ai-accent-soft); color: var(--ai-accent-ink); }
.ai-pill {
  margin-inline-start: auto;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--ai-accent-soft);
  color: var(--ai-accent-ink);
}

.ai-user-strip {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--ai-border);
  display: flex;
  align-items: center;
  gap: 6px;
}
.ai-user-btn {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  border: none;
  background: transparent;
  color: var(--ai-ink);
  padding: 6px 8px;
  border-radius: 9px;
  cursor: pointer;
  text-align: start;
}
.ai-user-btn:hover { background: var(--ai-accent-soft); }
.ai-user-initials {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--ai-gradient);
  color: #ffffff;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ai-user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.ai-user-name {
  font-size: 12.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ai-user-role {
  font-size: 11px;
  color: var(--ai-muted);
  text-transform: capitalize;
}

/* Main Workspace */
.ai-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.ai-topbar {
  height: 54px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: var(--ai-surface);
  border-bottom: 1px solid var(--ai-border);
}
.ai-topbar-left, .ai-topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ai-topbar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
}
.ai-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
}
.ai-status-dot.is-warn { background: #f59e0b; }
.ai-meta-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--ai-muted);
  background: var(--ai-bg);
  border: 1px solid var(--ai-border);
  padding: 4px 10px;
  border-radius: 999px;
}
.ai-web-badge {
  color: var(--ai-cyan-ink);
  background: var(--ai-cyan-bg);
  border-color: var(--ai-cyan-border);
}
.ai-icon-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ai-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 20px;
}
.ai-icon-btn:hover { background: var(--ai-accent-soft); color: var(--ai-ink); }

.ai-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.ai-panel-view {
  overflow-y: auto;
  padding: 24px;
}
.ai-panel-inner {
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
}
.ai-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.ai-panel-header h2 { margin: 0 0 4px; font-size: 21px; }
.ai-muted { margin: 0; color: var(--ai-muted); font-size: 13.5px; }
.ai-muted-inline { color: var(--ai-muted); font-weight: 400; font-size: 11.5px; }
.ai-panel-actions { display: flex; gap: 10px; align-items: center; }

/* Animated Welcome Stage (ported from ai_assistant.scss) */
.ai-welcome {
  max-width: 740px;
  margin: 14px auto 24px;
  text-align: center;
}
.ai-welcome-stage {
  position: relative;
  width: 146px;
  height: 146px;
  margin: 0 auto 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  isolation: isolate;
}
.ai-welcome-stage.is-compact { width: 120px; height: 120px; margin-bottom: 4px; }
.ai-welcome-stage.is-compact .ai-welcome-avatar-wrap { width: 82px; height: 82px; border-radius: 22px; }

.ai-ripple {
  position: absolute;
  width: 92px;
  height: 92px;
  border-radius: 25px;
  border: 2px solid var(--ai-welcome-ripple);
  pointer-events: none;
  z-index: -3;
  opacity: 0;
  animation: aiRipple 3.2s cubic-bezier(0.18, 0.78, 0.3, 1) infinite;
}
.ai-ripple.is-r2 { animation-delay: 1.6s; border-color: rgba(6, 182, 212, 0.48); }

.ai-orbit {
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 2;
}
.ai-orbit.is-o1 { animation: aiOrbitSpin 7.5s linear infinite; }
.ai-orbit.is-o2 { inset: 2px; animation: aiOrbitSpinRev 10.5s linear infinite; }

.ai-orbit-spark {
  position: absolute;
  border-radius: 50%;
}
.ai-orbit-spark.is-p1 {
  top: 0; left: 50%; width: 8px; height: 8px;
  background: #d946ef; box-shadow: 0 0 12px 2px rgba(217, 70, 239, 0.85);
  transform: translate(-50%, -50%);
}
.ai-orbit-spark.is-p2 {
  bottom: 0; left: 50%; width: 7px; height: 7px;
  background: #06b6d4; box-shadow: 0 0 12px 2px rgba(6, 182, 212, 0.85);
  transform: translate(-50%, 50%);
}
.ai-orbit-spark.is-p3 {
  top: 50%; right: 0; width: 6px; height: 6px;
  background: #fbb945; box-shadow: 0 0 10px 2px rgba(251, 185, 69, 0.85);
  transform: translate(50%, -50%);
}
.ai-orbit-spark.is-p4 {
  top: 50%; left: 0; width: 6px; height: 6px;
  background: #818cf8; box-shadow: 0 0 10px 2px rgba(129, 140, 248, 0.85);
  transform: translate(-50%, -50%);
}

.ai-welcome-avatar-wrap {
  position: relative;
  width: 94px;
  height: 94px;
  border-radius: 25px;
  padding: 3.5px;
  isolation: isolate;
  box-shadow: 0 12px 32px rgba(99, 102, 241, 0.34);
  animation: aiFloat 3.6s ease-in-out infinite;
}
.ai-welcome-avatar-wrap::before {
  content: "";
  position: absolute;
  inset: -12px;
  border-radius: 34px;
  background: var(--ai-gradient);
  filter: blur(22px);
  opacity: var(--ai-welcome-glow);
  z-index: -2;
  pointer-events: none;
}
.ai-welcome-ring {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  z-index: -1;
}
.ai-welcome-ring::before {
  content: "";
  position: absolute;
  inset: -50%;
  background: conic-gradient(from 0deg, #d946ef 0deg, #6366f1 95deg, #06b6d4 195deg, #fbb945 280deg, #d946ef 360deg);
  animation: aiOrbitSpin 3.6s linear infinite;
}
.ai-welcome-inner {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 10px;
  border-radius: 21px;
  background: var(--ai-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.ai-welcome-svg { width: 100%; height: 100%; display: block; }
.ai-svg-star, .ai-svg-dot { transform-box: fill-box; transform-origin: center; }
.ai-svg-star.is-star-lg { animation: aiTwinkle 2.1s ease-in-out infinite; }
.ai-svg-star.is-star-sm { animation: aiTwinkle 1.8s ease-in-out 0.6s infinite; }
.ai-svg-dot { animation: aiDotBob 2.4s ease-in-out infinite; }

@keyframes aiFloat { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes aiRipple { 0% { opacity: 0.7; transform: scale(0.95); } 100% { opacity: 0; transform: scale(1.6); } }
@keyframes aiOrbitSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes aiOrbitSpinRev { from { transform: rotate(360deg); } to { transform: rotate(0deg); } }
@keyframes aiTwinkle { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.35; transform: scale(0.65); } }
@keyframes aiDotBob { 0%,100% { transform: translateY(0); } 40% { transform: translateY(-3px); } }

.ai-welcome-title {
  font-size: 25px;
  font-weight: 800;
  background: var(--ai-title-gradient);
  background-size: 220% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 0 0 8px;
}
.ai-welcome-sub {
  font-size: 14.5px;
  color: var(--ai-muted);
  max-width: 580px;
  margin: 0 auto 24px;
  line-height: 1.6;
}
.ai-capabilities {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
  text-align: start;
}
.ai-cap-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--ai-surface);
  border: 1px solid var(--ai-border);
  box-shadow: var(--ai-shadow);
}
.ai-cap-icon { color: var(--ai-accent); flex-shrink: 0; margin-top: 2px; }
.ai-cap-title { font-weight: 700; font-size: 13.5px; margin-bottom: 3px; }
.ai-cap-desc { font-size: 12.5px; color: var(--ai-muted); line-height: 1.45; }

.ai-suggestions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px;
}
.ai-suggestion-btn {
  border: 1px solid var(--ai-border);
  background: var(--ai-surface);
  color: var(--ai-ink);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.ai-suggestion-btn:hover {
  border-color: var(--ai-accent);
  background: var(--ai-accent-soft);
  color: var(--ai-accent-ink);
}

/* Messages Thread */
.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
}
.ai-thread {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.ai-msg-row { display: flex; gap: 12px; align-items: flex-start; }
.ai-msg-row.is-user { justify-content: flex-end; }
.ai-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--ai-surface);
  border: 1px solid var(--ai-border);
  padding: 4px;
  flex-shrink: 0;
}
.ai-avatar img { width: 100%; height: 100%; object-fit: contain; }

.ai-bubble {
  max-width: 85%;
  padding: 13px 16px;
  border-radius: 16px;
  background: var(--ai-bot-bg);
  border: 1px solid var(--ai-border);
  box-shadow: var(--ai-shadow);
  font-size: 14px;
  line-height: 1.62;
}
.ai-bubble.is-wide { width: 100%; max-width: 780px; }
.ai-msg-row.is-user .ai-bubble {
  background: var(--ai-user-bg);
  color: var(--ai-user-ink);
  border-color: transparent;
  border-bottom-right-radius: 5px;
}
.ai-bubble.is-error {
  border-color: var(--ai-danger-border);
  background: var(--ai-danger-soft);
}
.ai-user-text { white-space: pre-wrap; word-break: break-word; }

/* Markdown */
.ai-md p.ai-p { margin: 0 0 9px; }
.ai-md p.ai-p:last-child { margin-bottom: 0; }
.ai-md .ai-h { margin: 10px 0 6px; font-weight: 700; }
.ai-md .ai-ul, .ai-md .ai-ol { margin: 6px 0 10px; padding-inline-start: 22px; }
.ai-md li { margin-bottom: 4px; }
.ai-md .ai-code {
  background: var(--ai-code-bg);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 0.9em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.ai-md .ai-pre {
  background: var(--ai-pre-bg);
  padding: 11px 13px;
  border-radius: 10px;
  overflow-x: auto;
  font-size: 12.5px;
}
.ai-md-link { color: var(--ai-accent-ink); text-decoration: underline; }

/* Summary Card & Steps */
.ai-summary-card {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--ai-bg);
  border: 1px solid var(--ai-border);
  margin-bottom: 12px;
}
.ai-summary-head {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ai-accent-ink);
  margin-bottom: 6px;
}
.ai-steps-wrap { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.ai-step-card {
  display: flex;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 11px;
  background: var(--ai-bg);
  border: 1px solid var(--ai-border);
}
.ai-step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--ai-accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Policy Citations & Web Widgets */
.ai-links-section { margin-top: 12px; }
.ai-sub-head {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ai-muted);
  margin-bottom: 8px;
}
.ai-link-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.ai-link-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 11px;
  border: 1px solid var(--ai-border);
  background: var(--ai-chip-doc-bg);
  color: var(--ai-chip-doc-ink);
  cursor: pointer;
  text-align: start;
  width: 100%;
}
.ai-link-card-title { font-weight: 700; font-size: 13px; display: block; }
.ai-link-card-sub { font-size: 11.5px; opacity: 0.85; display: block; }

.ai-widgets-wrap { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.ai-widget-weather,
.ai-widget-currency,
.ai-widget-sports,
.ai-widget-spotlight {
  border-radius: 14px;
  border: 1px solid var(--ai-border);
  background: var(--ai-bg);
  padding: 15px;
}
.ai-weather-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.ai-weather-loc { font-weight: 700; font-size: 15px; }
.ai-weather-cond { color: var(--ai-muted); font-size: 13px; }
.ai-weather-now { display: flex; align-items: center; gap: 8px; }
.ai-weather-emoji { font-size: 32px; }
.ai-weather-temp { font-size: 28px; font-weight: 800; }
.ai-weather-metrics { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ai-muted); margin: 10px 0; }
.ai-weather-days { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 10px; }
.ai-weather-day {
  background: var(--ai-surface);
  border: 1px solid var(--ai-border);
  border-radius: 10px;
  padding: 8px 6px;
  text-align: center;
  font-size: 12px;
}

.ai-curr-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--ai-muted); margin-bottom: 8px; }
.ai-curr-hero { display: flex; align-items: baseline; gap: 10px; font-size: 22px; font-weight: 800; flex-wrap: wrap; }
.ai-curr-to { color: var(--ai-curr-ink); }
.ai-curr-unit { font-size: 12.5px; color: var(--ai-muted); margin-top: 4px; }
.ai-curr-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.ai-curr-chip {
  background: var(--ai-surface);
  border: 1px solid var(--ai-border);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  display: flex;
  gap: 6px;
}
.ai-curr-code { font-weight: 700; }

.ai-sports-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-size: 12px; }
.ai-sports-status { padding: 2px 9px; border-radius: 999px; font-weight: 700; background: var(--ai-sports-time-bg); color: var(--ai-sports-time-ink); }
.ai-sports-matchup { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; text-align: center; }
.ai-sports-badge { width: 44px; height: 44px; object-fit: contain; margin: 0 auto 6px; display: block; }
.ai-sports-team-name { font-weight: 700; font-size: 14px; }
.ai-sports-score { font-size: 24px; font-weight: 800; background: var(--ai-sports-score-bg); color: var(--ai-sports-score-ink); padding: 4px 14px; border-radius: 10px; }
.ai-sports-rows { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.ai-sports-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--ai-surface); border: 1px solid var(--ai-border);
  border-radius: 9px; padding: 7px 10px; font-size: 12.5px;
}

.ai-web-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 8px;
}
.ai-web-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: var(--ai-ink);
  background: var(--ai-bg);
  border: 1px solid var(--ai-border);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.ai-web-card:hover { border-color: var(--ai-accent); transform: translateY(-2px); }
.ai-web-card-media { height: 115px; overflow: hidden; background: var(--ai-sidebar); }
.ai-web-card-media img { width: 100%; height: 100%; object-fit: cover; }
.ai-web-card-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.ai-web-meta { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ai-muted); }
.ai-web-meta img { width: 14px; height: 14px; border-radius: 3px; }
.ai-web-title { font-weight: 700; font-size: 13px; line-height: 1.35; }
.ai-web-snip { font-size: 12px; color: var(--ai-muted); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.ai-smart-sugs {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--ai-border);
}
.ai-smart-sug-btn {
  border: 1px solid var(--ai-accent-border);
  background: var(--ai-accent-soft);
  color: var(--ai-accent-ink);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.ai-smart-sug-btn:hover { background: var(--ai-accent); color: #fff; }

.ai-msg-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--ai-border);
}
.ai-act-btn {
  border: none;
  background: transparent;
  color: var(--ai-muted);
  cursor: pointer;
  padding: 4px 7px;
  border-radius: 6px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.ai-act-btn:hover { background: var(--ai-accent-soft); color: var(--ai-ink); }
.ai-act-btn.is-up { color: #10b981; }
.ai-act-btn.is-down { color: var(--ai-danger-ink); }

/* Typing Indicator */
.ai-typing { display: inline-flex; gap: 5px; padding: 14px 18px; }
.ai-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ai-accent);
  animation: aiBounce 1.2s infinite ease-in-out;
}
.ai-dot:nth-child(2) { animation-delay: 0.16s; }
.ai-dot:nth-child(3) { animation-delay: 0.32s; }
@keyframes aiBounce { 0%,80%,100% { transform: scale(0.6); opacity: 0.4; } 40% { transform: scale(1); opacity: 1; } }

/* Composer */
.ai-composer-wrap {
  padding: 12px 20px 16px;
  background: var(--ai-bg);
  border-top: 1px solid var(--ai-border);
}
.ai-composer {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--ai-surface);
  border: 1.5px solid var(--ai-border);
  border-radius: 16px;
  padding: 8px 10px 8px 15px;
  box-shadow: var(--ai-shadow);
}
.ai-composer:focus-within { border-color: var(--ai-accent); }
.ai-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--ai-ink);
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 140px;
  line-height: 1.5;
  padding: 5px 0;
}
.ai-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  border: none;
  background: var(--ai-brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.ai-send-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.ai-send-btn:not(:disabled):hover { background: var(--ai-brand-hover); }
.ai-composer-hint {
  max-width: 860px;
  margin: 6px auto 0;
  text-align: center;
  font-size: 11.5px;
  color: var(--ai-muted);
}

/* Admin Panels, Cards & Tables */
.ai-stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.ai-stat-card {
  background: var(--ai-surface);
  border: 1px solid var(--ai-border);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--ai-shadow);
}
.ai-stat-val { font-size: 24px; font-weight: 800; color: var(--ai-accent-ink); }
.ai-stat-lbl { font-size: 12px; color: var(--ai-muted); margin-top: 2px; }

.ai-config-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.ai-panel-card {
  background: var(--ai-surface);
  border: 1px solid var(--ai-border);
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: var(--ai-shadow);
}
.ai-panel-card h3 { margin: 0 0 14px; font-size: 15.5px; }
.ai-form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.ai-span-2 { grid-column: span 2; }

.ai-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}
.ai-item-card {
  background: var(--ai-surface);
  border: 1px solid var(--ai-border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--ai-shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ai-item-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.ai-item-title { font-weight: 700; font-size: 14.5px; }
.ai-item-meta { font-size: 12px; color: var(--ai-muted); }
.ai-item-foot { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 8px; border-top: 1px solid var(--ai-border); }

.ai-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.ai-badge.is-ok { background: var(--ai-success-bg); color: var(--ai-success-ink); }
.ai-badge.is-warn { background: var(--ai-warning-bg); color: var(--ai-warning-ink); }
.ai-badge.is-err { background: var(--ai-danger-bg); color: var(--ai-danger-ink); }
.ai-badge.is-info { background: var(--ai-accent-soft); color: var(--ai-accent-ink); }

.ai-table-card {
  background: var(--ai-surface);
  border: 1px solid var(--ai-border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--ai-shadow);
}
.ai-table-scroll { overflow-x: auto; }
.ai-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ai-table th, .ai-table td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--ai-border);
}
.ai-table th { background: var(--ai-sidebar); font-weight: 700; font-size: 12px; color: var(--ai-muted); text-transform: uppercase; }

/* Modal */
.ai-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}
.ai-modal {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  background: var(--ai-surface);
  border: 1px solid var(--ai-border);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}
.ai-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 18px;
  border-bottom: 1px solid var(--ai-border);
}
.ai-modal-head h3 { margin: 0; font-size: 16px; }
.ai-modal-body {
  padding: 18px;
  overflow-y: auto;
}
.ai-modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}
.ai-doc-preview {
  white-space: pre-wrap;
  background: var(--ai-bg);
  border: 1px solid var(--ai-border);
  border-radius: 10px;
  padding: 12px;
  max-height: 360px;
  overflow-y: auto;
  font-size: 12.5px;
  line-height: 1.55;
}

/* Toasts */
.ai-toast-stack {
  position: fixed;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
}
.ai-toast {
  background: var(--ai-surface);
  color: var(--ai-ink);
  border: 1px solid var(--ai-border);
  border-left: 4px solid var(--ai-accent);
  border-radius: 10px;
  padding: 11px 15px;
  font-size: 13px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
  max-width: 360px;
}
.ai-toast.is-success { border-left-color: #10b981; }
.ai-toast.is-danger { border-left-color: #ef4444; }

@media (max-width: 860px) {
  .ai-config-grid, .ai-form-grid { grid-template-columns: 1fr; }
  .ai-span-2 { grid-column: span 1; }
  .ai-sidebar { position: fixed; z-index: 500; height: 100vh; box-shadow: 0 10px 30px rgba(0,0,0,0.2); }
  .ai-meta-badge { display: none; }
}
