:root {
  --bg: #0f1220;
  --panel: #171b2e;
  --panel-2: #1e2338;
  --line: #2b3050;
  --ink: #e7e9f5;
  --muted: #9096b8;
  --primary: #6c63ff;
  --primary-light: #8b84ff;
  --accent: #33e0d0;
  --danger: #ff6b6b;
  --radius: 12px;
  --shadow: 0 6px 20px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 "Segoe UI", system-ui, sans-serif; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; color: #fff; }
h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); }
.muted { color: var(--muted); margin: 0 0 .5rem; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); }

/* App shell */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 1.5rem; padding: 1.5rem 1.2rem; position: sticky; top: 0; height: 100vh; }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, var(--primary), var(--accent)); color: #0f1220; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.brand-name { font-weight: 800; font-size: 1.2rem; margin-top: -1rem; }
nav { display: flex; flex-direction: column; gap: .3rem; margin-top: .5rem; }
.tab { background: none; border: 0; text-align: left; color: var(--muted); font: inherit; font-weight: 600; padding: .7rem .9rem; border-radius: 8px; cursor: pointer; border-left: 3px solid transparent; transition: background .15s, color .15s; }
.tab:hover { color: var(--ink); background: var(--panel-2); }
.tab.active { color: #fff; background: var(--panel-2); border-left-color: var(--accent); }
.user { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: .4rem; }
#userName { font-weight: 700; }
.link { background: none; border: 0; color: var(--danger); font: inherit; font-size: .9rem; cursor: pointer; text-align: left; padding: 0; }

.content { display: flex; flex-direction: column; min-width: 0; }
main { flex: 1; max-width: 1150px; width: 100%; margin: 0 auto; padding: 2rem 3vw; }
.panel { display: none; }
.panel.active { display: block; animation: fade .3s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.hero { background: linear-gradient(120deg, var(--panel-2), var(--panel)); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.3rem 1.5rem; margin-bottom: 1.5rem; }
.hero p { color: var(--muted); margin: 0; max-width: 60ch; }

.split { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.form, .results, .saved { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.3rem; }
.form { display: grid; gap: 1.2rem; max-height: calc(100vh - 6rem); overflow-y: auto; }
.results { min-height: 220px; }

/* Form controls */
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-weight: 700; margin-bottom: .5rem; color: var(--accent); text-transform: uppercase; font-size: .75rem; letter-spacing: .07em; }
label { display: block; font-weight: 600; margin-bottom: .35rem; color: var(--ink); }
input:not([type=radio]):not([type=checkbox]) { width: 100%; font: inherit; padding: .65rem .7rem; border: 1.5px solid var(--line); border-radius: 8px; background: var(--panel-2); color: var(--ink); transition: border-color .15s; }
input:not([type=radio]):not([type=checkbox]):focus { border-color: var(--primary-light); }
input[type=range] { padding: 0; margin-top: .6rem; accent-color: var(--primary-light); height: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.chip { background: var(--panel-2); border: 1px solid var(--line); color: var(--accent); border-radius: 999px; padding: .25rem .85rem; font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; transition: background .15s, transform .1s; }
.chip:hover { background: var(--primary); color: #fff; transform: translateY(-1px); }

/* Option cards */
.opts { display: grid; gap: .55rem; }
.seg { grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); }
.grid2 { grid-template-columns: repeat(2, 1fr); }
.opt { position: relative; margin: 0; cursor: pointer; }
.opt input { position: absolute; opacity: 0; }
.opt span { position: relative; display: block; border: 1.5px solid var(--line); border-radius: 8px; padding: .6rem .85rem .6rem 1rem; background: var(--panel-2); color: var(--ink); transition: border-color .15s, background .15s, transform .1s, box-shadow .15s; border-left: 4px solid var(--line); }
.opt b { display: block; font-weight: 600; }
.opt small { display: block; color: var(--muted); font-weight: 400; font-size: .85rem; }
.opt:hover span { border-left-color: var(--primary-light); transform: translateY(-1px); }
.opt input:checked + span { border-color: var(--accent); border-left-color: var(--accent); background: #1c2a3a; box-shadow: 0 0 0 1px var(--accent) inset; }
.opt input:checked + span::after { content: "✓"; position: absolute; top: .4rem; right: .55rem; color: var(--accent); font-weight: 800; font-size: .85rem; }
.opt input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.seg .opt span { text-align: center; border-left-width: 1.5px; border-bottom: 3px solid var(--line); }
.seg .opt input:checked + span { border-bottom-color: var(--accent); }

.go { position: sticky; bottom: 0; background: linear-gradient(120deg, var(--primary), #8f5cff); color: #fff; border: 0; border-radius: 8px; padding: .85rem 1.3rem; font: inherit; font-weight: 700; letter-spacing: .02em; cursor: pointer; transition: filter .15s, transform .1s; box-shadow: var(--shadow); }
.go:hover { filter: brightness(1.1); transform: translateY(-1px); }
.go:active { transform: translateY(0); }

/* Results */
.result-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px dashed var(--line); }
.score { background: conic-gradient(var(--accent) calc(var(--pct, 0) * 1%), var(--line) 0); border-radius: 50%; width: 84px; height: 84px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.score-inner { background: var(--panel); border-radius: 50%; width: 66px; height: 66px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.score strong { display: block; font-size: 1.5rem; color: var(--accent); line-height: 1.1; }
.score span { font-size: .65rem; color: var(--muted); }
.bars { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .3rem 1.5rem; margin-bottom: 1.2rem; }
.bars label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: .9rem; color: var(--ink); }
meter { width: 100%; height: 10px; display: block; border-radius: 6px; overflow: hidden; }
.note { padding: .8rem 1.05rem; border-left: 4px solid var(--accent); background: #17263a; color: var(--ink); margin: 0 0 1.1rem; border-radius: 0 6px 6px 0; }
.wrap { overflow-x: auto; margin-bottom: 1rem; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .7rem .95rem; border-bottom: 1px solid var(--line); }
tbody tr:nth-child(even) { background: var(--panel-2); }
tbody tr:hover { background: #232a45; }
th { background: #232849; color: #fff; font-weight: 600; font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }
td:last-child, th:last-child { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 600; }
tfoot td { font-weight: 700; border-top: 2px solid var(--primary-light); border-bottom: 0; background: var(--panel-2); color: #fff; }
tfoot td:last-child { color: var(--accent); }
.saved { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; border-left: 4px solid var(--primary-light); }
footer { padding: 1.5rem 5vw; color: var(--muted); font-size: .9rem; text-align: center; border-top: 1px solid var(--line); }

/* Login page */
.login-layout { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); }
.login-side { color: #fff; display: flex; flex-direction: column; justify-content: center; padding: 3rem 8%; background: radial-gradient(circle at 30% 20%, #262c52, var(--bg) 60%); }
.login-side .brand-mark { margin-bottom: 1rem; }
.login-side h1 { font-size: clamp(2.2rem, 5vw, 3.3rem); background: linear-gradient(120deg, var(--primary-light), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-side p { max-width: 26em; color: var(--muted); font-size: 1.1rem; }
.pitch { color: var(--muted); padding-left: 1.1rem; margin-top: 1rem; }
.pitch li { margin-bottom: .4rem; }
.login-box { display: flex; flex-direction: column; justify-content: center; padding: 3rem 8%; max-width: 480px; width: 100%; margin: 0 auto; }
.switch { display: flex; margin-bottom: 1.5rem; background: var(--panel); border-radius: 8px; padding: .3rem; border: 1px solid var(--line); }
.switch .tab { color: var(--muted); flex: 1; text-align: center; border-left: 0; border-radius: 6px; }
.switch .tab.active { color: #fff; background: var(--panel-2); }
.login-box form { display: grid; gap: 1rem; }
.error { color: var(--danger); min-height: 1.5em; margin: 0; }
.hint { color: var(--muted); font-size: .9rem; }

/* Tablets and phones */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  nav { flex-direction: row; margin-top: 0; }
  .user { margin-top: 0; margin-left: auto; border-top: 0; flex-direction: row; align-items: center; gap: .8rem; }
  .split { grid-template-columns: 1fr; }
  .form { max-height: none; overflow-y: visible; }
  .go { position: static; }
}
@media (max-width: 760px) {
  .login-layout { grid-template-columns: 1fr; min-height: 0; }
  .login-side, .login-box { padding: 2rem 6%; }
  .result-head, .saved { flex-direction: column; align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}