/* FalconViz Evaluator design system */
:root {
  --navy: #1e1e2d;
  --navy-2: #2a2a3d;
  --blue: #0f51a0;
  --blue-dark: #0b3f7e;
  --blue-soft: #e8f0fa;
  --indigo: #2e3192;
  --sky: #4a9be8;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --line: #e3e6eb;
  --line-strong: #cfd4dc;
  --text: #1e1e2d;
  --muted: #667085;
  --green: #12805c;
  --green-soft: #e3f5ee;
  --amber: #a15c07;
  --amber-soft: #fdf1dc;
  --red: #b42318;
  --red-soft: #fde8e6;
  --human: #7a4fd1;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(30, 30, 45, .05), 0 4px 16px rgba(30, 30, 45, .05);
  --font-head: "Montserrat", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 var(--font-body); -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0 0 1em; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
small, .small { font-size: .85rem; }
.muted { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; word-break: break-all; }
[x-cloak] { display: none !important; }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--navy) 0%, #17172a 100%); color: #c9cbe0;
  padding: 22px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand svg { flex: none; }
.brand b { font-family: var(--font-head); font-size: 1.05rem; letter-spacing: .01em; display: block; line-height: 1.1; }
.brand span { font-size: .7rem; text-transform: uppercase; letter-spacing: .14em; color: var(--sky); }
.nav-group { margin-bottom: 18px; }
.nav-title { font-size: .68rem; text-transform: uppercase; letter-spacing: .13em; color: #7f82a3; padding: 0 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: #c9cbe0; font-weight: 500; font-size: .92rem;
}
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav a.active { background: var(--blue); color: #fff; }
.nav a .count { margin-left: auto; background: rgba(255,255,255,.14); border-radius: 99px; font-size: .72rem; padding: 1px 8px; }
.sidebar-foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid rgba(255,255,255,.08); font-size: .85rem; }
.sidebar-foot .who { color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot .roles { color: #8f92b3; font-size: .75rem; margin-bottom: 8px; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--sky); cursor: pointer; font: inherit; }
.linkbtn:hover { text-decoration: underline; }

.main { padding: 30px clamp(16px, 4vw, 44px) 60px; min-width: 0; }
.page-head { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: flex-end; justify-content: space-between; margin-bottom: 22px; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); margin: 4px 0 0; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn.menu-toggle { display: none; }

/* ---------- Surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 18px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2, .card-head h3 { margin: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush .card-head { padding: 16px 22px 0; }
.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.grid > .card { margin-bottom: 0; }
.stack > * + * { margin-top: 18px; }

.stat { padding: 18px 20px; }
.stat .label { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.stat .value { font-family: var(--font-head); font-size: 1.9rem; font-weight: 700; line-height: 1.15; margin-top: 4px; }
.stat .value small { font-size: .95rem; color: var(--muted); font-weight: 500; }
.stat .hint { font-size: .82rem; color: var(--muted); margin-top: 2px; }

.hero {
  background: linear-gradient(120deg, var(--blue) 0%, var(--indigo) 100%); color: #fff; border: 0;
  position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; right: -60px; top: -80px; width: 280px; height: 280px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.16), transparent 65%);
}
.hero h2 { color: #fff; font-size: 1.3rem; }
.hero p { color: rgba(255,255,255,.86); max-width: 60ch; }
.hero .btn { background: #fff; color: var(--blue); border-color: #fff; }
.hero .btn:hover { background: var(--blue-soft); }

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; cursor: pointer;
  font: 600 .9rem var(--font-body); padding: 9px 16px; border-radius: 9px; border: 1px solid var(--blue);
  background: var(--blue); color: #fff; transition: background .12s, box-shadow .12s; white-space: nowrap;
}
.btn:hover { background: var(--blue-dark); text-decoration: none; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, button:focus-visible {
  outline: 3px solid rgba(74, 155, 232, .45); outline-offset: 1px;
}
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.btn.secondary:hover { background: var(--bg); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--blue); padding-inline: 8px; }
.btn.ghost:hover { background: var(--blue-soft); }
.btn.danger { background: var(--surface); color: var(--red); border-color: #f0b8b3; }
.btn.danger:hover { background: var(--red-soft); }
.btn.small { padding: 5px 10px; font-size: .82rem; border-radius: 7px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

label, .label { display: block; font-weight: 600; font-size: .86rem; margin-bottom: 5px; }
.help { color: var(--muted); font-size: .84rem; font-weight: 400; margin: 2px 0 6px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=datetime-local], input[type=file], select, textarea {
  width: 100%; font: inherit; color: inherit; background: #fff; border: 1px solid var(--line-strong);
  border-radius: 9px; padding: 9px 12px;
}
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
input[type=checkbox], input[type=radio] { accent-color: var(--blue); width: 16px; height: 16px; vertical-align: -3px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 500; }
.check input { margin-top: 3px; flex: none; }
.field { margin-bottom: 16px; }
.field-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); align-items: end; }
.errorlist, .field-error { color: var(--red); font-size: .85rem; margin: 4px 0 0; padding: 0; list-style: none; }
.inline-form { display: inline; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fafbfc; }
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: #fafbfd; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
.rank { font-family: var(--font-head); font-weight: 700; color: var(--muted); width: 36px; }
.rank.top { color: var(--blue); }

/* ---------- Chips, bars, alerts ---------- */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: .75rem; font-weight: 600; background: #eef0f4; color: #475067; white-space: nowrap; }
.chip.blue { background: var(--blue-soft); color: var(--blue); }
.chip.green { background: var(--green-soft); color: var(--green); }
.chip.amber { background: var(--amber-soft); color: var(--amber); }
.chip.red { background: var(--red-soft); color: var(--red); }
.chip.violet { background: #f0eafc; color: var(--human); }

.bar { height: 8px; border-radius: 99px; background: #e9ecf1; overflow: hidden; min-width: 70px; }
.bar span { display: block; height: 100%; border-radius: 99px; background: var(--blue); }
.bar-human span { background: var(--human); }
.bar-perf span { background: var(--green); }
.bar-final span { background: linear-gradient(90deg, var(--blue), var(--indigo)); }
.bar-lowconf span { background-image: repeating-linear-gradient(45deg, var(--blue) 0 5px, #7fb0e6 5px 10px); }
.bar-empty span { display: none; }
.bar-empty { background: repeating-linear-gradient(45deg, #eef0f4 0 5px, #f7f8fa 5px 10px); }
.scorecell { display: grid; grid-template-columns: 34px 1fr; gap: 8px; align-items: center; min-width: 110px; }
.scorecell b { font-variant-numeric: tabular-nums; text-align: right; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .82rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.progress { height: 12px; border-radius: 99px; background: #e9ecf1; overflow: hidden; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--sky)); transition: width .5s; }
.progress.over span { background: var(--red); }

.alert { border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; border: 1px solid; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.alert.success { background: var(--green-soft); border-color: #b5e2d0; color: #0b5c41; }
.alert.error { background: var(--red-soft); border-color: #f3bdb8; color: #8a1a11; }
.alert.warning { background: var(--amber-soft); border-color: #f3d9a4; color: #7a4504; }
.alert.info { background: var(--blue-soft); border-color: #bcd4f0; color: #0b3f7e; }

.empty { text-align: center; color: var(--muted); padding: 34px 16px; }

/* ---------- Auth pages ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.auth-art { background: linear-gradient(140deg, var(--navy) 0%, var(--blue) 70%, var(--indigo) 100%); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-art::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 80% 15%, rgba(74,155,232,.35), transparent 45%), radial-gradient(circle at 10% 95%, rgba(46,49,146,.6), transparent 50%); }
.auth-art > * { position: relative; }
.auth-art h1 { font-size: clamp(1.8rem, 3vw, 2.6rem); max-width: 16ch; }
.auth-art p { color: rgba(255,255,255,.8); max-width: 46ch; font-size: 1.02rem; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-form .inner { width: 100%; max-width: 380px; }

/* ---------- Report / Markdown ---------- */
.prose { max-width: 78ch; overflow-wrap: anywhere; }
.prose h1, .prose h2, .prose h3, .prose h4 { margin: 1.2em 0 .4em; font-size: 1.02rem; }
.prose h1 { font-size: 1.15rem; }
.prose ul, .prose ol { padding-left: 1.4em; margin: 0 0 1em; }
.prose code { background: #f0f2f5; padding: 1px 5px; border-radius: 5px; font-size: .88em; }
.prose pre { background: var(--navy); color: #e6e8f5; padding: 14px; border-radius: 10px; overflow-x: auto; }
.prose pre code { background: none; padding: 0; color: inherit; }
.prose blockquote { border-left: 3px solid var(--line-strong); margin: 0 0 1em; padding: 2px 14px; color: var(--muted); }
.prose table { border-collapse: collapse; margin: 0 0 1em; display: block; overflow-x: auto; font-size: .92rem; }
.prose th, .prose td { border: 1px solid var(--line); padding: 6px 11px; }
.prose th { background: #f6f7f9; }
.prose > :last-child { margin-bottom: 0; }
.answer { padding: 14px 0; border-top: 1px solid var(--line); }
.answer:first-of-type { border-top: 0; padding-top: 4px; }
.answer h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; font-family: var(--font-body); }

/* ---------- Markdown editor ---------- */
.md-editor { border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; background: #fff; }
.md-toolbar { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; border-bottom: 1px solid var(--line); background: #fafbfc; align-items: center; }
.md-toolbar button { border: 0; background: none; padding: 5px 9px; border-radius: 6px; cursor: pointer; font: 600 .82rem var(--font-body); color: #475067; }
.md-toolbar button:hover { background: #e9ecf1; }
.md-toolbar .spacer { flex: 1; }
.md-toolbar .tab.active { background: var(--blue-soft); color: var(--blue); }
.md-panes { display: grid; grid-template-columns: 1fr; }
.md-panes.split { grid-template-columns: 1fr 1fr; }
.md-panes textarea { border: 0; border-radius: 0; min-height: 260px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88rem; padding: 14px; }
.md-panes textarea:focus-visible { outline: none; }
.md-preview { padding: 14px 16px; border-left: 1px solid var(--line); background: #fcfcfd; overflow: auto; max-height: 520px; }
.md-foot { display: flex; justify-content: space-between; gap: 12px; padding: 6px 12px; border-top: 1px solid var(--line); font-size: .8rem; color: var(--muted); background: #fafbfc; }
.md-foot .over { color: var(--red); font-weight: 600; }
.save-state.ok { color: var(--green); }
.save-state.error { color: var(--red); font-weight: 600; }

/* ---------- Stepper ---------- */
.stepper { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; }
.stepper a { display: flex; align-items: center; gap: 8px; padding: 7px 12px 7px 8px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); color: var(--text); font-size: .84rem; font-weight: 500; }
.stepper a:hover { text-decoration: none; border-color: var(--blue); }
.stepper a .n { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .74rem; font-weight: 700; background: #e9ecf1; color: #475067; }
.stepper a.done .n { background: var(--green-soft); color: var(--green); }
.stepper a.todo .n { background: var(--amber-soft); color: var(--amber); }
.stepper a.active { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); font-weight: 600; }
.stepper a.active .n { background: var(--blue); color: #fff; }

/* ---------- Rubric editor ---------- */
.sortable-item { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; align-items: start; }
.handle { cursor: grab; color: #a4abb8; padding-top: 3px; user-select: none; font-size: 1.1rem; line-height: 1; }
.sortable-ghost { opacity: .4; }
.item { border: 1px solid var(--line); border-radius: 10px; background: #fff; margin-bottom: 10px; padding: 12px 14px; }
.item.inactive { background: #fafafb; }
.item.inactive .item-title { color: var(--muted); }
.item-head { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; }
.item-title { font-weight: 600; }
.item-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 5px; }
.item-body { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }
.level-row { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 8px; align-items: start; margin-bottom: 8px; }
.level-row .idx { width: 26px; height: 26px; border-radius: 50%; background: var(--blue-soft); color: var(--blue); font-weight: 700; font-size: .78rem; display: grid; place-items: center; margin-top: 6px; }
.level-row textarea { min-height: 44px; }
.option-row { display: grid; grid-template-columns: minmax(90px, 1fr) minmax(0, 2.5fr) 80px auto; gap: 8px; margin-bottom: 8px; }
ol.levels { margin: 8px 0 0; padding-left: 0; list-style: none; counter-reset: lvl -1; font-size: .88rem; color: #475067; }
ol.levels li { counter-increment: lvl; padding: 3px 0 3px 30px; position: relative; }
ol.levels li::before { content: counter(lvl); position: absolute; left: 0; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #eef0f4; font-size: .72rem; font-weight: 700; display: grid; place-items: center; }
ol.levels li .p { float: right; font-variant-numeric: tabular-nums; color: var(--blue); font-weight: 600; margin-left: 10px; }

/* ---------- Review screen ---------- */
.review-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.review-layout .sticky { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
.qcard { border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 12px; background: #fff; }
.qcard.scored { border-left: 3px solid var(--green); }
.qcard .qtext { font-weight: 600; margin-bottom: 8px; }
.choice-list { display: grid; gap: 6px; }
.choice-list label { display: flex; gap: 9px; font-weight: 400; font-size: .9rem; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; margin: 0; }
.choice-list label:hover { border-color: var(--blue); }
.choice-list label:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); }
.choice-list input { margin-top: 3px; flex: none; }
.jevbox { margin-top: 10px; background: #f7f9fc; border: 1px dashed #bcd4f0; border-radius: 8px; padding: 9px 12px; font-size: .86rem; }
details > summary { cursor: pointer; color: var(--blue); font-weight: 600; font-size: .86rem; }

/* ---------- Upload ---------- */
.dropzone { border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 30px; text-align: center; background: #fbfcfd; transition: border-color .15s, background .15s; }
.dropzone.drag { border-color: var(--blue); background: var(--blue-soft); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 30; inset: 0 auto 0 0; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); }
  .btn.menu-toggle { display: inline-flex; margin-bottom: 14px; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { padding: 32px 24px; min-height: 0; }
  .auth-art .lede { display: none; }
  .review-layout, .md-panes.split { grid-template-columns: 1fr; }
  .review-layout .sticky { position: static; max-height: none; }
  .md-preview { border-left: 0; border-top: 1px solid var(--line); }
  .option-row { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Run results ---------- */
.run-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.run-layout .sticky { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
.run-layout .card { margin-bottom: 12px; }
tr.clickable { cursor: pointer; }
tr.clickable.selected, tr.clickable.selected:hover { background: var(--blue-soft); box-shadow: inset 3px 0 0 var(--blue); }
pre.sent { white-space: pre-wrap; overflow-wrap: anywhere; background: #f7f8fa; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: .8rem; margin: 6px 0 0; max-height: 320px; overflow-y: auto; }
.dist { display: grid; grid-template-columns: 22px minmax(0, 1fr) 42px; gap: 4px 8px; align-items: start; font-size: .86rem; padding: 6px 8px; border-radius: 8px; color: #475067; }
.dist .idx { width: 20px; height: 20px; border-radius: 50%; background: #eef0f4; font-size: .72rem; font-weight: 700; display: grid; place-items: center; }
.dist b { text-align: right; font-variant-numeric: tabular-nums; }
.dist .bar { grid-column: 2 / 4; height: 5px; min-width: 0; }
.dist.top { background: var(--blue-soft); color: var(--text); }
.dist.top .idx { background: var(--blue); color: #fff; }
@media (max-width: 1250px) { .run-layout { grid-template-columns: 1fr; } .run-layout .sticky { position: static; max-height: none; } }

@media print {
  .sidebar, .menu-toggle, .btn, .crumbs { display: none !important; }
  .shell { display: block; } .main { padding: 0; } body { background: #fff; font-size: 11pt; }
  .card { box-shadow: none; break-inside: auto; } .answer { break-inside: avoid; }
}

/* Run results table: fit the panel instead of scrolling sideways. */
table.data.results { table-layout: fixed; }
table.data.results th, table.data.results td { padding-left: 12px; padding-right: 12px; white-space: normal; }
table.data.results th:nth-child(1) { width: 21%; }
table.data.results th:nth-child(3) { width: 20%; }
table.data.results th:nth-child(4) { width: 18%; }
table.data.results th { overflow-wrap: anywhere; }
table.data.results .scorecell { min-width: 0; grid-template-columns: 30px minmax(30px, 1fr); }
table.data.results .bar { min-width: 0; }
