/* ===========================================================================
   GoGuru admin dashboard — dark bento theme

   Colour discipline (validated with the dataviz palette validator against
   the #16151d surface):
     • DATA MARKS carry meaning -> one hue only (--data). A per-tutor bar
       chart is magnitude of a single measure, so every bar is the same
       colour; ramping bar colour by size would double-encode length.
     • STATUS colours are reserved and always ship with a text label, never
       colour alone (their CVD separation sits at the floor).
     • GRADIENTS encode nothing — they're atmosphere — so they stay bright
       and playful per the reference kit.
   =========================================================================== */

:root {
  /* surfaces */
  --bg: #121118;
  --surface: #16151d;
  --card: #1e1d28;
  --card-2: #24222f;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.13);

  /* ink */
  --ink: #f4f3ff;
  --ink-2: #9c99b8;
  --ink-3: #6e6b87;

  /* meaning-carrying */
  --data: #8b7fff;
  --good: #22a97e;
  --alert: #e04545;

  /* decorative only */
  --violet: #8b7fff;
  --pink: #e86eb5;
  --blue: #5baaff;
  --amber: #ffd166;

  --grad-hero: linear-gradient(135deg, #7b6eea 0%, #a86ae0 45%, #e86eb5 100%);
  --grad-cool: linear-gradient(135deg, #5baaff 0%, #7b6eea 100%);
  --grad-warm: linear-gradient(135deg, #e86eb5 0%, #ffa26b 100%);

  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 10px;

  --shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.85);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
button { font: inherit; color: inherit; }

/* ambient background glow — pure decoration */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(680px 420px at 12% -8%, rgba(123, 110, 234, 0.20), transparent 70%),
    radial-gradient(560px 380px at 92% 4%, rgba(232, 110, 181, 0.13), transparent 70%),
    radial-gradient(700px 500px at 60% 110%, rgba(91, 170, 255, 0.10), transparent 70%);
}

/* ===========================  LOGIN  ==================================== */

.login-wrap {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: linear-gradient(180deg, rgba(36, 34, 47, 0.96), rgba(24, 23, 33, 0.96));
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  padding: 34px 30px;
  box-shadow: var(--shadow);
  animation: rise 0.6s var(--ease) both;
}

.login-mark {
  width: 54px;
  height: 54px;
  border-radius: 17px;
  background: var(--grad-hero);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.02em;
  margin-bottom: 18px;
  box-shadow: 0 10px 26px -8px rgba(123, 110, 234, 0.75);
}

.login-card h1 { margin: 0 0 4px; font-size: 23px; letter-spacing: -0.02em; }
.login-card .sub { margin: 0 0 22px; color: var(--ink-2); font-size: 13.5px; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-3);
  margin-bottom: 7px;
  font-weight: 600;
}
/* The security question is a sentence, not a field name — the uppercase
   micro-label treatment makes it read as shouting and hurts legibility. */
.field label.question {
  text-transform: none;
  letter-spacing: 0;
  font-size: 14px;
  color: var(--ink);
  font-weight: 600;
  margin-bottom: 9px;
}

.field input {
  width: 100%;
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 12px 13px;
  color: var(--ink);
  font-size: 15px;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.field input:focus {
  outline: none;
  border-color: var(--data);
  box-shadow: 0 0 0 3px rgba(139, 127, 255, 0.22);
}

.btn-primary {
  width: 100%;
  margin-top: 8px;
  border: 0;
  border-radius: var(--r-sm);
  padding: 13px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  background: var(--grad-hero);
  color: #fff;
  transition: transform 0.16s var(--ease), filter 0.16s, box-shadow 0.16s;
  box-shadow: 0 10px 24px -10px rgba(123, 110, 234, 0.9);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.07); }
.btn-primary:active:not(:disabled) { transform: translateY(0) scale(0.99); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }

.form-error {
  margin-top: 13px;
  background: rgba(224, 69, 69, 0.13);
  border: 1px solid rgba(224, 69, 69, 0.4);
  color: #ff9b9b;
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font-size: 13px;
  animation: shake 0.4s;
}
.form-error[hidden] { display: none; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* ===========================  SHELL  ==================================== */

.shell { position: relative; z-index: 1; display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex: 0 0 220px;
  padding: 22px 14px;
  border-right: 1px solid var(--line);
  background: rgba(18, 17, 24, 0.72);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 8px 20px;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.02em;
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: var(--grad-hero);
  display: grid;
  place-items: center;
  font-size: 15px;
  box-shadow: 0 8px 18px -8px rgba(123, 110, 234, 0.85);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 11px;
  color: var(--ink-2);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  background: none;
  width: 100%;
  text-align: left;
  transition: background 0.16s, color 0.16s, transform 0.16s var(--ease);
}
.nav-link:hover { background: rgba(255, 255, 255, 0.05); color: var(--ink); transform: translateX(2px); }
.nav-link.active {
  background: linear-gradient(135deg, rgba(123, 110, 234, 0.26), rgba(232, 110, 181, 0.14));
  border-color: rgba(139, 127, 255, 0.42);
  color: var(--ink);
}
.nav-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: 0.65; }

.sidebar-foot { margin-top: auto; font-size: 11.5px; color: var(--ink-3); padding: 10px 12px; line-height: 1.6; }

.main { flex: 1; min-width: 0; padding: 24px 28px 60px; }

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.topbar h1 { margin: 0; font-size: 27px; letter-spacing: -0.03em; }
.topbar .greet { color: var(--ink-2); font-size: 13.5px; margin-top: 3px; }
.topbar-spacer { flex: 1; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 12.5px;
  color: var(--ink-2);
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px rgba(34, 169, 126, 0.2); }
.pill .dot.stale { background: var(--amber); box-shadow: 0 0 0 3px rgba(255, 209, 102, 0.18); }

.btn-refresh {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: var(--grad-hero);
  border: 0;
  border-radius: 999px;
  padding: 10px 20px;
  font-weight: 650;
  font-size: 13.5px;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 24px -12px rgba(123, 110, 234, 0.95);
  transition: transform 0.16s var(--ease), filter 0.16s;
}
.btn-refresh:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.08); }
.btn-refresh:disabled { opacity: 0.6; cursor: progress; }
.btn-refresh .spin { display: inline-block; }
.btn-refresh.busy .spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===========================  BENTO GRID  =============================== */

.bento {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
  transition: opacity 0.25s;
}
/* Anti-pattern guard: never flash skeletons on refetch — hold the previous
   render at reduced opacity so nothing jumps. */
.bento.is-refreshing { opacity: 0.55; }

.card {
  position: relative;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  animation: rise 0.55s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 45ms);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

/* refresh pulse — a soft ring that expands once when new data lands */
.card.pulse::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1.5px solid rgba(139, 127, 255, 0.75);
  animation: pulsering 0.85s var(--ease) forwards;
  pointer-events: none;
}
@keyframes pulsering {
  0% { opacity: 0.9; transform: scale(0.985); }
  100% { opacity: 0; transform: scale(1.012); }
}

.card.grad { background: var(--grad-hero); border-color: transparent; }
.card.grad .card-label,
.card.grad .stat-sub { color: rgba(255, 255, 255, 0.82); }
.card.grad .stat-num { color: #fff; }

.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-3);
  font-weight: 700;
}
.card-head .spacer { flex: 1; }

/* column spans */
.c3 { grid-column: span 3; }
.c4 { grid-column: span 4; }
.c5 { grid-column: span 5; }
.c6 { grid-column: span 6; }
.c7 { grid-column: span 7; }
.c8 { grid-column: span 8; }
.c12 { grid-column: span 12; }

/* ===========================  STAT TILES  =============================== */

/* Proportional figures on display-size numbers — tabular-nums makes large
   numerals look loose. Tabular is reserved for table columns below. */
.stat-num {
  font-size: 48px;
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1;
  font-variant-numeric: proportional-nums;
}
.stat-num.sm { font-size: 34px; }
.stat-sub { color: var(--ink-2); font-size: 13px; margin-top: 9px; }

.split { display: flex; gap: 18px; margin-top: 14px; }
.split-item .k { font-size: 21px; font-weight: 750; letter-spacing: -0.02em; }
.split-item .v { font-size: 11.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.07em; margin-top: 2px; }

/* goal ring */
.ring-wrap { display: flex; align-items: center; gap: 18px; }
.ring { position: relative; width: 96px; height: 96px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring .ring-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

/* ===========================  BARS / CHARTS  ============================ */

.bar-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
.bar-row:last-child { border-bottom: 0; }
.bar-name { font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; min-width: 0; }
.bar-name span.t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* numbers that align vertically DO get tabular figures */
.bar-vals { display: flex; gap: 14px; font-variant-numeric: tabular-nums; font-size: 13px; }
.bar-vals .v7 { font-weight: 750; color: var(--ink); min-width: 22px; text-align: right; }
.bar-vals .v30 { color: var(--ink-3); min-width: 28px; text-align: right; }

/* One measure -> one hue for every bar. The track is a recessive surface,
   not a second data series. */
.bar-track {
  grid-column: 1 / -1;
  height: 7px;
  background: rgba(255, 255, 255, 0.055);
  border-radius: 4px;
  overflow: hidden;
}
/* Width is set inline by the renderer (always correct). The grow-in is a
   CSS transform so it never depends on a JS frame firing — a paused
   rAF in a background tab can't leave a bar stuck at zero width. */
.bar-fill {
  height: 100%;
  background: var(--data);
  border-radius: 4px;
  transform-origin: left center;
  animation: barGrow 0.85s var(--ease) both;
}
@keyframes barGrow {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
/* Status always carries a word, never colour alone. */
.chip.good { background: rgba(34, 169, 126, 0.16); color: #4fd4a6; border: 1px solid rgba(34, 169, 126, 0.4); }
.chip.hot { background: rgba(224, 69, 69, 0.15); color: #ff8b8b; border: 1px solid rgba(224, 69, 69, 0.4); }
.chip.neutral { background: rgba(255, 255, 255, 0.06); color: var(--ink-2); border: 1px solid var(--line-strong); }
.chip.pitch { background: rgba(139, 127, 255, 0.17); color: #b7aeff; border: 1px solid rgba(139, 127, 255, 0.45); }

/* sparkline / mini bars */
.spark { width: 100%; height: 54px; display: block; }
.spark .line { fill: none; stroke: var(--data); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark .area { fill: url(#sparkfill); }
.spark .dot { fill: var(--data); }
.minibars { display: flex; align-items: flex-end; gap: 3px; height: 60px; }
.minibar {
  flex: 1;
  background: var(--data);
  border-radius: 4px 4px 0 0; /* rounded data-end, anchored to baseline */
  min-height: 3px;
  opacity: 0.85;
  transition: height 0.7s var(--ease), opacity 0.16s;
}
.minibar:hover { opacity: 1; }

/* ===========================  OUTREACH TAPS  ============================ */

.tap-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 12px; }

.tap {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: linear-gradient(160deg, var(--card-2), rgba(30, 29, 40, 0.6));
  border-radius: var(--r-md);
  padding: 15px 14px 13px;
  cursor: pointer;
  text-align: left;
  transition: transform 0.16s var(--ease), border-color 0.16s, box-shadow 0.16s;
}
.tap:hover { transform: translateY(-2px); border-color: rgba(139, 127, 255, 0.5); box-shadow: 0 14px 28px -18px rgba(123, 110, 234, 0.9); }
.tap:active { transform: translateY(0) scale(0.975); }
.tap .g {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  text-transform: uppercase;
}
.tap .today { font-size: 33px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; margin-top: 5px; }
.tap .meta { font-size: 11.5px; color: var(--ink-3); margin-top: 5px; font-variant-numeric: tabular-nums; }
.tap.bump { animation: bump 0.42s var(--ease); }
@keyframes bump {
  0% { transform: scale(1); }
  35% { transform: scale(1.06); }
  100% { transform: scale(1); }
}
/* ripple burst on tap */
.tap .ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(139, 127, 255, 0.42);
  transform: translate(-50%, -50%) scale(0);
  animation: ripple 0.55s ease-out forwards;
  pointer-events: none;
}
@keyframes ripple { to { transform: translate(-50%, -50%) scale(11); opacity: 0; } }

.undo {
  background: none;
  border: 1px solid var(--line-strong);
  color: var(--ink-3);
  border-radius: 7px;
  font-size: 11px;
  padding: 3px 8px;
  cursor: pointer;
  transition: color 0.16s, border-color 0.16s;
}
.undo:hover { color: var(--ink); border-color: var(--ink-3); }

/* ===========================  TABLES / LISTS  =========================== */

.rows { display: flex; flex-direction: column; }
.row {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}
.row:last-child { border-bottom: 0; }
.row .ico {
  width: 28px; height: 28px; border-radius: 9px; flex: none;
  display: grid; place-items: center; font-size: 13px;
  background: rgba(139, 127, 255, 0.15);
}
.row .body { flex: 1; min-width: 0; }
.row .t1 { font-weight: 600; }
.row .t2 { color: var(--ink-3); font-size: 12px; margin-top: 2px; }
.row .when { color: var(--ink-3); font-size: 11.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  font-weight: 700;
  padding: 0 10px 9px 0;
  border-bottom: 1px solid var(--line);
}
table.data td { padding: 9px 10px 9px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr:last-child td { border-bottom: 0; }

.scroll-y { max-height: 340px; overflow-y: auto; }
.scroll-y::-webkit-scrollbar { width: 7px; }
.scroll-y::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 4px; }

.empty { color: var(--ink-3); font-size: 13px; padding: 18px 0; text-align: center; }

.warn {
  background: rgba(255, 209, 102, 0.09);
  border: 1px solid rgba(255, 209, 102, 0.32);
  color: #ffd88a;
  border-radius: var(--r-sm);
  padding: 11px 13px;
  font-size: 12.5px;
  line-height: 1.55;
}

/* form inline (campaigns) */
.inline-form { display: grid; grid-template-columns: 1.4fr 0.8fr 0.7fr 1fr auto; gap: 9px; margin-bottom: 14px; }
.inline-form input {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 9px 11px;
  color: var(--ink);
  font-size: 13px;
  min-width: 0;
}
.inline-form input:focus { outline: none; border-color: var(--data); }
.btn-sm {
  background: var(--data);
  border: 0;
  border-radius: 9px;
  padding: 9px 15px;
  font-weight: 650;
  font-size: 13px;
  color: #fff;
  cursor: pointer;
  transition: filter 0.16s, transform 0.16s;
  white-space: nowrap;
}
.btn-sm:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-x {
  background: none; border: 0; color: var(--ink-3); cursor: pointer;
  font-size: 15px; padding: 2px 6px; border-radius: 6px;
}
.btn-x:hover { color: #ff8b8b; background: rgba(224, 69, 69, 0.12); }

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(90px);
  background: var(--card-2);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 11px 22px;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: transform 0.4s var(--ease), opacity 0.3s;
  z-index: 50;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ===========================  3D BLOBS  ================================= */
/* Pure decoration — soft shaded orbs and a torus, echoing the reference kit. */

.blob { position: absolute; pointer-events: none; z-index: 0; filter: blur(0.2px); }
.blob.orb {
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 26%, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0) 42%),
    radial-gradient(circle at 68% 76%, rgba(0, 0, 0, 0.34), rgba(0, 0, 0, 0) 55%),
    linear-gradient(150deg, var(--violet), var(--pink));
  box-shadow: 0 22px 44px -20px rgba(0, 0, 0, 0.8);
}
.blob.float { animation: floaty 7s ease-in-out infinite; }
.blob.float.slow { animation-duration: 10s; }
@keyframes floaty {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-13px) rotate(7deg); }
}
.card > .blob { opacity: 0.9; }

/* ===========================  ASSISTANT PANEL  ========================== */
/* Text-only chat. The gradient sits on the frame and the mark; message
   bodies stay on flat surfaces so nothing decorative sits behind text
   the user has to read carefully. */

.btn-ask {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 9px 17px;
  font-weight: 620;
  font-size: 13.5px;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.16s var(--ease), border-color 0.16s, background 0.16s;
}
.btn-ask:hover { transform: translateY(-1px); border-color: rgba(139, 127, 255, 0.6); background: var(--card-2); }
.btn-ask.is-off { opacity: 0.55; }
.ask-mark {
  background: var(--grad-hero);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 15px;
  line-height: 1;
}

.chat-scrim {
  position: fixed;
  inset: 0;
  background: rgba(8, 7, 12, 0.55);
  opacity: 0;
  transition: opacity 0.22s var(--ease);
  z-index: 60;
}
body.chat-open .chat-scrim { opacity: 1; }

.chat-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(430px, 100vw);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(30, 29, 40, 0.99), rgba(20, 19, 27, 0.99));
  border-left: 1px solid var(--line-strong);
  box-shadow: -30px 0 60px -30px rgba(0, 0, 0, 0.9);
  transform: translateX(100%);
  transition: transform 0.24s var(--ease);
  z-index: 61;
}
body.chat-open .chat-panel { transform: translateX(0); }

.chat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 14px 14px 18px;
  border-bottom: 1px solid var(--line);
}
.chat-title { display: flex; align-items: center; gap: 9px; font-weight: 680; font-size: 15px; margin-right: auto; }
.chat-icon {
  background: none;
  border: 0;
  color: var(--ink-3);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 6px 8px;
  border-radius: 8px;
  transition: color 0.16s, background 0.16s;
}
.chat-icon:hover { color: var(--ink); background: rgba(255, 255, 255, 0.07); }

.chat-log { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.chat-log::-webkit-scrollbar { width: 7px; }
.chat-log::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 4px; }

.chat-intro { color: var(--ink-2); font-size: 13px; line-height: 1.65; }
.chat-intro p { margin: 0 0 9px; }
.chat-intro strong { color: var(--ink); }
.chat-intro-mark {
  width: 38px; height: 38px; border-radius: 13px;
  background: var(--grad-hero);
  display: grid; place-items: center;
  font-size: 17px; margin-bottom: 13px;
  box-shadow: 0 10px 24px -10px rgba(123, 110, 234, 0.8);
}

.chat-msg {
  font-size: 13.5px;
  line-height: 1.62;
  border-radius: 14px;
  padding: 11px 14px;
  max-width: 92%;
  animation: rise 0.32s var(--ease) both;
  overflow-wrap: anywhere;
}
.chat-msg p { margin: 0 0 9px; }
.chat-msg p:last-child { margin-bottom: 0; }
.chat-msg ul { margin: 0 0 9px; padding-left: 19px; }
.chat-msg ul:last-child { margin-bottom: 0; }
.chat-msg li { margin-bottom: 4px; }
.chat-msg code {
  background: rgba(0, 0, 0, 0.35);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 12px;
}
.chat-msg.user {
  align-self: flex-end;
  background: rgba(139, 127, 255, 0.17);
  border: 1px solid rgba(139, 127, 255, 0.34);
}
.chat-msg.assistant {
  align-self: flex-start;
  background: var(--card-2);
  border: 1px solid var(--line);
  max-width: 100%;
}
.chat-msg.error {
  background: rgba(255, 209, 102, 0.09);
  border-color: rgba(255, 209, 102, 0.32);
  color: #ffd88a;
}

/* Which tools produced the answer — provenance, not decoration. */
.chat-sources { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 10px; }
.chat-sources-label { font-size: 10px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.07em; margin-right: 2px; }
.chat-source {
  font-size: 10.5px;
  color: var(--ink-2);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 2px 8px;
}

.chat-typing { display: flex; gap: 5px; align-items: center; height: 15px; }
.chat-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink-3);
  animation: chatBlink 1.3s ease-in-out infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.18s; }
.chat-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes chatBlink { 0%, 60%, 100% { opacity: 0.28; } 30% { opacity: 1; } }
.chat-elapsed { font-size: 11px; color: var(--ink-3); margin-top: 7px; }

.chat-chips { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 18px 12px; }
.chat-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--ink-2);
  cursor: pointer;
  transition: color 0.16s, border-color 0.16s, background 0.16s;
}
.chat-chip:hover { color: var(--ink); border-color: rgba(139, 127, 255, 0.55); background: rgba(139, 127, 255, 0.12); }

.chat-form {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  padding: 12px 18px 0;
  border-top: 1px solid var(--line);
}
.chat-form textarea {
  flex: 1;
  resize: none;
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.5;
  padding: 11px 13px;
  max-height: 140px;
  outline: none;
  transition: border-color 0.16s;
}
.chat-form textarea:focus { border-color: rgba(139, 127, 255, 0.65); }
.chat-form textarea:disabled { opacity: 0.5; cursor: not-allowed; }

.chat-send {
  flex: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: var(--grad-hero);
  color: #fff;
  font-size: 17px;
  cursor: pointer;
  box-shadow: 0 8px 20px -10px rgba(123, 110, 234, 0.9);
  transition: filter 0.16s, transform 0.16s;
}
.chat-send:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-1px); }
.chat-send:disabled { opacity: 0.45; cursor: progress; }

.chat-foot { padding: 9px 18px 16px; font-size: 10.5px; color: var(--ink-3); line-height: 1.5; }

/* ===========================  RESPONSIVE  =============================== */

@media (max-width: 1180px) {
  .c3, .c4, .c5 { grid-column: span 6; }
  .c7, .c8 { grid-column: span 12; }
  .inline-form { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 820px) {
  .sidebar { display: none; }
  .main { padding: 18px 15px 50px; }
  .c3, .c4, .c5, .c6, .c7, .c8 { grid-column: span 12; }
  .stat-num { font-size: 40px; }
  .topbar h1 { font-size: 22px; }
  .chat-panel { width: 100vw; border-left: 0; }
  .chat-msg { max-width: 100%; }
}

/* Respect the OS setting — every animation here is decorative. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
