/* ═══════════════════════════════════════════════════════════════
   CABot — AI Chartered Accountant | Production CSS v4.0
   Theme: Dark Glassmorphism · Purple Accent · Premium UI
═══════════════════════════════════════════════════════════════ */

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

/* ── Variables ─────────────────────────────────────────────── */
:root {
  /* Chartered Authority System — Financial Fortress Palette */
  --bg0: #f8f9ff; /* background */
  --bg1: #ffffff; /* surface-container-lowest (sidebar, panels) */
  --bg2: #ffffff; /* level 1 card */
  --bg3: #eff4ff; /* hover states / surface-container-low */
  --bg4: #e5eeff; /* active states / surface-container */
  --bg5: #dce9ff; /* surface-container-high */

  /* Primary Brand: Deep Navy Blue */
  --a1:  #002046; /* primary */
  --a2:  #1b365d; /* primary-container */
  --a3:  #d6e3ff; /* primary-fixed */
  --a4:  #aec7f7; /* inverse-primary */
  
  /* Gradients & Accents (kept for compatibility, styled solid or subtle) */
  --ag:  #1b365d; 
  --ag2: #002046;
  --aglow: rgba(0, 32, 70, 0.08);
  --aglow2: rgba(0, 32, 70, 0.04);

  /* Semantic */
  --green:  #10b981;
  --green2: #059669;
  --red:    #ba1a1a;
  --red2:   #93000a;
  --orange: #f59e0b;
  --orange2:#d97706;
  
  /* Gold Prestige Accent */
  --gold:   #c5a059;

  /* Typography Colors */
  --t1: #0b1c30; /* on-surface (high contrast text) */
  --t2: #44474e; /* on-surface-variant (secondary text) */
  --t3: #74777f; /* outline (tertiary/muted) */
  --t4: #ffffff; /* on-primary (for buttons/headers) */

  /* Structural */
  --border: #c4c6cf; /* outline-variant (1px subtle border) */
  --border2: #e2e8f0; /* lighter border */

  /* Elevation (Soft, paper-based depth) */
  --sh:  0 1px 3px rgba(27, 54, 93, 0.04);
  --sha: 0 4px 12px rgba(27, 54, 93, 0.08);
  --shx: 0 10px 30px rgba(27, 54, 93, 0.12);

  /* Geometry */
  --sw:  280px;
  --th:  60px;
  --rb:  4px; /* Soft 4px corners (rounded DEFAULT) */
  --transition: .2s ease-in-out;
}

/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%; overflow: hidden;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg0); color: var(--t1);
  font-size: 14px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body { display: flex; }

/* Scrollbar */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg5); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--a1); }

/* ── Animations ────────────────────────────────────────────── */
@keyframes fadeUp   { from { opacity:0; transform:translateY(14px) } to { opacity:1; transform:none } }
@keyframes fadeIn   { from { opacity:0 } to { opacity:1 } }
@keyframes float    { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-8px)} }
@keyframes spin     { to { transform:rotate(360deg) } }
@keyframes blinkC   { 0%,100%{opacity:1} 50%{opacity:0} }
@keyframes tdot     { 0%,100%{transform:translateY(0);background:var(--t3)} 50%{transform:translateY(-6px);background:var(--a1)} }
@keyframes pulse    { 0%,100%{box-shadow:0 0 0 0 rgba(99,102,241,.5)} 70%{box-shadow:0 0 0 8px rgba(99,102,241,0)} }
@keyframes shimmer  { from{background-position:-200% 0} to{background-position:200% 0} }
@keyframes slideIn  { from{transform:translateX(-100%)} to{transform:translateX(0)} }
@keyframes bounceIn { 0%{transform:scale(.8);opacity:0} 70%{transform:scale(1.05)} 100%{transform:scale(1);opacity:1} }
@keyframes glow     { 0%,100%{opacity:.6} 50%{opacity:1} }
@keyframes countUp  { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:none} }

/* ══════════════════════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sw); min-width: var(--sw);
  height: 100vh;
  background: var(--bg1);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
  transition: width var(--transition), min-width var(--transition), transform var(--transition);
  z-index: 200; flex-shrink: 0;
  position: relative;
}
.sidebar::before {
  content: '';
  position: absolute; top:0; right:0; width:1px; height:100%;
  background: linear-gradient(180deg, transparent, var(--a1), transparent);
  opacity: .3;
}
.sidebar.collapsed { width: 0; min-width: 0; }

/* Brand */
.sb-header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: linear-gradient(180deg, rgba(99,102,241,.06) 0%, transparent 100%);
}

.brand-badge {
  width: 38px; height: 38px; border-radius: var(--rb);
  background: var(--ag);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; font-weight: 900;
  flex-shrink: 0; letter-spacing: -.5px;
  box-shadow: var(--sh);
}

.brand-info { flex: 1; min-width: 0; }
.brand-name {
  font-size: 16px; font-weight: 800; line-height: 1.1;
  background: var(--ag); -webkit-background-clip: text;
  -webkit-text-fill-color: transparent; background-clip: text;
  white-space: nowrap;
}
.brand-sub { font-size: 10px; color: var(--t3); white-space: nowrap; margin-top: 1px; }

.ib {
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: 8px; color: var(--t2);
  width: 30px; height: 30px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all var(--transition);
}
.ib:hover { background: var(--bg4); color: var(--t1); border-color: var(--border); }
.ib svg { width: 14px; height: 14px; }

/* Sidebar body */
.sb-body {
  flex: 1; overflow-y: auto; display: flex;
  flex-direction: column; padding: 10px; gap: 4px;
}

/* New chat button */
.new-btn {
  width: 100%; padding: 9px 14px;
  background: var(--ag);
  border: none; border-radius: var(--rb);
  color: #fff; font-size: 13px; font-weight: 700;
  font-family: inherit; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  margin-bottom: 6px;
  box-shadow: var(--sh);
  transition: all var(--transition);
  position: relative; overflow: hidden;
}
.new-btn::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,.1) 0%, transparent 50%);
  opacity: 0; transition: opacity var(--transition);
}
.new-btn:hover::before { opacity: 1; }
.new-btn:hover { transform: translateY(-1px); box-shadow: var(--sha); }
.new-btn:active { transform: translateY(0); }
.new-btn svg { width: 14px; height: 14px; flex-shrink: 0; }

/* Section label */
.sec-label {
  font-size: 9.5px; font-weight: 700; color: var(--t3);
  text-transform: uppercase; letter-spacing: .9px;
  display: flex; align-items: center; gap: 5px;
  margin: 8px 0 5px; padding: 0 2px;
}
.sec-label svg { width: 11px; height: 11px; flex-shrink: 0; }

/* Model select */
.model-sel {
  flex: 1; background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 8px; color: var(--t1);
  padding: 6px 9px; font-size: 12px; font-family: inherit;
  cursor: pointer; outline: none; min-width: 0;
  transition: border-color var(--transition);
}
.model-sel:focus { border-color: var(--a1); box-shadow: 0 0 0 2px var(--aglow); }
.model-sel option { background: var(--bg2); }

.row-flex { display: flex; gap: 5px; }

/* Status */
.status-row { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.sdot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--t3); flex-shrink: 0;
  transition: background .3s, box-shadow .3s;
}
.sdot.online  { background: var(--green); box-shadow: 0 0 8px rgba(16,185,129,.6); animation: pulse 2s infinite; }
.sdot.offline { background: var(--red); }
.stxt { font-size: 11px; color: var(--t3); }

/* Export */
.exp-section { display: flex; flex-direction: column; gap: 5px; }
.client-inp {
  width: 100%; background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 8px; color: var(--t1);
  padding: 6px 9px; font-size: 12px; font-family: inherit;
  outline: none; transition: border-color var(--transition);
}
.client-inp:focus { border-color: var(--a1); box-shadow: 0 0 0 2px var(--aglow); }
.client-inp::placeholder { color: var(--t3); }

.exp-btns { display: flex; gap: 5px; }
.exp-btn {
  flex: 1; padding: 7px 6px;
  border: 1px solid var(--border2); border-radius: 8px;
  font-size: 11px; font-weight: 600; font-family: inherit;
  cursor: pointer; display: flex; align-items: center;
  justify-content: center; gap: 5px;
  transition: all var(--transition); background: var(--bg3);
}
.exp-btn svg { width: 12px; height: 12px; flex-shrink: 0; }
.pdf-btn { color: var(--red2); border-color: rgba(239,68,68,.2); }
.pdf-btn:hover { background: rgba(239,68,68,.1); border-color: rgba(239,68,68,.4); transform: translateY(-1px); }
.xls-btn { color: var(--green2); border-color: rgba(52,211,153,.2); }
.xls-btn:hover { background: rgba(52,211,153,.1); border-color: rgba(52,211,153,.4); transform: translateY(-1px); }
.exp-btn:disabled { opacity: .35; cursor: not-allowed; transform: none; }

/* Quick chips */
.chips { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
.chip {
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: 8px; color: var(--t2);
  padding: 6px 7px; font-size: 11px; font-family: inherit;
  cursor: pointer; text-align: left; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: all var(--transition);
}
.chip:hover {
  background: var(--bg4); border-color: var(--border);
  color: var(--t1); transform: translateY(-1px);
}

/* History */
.hist-list { display: flex; flex-direction: column; gap: 2px; }
.hist-item {
  padding: 7px 9px; border-radius: 8px; font-size: 11.5px; color: var(--t2);
  cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 6px;
  transition: all var(--transition);
}
.hist-item:hover { background: var(--bg3); color: var(--t1); }
.hist-item svg { width: 12px; height: 12px; flex-shrink: 0; color: var(--t3); }
.empty-note { font-size: 11px; color: var(--t3); padding: 5px 2px; font-style: italic; }

/* Sidebar footer */
.sb-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: linear-gradient(0deg, rgba(99,102,241,.05) 0%, transparent 100%);
}
.fca-badge {
  display: flex; align-items: center; gap: 5px;
  font-size: 10px; color: var(--a3); font-weight: 600;
  background: rgba(99,102,241,.1); border: 1px solid rgba(99,102,241,.2);
  border-radius: 6px; padding: 4px 8px; margin-bottom: 5px;
}
.fca-badge svg { width: 10px; height: 10px; }
.ver-tag { font-size: 9.5px; color: var(--t3); }

/* ── Deadline Ticker ──────────────────────────────────────── */
.deadline-ticker {
  background: linear-gradient(135deg, rgba(245,158,11,.08) 0%, rgba(239,68,68,.05) 100%);
  border: 1px solid rgba(245,158,11,.2);
  border-radius: 10px; padding: 8px 10px;
  margin-bottom: 4px;
}
.ticker-label {
  font-size: 9px; font-weight: 700; color: var(--orange);
  text-transform: uppercase; letter-spacing: .8px;
  display: flex; align-items: center; gap: 4px; margin-bottom: 5px;
}
.ticker-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,.04);
}
.ticker-item:last-child { border-bottom: none; }
.ticker-name { font-size: 10.5px; color: var(--t2); }
.ticker-days {
  font-size: 10px; font-weight: 700; font-family: 'JetBrains Mono', monospace;
  padding: 2px 6px; border-radius: 4px;
}
.days-urgent { background: rgba(239,68,68,.15); color: var(--red2); }
.days-soon   { background: rgba(245,158,11,.15); color: var(--orange2); }
.days-ok     { background: rgba(16,185,129,.12); color: var(--green2); }

/* ══════════════════════════════════════════════════════════════
   MAIN AREA
══════════════════════════════════════════════════════════════ */
.main { flex: 1; display: flex; flex-direction: column; height: 100vh; overflow: hidden; min-width: 0; }

/* Topbar */
.topbar {
  height: var(--th); display: flex; align-items: center;
  padding: 0 16px; gap: 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg1); flex-shrink: 0;
  position: relative; z-index: 10;
}
.topbar::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--a1), transparent);
  opacity: .3;
}

.tb-brand { flex: 1; }
.tb-name {
  display: block; font-size: 17px; font-weight: 800; line-height: 1;
  background: var(--ag); -webkit-background-clip: text;
  -webkit-text-fill-color: transparent; background-clip: text;
}
.tb-sub { display: block; font-size: 10px; color: var(--t3); margin-top: 1px; }

.tb-actions { display: flex; align-items: center; gap: 6px; }

.fca-pill {
  display: flex; align-items: center; gap: 5px;
  background: linear-gradient(135deg, rgba(251,191,36,.12), rgba(245,158,11,.08));
  border: 1px solid rgba(251,191,36,.25);
  border-radius: 7px; padding: 4px 10px;
  font-size: 11px; font-weight: 700; color: var(--gold);
}
.fca-pill svg { width: 12px; height: 12px; }

.stop-btn {
  display: flex; align-items: center; gap: 5px;
  background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.3);
  border-radius: 8px; padding: 5px 11px;
  color: var(--red2); font-size: 12px; font-weight: 600;
  font-family: inherit; cursor: pointer;
  transition: all var(--transition);
}
.stop-btn:hover { background: rgba(239,68,68,.18); border-color: rgba(239,68,68,.5); }
.stop-btn svg { width: 13px; height: 13px; }

/* ── Chat Window ──────────────────────────────────────────── */
.chat-win { flex: 1; overflow-y: auto; scroll-behavior: smooth; }

/* ── Welcome Screen ───────────────────────────────────────── */
.welcome {
  display: flex; flex-direction: column; align-items: center;
  padding: 40px 24px 24px; text-align: center;
  position: relative; overflow: hidden;
  animation: fadeUp .5s ease;
}

.wlc-glow {
  position: absolute; top: -100px; left: 50%; transform: translateX(-50%);
  width: 500px; height: 400px; pointer-events: none;
  background: radial-gradient(ellipse, rgba(27, 54, 93, 0.05) 0%, transparent 65%);
}

.wlc-avatar {
  width: 64px; height: 64px; border-radius: 8px;
  background: var(--ag);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 24px; font-weight: 900;
  box-shadow: var(--shx);
  margin-bottom: 20px;
  position: relative; z-index: 1;
}
.wlc-avatar::after {
  content: '';
}

.wlc-h1 {
  font-size: 32px; font-weight: 900; letter-spacing: -.5px;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--t1) 30%, var(--a3) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  position: relative; z-index: 1;
}

.wlc-p1 { font-size: 15px; color: var(--t2); margin-bottom: 6px; position: relative; z-index: 1; }
.wlc-p1 strong { color: var(--a3); }
.wlc-p2 { font-size: 12.5px; color: var(--t3); line-height: 1.8; margin-bottom: 28px; position: relative; z-index: 1; }

/* Feature grid */
.feat-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; max-width: 680px; width: 100%; margin-bottom: 20px;
  position: relative; z-index: 1;
}
.feat {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 8px; padding: 16px 14px; text-align: left;
  transition: all var(--transition); cursor: pointer;
  position: relative; overflow: hidden;
}
.feat::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--a1), transparent);
  opacity: 0; transition: opacity var(--transition);
}
.feat:hover::before { opacity: 1; }
.feat:hover {
  border-color: var(--a1); background: var(--bg3);
  transform: translateY(-1px); box-shadow: var(--sha);
}
.feat-icon { font-size: 22px; display: block; margin-bottom: 8px; }
.feat b { font-size: 12px; font-weight: 700; display: block; margin-bottom: 4px; color: var(--t1); }
.feat p { font-size: 11px; color: var(--t3); line-height: 1.5; }

.wlc-hint { font-size: 12px; color: var(--t3); position: relative; z-index: 1; }

/* Ollama notice */
.ollama-notice {
  background: linear-gradient(135deg, rgba(245,158,11,.1), rgba(239,68,68,.05));
  border: 1px solid rgba(245,158,11,.25);
  border-radius: 14px; padding: 16px;
  max-width: 480px; width: 100%; text-align: left;
  margin-bottom: 16px; position: relative; z-index: 1;
}
.ollama-notice h4 { font-size: 13px; font-weight: 700; color: var(--orange); margin-bottom: 6px; }
.ollama-notice p { font-size: 12px; color: var(--t2); line-height: 1.7; }
.ollama-notice ol { padding-left: 18px; margin-top: 8px; }
.ollama-notice li { font-size: 11.5px; color: var(--t2); margin-bottom: 4px; }
.ollama-notice code { font-family: 'JetBrains Mono', monospace; background: rgba(0,0,0,.3); border: 1px solid var(--border); padding: 1px 5px; border-radius: 4px; font-size: 11px; color: var(--a3); }

/* ── Messages ─────────────────────────────────────────────── */
.msgs {
  padding: 20px 20px 8px; display: flex; flex-direction: column;
  gap: 18px; max-width: 860px; margin: 0 auto; width: 100%;
}

.msg { display: flex; gap: 11px; align-items: flex-start; animation: fadeUp .22s ease; }
.msg.user { flex-direction: row-reverse; }

.av {
  width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; flex-shrink: 0;
}
.av.ai {
  background: var(--ag); color: #fff; font-size: 11px; letter-spacing: -.5px;
  box-shadow: 0 3px 10px rgba(99,102,241,.35);
}
.av.usr { background: var(--bg4); border: 1px solid var(--border); color: var(--t2); font-size: 16px; }

.msg-body { flex: 1; max-width: calc(100% - 45px); }
.msg-meta {
  display: flex; align-items: center; gap: 7px;
  margin-bottom: 5px; font-size: 11px;
}
.msg.user .msg-meta { flex-direction: row-reverse; }
.msg-name { font-weight: 700; color: var(--a3); }
.msg.user .msg-name { color: var(--t3); }
.msg-time { color: var(--t3); }

.bubble {
  padding: 13px 17px; border-radius: 16px;
  font-size: 13.5px; line-height: 1.8; word-break: break-word;
}
.msg.user .bubble {
  background: var(--ag); color: #fff;
  border-radius: 16px 4px 16px 16px;
  box-shadow: 0 4px 16px rgba(99,102,241,.3);
}
.msg.ai .bubble {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 4px 16px 16px 16px; color: var(--t1);
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.bubble.err {
  background: rgba(239,68,68,.08) !important;
  border-color: rgba(239,68,68,.25) !important;
  color: var(--red2) !important;
}

/* Markdown in AI bubble */
.bubble h1,.bubble h2,.bubble h3 { font-weight: 700; color: var(--a3); margin: 14px 0 6px; line-height: 1.3; }
.bubble h1 { font-size: 16.5px; }
.bubble h2 { font-size: 15px; border-bottom: 1px solid var(--border); padding-bottom: 5px; }
.bubble h3 { font-size: 13.5px; }
.bubble p { margin: 6px 0; }
.bubble hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.bubble strong { font-weight: 700; color: var(--a4); }
.bubble em { color: var(--a3); font-style: italic; }
.bubble ul, .bubble ol { padding-left: 20px; margin: 7px 0; }
.bubble li { margin: 3px 0; }
.bubble blockquote {
  border-left: 3px solid var(--a1); padding: 8px 12px;
  color: var(--t2); margin: 10px 0; font-style: italic;
  background: rgba(99,102,241,.06); border-radius: 0 8px 8px 0;
}
.bubble code {
  font-family: 'JetBrains Mono', monospace;
  background: rgba(99,102,241,.12); border: 1px solid rgba(99,102,241,.2);
  padding: 2px 6px; border-radius: 5px; font-size: 12px; color: var(--a3);
}
.bubble pre {
  background: var(--bg0); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px; overflow-x: auto; margin: 10px 0;
}
.bubble pre code { background: none; border: none; padding: 0; color: #c0c9e8; font-size: 12px; }

/* Tables */
.bubble table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 12.5px; border-radius: 9px; overflow: hidden; }
.bubble thead { background: rgba(99,102,241,.18); }
.bubble th { border: 1px solid var(--border); padding: 8px 12px; text-align: left; font-weight: 700; color: var(--a3); font-size: 11.5px; }
.bubble td { border: 1px solid var(--border2); padding: 7px 12px; color: var(--t1); }
.bubble tbody tr:nth-child(even) td { background: rgba(255,255,255,.02); }
.bubble tbody tr:hover td { background: rgba(99,102,241,.06); }

/* Message actions */
.msg-acts { display: flex; gap: 4px; margin-top: 7px; opacity: 0; transition: opacity var(--transition); }
.msg:hover .msg-acts { opacity: 1; }
.msg.user .msg-acts { justify-content: flex-end; }
.act-btn {
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: 6px; color: var(--t3);
  padding: 3px 9px; font-size: 11px; font-family: inherit;
  cursor: pointer; display: flex; align-items: center; gap: 4px;
  transition: all var(--transition);
}
.act-btn:hover { background: var(--bg4); color: var(--t1); border-color: var(--border); }
.act-btn svg { width: 10px; height: 10px; }

/* Typing dots */
.typing-dots { display: flex; gap: 4px; padding: 4px 0; }
.typing-dots span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--t3);
  animation: tdot 1.3s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }

/* Stream cursor */
.scursor {
  display: inline-block; width: 2px; height: 1.1em;
  background: var(--a1); margin-left: 2px; vertical-align: middle;
  border-radius: 1px; animation: blinkC 1s steps(1) infinite;
}

/* ══════════════════════════════════════════════════════════════
   INPUT BAR
══════════════════════════════════════════════════════════════ */
.inp-bar {
  padding: 10px 18px 14px;
  background: var(--bg1);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Horizontal chips row */
.chips-row {
  display: flex; gap: 6px; overflow-x: auto;
  padding-bottom: 8px; margin-bottom: 6px;
  scrollbar-width: none;
}
.chips-row::-webkit-scrollbar { display: none; }
.chip-h {
  flex-shrink: 0; padding: 5px 11px;
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: 99px; color: var(--t2);
  font-size: 11px; font-weight: 500; font-family: inherit;
  cursor: pointer; white-space: nowrap;
  transition: all var(--transition);
}
.chip-h:hover {
  background: var(--bg4); border-color: var(--border);
  color: var(--t1); transform: translateY(-1px);
}

/* File strip */
.file-strip {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 12px;
  background: rgba(99,102,241,.08);
  border: 1px solid var(--border);
  border-radius: 10px; margin-bottom: 8px;
  max-width: 860px; margin-left: auto; margin-right: auto;
}
.file-chip {
  display: flex; align-items: center; gap: 6px;
  background: rgba(99,102,241,.15); border: 1px solid rgba(99,102,241,.25);
  border-radius: 7px; padding: 4px 9px;
  font-size: 12px; color: var(--a3); flex: 1; min-width: 0;
}
.file-chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-chip svg { width: 12px; height: 12px; flex-shrink: 0; }
.file-ready { font-size: 11px; color: var(--green); font-weight: 600; display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.file-ready svg { width: 11px; height: 11px; }
.file-rm {
  background: none; border: none; color: var(--t3); cursor: pointer;
  padding: 2px; border-radius: 5px; transition: color var(--transition); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.file-rm:hover { color: var(--red); }
.file-rm svg { width: 12px; height: 12px; }

/* Input row */
.inp-row { display: flex; align-items: flex-end; gap: 8px; max-width: 860px; margin: 0 auto; }

.upload-btn {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--bg3); border: 1px solid var(--border2);
  color: var(--t2); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all var(--transition);
}
.upload-btn:hover { background: var(--aglow2); border-color: var(--border); color: var(--a3); }
.upload-btn svg { width: 16px; height: 16px; }

.inp-box-wrap {
  flex: 1; display: flex; align-items: flex-end; gap: 8px;
  background: var(--bg3); border: 1.5px solid var(--border2);
  border-radius: 14px; padding: 9px 12px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.inp-box-wrap:focus-within { border-color: var(--a1); box-shadow: 0 0 0 3px var(--aglow); }
.inp-box {
  flex: 1; background: none; border: none; outline: none; color: var(--t1);
  font-size: 13.5px; font-family: inherit; line-height: 1.6; resize: none;
  max-height: 150px; overflow-y: auto; padding: 0;
}
.inp-box::placeholder { color: var(--t3); }

.send-btn {
  width: 36px; height: 36px; border-radius: 10px; border: none;
  background: var(--ag); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all var(--transition);
  box-shadow: 0 2px 10px rgba(99,102,241,.35);
}
.send-btn:disabled { background: var(--bg5); color: var(--t3); box-shadow: none; cursor: not-allowed; }
.send-btn:not(:disabled):hover { transform: scale(1.08); box-shadow: 0 4px 16px rgba(99,102,241,.5); }
.send-btn svg { width: 15px; height: 15px; }

.inp-note {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  font-size: 10px; color: var(--t3); margin-top: 7px;
  max-width: 860px; margin-left: auto; margin-right: auto;
}

/* ══════════════════════════════════════════════════════════════
   UPLOAD OVERLAY
══════════════════════════════════════════════════════════════ */
.upload-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.75);
  z-index: 999; display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px);
}
.upload-spinner-box {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 20px; padding: 32px 44px; text-align: center;
  box-shadow: var(--shx); animation: bounceIn .3s ease;
}
.spinner {
  width: 44px; height: 44px; border: 3px solid var(--bg5);
  border-top-color: var(--a1); border-radius: 50%;
  animation: spin .8s linear infinite; margin: 0 auto 14px;
}
.upload-spinner-box p { font-size: 13px; color: var(--t2); margin-top: 2px; }
.upload-spinner-box small { font-size: 11px; color: var(--t3); }

/* ══════════════════════════════════════════════════════════════
   TOAST
══════════════════════════════════════════════════════════════ */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(60px);
  background: var(--bg4); border: 1px solid var(--border);
  border-radius: 11px; padding: 10px 18px;
  font-size: 13px; color: var(--t1); z-index: 1000;
  opacity: 0; transition: transform .28s cubic-bezier(.34,1.56,.64,1), opacity .28s ease;
  box-shadow: var(--sh); pointer-events: none; white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ══════════════════════════════════════════════════════════════
   MOBILE OVERLAY
══════════════════════════════════════════════════════════════ */
.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 150; backdrop-filter: blur(4px); }
.overlay.open { display: block; }

/* ══════════════════════════════════════════════════════════════
   TAX CALCULATOR MODAL
══════════════════════════════════════════════════════════════ */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.8);
  z-index: 500; display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(8px); animation: fadeIn .2s ease;
}
.modal {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 20px; padding: 28px; width: 480px; max-width: 95vw;
  box-shadow: var(--shx); animation: bounceIn .3s ease;
  max-height: 90vh; overflow-y: auto;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.modal-title { font-size: 16px; font-weight: 800; color: var(--t1); }
.modal-close {
  background: var(--bg3); border: 1px solid var(--border2); border-radius: 8px;
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--t2); transition: all var(--transition);
}
.modal-close:hover { background: var(--bg4); color: var(--t1); }
.modal-close svg { width: 14px; height: 14px; }

.calc-group { margin-bottom: 14px; }
.calc-label { font-size: 11px; font-weight: 600; color: var(--t2); margin-bottom: 5px; display: block; }
.calc-input {
  width: 100%; background: var(--bg3); border: 1px solid var(--border2);
  border-radius: 9px; color: var(--t1); padding: 8px 12px;
  font-size: 13px; font-family: inherit; outline: none;
  transition: border-color var(--transition);
}
.calc-input:focus { border-color: var(--a1); box-shadow: 0 0 0 2px var(--aglow); }
.calc-select {
  width: 100%; background: var(--bg3); border: 1px solid var(--border2);
  border-radius: 9px; color: var(--t1); padding: 8px 12px;
  font-size: 13px; font-family: inherit; outline: none; cursor: pointer;
  transition: border-color var(--transition);
}
.calc-select:focus { border-color: var(--a1); }
.calc-select option { background: var(--bg2); }

.calc-btn {
  width: 100%; padding: 10px; background: var(--ag);
  border: none; border-radius: 10px; color: #fff;
  font-size: 14px; font-weight: 700; font-family: inherit; cursor: pointer;
  box-shadow: 0 4px 16px rgba(99,102,241,.35); transition: all var(--transition);
}
.calc-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(99,102,241,.45); }

.calc-result {
  margin-top: 16px; background: var(--bg3);
  border: 1px solid var(--border); border-radius: 12px; padding: 16px;
}
.calc-result h4 { font-size: 12px; font-weight: 700; color: var(--a3); margin-bottom: 12px; text-transform: uppercase; letter-spacing: .5px; }
.calc-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 0; border-bottom: 1px solid var(--border2); font-size: 12px;
}
.calc-row:last-child { border-bottom: none; }
.calc-row.total { font-weight: 700; color: var(--t1); font-size: 13px; padding-top: 8px; }
.calc-row.highlight { color: var(--green); }
.calc-row span:last-child { font-family: 'JetBrains Mono', monospace; font-weight: 600; }

/* ══════════════════════════════════════════════════════════════
   KEYBOARD SHORTCUT TOOLTIP
══════════════════════════════════════════════════════════════ */
kbd {
  display: inline-block; padding: 2px 6px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 5px; font-size: 10px; font-family: 'JetBrains Mono', monospace;
  color: var(--t2);
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════════ */
@media (max-width: 800px) {
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    transform: translateX(-100%); transition: transform var(--transition);
    z-index: 200;
  }
  .sidebar.open { transform: translateX(0); }
  .mob-only { display: flex !important; }
  .feat-grid { grid-template-columns: repeat(2, 1fr); }
  .msgs { padding: 14px; }
  .inp-bar { padding: 8px 12px 12px; }
  .chips-row { padding-bottom: 6px; margin-bottom: 4px; }
}

@media (max-width: 500px) {
  .feat-grid { grid-template-columns: 1fr; }
  .wlc-h1 { font-size: 24px; }
  .chips { grid-template-columns: 1fr 1fr; }
  .fca-pill { display: none; }
}

/* Chartered Authority Theme Overrides */
.ai-md table {
  font-family: 'JetBrains Mono', 'Inter', monospace;
  font-size: 13px;
}
.ai-md tr:hover td {
  background: rgba(197, 160, 89, 0.1); /* faint Gold tint on hover */
}
.send-btn {
  background: var(--a1);
  color: var(--t4);
}
.send-btn:hover:not(:disabled) {
  background: var(--a2);
  box-shadow: var(--sha);
}
.msg.user .bubble {
  background: var(--a3); /* primary-fixed */
  color: var(--t1); /* on-surface */
  border: 1px solid var(--border);
}
.msg.ai .bubble {
  background: var(--bg2); /* White card */
  border: 1px solid var(--border);
  box-shadow: var(--sh);
}

/* Calculator Tabs */
.calc-tabs {
  display: flex; gap: 8px; margin-bottom: 16px;
  border-bottom: 1px solid var(--border2);
  padding-bottom: 8px;
}
.calc-tab {
  background: none; border: none; color: var(--t3);
  font-size: 13px; font-weight: 600; font-family: inherit;
  padding: 6px 12px; cursor: pointer; border-radius: 4px;
  transition: all var(--transition);
}
.calc-tab:hover { background: var(--bg3); color: var(--t2); }
.calc-tab.active {
  background: var(--a3); color: var(--a1);
  box-shadow: inset 0 0 0 1px rgba(0,32,70,.1);
}

/* ══════════════════════════════════════════════════════════════
   SPLASH SCREEN
══════════════════════════════════════════════════════════════ */
.splash-screen {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  background: var(--bg0); z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.6s;
}
.splash-screen.hidden { opacity: 0; visibility: hidden; }

.splash-content {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; animation: fadeUp 0.8s ease-out;
}

.splash-logo {
  width: 72px; height: 72px; border-radius: 8px;
  background: var(--a1); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 900; letter-spacing: -1px;
  box-shadow: 0 10px 30px rgba(27, 54, 93, 0.15);
  margin-bottom: 24px; position: relative;
}
.splash-logo::after {
  content: ''; position: absolute; inset: -4px;
  border-radius: 12px; border: 2px solid var(--a3);
  opacity: 0.5; animation: pulse 2s infinite;
}

.splash-title {
  font-size: 32px; font-weight: 800; color: var(--a1);
  letter-spacing: -0.5px; line-height: 1.2;
}

.splash-subtitle {
  font-size: 14px; font-weight: 600; color: var(--gold);
  text-transform: uppercase; letter-spacing: 1px;
  margin-bottom: 32px;
}

.splash-loader {
  width: 240px; height: 4px; background: var(--border2);
  border-radius: 4px; overflow: hidden; position: relative;
  margin-bottom: 12px;
}
.splash-loader::after {
  content: ''; position: absolute; left: 0; top: 0; height: 100%;
  width: 30%; background: var(--a1); border-radius: 4px;
  animation: shimmer 1.5s infinite ease-in-out;
}

.splash-status {
  font-size: 12px; font-weight: 500; color: var(--t3);
  font-family: 'JetBrains Mono', monospace;
}

@keyframes fadeUp {
  0% { opacity: 0; transform: translateY(20px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.15); opacity: 0; }
  100% { transform: scale(1); opacity: 0; }
}

@keyframes shimmer {
  0% { left: -30%; }
  100% { left: 100%; }
}
