/* ikai-demo Stage 1 — shared styles. Dark, minimal, mobile-first (>=380px). */
:root {
  --bg: #0b1020;
  --bg2: #10162b;
  --card: #141b33;
  --card2: #182140;
  --line: #232c4d;
  --line2: #2c3760;
  --ink: #eef1fb;
  --muted: #a6b0d0;
  --faint: #6b769b;
  --blue: #2f54ff;
  --blue2: #7c5cff;
  --grad: linear-gradient(115deg, #2f54ff, #7c5cff);
  --green: #19b566;
  --danger: #ff5d6c;
  --radius: 16px;
  --shadow: 0 18px 40px -22px rgba(0, 0, 0, .8);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1100px 600px at 80% -10%, rgba(47, 84, 255, .18), transparent 60%),
              radial-gradient(900px 500px at -10% 10%, rgba(124, 92, 255, .14), transparent 55%),
              var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: #9db0ff; }

/* Layout helpers */
.wrap { width: 100%; max-width: 460px; margin: 0 auto; padding: 28px 20px 48px; }
.center-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.stack > * + * { margin-top: 14px; }

/* Brand */
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 22px; letter-spacing: -.02em; text-decoration: none; color: var(--ink); }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--grad); box-shadow: 0 0 16px rgba(47, 84, 255, .7); }
.brand small { font-size: 11px; font-weight: 600; color: var(--faint); letter-spacing: .06em; text-transform: uppercase; }

/* Card */
.card {
  background: linear-gradient(180deg, var(--card), var(--bg2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 22px;
}
h1 { font-size: 26px; line-height: 1.2; letter-spacing: -.02em; margin: 0 0 8px; }
h2 { font-size: 18px; margin: 0 0 6px; letter-spacing: -.01em; }
.sub { color: var(--muted); margin: 0 0 20px; font-size: 15px; }
.eyebrow { color: var(--faint); font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; margin: 0 0 14px; }

/* Forms */
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 6px; }
.field + .field { margin-top: 14px; }
input, select {
  width: 100%; font-size: 16px; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line2); border-radius: 11px;
  padding: 13px 14px; outline: none; -webkit-appearance: none; appearance: none;
}
input::placeholder { color: var(--faint); }
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47, 84, 255, .25); }
select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a6b0d0' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 38px;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; font-size: 16px; font-weight: 700; cursor: pointer;
  border: 0; border-radius: 12px; padding: 14px 20px; color: #fff;
  background: var(--grad); box-shadow: 0 12px 26px -12px rgba(47, 84, 255, .9);
  text-decoration: none; transition: transform .12s ease, opacity .12s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line2); box-shadow: none; }
.btn.small { width: auto; padding: 9px 14px; font-size: 13px; }

/* Inline messages */
.msg { font-size: 14px; padding: 11px 13px; border-radius: 10px; margin-top: 14px; }
.msg.err { background: rgba(255, 93, 108, .12); border: 1px solid rgba(255, 93, 108, .4); color: #ffb7bf; }
.msg.ok  { background: rgba(25, 181, 102, .12); border: 1px solid rgba(25, 181, 102, .4); color: #9ff0c4; }
.muted { color: var(--muted); }
.faint { color: var(--faint); font-size: 13px; }
.hidden { display: none !important; }

/* Module / choice cards (onboarding) */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pick {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  background: var(--bg); border: 1px solid var(--line2); border-radius: 12px;
  padding: 13px 14px; font-size: 14px; font-weight: 600; color: var(--ink);
  user-select: none; transition: border-color .12s ease, background .12s ease;
}
.pick .ic { font-size: 18px; line-height: 1; }
.pick input { display: none; }
.pick.on { border-color: var(--blue); background: rgba(47, 84, 255, .14); box-shadow: 0 0 0 1px var(--blue) inset; }
.pick .check { margin-left: auto; opacity: 0; color: #9db0ff; font-weight: 800; }
.pick.on .check { opacity: 1; }

/* Demo banner (authenticated pages) */
.demobar {
  position: sticky; top: 0; z-index: 50;
  background: linear-gradient(90deg, rgba(47, 84, 255, .22), rgba(124, 92, 255, .22));
  border-bottom: 1px solid var(--line2);
  backdrop-filter: blur(8px);
  padding: 9px 16px; font-size: 13px; color: var(--ink);
  display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; text-align: center;
}
.demobar b { font-weight: 700; }
.demobar a { color: #cdd7ff; font-weight: 700; white-space: nowrap; }

/* Dashboard */
.dash { max-width: 1040px; margin: 0 auto; padding: 20px 18px 60px; }
.dash-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 22px; }
.dash-links { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.dash-links a { color: var(--muted); text-decoration: none; }
.dash-links a:hover { color: var(--ink); }
.dash-grid { display: grid; grid-template-columns: 220px 1fr; gap: 18px; }
.sidebar { display: flex; flex-direction: column; gap: 6px; }
.tab {
  text-align: left; width: 100%; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: 11px;
  color: var(--muted); font-size: 14px; font-weight: 600; padding: 12px 14px;
  display: flex; align-items: center; gap: 10px; transition: .12s ease;
}
.tab:hover { color: var(--ink); border-color: var(--line2); }
.tab.on { background: rgba(47, 84, 255, .16); border-color: var(--blue); color: #fff; }
.tab .ic { font-size: 16px; }
.panel { background: linear-gradient(180deg, var(--card), var(--bg2)); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px 22px; min-height: 300px; min-width: 0; }
.sidebar { min-width: 0; }
.panel .ph {
  margin-top: 18px; border: 1px dashed var(--line2); border-radius: 12px;
  padding: 34px 20px; text-align: center; color: var(--faint); background: rgba(255, 255, 255, .015);
}
.badge { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: #9ff0c4; background: rgba(25, 181, 102, .14); border: 1px solid rgba(25, 181, 102, .35); padding: 3px 8px; border-radius: 100px; }
.cta-row { margin-top: 22px; display: flex; gap: 10px; flex-wrap: wrap; }

/* Stage 2 — toolbar / date range */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 18px 0 6px; }
.seg { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 600; padding: 7px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.seg button.on { background: var(--grad); color: #fff; box-shadow: 0 6px 14px -8px rgba(47, 84, 255, .8); }
.toolbar .seg-label { font-size: 12px; color: var(--faint); font-weight: 600; }

/* Panel head + sample chip */
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.chip.sample { display: inline-flex; align-items: center; gap: 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  color: #cdb56a; background: rgba(214, 178, 90, .12); border: 1px solid rgba(214, 178, 90, .32); padding: 3px 9px; border-radius: 100px; }

/* KPI cards */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 16px; }
.kpi { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; }
.kpi .lab { font-size: 11px; color: var(--muted); font-weight: 600; }
.kpi .val { font-size: clamp(18px, 2.4vw, 24px); font-weight: 800; letter-spacing: -.02em; margin-top: 5px; line-height: 1.1; }
.kpi .delta { font-size: 11px; font-weight: 700; margin-top: 5px; display: inline-flex; align-items: center; gap: 3px; }
.kpi .delta.up { color: #4fe0a0; } .kpi .delta.down { color: #ff8b96; }

/* Chart */
.chartcard { margin-top: 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 14px 14px 10px; }
.chartcard .ch-h { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.chartcard .ch-h b { font-size: 12px; color: var(--muted); font-weight: 600; }
.chartcard .ch-h .big { font-size: 16px; font-weight: 800; color: var(--ink); }
.chart svg { width: 100%; height: 90px; display: block; }
.chartcard .x { display: flex; justify-content: space-between; font-size: 10px; color: var(--faint); margin-top: 4px; }

/* Table */
.tblwrap { margin-top: 14px; border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.dt { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 420px; }
table.dt th, table.dt td { padding: 9px 13px; text-align: left; white-space: nowrap; }
table.dt th { font-size: 9.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--faint); background: var(--bg2); border-bottom: 1px solid var(--line); }
table.dt td { border-top: 1px solid var(--line); color: var(--ink); }
table.dt .r { text-align: right; }
table.dt tbody tr:nth-child(even) td { background: rgba(255,255,255,.01); }

/* Per-tab CTA */
.ctablock { margin-top: 16px; border: 1px dashed var(--line2); border-radius: 12px; padding: 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: rgba(47, 84, 255, .05); }
.ctablock p { margin: 0; font-size: 13px; color: var(--muted); }
.ctablock .btn.small { flex: none; }

/* Ask ikai chat */
.chat { display: flex; flex-direction: column; min-height: 420px; }
.remaining { font-size: 11px; color: var(--faint); font-weight: 600; margin: 0 0 10px; }
.msgs { display: flex; flex-direction: column; gap: 10px; padding: 4px 0 10px; }
.bubble { max-width: 82%; padding: 11px 13px; border-radius: 13px; font-size: 13.5px; line-height: 1.45; }
.bubble.user { align-self: flex-end; background: var(--grad); color: #fff; border-bottom-right-radius: 4px; }
.bubble.ai { align-self: flex-start; background: var(--bg); border: 1px solid var(--line); color: var(--ink); border-bottom-left-radius: 4px; }
.bubble.ai .tag { display: block; margin-top: 6px; font-size: 9.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--faint); }
.typing { display: inline-flex; gap: 4px; align-items: center; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
.starters { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 12px; }
.starter { font-size: 12px; font-weight: 600; color: #9db0ff; background: rgba(47, 84, 255, .1); border: 1px solid var(--line2); border-radius: 100px; padding: 8px 12px; cursor: pointer; text-align: left; }
.starter:hover { border-color: var(--blue); }
.chat-form { display: flex; gap: 8px; margin-top: auto; }
.chat-form input { flex: 1; }
.chat-form .send { width: 46px; flex: none; border: 0; border-radius: 11px; background: var(--grad); color: #fff; cursor: pointer; font-size: 18px; }
.chat-form .send:disabled { opacity: .5; cursor: default; }

/* Mobile */
@media (max-width: 760px) {
  .dash-grid { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
  .tab { white-space: nowrap; }
  .kpis { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 420px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .bubble { max-width: 90%; }
}
@media (max-width: 420px) {
  .grid { grid-template-columns: 1fr; }
  .wrap { padding: 22px 16px 40px; }
  h1 { font-size: 23px; }
}
