/* ═══════════════════════════════════════════════════════════
   FinAgent — B2B KYC & Due Diligence  |  style.css
   ═══════════════════════════════════════════════════════════ */

/* ── Variables ──────────────────────────────────────────────── */
:root {
  --bg:         #070d1a;
  --bg2:        #0d1526;
  --card:       #111e30;
  --card2:      #162035;
  --border:     #1e3050;
  --border2:    #243a5e;

  --blue:       #3b82f6;
  --blue-dark:  #1d4ed8;
  --blue-glow:  rgba(59,130,246,.25);
  --red:        #e94560;
  --red-dark:   #c0392b;
  --green:      #22c55e;
  --amber:      #f59e0b;
  --purple:     #a855f7;

  --text:       #e2e8f0;
  --text2:      #94a3b8;
  --text3:      #64748b;

  --radius:     12px;
  --radius-sm:  8px;
  --shadow:     0 4px 24px rgba(0,0,0,.45);
  --shadow-sm:  0 2px 10px rgba(0,0,0,.3);

  --font: 'Inter', system-ui, sans-serif;
}

/* ── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: var(--blue); text-decoration: none; }
input, button { font-family: inherit; }

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ════════════════════════════════════════════════════════════
   NAVBAR
   ════════════════════════════════════════════════════════════ */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 64px;
  background: rgba(7,13,26,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-brand { display: flex; align-items: center; gap: 12px; }
.nav-logo  { height: 40px; width: auto; }
.nav-title { display: flex; flex-direction: column; line-height: 1.2; }
.nav-name  { font-weight: 700; font-size: 1.1rem; letter-spacing: .5px; color: var(--text); }
.nav-sub   { font-size: .7rem; color: var(--text3); text-transform: uppercase; letter-spacing: 1px; }

.nav-center { display: flex; gap: 10px; }
.nav-badge  {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 20px; font-size: .72rem; font-weight: 600;
  border: 1px solid;
}
.badge-ai    { color: var(--blue);  border-color: var(--blue);  background: rgba(59,130,246,.1); }
.badge-neo4j { color: var(--green); border-color: var(--green); background: rgba(34,197,94,.1); }
.badge-doku  { color: var(--amber); border-color: var(--amber); background: rgba(245,158,11,.1); }

.nav-status { font-size: .78rem; }
.status-dot { display: flex; align-items: center; gap: 6px; }
.status-dot i { font-size: .6rem; }
.status-checking { color: var(--amber); }
.status-ok       { color: var(--green); }
.status-error    { color: var(--red);   }

/* ════════════════════════════════════════════════════════════
   HERO
   ════════════════════════════════════════════════════════════ */
.hero {
  padding: 40px 28px 28px;
  background: linear-gradient(180deg, rgba(59,130,246,.07) 0%, transparent 100%);
  border-bottom: 1px solid var(--border);
}
.hero-title {
  font-size: 1.9rem; font-weight: 800; line-height: 1.25;
  margin-bottom: 10px;
}
.accent { color: var(--blue); }
.hero-desc {
  max-width: 780px; color: var(--text2); line-height: 1.65; font-size: .9rem;
  margin-bottom: 18px;
}
.hero-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.stat-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 20px;
  background: var(--card); border: 1px solid var(--border);
  font-size: .8rem; color: var(--text2);
}
.stat-pill i { color: var(--blue); }

/* ════════════════════════════════════════════════════════════
   WORKSPACE LAYOUT
   ════════════════════════════════════════════════════════════ */
.workspace {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 20px;
  padding: 20px 28px;
  min-height: calc(100vh - 64px - 140px);
  align-items: start;
}
@media (max-width: 1100px) {
  .workspace { grid-template-columns: 1fr; }
}

.panel { display: flex; flex-direction: column; gap: 16px; }

/* ════════════════════════════════════════════════════════════
   CARDS
   ════════════════════════════════════════════════════════════ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.card-title {
  font-size: .85rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .8px; color: var(--text2); margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
}
.card-title i { color: var(--blue); }

/* ── Mode card ───────────────────────────────────────────────── */
.mode-options { display: flex; flex-direction: column; gap: 10px; }
.mode-option  { cursor: pointer; }
.mode-option input { display: none; }
.mode-body {
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  transition: .2s border-color, .2s background;
}
.mode-option input:checked + .mode-body {
  border-color: var(--blue);
  background: rgba(59,130,246,.08);
}
.mode-header {
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: .9rem; margin-bottom: 4px;
}
.mode-body p { font-size: .78rem; color: var(--text2); line-height: 1.5; }

/* Tags */
.tag {
  padding: 2px 8px; border-radius: 10px; font-size: .65rem;
  font-weight: 700; letter-spacing: .5px;
}
.tag-free    { background: rgba(34,197,94,.15); color: var(--green); border: 1px solid var(--green); }
.tag-premium { background: rgba(233,69,96,.15); color: var(--red);   border: 1px solid var(--red); }
.tag-demo    { background: rgba(245,158,11,.15); color: var(--amber); border: 1px solid var(--amber); font-size: .6rem; }

/* ── Upload card ─────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border2);
  border-radius: var(--radius-sm);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: .2s;
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--blue);
  background: rgba(59,130,246,.05);
}
.drop-icon   { font-size: 2rem; color: var(--blue); margin-bottom: 8px; }
.drop-zone p { font-size: .82rem; color: var(--text2); }
.drop-hint   { font-size: .72rem; color: var(--text3); margin-top: 4px; }
.file-link   { color: var(--blue); cursor: pointer; font-weight: 600; }

.upload-status {
  margin-top: 10px; padding: 10px 14px;
  border-radius: var(--radius-sm); font-size: .82rem;
}
.upload-status.success { background: rgba(34,197,94,.1);  color: var(--green); border: 1px solid var(--green); }
.upload-status.error   { background: rgba(233,69,96,.1);  color: var(--red);   border: 1px solid var(--red); }
.upload-status.loading { background: rgba(59,130,246,.1); color: var(--blue);  border: 1px solid var(--blue); }
.processed-files { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.processed-file  {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  background: var(--card2); border-radius: 6px; font-size: .78rem; color: var(--green);
}

/* ── Chat card ───────────────────────────────────────────────── */
.chat-card { flex: 1; display: flex; flex-direction: column; }
.chat-messages {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
  padding: 4px 2px;
  margin: 0;
}
.message { display: flex; gap: 10px; align-items: flex-start; }
.msg-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: .85rem;
}
.msg-assistant .msg-avatar { background: var(--blue-dark); color: white; }
.msg-user .msg-avatar      { background: var(--card2); color: var(--text2); }
.msg-user      { flex-direction: row-reverse; }

.msg-bubble {
  max-width: 85%; padding: 10px 14px;
  border-radius: var(--radius-sm); font-size: .85rem; line-height: 1.6;
}
.msg-assistant .msg-bubble { background: var(--card2); border: 1px solid var(--border); }
.msg-user      .msg-bubble { background: var(--blue-dark); color: white; }

.msg-bubble p { margin-bottom: 6px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble strong { color: var(--blue); }
.msg-user .msg-bubble strong { color: #bfdbfe; }

/* Typing indicator */
.msg-typing .msg-bubble { padding: 12px 16px; }
.typing-dots span {
  display: inline-block; width: 6px; height: 6px;
  background: var(--text3); border-radius: 50%; margin: 0 2px;
  animation: typing 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes typing { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-6px); } }

/* Chat input */
.chat-input-area {
  display: flex; gap: 8px;
  background: var(--card2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 4px;
}
.chat-input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font-size: .88rem; padding: 8px 10px;
}
.chat-input::placeholder { color: var(--text3); }
.btn-send {
  width: 38px; height: 38px; border-radius: 8px;
  background: var(--blue); color: white; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: .2s background;
}
.btn-send:hover { background: var(--blue-dark); }

/* ════════════════════════════════════════════════════════════
   GRAPH CARD
   ════════════════════════════════════════════════════════════ */
.graph-card { flex: 1; }
.graph-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.graph-controls { display: flex; align-items: center; gap: 8px; }
.graph-filter-input {
  background: var(--card2); border: 1px solid var(--border);
  color: var(--text); border-radius: 6px; padding: 5px 10px;
  font-size: .8rem; width: 160px; outline: none;
}
.graph-filter-input:focus { border-color: var(--blue); }
.btn-icon {
  width: 30px; height: 30px; border-radius: 6px;
  background: var(--card2); border: 1px solid var(--border);
  color: var(--text2); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; transition: .2s;
}
.btn-icon:hover { border-color: var(--blue); color: var(--blue); }

.graph-legend {
  display: flex; gap: 14px; flex-wrap: wrap;
  margin-bottom: 12px; font-size: .72rem;
}
.legend-item {
  display: flex; align-items: center; gap: 5px; color: var(--text2);
}
.legend-item i { color: var(--c); font-size: .55rem; }

.graph-container {
  width: 100%; height: 420px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  position: relative; overflow: hidden;
}
.graph-placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  color: var(--text3);
}
.graph-info {
  margin-top: 8px; padding: 8px 12px;
  background: var(--card2); border-radius: 6px;
  font-size: .78rem; color: var(--text2);
}

/* ════════════════════════════════════════════════════════════
   PIPELINE CARD
   ════════════════════════════════════════════════════════════ */
.pipeline { display: flex; flex-direction: column; gap: 0; }
.pipeline-step {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card2); transition: .25s;
}
.pipeline-connector {
  width: 2px; height: 14px;
  background: var(--border); margin-left: 26px;
}
.step-icon {
  width: 34px; height: 34px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); border: 1px solid var(--border);
  font-size: .9rem; color: var(--text3); flex-shrink: 0; transition: .25s;
}
.step-body { flex: 1; }
.step-name { display: block; font-size: .83rem; font-weight: 600; margin-bottom: 2px; }
.step-desc { font-size: .73rem; color: var(--text3); }
.step-status { font-size: .8rem; }

/* States */
.step-idle    .step-status { color: var(--text3); }
.step-running { border-color: var(--blue); background: rgba(59,130,246,.06); }
.step-running .step-icon   { background: var(--blue-dark); border-color: var(--blue); color: white; }
.step-running .step-status { color: var(--blue); animation: spin .8s linear infinite; display: inline-block; }
.step-done    { border-color: var(--green); }
.step-done    .step-icon   { background: rgba(34,197,94,.15); border-color: var(--green); color: var(--green); }
.step-done    .step-status { color: var(--green); }
.step-blocked { border-color: var(--red); }
.step-blocked .step-icon   { background: rgba(233,69,96,.15); border-color: var(--red); color: var(--red); }
.step-blocked .step-status { color: var(--red); }

@keyframes spin { to { transform: rotate(360deg); } }

/* ════════════════════════════════════════════════════════════
   PAYWALL MODAL
   ════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(7,13,26,.85);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 40px;
  max-width: 520px; width: 100%;
  position: relative;
  box-shadow: 0 24px 80px rgba(0,0,0,.7);
  text-align: center;
}
.modal-close {
  position: absolute; top: 14px; right: 14px;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--card2); border: 1px solid var(--border);
  color: var(--text2); cursor: pointer; font-size: .85rem;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { color: var(--red); border-color: var(--red); }

.paywall-badge {
  display: inline-block; padding: 4px 14px;
  background: rgba(233,69,96,.15); color: var(--red);
  border: 1px solid var(--red); border-radius: 20px;
  font-size: .65rem; font-weight: 700; letter-spacing: 1.5px;
  margin-bottom: 16px;
}
.paywall-icon {
  font-size: 2.8rem; color: var(--red); margin-bottom: 12px;
}
.paywall-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 10px; }
.paywall-desc  { color: var(--text2); font-size: .88rem; line-height: 1.65; margin-bottom: 22px; }

.paywall-price-box {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 16px; margin-bottom: 20px;
}
.price-label  { font-size: .72rem; color: var(--text3); text-transform: uppercase; letter-spacing: .8px; }
.price-amount { font-size: 2rem; font-weight: 800; color: var(--text); margin: 4px 0; }
.price-number { color: var(--blue); }
.price-detail { font-size: .72rem; color: var(--green); }

.paywall-features {
  display: flex; flex-direction: column; gap: 8px;
  text-align: left; margin-bottom: 24px;
}
.feature-item {
  display: flex; align-items: center; gap: 10px;
  font-size: .84rem; color: var(--text2);
}
.feature-item i { color: var(--green); font-size: .75rem; }

.paywall-actions { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 14px 24px; border-radius: var(--radius-sm); font-weight: 600;
  font-size: .9rem; cursor: pointer; border: none; transition: .2s;
  text-decoration: none; color: white;
}
.btn-doku {
  background: linear-gradient(90deg, #e94560, #c0392b);
  box-shadow: 0 4px 20px rgba(233,69,96,.35);
}
.btn-doku:hover { filter: brightness(1.1); transform: translateY(-1px); color: white; }
.btn-simulate {
  background: var(--card2); border: 2px solid var(--border2); color: var(--text);
}
.btn-simulate:hover { border-color: var(--amber); color: var(--amber); }

.paywall-processing {
  display: flex; align-items: center; justify-content: center;
  gap: 12px; padding: 14px;
  background: rgba(59,130,246,.06); border-radius: var(--radius-sm);
  margin-bottom: 12px; font-size: .85rem; color: var(--blue);
}
.spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--blue);
  animation: spin .7s linear infinite; flex-shrink: 0;
}
.paywall-session-info {
  font-size: .72rem; color: var(--text3); font-family: monospace;
}
.paywall-session-info code { color: var(--text2); }

/* ════════════════════════════════════════════════════════════
   TOAST
   ════════════════════════════════════════════════════════════ */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 300; padding: 12px 24px; border-radius: var(--radius-sm);
  font-size: .87rem; font-weight: 500; box-shadow: var(--shadow);
  animation: slideUp .25s ease; max-width: 500px; text-align: center;
}
.toast.success { background: var(--green); color: white; }
.toast.error   { background: var(--red);   color: white; }
.toast.info    { background: var(--blue);  color: white; }
.toast.warning { background: var(--amber); color: #1a1a1a; }
@keyframes slideUp { from { transform: translateX(-50%) translateY(20px); opacity: 0; } }

/* ════════════════════════════════════════════════════════════
   UTILITIES
   ════════════════════════════════════════════════════════════ */
.hidden  { display: none !important; }
.loading { opacity: .6; pointer-events: none; }

/* Code blocks inside messages */
.msg-bubble pre {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; padding: 10px 12px; margin-top: 8px;
  font-size: .78rem; overflow-x: auto; white-space: pre-wrap;
  word-break: break-word;
}
.msg-bubble code { font-family: 'Courier New', monospace; color: var(--blue); }

/* ════════════════════════════════════════════════════════════
   APP LAYOUT — Sidebar + Main
   ════════════════════════════════════════════════════════════ */
body.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width .25s ease;
  z-index: 50;
}
.sidebar.collapsed { width: 60px; }
.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .sidebar-nav-item span,
.sidebar.collapsed .sidebar-section-label,
.sidebar.collapsed .sidebar-mode,
.sidebar.collapsed .sidebar-footer .nav-badge { display: none; }
.sidebar.collapsed .sidebar-nav-item { justify-content: center; padding: 10px 0; }
.sidebar.collapsed .sidebar-brand { justify-content: center; padding: 14px 0; }

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-logo { height: 32px; width: auto; flex-shrink: 0; }
.sidebar-brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.sidebar-name { font-weight: 700; font-size: .95rem; color: var(--text); }
.sidebar-sub  { font-size: .62rem; color: var(--text3); text-transform: uppercase; letter-spacing: .8px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 12px 8px; }
.sidebar-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  background: none; border: none; color: var(--text2);
  font-size: .85rem; font-weight: 500; cursor: pointer;
  text-align: left; position: relative;
  transition: background .15s, color .15s;
}
.sidebar-nav-item:hover { background: rgba(255,255,255,.05); color: var(--text); }
.sidebar-nav-item.active { background: rgba(59,130,246,.15); color: var(--blue); }
.sidebar-nav-item i { width: 16px; text-align: center; flex-shrink: 0; }
.sidebar-badge {
  margin-left: auto; background: var(--blue); color: #fff;
  font-size: .62rem; font-weight: 700; padding: 1px 6px;
  border-radius: 10px; min-width: 18px; text-align: center;
}

.sidebar-section-label {
  font-size: .65rem; font-weight: 600; color: var(--text3);
  text-transform: uppercase; letter-spacing: 1px;
  padding: 6px 12px 2px;
}
.sidebar-mode { padding: 0 8px 10px; border-bottom: 1px solid var(--border); }
.mode-toggle { display: flex; flex-direction: column; gap: 4px; padding: 4px 0; }
.mode-toggle-opt { cursor: pointer; }
.mode-toggle-opt input { display: none; }
.mode-toggle-body {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: var(--radius-sm);
  border: 1px solid transparent; font-size: .82rem;
  color: var(--text2); transition: .15s;
}
.mode-toggle-opt input:checked + .mode-toggle-body {
  background: rgba(59,130,246,.12); color: var(--blue);
  border-color: rgba(59,130,246,.3);
}
.mode-toggle-opt:hover .mode-toggle-body { background: rgba(255,255,255,.04); }
.mode-toggle-body i { width: 14px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  margin-top: auto; padding: 12px; border-top: 1px solid var(--border);
  font-size: .73rem;
}

/* ── App Main ──────────────────────────────────────────────── */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* ── Topbar ──────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; height: 48px; flex-shrink: 0;
  background: rgba(7,13,26,.95); border-bottom: 1px solid var(--border);
  gap: 12px;
}
.topbar-left  { display: flex; align-items: center; gap: 10px; }
.topbar-center {
  display: flex; gap: 8px; flex-wrap: wrap;
  justify-content: center; flex: 1;
}
.topbar-right { display: flex; align-items: center; gap: 6px; }
.topbar-breadcrumb {
  font-size: .82rem; font-weight: 600; color: var(--text2);
  display: flex; align-items: center; gap: 6px;
}
.sidebar-toggle-btn {
  background: none; border: 1px solid var(--border);
  color: var(--text2); padding: 5px 8px; border-radius: 6px;
  cursor: pointer; font-size: .8rem;
}
.sidebar-toggle-btn:hover { color: var(--text); border-color: var(--border2); }

/* Stat pills (topbar) */
.topbar-center .stat-pill {
  padding: 3px 10px; font-size: .71rem;
}

/* ── Views ──────────────────────────────────────────────────── */
.view {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
}
.view.active { display: flex; flex-direction: column; min-height: 0; }

/* ════════════════════════════════════════════════════════════
   VIEW: DASHBOARD
   ════════════════════════════════════════════════════════════ */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  grid-template-rows: 480px auto;
  gap: 14px;
  padding: 14px;
  align-items: start;
}
.dash-graph    { grid-column: 1 / 3; }
.dash-pipeline { grid-column: 1; }
.dash-upload   { grid-column: 2; }
.dash-graph .graph-container { height: 410px; }

@media (max-width: 1050px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
    grid-template-rows: 380px auto auto;
  }
  .dash-graph, .dash-pipeline, .dash-upload { grid-column: 1; }
}

/* ════════════════════════════════════════════════════════════
   VIEW: INVESTIGATION (CHAT)
   ════════════════════════════════════════════════════════════ */
.chat-workspace {
  display: flex;
  flex-direction: row;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Chat main panel */
.chat-main {
  display: flex; flex-direction: column;
  flex: 1; min-width: 0;
  border-right: 1px solid var(--border);
  overflow: hidden;
}
.chat-main .chat-messages {
  flex: 1; min-height: 0;
  overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.chat-main .chat-input-area {
  flex-shrink: 0;
  padding: 10px 14px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; background: var(--bg2);
}
.chat-main .chat-input {
  flex: 1; background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 14px; color: var(--text);
  font-size: .88rem; resize: none;
}
.chat-main .chat-input:focus { border-color: var(--blue); outline: none; }
.chat-main .btn-send {
  background: var(--blue); border: none; color: #fff;
  padding: 10px 14px; border-radius: 8px; cursor: pointer; font-size: .9rem;
  flex-shrink: 0;
}
.chat-main .btn-send:hover { filter: brightness(1.1); }

/* Message timestamps */
.msg-meta { font-size: .65rem; color: var(--text3); margin-top: 4px; }

/* ── Drag-to-resize handle ───────────────────────────── */
.panel-resize-handle {
  width: 5px; flex-shrink: 0; cursor: col-resize;
  background: transparent;
  border-left: 2px solid var(--border);
  transition: border-color .15s;
  position: relative;
  z-index: 10;
}
.panel-resize-handle:hover,
.panel-resize-handle.dragging { border-color: var(--blue); }

/* Chat side panel */
.chat-side {
  display: flex; flex-direction: column; gap: 0;
  overflow-y: auto; background: var(--bg);
  width: 300px; flex-shrink: 0; min-width: 180px; max-width: 70vw;
  position: relative;
  transition: width .0s;
}
/* Fullscreen mode */
.chat-side.panel-fullscreen {
  width: 65vw !important;
}

/* Side panel header with actions */
.chat-side-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px; border-bottom: 1px solid var(--border);
  background: var(--bg2); font-size: .75rem; font-weight: 600; color: var(--text2);
}
.chat-side-header .panel-btns { display: flex; gap: 4px; }
.panel-btn {
  background: none; border: 1px solid var(--border); color: var(--text3);
  padding: 3px 7px; border-radius: 5px; cursor: pointer; font-size: .7rem;
  display: flex; align-items: center; gap: 4px;
}
.panel-btn:hover { color: var(--text); border-color: var(--blue); background: rgba(59,130,246,.08); }

.chat-graph-card { border-radius: 0; border: none; border-bottom: 1px solid var(--border); }
.doc-list-card   { border-radius: 0; border: none; flex: 1; }

/* Mini graph */
.graph-container-mini {
  height: 200px; position: relative;
  background: var(--bg); border-top: 1px solid var(--border);
  transition: height .2s;
}
.chat-side.panel-fullscreen .graph-container-mini { height: 55vh; }

/* Document list (compact, chat side) */
.doc-list { padding: 6px 10px; display: flex; flex-direction: column; gap: 4px; }
.doc-list-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 6px;
  background: var(--card2); border: 1px solid var(--border);
  font-size: .76rem; color: var(--text2);
}
.doc-list-item i { color: var(--amber); flex-shrink: 0; }
.doc-list-item .doc-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-list-item a { color: var(--blue); font-size: .7rem; flex-shrink: 0; }
.empty-state-small { font-size: .75rem; color: var(--text3); padding: 12px; text-align: center; }

@media (max-width: 900px) {
  .chat-side { display: none; }
}

/* Export report button (inside chat messages) */
.btn-export-report {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 12px; padding: 8px 16px;
  background: rgba(59,130,246,.12); color: var(--blue);
  border: 1px solid rgba(59,130,246,.3); border-radius: 8px;
  font-size: .82rem; font-weight: 600; cursor: pointer;
  text-decoration: none; transition: .15s;
}
.btn-export-report:hover { background: rgba(59,130,246,.22); color: var(--blue); }

/* Chat history timestamp group label */
.chat-date-separator {
  text-align: center; font-size: .68rem; color: var(--text3);
  position: relative; margin: 8px 0;
}
.chat-date-separator::before, .chat-date-separator::after {
  content: ''; position: absolute; top: 50%; width: 30%;
  height: 1px; background: var(--border);
}
.chat-date-separator::before { left: 0; }
.chat-date-separator::after  { right: 0; }

/* ════════════════════════════════════════════════════════════
   VIEW: DOCUMENTS
   ════════════════════════════════════════════════════════════ */
.docs-workspace { padding: 20px 24px; overflow-y: auto; flex: 1; }
.docs-header    { margin-bottom: 20px; }
.docs-title { font-size: 1.2rem; font-weight: 700; display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.docs-sub   { font-size: .83rem; color: var(--text2); }

.drop-zone-compact {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px; border-radius: 8px;
  border: 1px dashed var(--border2);
  background: var(--card2); font-size: .82rem; color: var(--text2);
  cursor: pointer;
}
.drop-zone-compact i { color: var(--blue); }
.drop-zone-compact:hover { border-color: var(--blue); }

.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.doc-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
  transition: border-color .15s, box-shadow .15s;
}
.doc-card:hover { border-color: var(--blue); box-shadow: 0 0 0 1px rgba(59,130,246,.2); }
.doc-card-icon { font-size: 2rem; color: var(--amber); }
.doc-card-name { font-weight: 600; font-size: .88rem; word-break: break-word; }
.doc-card-meta { font-size: .73rem; color: var(--text3); }
.doc-card-actions { display: flex; gap: 8px; margin-top: auto; }
.doc-card-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 6px; font-size: .75rem;
  font-weight: 500; cursor: pointer; border: none; transition: .15s;
}
.doc-btn-dl  { background: rgba(59,130,246,.12); color: var(--blue); }
.doc-btn-dl:hover  { background: rgba(59,130,246,.22); }
.doc-card-new { border-style: dashed; }
.doc-empty {
  grid-column: 1/-1; text-align: center;
  color: var(--text3); padding: 60px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.doc-empty i { opacity: .3; }
.doc-empty p { font-size: .88rem; }

/* ════════════════════════════════════════════════════════════
   AGENT TRACE ACCORDION (inside chat bubble)
   ════════════════════════════════════════════════════════════ */
.agent-trace {
  margin-top: 12px;
  border: 1px solid rgba(59,130,246,.25);
  border-radius: 8px;
  overflow: hidden;
  font-size: .78rem;
}
.trace-header {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px;
  background: rgba(59,130,246,.08);
  color: var(--blue); font-weight: 600; font-size: .74rem;
  cursor: pointer; user-select: none;
  border-bottom: 1px solid rgba(59,130,246,.15);
}
.trace-header:hover { background: rgba(59,130,246,.14); }
.trace-toggle-icon { margin-left: auto; transition: transform .2s; }
.agent-trace.open .trace-toggle-icon { transform: rotate(180deg); }
.trace-steps { display: none; }
.agent-trace.open .trace-steps { display: block; }

.trace-step {
  border-bottom: 1px solid rgba(255,255,255,.04);
}
.trace-step:last-child { border-bottom: none; }
.trace-step-header {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; cursor: pointer; user-select: none;
  transition: background .15s;
}
.trace-step-header:hover { background: rgba(255,255,255,.04); }
.trace-step-icon {
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .65rem; flex-shrink: 0;
}
.trace-step-icon.done    { background: rgba(16,185,129,.2); color: #10b981; }
.trace-step-icon.running { background: rgba(59,130,246,.2); color: #3b82f6; }
.trace-step-icon.blocked { background: rgba(245,158,11,.2); color: #f59e0b; }
.trace-step-label { font-weight: 600; color: var(--text); font-size: .76rem; }
.trace-step-meta  { margin-left: auto; color: var(--text3); font-size: .68rem; white-space: nowrap; }
.trace-step-body  { display: none; padding: 0 12px 10px 44px; }
.trace-step.open .trace-step-body { display: block; }
.trace-step-chevron { color: var(--text3); font-size: .6rem; margin-left: 4px; transition: transform .15s; }
.trace-step.open .trace-step-chevron { transform: rotate(90deg); }

.trace-code {
  background: #0a1020; border: 1px solid var(--border);
  border-radius: 6px; padding: 8px 10px;
  font-family: 'Courier New', monospace; font-size: .72rem;
  color: #7dd3fc; white-space: pre-wrap; word-break: break-all;
  max-height: 160px; overflow-y: auto; margin-top: 4px;
}
.trace-text {
  color: var(--text2); line-height: 1.5; margin-top: 4px;
  white-space: pre-wrap;
}

/* ════════════════════════════════════════════════════════════
   HIDE OLD LAYOUT ELEMENTS (no longer used in new design)
   ════════════════════════════════════════════════════════════ */
.navbar, .hero, .panel-left, .panel-right, .workspace:not(.workspace-chat):not(.workspace-docs):not(.workspace-dashboard) {
  display: none !important;
}
/* Old chat card elements that moved into view-chat */
.workspace .chat-card, .workspace .upload-card, .workspace .mode-card { display: none !important; }

