:root {
    color-scheme: light;
    font-family: 'Segoe UI', system-ui, sans-serif;
    color: #18243a;
    background: #f4f7fc;
    --side: #101b30;
    --muted: #576680;
    --line: #e0e7f1;
    --blue: #2758df;
    --indigo: #486cf5;
    --mint: #109a7f;
    --surface: #fff;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; }
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .65; }
:focus-visible { outline: 3px solid #6291ff; outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
svg { flex: none; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 236px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--side); color: #c4cfe2; padding: 30px 16px 16px; }
.brand { display: flex; align-items: center; gap: 11px; color: white; margin: 0 7px 44px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 1.125rem; letter-spacing: -.02em; }
.brand small { margin-top: 4px; font-size: .75rem; letter-spacing: .06em; color: #9fabbe; }
.nav-group + .nav-group { margin-top: 27px; }
.nav-heading { color: #9fabbe; font-size: .75rem; font-weight: 700; letter-spacing: .08em; padding-left: 12px; margin-bottom: 9px; }
.nav-link { display: flex; align-items: center; gap: 11px; padding: 12px; min-height: 43px; margin-bottom: 3px; border-radius: 8px; font-size: .92rem; font-weight: 600; }
.nav-link:hover { color: white; background: #1a2a45; }
.nav-link[aria-current] { background: #223767; color: #fff; }
.nav-link[aria-current] svg { color: #9eb5ff; }
.sidebar-footer { margin-top: auto; border-top: 1px solid #2a3549; padding: 15px 7px 3px; display: flex; align-items: center; gap: 10px; }
.sidebar-footer strong, .sidebar-footer small { display: block; }
.sidebar-footer strong { color: #edf2ff; font-size: .875rem; }
.sidebar-footer small { color: #a9b5c8; font-size: .8rem; margin-top: 4px; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: #273c64; color: #d8e4ff; font-size: .8rem; font-weight: 700; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 62px; gap: 14px; padding: 0 31px; background: #fff; border-bottom: 1px solid var(--line); font-size: .92rem; font-weight: 650; }
main { margin: 0 auto; max-width: 1530px; padding: 26px 31px 45px; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 23px; }
h1 { font-size: clamp(1.65rem, 3vw, 2.125rem); line-height: 1.15; letter-spacing: -.04em; }
h2 { font-size: 1.1rem; letter-spacing: -.015em; }
.page-head p, .panel-head p { margin-top: 6px; color: var(--muted); line-height: 1.5; }
.panel-head p { font-size: .875rem; }

.button { border: 1px solid transparent; border-radius: 8px; min-height: 39px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 7px 13px; white-space: nowrap; color: #fff; background: var(--blue); font-size: .875rem; font-weight: 650; }
.button:hover { background: #1848ca; }
.button.secondary { color: #263753; background: white; border-color: #d6e0ed; }
.button.secondary:hover { background: #edf3fc; }
.button.ghost { color: #304eaa; background: transparent; padding-inline: 6px; }
.button.ghost:hover { background: #edf2ff; }
.button.danger { background: #aa2435; }
.button.danger:hover { background: #921b2b; }
.button.compact { min-height: 33px; padding: 5px 9px; }
.icon-btn { display: inline-grid; place-items: center; border: 1px solid #dce4ef; width: 33px; height: 33px; background: #fff; border-radius: 7px; color: #4c5d78; }
.icon-btn:hover { background: #eef3fd; color: #163fb9; }
.icon-btn.remove:hover { background: #fff0f1; color: #a72637; }
.actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; white-space: nowrap; }
.campaign-actions { flex-wrap: wrap; max-width: 310px; }
.pill { display: inline-flex; align-items: center; gap: 6px; width: max-content; border-radius: 24px; padding: 5px 9px; line-height: 1.15; font-size: .8125rem; font-weight: 650; white-space: nowrap; }
.pill::before { content: ''; height: 6px; width: 6px; border-radius: 50%; background: currentColor; }
.pill.neutral { background: #eef2f8; color: #465873; }
.pill.good { background: #ddf5ee; color: #12634f; }
.pill.info { background: #e7eeff; color: #2d4ba3; }
.pill.warn { background: #fff1d6; color: #774909; }
.pill.bad { background: #feecee; color: #9b2a3d; }

.hero { position: relative; overflow: hidden; min-height: 161px; display: flex; align-items: center; padding: 25px 29px; border-radius: 14px; color: #fff; background: linear-gradient(112deg, #172d60 8%, #214696 66%, #2757c2 100%); margin-bottom: 20px; }
.hero-content { position: relative; z-index: 1; }
.hero h2 { font-size: clamp(1.35rem, 3vw, 1.65rem); }
.hero p { color: #e0e9ff; margin-top: 7px; line-height: 1.5; max-width: 36rem; }
.hero .button { margin-top: 16px; color: #1f49ba; background: #fff; }
.hero .button:hover { background: #e6efff; }
.hero-wave { position: absolute; width: 42%; min-width: 270px; height: auto; right: 0; opacity: .74; }
.metrics { display: grid; gap: 14px; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 18px; }
.metric { padding: 14px 16px 16px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.metric-top { display: flex; align-items: center; gap: 9px; color: #465674; font-size: .875rem; font-weight: 600; }
.metric-icon { width: 33px; height: 33px; display: grid; place-items: center; border-radius: 8px; background: #ebf0ff; color: #3158d7; flex: none; }
.metric-icon.green { background: #e1f7f1; color: #137761; }
.metric-icon.violet { background: #f1ecff; color: #6945ba; }
.metric-icon.sky { background: #e7f4fd; color: #16638e; }
.metric-value { display: block; margin: 8px 0 0; line-height: 1.05; font-size: 1.95rem; letter-spacing: -.055em; font-weight: 720; }

.overview-grid { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(245px, 1fr); gap: 16px; margin-bottom: 16px; }
.panel { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.panel + .panel.stacked { margin-top: 16px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 17px 19px 13px; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: .8125rem; color: var(--muted); align-items: center; padding-top: 2px; }
.legend span { display: inline-flex; gap: 5px; align-items: center; white-space: nowrap; }
.legend i { width: 8px; height: 8px; border-radius: 50%; background: var(--indigo); }
.legend .answer-color { background: var(--mint); }
.chart { margin: 0 18px 14px; }
.plot { width: 100%; height: 140px; display: block; overflow: visible; }
.plot line { stroke: #e3eaf4; stroke-dasharray: 3 4; }
.plot polyline { fill: none; stroke-width: 2.5; vector-effect: non-scaling-stroke; }
.plot .attempt { stroke: var(--indigo); }
.plot .answer { stroke: var(--mint); }
.plot circle.attempt { fill: white; }
.plot circle.answer { fill: var(--mint); }
.chart-dates { display: flex; justify-content: space-between; gap: 3px; padding: 6px 4px 0 9px; color: var(--muted); font-size: .8125rem; }
.scale { fill: #596b85; font-size: 11px; }
.setup { padding: 2px 18px 14px; display: grid; gap: 8px; }
.setup-link { min-height: 46px; display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 8px; background: #f3f6fb; color: #2c4267; font-size: .875rem; font-weight: 650; }
.setup-link:hover { background: #e9efff; color: #2043a9; }
.setup-link svg { color: #4664ad; }
.setup-link .step-status { margin-left: auto; font-size: .8rem; color: #546380; }
.setup-link .step-status.done { color: #12634f; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; text-align: left; }
th, td { padding: 10px 14px; vertical-align: middle; }
th:first-child, td:first-child { padding-left: 19px; }
th:last-child, td:last-child { padding-right: 19px; }
th { background: #f5f7fb; color: #465672; font-size: .8125rem; font-weight: 680; white-space: nowrap; }
td { border-bottom: 1px solid #e9eef5; }
tr:last-child td { border-bottom: 0; }
td.numeric { font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell-main { color: #1c2d4b; font-weight: 650; overflow-wrap: anywhere; }
.cell-meta { display: block; margin-top: 3px; color: var(--muted); font-size: .8125rem; }
.empty { min-height: 170px; display: grid; place-items: center; text-align: center; padding: 22px; }
.empty-icon { display: inline-grid; place-items: center; width: 43px; height: 43px; border-radius: 12px; color: #3e64db; background: #edf2ff; margin-bottom: 9px; }
.empty h3 { font-size: 1rem; }
.empty p { color: var(--muted); font-size: .9rem; margin-top: 5px; line-height: 1.5; }
.empty .button { margin-top: 13px; }
.loading { color: var(--muted); padding: 22px 0; }
.filter-form { display: grid; grid-template-columns: repeat(2, minmax(110px, .8fr)) repeat(2, minmax(145px, 1fr)) auto; gap: 10px; align-items: end; padding: 16px 18px; }
.billing-controls { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin-bottom: 14px; }
.billing-controls .field { flex: 1 1 220px; max-width: 380px; }
.billing-alert { margin-bottom: 14px; padding: 10px 14px; border: 1px solid #f1ddad; border-radius: 8px; background: #fffaec; color: #774909; font-size: .9rem; }
#sign-in { display: grid; place-items: center; min-height: 100vh; }
.login-panel { width: min(100%, 410px); padding: 28px; }
.login-panel h1 { margin: 12px 0 20px; }
.login-panel form { display: grid; gap: 14px; }
.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 19px; color: var(--muted); font-size: .875rem; border-top: 1px solid var(--line); }
.progress { display: flex; gap: 7px; align-items: center; }
progress { width: 66px; height: 6px; border: 0; border-radius: 8px; background: #e5ebf5; }
progress::-webkit-progress-bar { border-radius: 8px; background: #e5ebf5; }
progress::-webkit-progress-value { border-radius: 8px; background: var(--indigo); }
progress::-moz-progress-bar { border-radius: 8px; background: var(--indigo); }

dialog { width: min(540px, calc(100% - 28px)); max-height: calc(100dvh - 30px); padding: 0; border: 1px solid var(--line); border-radius: 14px; color: inherit; box-shadow: 0 20px 80px #10234240; }
dialog::backdrop { background: #0d18328a; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 17px 20px; border-bottom: 1px solid var(--line); }
.dialog-body { display: grid; gap: 13px; padding: 17px 20px; }
.dialog-body p { line-height: 1.55; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; padding: 12px 20px; border-top: 1px solid var(--line); background: #f6f8fc; }
.field { display: grid; gap: 5px; min-width: 0; }
.field > span { font-size: .875rem; color: #344760; font-weight: 650; }
.field input, .field select, .field textarea { min-width: 0; width: 100%; padding: 8px 9px; border: 1px solid #cdd9e9; border-radius: 7px; color: #14243e; background: #fff; }
.field select { appearance: none; padding-right: 24px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='m2 4 4 4 4-4' fill='none' stroke='%23576680' stroke-width='1.5'/%3E%3C/svg%3E"); background-position: right 8px center; background-repeat: no-repeat; }
.field textarea { min-height: 85px; resize: vertical; }
.field small, .help { color: var(--muted); font-size: .8125rem; }
.inline-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.scenario-extra { display: grid; gap: 12px; }
.form-error { background: #fff0f2; color: #952238; padding: 9px; border-radius: 7px; font-size: .9rem; }
audio { width: 100%; }
.toast { position: fixed; inset: auto 20px 20px auto; width: max-content; max-width: calc(100vw - 40px); padding: 11px 15px; z-index: 9; color: #fff; background: #163555; border-radius: 8px; box-shadow: 0 6px 24px #2034593d; }

@media (max-width: 1050px) {
    .shell { grid-template-columns: 199px minmax(0, 1fr); }
    .topbar, main { padding-inline: 20px; }
    .filter-form { grid-template-columns: repeat(3, minmax(100px, 1fr)); }
}

@media (max-width: 820px) {
    .shell { grid-template-columns: minmax(0, 1fr); }
    .sidebar { height: auto; position: static; padding: 11px 15px 6px; }
    .brand { margin: 0 0 8px; }
    .brand img { width: 34px; height: 34px; }
    .brand small, .nav-heading, .sidebar-footer { display: none; }
    .sidebar nav { display: flex; gap: 4px; overflow-x: auto; }
    .nav-group, .nav-group + .nav-group { display: flex; gap: 3px; margin: 0; }
    .nav-link { white-space: nowrap; min-height: 36px; padding: 7px 9px; gap: 5px; }
    .nav-link svg { width: 16px; height: 16px; }
    .topbar { min-height: 44px; }
}

@media (max-width: 570px) {
    .topbar, main { padding-inline: 12px; }
    main { padding-top: 17px; }
    .page-head { align-items: flex-start; flex-wrap: wrap; margin-bottom: 16px; }
    .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
    .metric { padding: 10px; }
    .metric-value { font-size: 1.65rem; }
    .overview-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
    .hero { padding: 17px; }
    .hero-wave { opacity: .24; right: -50px; }
    .filter-form, .inline-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .plot { height: 125px; }
    .chart-dates { font-size: .75rem; }
}
