/* Hypersense AI — design system */
:root {
  --bg: #06080f;
  --bg-2: #0b0f1a;
  --surface: rgba(255, 255, 255, 0.035);
  --surface-2: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #e9edf6;
  --muted: #8b94ab;
  --faint: #5b6478;
  --cyan: #22d3ee;
  --violet: #8b5cf6;
  --pink: #f472b6;
  --lime: #a3e635;
  --amber: #fbbf24;
  --red: #fb7185;
  --grad: linear-gradient(120deg, var(--cyan), var(--violet) 55%, var(--pink));
  --radius: 18px;
  --radius-sm: 12px;
  --display: "Sora", system-ui, sans-serif;
  --body: "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.8);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--body); font-size: 14.5px;
  line-height: 1.55; -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
h1, h2, h3, h4 { font-family: var(--display); font-weight: 600; letter-spacing: -0.02em; margin: 0; }
h1 { font-size: 2.6rem; line-height: 1.08; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.05rem; }
p { margin: 0.4rem 0; }
a { color: inherit; text-decoration: none; }
b, strong { font-weight: 600; }
em { font-style: normal; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.tiny { font-size: 0.78rem; }
.mono { font-family: var(--mono); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
button { font: inherit; }
input, select, textarea {
  font: inherit; color: var(--text); background: rgba(0, 0, 0, 0.35); border: 1px solid var(--border);
  border-radius: 10px; padding: 0.6rem 0.8rem; width: 100%; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--violet); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2); }
select option { background: var(--bg-2); }
label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.82rem; color: var(--muted); font-weight: 500; }

/* ---------- ambience */
.aurora { position: fixed; inset: 0; z-index: -2; overflow: hidden; pointer-events: none; }
.aurora span { position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.55; animation: drift 24s ease-in-out infinite alternate; }
.aurora span:nth-child(1) { width: 60vw; height: 60vw; left: -18vw; top: -25vw; background: radial-gradient(circle, #1d4ed8 0%, transparent 65%); }
.aurora span:nth-child(2) { width: 50vw; height: 50vw; right: -15vw; top: 10vh; background: radial-gradient(circle, #7c3aed 0%, transparent 65%); animation-delay: -8s; }
.aurora span:nth-child(3) { width: 45vw; height: 45vw; left: 30vw; bottom: -30vw; background: radial-gradient(circle, #0891b2 0%, transparent 65%); animation-delay: -16s; }
@keyframes drift { from { transform: translate3d(0, 0, 0) scale(1); } to { transform: translate3d(6vw, 4vh, 0) scale(1.12); } }
.grid-overlay {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 48px 48px; mask-image: radial-gradient(ellipse at 30% 0%, #000 20%, transparent 70%);
}

/* ---------- glass + buttons */
.glass, .card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: var(--shadow);
}
.card { padding: 1.25rem 1.4rem; position: relative; }
.card.tight { padding: 1rem 1.1rem; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 0.9rem; }
.card-head h3 { font-size: 0.95rem; }
.card-head .hint { color: var(--faint); font-size: 0.78rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; cursor: pointer;
  border-radius: 999px; padding: 0.65rem 1.2rem; font-weight: 600; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text); transition: transform .12s, box-shadow .2s, background .2s;
}
.btn:hover { transform: translateY(-1px); background: rgba(255,255,255,0.1); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.btn.primary { background: var(--grad); border: 0; color: #08070f; box-shadow: 0 10px 30px -10px rgba(139, 92, 246, 0.8); }
.btn.primary:hover { box-shadow: 0 14px 34px -10px rgba(34, 211, 238, 0.7); }
.btn.ghost { background: transparent; }
.btn.small { padding: 0.4rem 0.85rem; font-size: 0.8rem; }
.btn.danger { color: var(--red); border-color: rgba(251, 113, 133, 0.35); }
.chip {
  display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.22rem 0.65rem; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted);
}
.chip.ok { color: var(--lime); border-color: rgba(163, 230, 53, 0.35); }
.chip.warn { color: var(--amber); border-color: rgba(251, 191, 36, 0.35); }
.chip.bad { color: var(--red); border-color: rgba(251, 113, 133, 0.35); }
.chip.accent { color: var(--cyan); border-color: rgba(34, 211, 238, 0.35); }
.form-error { color: var(--red); font-size: 0.85rem; margin-top: 0.6rem; }

/* ---------- brand */
.brand-mark { display: inline-flex; align-items: center; gap: 0.6rem; font-family: var(--display); font-weight: 700; font-size: 1.05rem; letter-spacing: -0.02em; }
.brand-mark .mark { width: 26px; height: 26px; border-radius: 8px; background: var(--grad); box-shadow: 0 0 24px rgba(139, 92, 246, 0.7); position: relative; }
.brand-mark .mark::after { content: ""; position: absolute; inset: 7px; border-radius: 4px; background: var(--bg); opacity: 0.85; }
.brand-name b { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; margin-left: 2px; }

/* ---------- login */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 2rem; }
.login-wrap { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 4rem; max-width: 1100px; width: 100%; align-items: center; }
.login-hero h1 { margin: 1.8rem 0 1rem; font-size: 3.4rem; }
.lede { font-size: 1.05rem; color: var(--muted); max-width: 46ch; }
.hero-points { list-style: none; padding: 0; margin: 2rem 0 0; display: flex; gap: 2rem; color: var(--muted); font-size: 0.85rem; }
.hero-points b { display: block; font-family: var(--display); font-size: 1.6rem; color: var(--text); }
.login-card { padding: 2.2rem; }
.login-card form { display: flex; flex-direction: column; gap: 1rem; margin-top: 1.4rem; }
.login-card .btn { margin-top: 0.4rem; }
@media (max-width: 900px) { .login-wrap { grid-template-columns: 1fr; gap: 2rem; } .login-hero h1 { font-size: 2.4rem; } }

/* ---------- shell */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 1.4rem 1rem; display: flex; flex-direction: column; gap: 1.6rem; border-right: 1px solid var(--border); background: rgba(6, 8, 15, 0.55); backdrop-filter: blur(16px); }
#nav { display: flex; flex-direction: column; gap: 0.2rem; }
#nav a { display: flex; align-items: center; gap: 0.7rem; padding: 0.6rem 0.8rem; border-radius: 12px; color: var(--muted); font-weight: 500; transition: background .15s, color .15s; }
#nav a i { font-style: normal; width: 20px; text-align: center; opacity: 0.8; }
#nav a:hover { background: var(--surface-2); color: var(--text); }
#nav a.active { background: linear-gradient(90deg, rgba(139, 92, 246, 0.25), rgba(34, 211, 238, 0.08)); color: var(--text); box-shadow: inset 2px 0 0 var(--violet); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 0.6rem; }
.llm-pill { display: flex; align-items: center; gap: 0.5rem; font-size: 0.78rem; color: var(--muted); padding: 0.35rem 0.6rem; }
.llm-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); box-shadow: 0 0 10px currentColor; }
.llm-pill.ok .dot { background: var(--lime); color: var(--lime); }
.llm-pill.bad .dot { background: var(--red); color: var(--red); }
.user-chip { font-size: 0.82rem; padding: 0.5rem 0.6rem; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.user-chip small { display: block; color: var(--faint); text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.65rem; }
.content { padding: 2rem 2.4rem 4rem; max-width: 1500px; width: 100%; }
.loading { color: var(--muted); padding: 4rem; text-align: center; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 2rem; margin-bottom: 1.6rem; }
.page-head h1 { font-size: 2rem; }
.page-head .sub { color: var(--muted); margin-top: 0.3rem; max-width: 70ch; }
.eyebrow { font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--cyan); font-weight: 600; margin-bottom: 0.5rem; }

.grid { display: grid; gap: 1.1rem; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.three { grid-template-columns: repeat(3, 1fr); }
.grid.wide-left { grid-template-columns: 1.6fr 1fr; }
.grid.wide-right { grid-template-columns: 1fr 1.6fr; }
.stack { display: flex; flex-direction: column; gap: 1.1rem; }
@media (max-width: 1100px) { .grid.two, .grid.three, .grid.wide-left, .grid.wide-right { grid-template-columns: 1fr; } }

.kpi { padding: 1.1rem 1.3rem; }
.kpi .label { font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.kpi .value { font-family: var(--display); font-size: 2rem; font-weight: 600; margin-top: 0.3rem; letter-spacing: -0.03em; }
.kpi .value.grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.kpi .delta { font-size: 0.78rem; color: var(--muted); margin-top: 0.2rem; }
.chart { width: 100%; height: 320px; }
.chart.tall { height: 440px; }
.chart.short { height: 220px; }

table.data { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
table.data th, table.data td { text-align: left; padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--border); }
table.data th { color: var(--muted); font-weight: 600; font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; }
table.data td.num, table.data th.num { text-align: right; font-family: var(--mono); }
table.data tr:hover td { background: rgba(255,255,255,0.025); }

.bar { height: 6px; border-radius: 3px; background: rgba(255,255,255,0.08); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--grad); border-radius: 3px; }
.score-ring { --p: 0; width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; font-family: var(--display); font-weight: 600; font-size: 1.1rem;
  background: conic-gradient(var(--cyan) calc(var(--p) * 1%), rgba(255,255,255,0.07) 0); position: relative; }
.score-ring::before { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: #0c1020; }
.score-ring span { position: relative; }

/* ---------- analyst / chat */
.analyst { display: grid; grid-template-columns: 250px 1fr; gap: 1.1rem; height: calc(100vh - 8.5rem); min-height: 560px; }
.convo-list { overflow: auto; display: flex; flex-direction: column; gap: 0.3rem; padding: 0.9rem; }
.convo-list a { display: block; padding: 0.55rem 0.7rem; border-radius: 10px; color: var(--muted); font-size: 0.83rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convo-list a:hover, .convo-list a.active { background: var(--surface-2); color: var(--text); }
.chat { display: flex; flex-direction: column; overflow: hidden; }
.chat-log { flex: 1; overflow: auto; padding: 1.4rem 1.6rem; display: flex; flex-direction: column; gap: 1.2rem; }
.msg { max-width: 82ch; }
.msg.user { align-self: flex-end; background: linear-gradient(120deg, rgba(139,92,246,0.35), rgba(34,211,238,0.2)); border: 1px solid rgba(139,92,246,0.4); padding: 0.75rem 1rem; border-radius: 16px 16px 4px 16px; }
.msg.assistant { align-self: flex-start; }
.msg .who { font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--cyan); font-weight: 600; margin-bottom: 0.35rem; }
.md h1, .md h2, .md h3 { margin: 0.9rem 0 0.4rem; font-size: 1.05rem; }
.md p { margin: 0.45rem 0; }
.md ul, .md ol { padding-left: 1.3rem; margin: 0.4rem 0; }
.md li { margin: 0.2rem 0; }
.md table { border-collapse: collapse; margin: 0.6rem 0; font-size: 0.85rem; }
.md th, .md td { border: 1px solid var(--border); padding: 0.35rem 0.6rem; }
.md code { font-family: var(--mono); font-size: 0.82rem; background: rgba(255,255,255,0.07); padding: 0.1rem 0.35rem; border-radius: 5px; }
.md pre { background: rgba(0,0,0,0.4); padding: 0.8rem; border-radius: 10px; overflow: auto; }
.md blockquote { border-left: 3px solid var(--violet); margin: 0.5rem 0; padding-left: 0.8rem; color: var(--muted); }
.trail { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.4rem 0 0.6rem; }
.trail .chip { cursor: pointer; font-family: var(--mono); font-weight: 500; font-size: 0.72rem; }
.trail .chip.running { border-color: var(--violet); color: var(--violet); animation: pulse 1.2s infinite; }
.trail-detail { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); background: rgba(0,0,0,0.35); padding: 0.6rem 0.8rem; border-radius: 10px; white-space: pre-wrap; word-break: break-word; margin-bottom: 0.6rem; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
.chat-status { font-size: 0.8rem; color: var(--violet); margin: 0.2rem 0 0.5rem; animation: pulse 1.4s infinite; }
.chat-status::after { content: " · " attr(data-elapsed); color: var(--faint); }
.chat-status:not([data-elapsed])::after { content: ""; }
.msg-actions { margin-top: 0.4rem; opacity: 0.55; transition: opacity .15s; }
.msg:hover .msg-actions { opacity: 1; }
.chat-chart { width: 100%; min-height: 180px; margin: 0.6rem 0; background: rgba(0,0,0,0.25); border: 1px solid var(--border); border-radius: 12px; padding: 0.6rem; }
.chat-chart.pending { display: grid; place-items: center; color: var(--faint); font-size: 0.8rem; min-height: 60px; }
.think-head { cursor: pointer; background: none; border: 1px solid var(--border); color: var(--muted); border-radius: 999px; padding: 0.2rem 0.7rem; font-size: 0.72rem; margin: 0.2rem 0 0.5rem; }
.think-head.live { color: var(--violet); border-color: var(--violet); animation: pulse 1.2s infinite; }
.think-body { font-size: 0.78rem; color: var(--faint); background: rgba(0,0,0,0.3); border-left: 2px solid var(--violet); padding: 0.6rem 0.8rem; border-radius: 0 10px 10px 0; margin-bottom: 0.6rem; white-space: pre-wrap; max-height: 260px; overflow: auto; }
.chat-input { border-top: 1px solid var(--border); padding: 0.9rem 1.1rem; display: flex; gap: 0.7rem; align-items: flex-end; }
.chat-input textarea { resize: none; min-height: 48px; max-height: 160px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0 1.6rem 1rem; }
.suggestions button { cursor: pointer; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); border-radius: 999px; padding: 0.4rem 0.8rem; font-size: 0.78rem; transition: all .15s; }
.suggestions button:hover { color: var(--text); border-color: var(--violet); }
.empty-chat { margin: auto; text-align: center; color: var(--muted); max-width: 44ch; }
.empty-chat h2 { margin-bottom: 0.5rem; }
.cursor::after { content: "▍"; animation: pulse 0.9s infinite; color: var(--cyan); }

/* ---------- personas */
.persona-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1.1rem; }
.persona { cursor: pointer; transition: transform .15s, border-color .15s; overflow: hidden; }
.persona:hover { transform: translateY(-3px); border-color: var(--border-strong); }
.persona::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--grad); opacity: 0.8; }
.persona .name { font-family: var(--display); font-size: 1.05rem; font-weight: 600; margin: 0.3rem 0 0.2rem; }
.persona .traits { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.7rem 0; }
.persona .stats { display: flex; gap: 1.4rem; margin-top: 0.4rem; }
.persona .stats b { display: block; font-family: var(--display); font-size: 1.3rem; }
.persona .stats span { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.index-row { display: grid; grid-template-columns: 120px 1fr 56px; align-items: center; gap: 0.7rem; font-size: 0.82rem; padding: 0.25rem 0; }
.index-row .bar { position: relative; }
.index-row .bar > i { background: var(--violet); }
.index-row .bar.high > i { background: var(--cyan); }
.index-row .bar.low > i { background: var(--faint); }

/* ---------- what-if */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.form-grid .full { grid-column: 1 / -1; }
.result-hero { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1.2rem; text-align: center; padding: 1.4rem 0 0.6rem; }
.result-hero .big { font-family: var(--display); font-size: 2.6rem; font-weight: 600; letter-spacing: -0.03em; }
.result-hero .big.grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.result-hero .ci { color: var(--muted); font-size: 0.8rem; font-family: var(--mono); }
.arrow { font-size: 2rem; color: var(--faint); }
.uplift { text-align: center; margin: 0.8rem 0; }
.uplift .v { font-family: var(--display); font-size: 1.6rem; font-weight: 600; }
.uplift .v.pos { color: var(--lime); } .uplift .v.neg { color: var(--red); }
.multi { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.multi label { flex-direction: row; align-items: center; gap: 0.35rem; cursor: pointer; padding: 0.25rem 0.6rem; border: 1px solid var(--border); border-radius: 999px; font-size: 0.76rem; color: var(--muted); }
.multi label:has(input:checked) { border-color: var(--violet); color: var(--text); background: rgba(139,92,246,0.18); }
.multi input { width: auto; margin: 0; accent-color: var(--violet); }

/* ---------- admin */
.console { font-family: var(--mono); font-size: 0.75rem; background: rgba(0,0,0,0.5); border-radius: 12px; padding: 0.9rem 1rem; height: 320px; overflow: auto; white-space: pre-wrap; color: #b7c0d3; }
.stage-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.55rem 0; border-bottom: 1px solid var(--border); }
.stage-row:last-child { border-bottom: 0; }
.stage-row .name { font-weight: 600; text-transform: capitalize; }
.stage-row .desc { color: var(--muted); font-size: 0.8rem; }

.toast { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%); background: #151a2b; border: 1px solid var(--border-strong); padding: 0.7rem 1.1rem; border-radius: 12px; box-shadow: var(--shadow); font-size: 0.85rem; z-index: 50; }
.toast.error { border-color: var(--red); }
.fade-in { animation: fadeIn .35s ease both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  #nav { flex-direction: row; flex-wrap: wrap; }
  #nav a span { display: none; }
  .sidebar-foot { margin-left: auto; flex-direction: row; align-items: center; }
  .content { padding: 1.2rem 1rem 3rem; }
  .analyst { grid-template-columns: 1fr; height: auto; }
  .convo-list { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .result-hero { grid-template-columns: 1fr; }
}
