/*
 * Consayik's one stylesheet: hand-written, no framework, no build step. Colours are tokens with a light and a dark
 * set; the dark set applies when the device prefers it.
 */
:root {
    color-scheme: light;
    --bg: #f5f6f8;
    --panel: #ffffff;
    --ink: #17202e;
    --muted: #64707f;
    --line: #e1e5ea;
    --accent: #3b4fd8;
    --accent-ink: #ffffff;
    --accent-soft: #eef0fd;
    --field: #ffffff;
    --hover: #f8f9fb;
    --sidebar: #111827;
    --sidebar-ink: #c9d1dc;
    --sidebar-muted: #7d8898;
    --sidebar-current: #1f2937;
    --ok: #17794a;
    --ok-soft: #e4f4ea;
    --warn: #935f00;
    --warn-soft: #fcf1dc;
    --bad: #b42323;
    --bad-soft: #fde9e9;
    --busy: #6c3fc1;
    --busy-soft: #efe8fb;
    --neutral-soft: #eef0f3;
    --bar: #8a98f0;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --bg: #0d1117;
        --panel: #161b22;
        --ink: #e4e8ee;
        --muted: #8e99a8;
        --line: #2a313c;
        --accent: #7c8cff;
        --accent-ink: #0d1117;
        --accent-soft: #1d2340;
        --field: #0f141a;
        --hover: #1b212a;
        --sidebar: #0a0d12;
        --sidebar-current: #1b212a;
        --ok: #4fc285;
        --ok-soft: #12291d;
        --warn: #e0a640;
        --warn-soft: #2e2410;
        --bad: #f07272;
        --bad-soft: #321616;
        --busy: #b394f0;
        --busy-soft: #241a38;
        --neutral-soft: #222831;
        --bar: #5a68c8;
        --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
    background: var(--bg);
    color: var(--ink);
    font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
p { margin: 0 0 .75em; }
code, pre { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; }
pre { background: var(--hover); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow-x: auto; }

/* ---------- Shell ---------- */

.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.sidebar {
    background: var(--sidebar);
    color: var(--sidebar-ink);
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 17px; padding: 4px 8px 14px; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: linear-gradient(135deg, #5b6cff, #22c3a6); display: grid; place-items: center; font-size: 14px; color: #fff; }

.org-switch { margin: 0 4px 12px; }
.org-switch select { width: 100%; background: var(--sidebar-current); color: var(--sidebar-ink); border: 1px solid #2c3442; }

.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--sidebar-muted); padding: 14px 10px 4px; }

.sidebar a.nav {
    display: flex; align-items: center; gap: 10px;
    color: var(--sidebar-ink);
    padding: 7px 10px;
    border-radius: 7px;
}
.sidebar a.nav:hover { background: var(--sidebar-current); text-decoration: none; color: #fff; }
.sidebar a.nav.current { background: var(--sidebar-current); color: #fff; font-weight: 600; }
.sidebar a.nav svg { width: 16px; height: 16px; flex: none; opacity: .85; }

.sidebar-foot { margin-top: auto; padding: 12px 6px 0; border-top: 1px solid #222a36; font-size: 13px; }
.sidebar-foot .balance { display: flex; justify-content: space-between; padding: 6px 4px; }
.sidebar-foot .who { color: var(--sidebar-muted); padding: 6px 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot button { background: none; border: 0; color: var(--sidebar-muted); padding: 4px; cursor: pointer; font: inherit; }
.sidebar-foot button:hover { color: #fff; }

.main { padding: 24px 32px 48px; min-width: 0; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin: 0; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Panels and grids ---------- */

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.panel > h2:first-child { margin-bottom: 12px; }
.panel.flush { padding: 0; overflow: hidden; }
.panel.flush > h2:first-child { padding: 16px 18px 0; }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.side { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 12.5px; }
.stat .value { font-size: 24px; font-weight: 650; margin-top: 2px; }
.stat .sub { color: var(--muted); font-size: 12px; }

/* ---------- Tables ---------- */

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; background: var(--hover); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--hover); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td .muted, .muted { color: var(--muted); }
.clip { max-width: 420px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.table-wrap { overflow-x: auto; }

/* ---------- Forms ---------- */

label { display: block; font-weight: 550; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.field .hint { color: var(--muted); font-size: 12.5px; margin-top: 4px; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=date], input[type=datetime-local], input[type=search], input[type=file], select, textarea {
    width: 100%;
    font: inherit;
    color: var(--ink);
    background: var(--field);
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 8px 10px;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 500; }
.check input { margin-top: 3px; }
.inline { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.inline .field { margin: 0; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 14px; }
.filters .field { margin: 0; min-width: 150px; }
.validation { color: var(--bad); font-size: 13px; }
.validation ul { margin: 0; padding-left: 18px; }

.button, button.button {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    background: var(--accent); color: var(--accent-ink);
    border: 1px solid transparent; border-radius: 7px;
    padding: 8px 14px;
    font: inherit; font-weight: 600;
    cursor: pointer; white-space: nowrap;
}
.button:hover { filter: brightness(1.07); text-decoration: none; }
.button.secondary { background: var(--panel); color: var(--ink); border-color: var(--line); }
.button.secondary:hover { background: var(--hover); }
.button.danger { background: var(--bad); color: #fff; }
.button.small { padding: 4px 10px; font-size: 13px; }
.button.link { background: none; color: var(--accent); padding: 0; border: 0; font-weight: 500; }
.button:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Badges, flashes ---------- */

.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--neutral-soft); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.busy { background: var(--busy-soft); color: var(--busy); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { background: var(--accent-soft); color: var(--accent); border-radius: 5px; padding: 1px 7px; font-size: 12px; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; background: var(--ok-soft); color: var(--ok); border: 1px solid transparent; }
.flash.error { background: var(--bad-soft); color: var(--bad); }
.flash.warn { background: var(--warn-soft); color: var(--warn); }
.secret { font-family: ui-monospace, Consolas, monospace; background: var(--hover); border: 1px dashed var(--line); padding: 10px; border-radius: 7px; word-break: break-all; user-select: all; }

/* ---------- Charts (CSS only) ---------- */

.bars { display: flex; align-items: flex-end; gap: 3px; height: 140px; padding-top: 8px; }
.bars .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; min-width: 4px; position: relative; }
.bars .col .fill { background: var(--bar); border-radius: 3px 3px 0 0; min-height: 1px; }
.bars .col .fill.neg { background: var(--bad); opacity: .75; border-radius: 0; }
.bars .col:hover .fill { filter: brightness(1.15); }
.bars-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 11.5px; margin-top: 4px; }

.meter { height: 8px; background: var(--neutral-soft); border-radius: 99px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.meter.ok > span { background: var(--ok); }
.meter.bad > span { background: var(--bad); }
.meter.warn > span { background: var(--warn); }

.rank { display: grid; grid-template-columns: minmax(0, 1fr) 120px 48px; gap: 10px; align-items: center; padding: 5px 0; }
.rank .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trend-up { color: var(--bad); font-size: 12px; }
.trend-down { color: var(--ok); font-size: 12px; }

/* ---------- Conversation ---------- */

.transcript { display: flex; flex-direction: column; gap: 8px; max-height: 640px; overflow-y: auto; padding-right: 4px; }
.turn { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 8px; }
.turn .at { color: var(--muted); font-size: 12px; padding-top: 7px; text-align: right; font-variant-numeric: tabular-nums; }
.turn .bubble { background: var(--hover); border: 1px solid var(--line); border-radius: 10px; padding: 7px 11px; }
.turn.agent .bubble { background: var(--accent-soft); border-color: transparent; }
.turn .who { font-size: 12px; font-weight: 650; color: var(--muted); }
.turn.agent .who { color: var(--accent); }
.turn[data-at] .at { cursor: pointer; }
.turn[data-at] .at:hover { color: var(--accent); }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }

.moment { border-left: 3px solid var(--accent); padding: 2px 0 2px 10px; margin-bottom: 10px; }
.moment q { color: var(--muted); display: block; font-style: italic; }

/* ---------- Evaluation form ---------- */

.criterion { border-top: 1px solid var(--line); padding: 14px 0; display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; }
.criterion:first-of-type { border-top: 0; }
.criterion .guidance { color: var(--muted); font-size: 13px; }
.criterion .ai { font-size: 13px; background: var(--hover); border-radius: 7px; padding: 8px 10px; margin-top: 8px; }
.section-title { margin: 18px 0 0; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.points { display: flex; gap: 4px; flex-wrap: wrap; }
.points label { margin: 0; }
.points input { display: none; }
.points span { display: inline-block; min-width: 34px; text-align: center; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; font-weight: 500; background: var(--field); }
.points input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.scorebox { position: sticky; top: 16px; }
.scorebox .big { font-size: 40px; font-weight: 700; }

.criteria-editor .row { display: grid; grid-template-columns: 1fr 1.6fr 2.4fr 110px 80px 80px 70px 70px 32px; gap: 6px; align-items: start; padding: 6px 0; border-bottom: 1px solid var(--line); }
.criteria-editor .row.head { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.criteria-editor textarea { min-height: 38px; height: 38px; }
.criteria-editor .row input[type=checkbox] { margin-top: 10px; }
.icon-button { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 18px; padding: 4px; }
.icon-button:hover { color: var(--bad); }

/* ---------- Insights ---------- */

.answer { line-height: 1.6; }
.answer table { margin: 8px 0 12px; font-size: 13px; }
.answer th { text-transform: none; letter-spacing: 0; }
.answer h1, .answer h2, .answer h3 { font-size: 15px; margin-top: 14px; }
.answer ul { padding-left: 20px; margin: 4px 0 10px; }
.question { font-weight: 650; font-size: 15px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 99px; padding: 4px 11px; font: inherit; font-size: 13px; cursor: pointer; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.thinking { display: none; color: var(--muted); }
form.busy .thinking { display: inline; }

/* ---------- Public pages ---------- */

.public { max-width: 1080px; margin: 0 auto; padding: 0 24px; }
.public-nav { display: flex; align-items: center; justify-content: space-between; padding: 18px 0; }
.public-nav .brand { color: var(--ink); padding: 0; }
.public-nav nav { display: flex; gap: 18px; align-items: center; }
.hero { padding: 64px 0 40px; display: grid; grid-template-columns: 1.1fr .9fr; gap: 40px; align-items: center; }
.hero h1 { font-size: 42px; line-height: 1.1; letter-spacing: -.02em; }
.hero p.lead { font-size: 18px; color: var(--muted); }
.hero .cta { display: flex; gap: 10px; margin-top: 20px; }
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; padding: 24px 0 64px; }
.feature h3 { font-size: 15px; }
.feature p { color: var(--muted); margin: 0; }
.mock { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 10px 40px rgba(16, 24, 40, .12); padding: 18px; }
.auth { max-width: 420px; margin: 48px auto; }
.auth .brand { color: var(--ink); justify-content: center; padding-bottom: 20px; }
footer.public-foot { color: var(--muted); padding: 24px 0 40px; border-top: 1px solid var(--line); font-size: 13px; }

.pager { display: flex; gap: 8px; justify-content: space-between; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line); color: var(--muted); }

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

@media (max-width: 960px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
    .sidebar .nav-label, .sidebar-foot, .org-switch { display: none; }
    .main { padding: 16px; }
    .grid.two, .grid.three, .grid.side, .hero, .features { grid-template-columns: 1fr; }
    .criterion { grid-template-columns: 1fr; }
    .criteria-editor .row { grid-template-columns: 1fr 1fr; }
    .criteria-editor .row.head { display: none; }
}
