* { box-sizing: border-box; }
:root {
  --bg: #0f172a; --panel: #111827; --bot: #1e293b; --user: #2563eb;
  --text: #e5e7eb; --muted: #94a3b8; --line: #1f2937; --accent: #38bdf8;
  --navbar:#9c0909;
}
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, Segoe UI, Roboto, "Noto Sans", sans-serif;
  background: var(--bg); color: var(--text);
}
.app { width: 100%; max-width: 100%; margin: 0; height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 16px; border-bottom: 1px solid var(--line); background:radial-gradient(circle,rgba(238, 174, 202, 1) 0%, rgba(148, 187, 233, 1) 100%);
  color:#040404;
}
.brand { font-weight: 700; letter-spacing: .3px; display:flex; align-items: center;}
.meta { display: flex; gap: 8px; align-items: center; }
.user {
  width: 110px; background: #0b1220; color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 13px;
}
.ghost {
  background: transparent; color:#040404; border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 13px;
}
.ghost:hover { color: var(--text); border-color: var(--accent); }
.ghost.danger:hover { color: #fca5a5; border-color: #f87171; }

.log { flex: 1; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 12px; }
.msg { display: flex; max-width: 100%; }
.msg.user { justify-content: flex-end; }
.msg.bot { justify-content: flex-start; }
.bubble {
  padding: 10px 14px; border-radius: 14px; line-height: 1.5;
  word-wrap: break-word; overflow-wrap: break-word; font-size: 15px;
}
/* user (input) bubbles: right-aligned, cap at 60vw but shrink to fit shorter
   messages (content-sized, not a fixed width). */
.msg.user { width: 100%; background:  transparent; border:none}
.msg.user .bubble { max-width: 60vw; width: fit-content; white-space: pre-wrap; }
/* bot bubbles render markdown -> wide, so tables have room */
.msg.bot .bubble { max-width: 96%; position: relative; }
.msg.bot .bubble { background: var(--bot); border-top-left-radius: 4px; }
/* bubbles carrying a chart or a report table should use the full width so the
   graph/table isn't shrunk to the text width */
.msg.bot .bubble.has-chart,
.msg.bot .bubble.has-report { width: 96%; max-width: 96%; }

/* token-usage badge at the top of a bot answer */
.usage-badge {
  display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap;
}
.usage-badge .tok {
  font-size: 11px; line-height: 1; color: var(--muted);
  background: #0b1220; border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.usage-badge .tok-in { color: #7dd3fc; }
.usage-badge .tok-out { color: #86efac; }
.usage-badge .tok-cost { color: #fcd34d; border-color: #7c5e12; }
/* keep the badge clear of the hover toolbar (top-right) */
.bubble.md.has-copy .usage-badge { padding-right: 150px; }

/* bubble toolbar (Copy + Screenshot), side by side, top-right on hover */
.bubble-tools {
  position: absolute; top: 8px; right: 8px;
  display: flex; gap: 6px;
  opacity: 0; transition: opacity .15s;
}
.msg.bot .bubble:hover .bubble-tools,
.bubble-tools:focus-within { opacity: 1; }
.tool-btn {
  background: rgba(15,23,42,0.85); color: var(--muted);
  border: 1px solid var(--line); border-radius: 7px;
  padding: 3px 9px; font-size: 12px; cursor: pointer;
  transition: color .15s, border-color .15s;
}
.tool-btn:hover { color: var(--text); border-color: var(--accent); }
.tool-btn.copied { color: #34d399; border-color: #34d399; }
/* keep first line of text clear of the toolbar */
.bubble.md.has-copy { padding-top: 30px; }

/* default per-table download buttons (frontend-built CSV/PDF) */
.table-dl { display: flex; gap: 8px; margin: 4px 0 12px; }
.dl-sm { margin-top: 0; padding: 5px 12px; font-size: 12px; }
.msg.user .bubble { background: var(--user); color: white; border-top-right-radius: 4px; }
.thinking { color: var(--muted); font-style: italic; display: flex; align-items: center; gap: 8px; }

/* small working spinner (Claude-style) shown while tools run */
.spinner {
  width: 13px; height: 13px; flex: 0 0 auto;
  border: 2px solid rgba(148,163,184,0.35);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- rendered markdown inside bot bubbles ---- */
.bubble.md > *:first-child { margin-top: 0; }
.bubble.md > *:last-child { margin-bottom: 0; }
.bubble.md p { margin: 6px 0; }
.bubble.md h3, .bubble.md h4, .bubble.md h5, .bubble.md h6 {
  margin: 12px 0 6px; line-height: 1.3; font-weight: 700;
}
.bubble.md h3 { font-size: 17px; }
.bubble.md h4 { font-size: 15px; }
.bubble.md ul, .bubble.md ol { margin: 6px 0; padding-left: 22px; }
.bubble.md li { margin: 3px 0; }
.bubble.md strong { font-weight: 700; color: #fff; }
.bubble.md code {
  background: #0b1220; border: 1px solid var(--line); border-radius: 5px;
  padding: 1px 5px; font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.bubble.md a { color: var(--accent); }

/* tables: clean, striped, horizontally scrollable if wide */
.bubble.md .table-wrap {
  overflow-x: auto; margin: 10px 0; border-radius: 10px; border: 1px solid var(--line);
  -webkit-overflow-scrolling: touch;   /* momentum scroll on touch devices */
}
/* min-width:100% fills narrow tables but lets wide ones overflow → scroll */
.bubble.md table { border-collapse: collapse; min-width: 100%; font-size: 14px; }
.bubble.md thead th {
  background: #0b1220; color: var(--text); text-align: left; font-weight: 700;
  padding: 9px 12px; white-space: nowrap; border-bottom: 1px solid var(--line);
}
.bubble.md tbody td {
  padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.bubble.md tbody tr:nth-child(even) { background: rgba(255,255,255,0.03); }
.bubble.md tbody tr:last-child td { border-bottom: none; }
/* right-align numeric-looking columns for readability */
.bubble.md td, .bubble.md th { vertical-align: top; }

.composer { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--panel); }
.input {
  flex: 1; background: #0b1220; color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px; font-size: 15px; outline: none;
}
.input:focus { border-color: var(--accent); }
.send {
  background: var(--accent); color: #04283a; border: none; border-radius: 10px;
  padding: 0 18px; font-weight: 700; cursor: pointer; font-size: 15px;
}
.send:disabled { opacity: .5; cursor: default; }

/* login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card {
  width: 320px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 28px 24px; display: flex; flex-direction: column; gap: 12px;
}
.login-brand { font-size: 20px; font-weight: 700; text-align: center; }
.login-sub { color: var(--muted); font-size: 13px; text-align: center; margin-bottom: 6px; }
.login-btn { padding: 12px; margin-top: 4px; }
.login-error { color: #f87171; font-size: 13px; min-height: 16px; text-align: center; }
.who { color: #040404; font-size: 13px; }

/* remaining prepaid balance chip in the topbar */
.balance-chip {
  font-size: 12px; font-weight: 700; color: #0a7a3f;
  background: #eafff2; border: 1px solid #b7e6cb;
  border-radius: 999px; padding: 4px 10px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
.balance-chip:empty { display: none; }
.balance-chip.low { color: #8a6d00; background: #fff8e0; border-color: #e6d38a; }
.balance-chip.zero { color: #b91c1c; background: #ffecec; border-color: #e6b7b7; }

/* ---- topic bar ---- */
.topics { display: flex; align-items: center; gap: 8px; flex: 1; justify-content: center; }
.topic-lbl { color: #040404;; font-size: 12px; }
.topic-select {
  background: #0b1220; color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 8px; font-size: 13px; max-width: 260px;
}
.topic-select:focus { border-color: var(--accent); outline: none; }

/* ---- download button (report / chart PNG) ---- */
.dl-btn {
  margin-top: 10px; display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent); color: #04283a; border: none; border-radius: 9px;
  padding: 8px 14px; font-size: 13px; font-weight: 700; cursor: pointer;
}
.dl-btn:hover { filter: brightness(1.08); }
.dl-btn + .dl-btn { margin-left: 8px; }

/* ---- chart ---- */
.chart-wrap {
  margin-top: 10px; width: 100%; max-width: 100%; overflow-x: auto;
  background: #0b1220; border: 1px solid var(--line); border-radius: 10px; padding: 8px;
}
.chart-wrap canvas { display: block; max-width: 100%; }

/* small-screen: stack the topbar so the topic bar doesn't crowd out the brand */
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 8px; }
  .topics { order: 3; flex-basis: 100%; justify-content: flex-start; }
  .topic-select { flex: 1; max-width: none; }
}
@media screen and (min-width: 640px){
    ::-webkit-scrollbar {
      width: 5px;
      height:5px;
    }
    /* Track */
    ::-webkit-scrollbar-track {
      background: var(--bot);
      border:1px solid var(--bot);
      box-shadow: inset 0 0 2px #ccc;
      cursor: grab;
    }
}
/* Handle */
::-webkit-scrollbar-thumb {
  background: var(--navbar);;/* #888; */ 
  cursor: grab;
}

/* Handle on hover */
::-webkit-scrollbar-thumb:hover {
  background:#666666;
  cursor: grab;
}
.logo{
  display: inline-block;
  max-height:50px;
  padding: 3px 5px;
  border:1px solid white;
  border-radius: 9px;
  margin:0px 10px;
  background-color: #ebebed;
}
.logoimage{
  max-height:40px;
}