/* County Party Hub — design tokens + layout. Bootstrap supplies form/table/button basics. */
:root {
    --navy: #1b2a4a;
    --navy-2: #24365e;
    --navy-3: #31477a;
    --red: #c8102e;
    --red-soft: #fbe9ec;
    --bg: #f4f5f8;
    --surface: #ffffff;
    --border: #e2e5eb;
    --text: #1d2533;
    --muted: #697386;
    --good: #1f7a4d;
    --good-bg: #e6f4ec;
    --info: #2457a6;
    --info-bg: #e8effb;
    --warn: #9a5b00;
    --warn-bg: #fdf1dc;
    --bad: #b42318;
    --bad-bg: #fdecea;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
    --bs-primary: var(--navy);
    --bs-primary-rgb: 27, 42, 74;
    --bs-link-color: var(--info);
    --bs-link-color-rgb: 36, 87, 166;
}

html, body { height: 100%; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
h1:focus { outline: none; }

.btn-primary { --bs-btn-bg: var(--navy); --bs-btn-border-color: var(--navy); --bs-btn-hover-bg: var(--navy-2); --bs-btn-hover-border-color: var(--navy-2); --bs-btn-active-bg: var(--navy-3); --bs-btn-disabled-bg: var(--navy); --bs-btn-disabled-border-color: var(--navy); }
.btn-outline-primary { --bs-btn-color: var(--navy); --bs-btn-border-color: #c3cad8; --bs-btn-hover-bg: var(--navy); --bs-btn-hover-border-color: var(--navy); --bs-btn-disabled-color: #8a93a6; --bs-btn-disabled-border-color: #d7dbe3; }
.btn:disabled[title="Planned"]::after { content: " · planned"; font-size: .75em; opacity: .8; }
.form-control:focus, .form-select:focus, .btn:focus-visible { border-color: var(--navy-3); box-shadow: 0 0 0 .2rem rgba(49, 71, 122, .2); }

/* ---------------------------------------------------------------- Shell */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 252px; flex-shrink: 0; background: var(--navy); color: #cfd6e4;
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: .6rem; padding: 1.1rem 1.1rem .9rem; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-mark {
    display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px;
    background: var(--red); color: #fff; font-size: 18px; flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: .98rem; letter-spacing: .01em; }
.brand-text small { color: #9fb0cf; font-size: .78rem; }

.workspaces { display: flex; gap: .35rem; padding: 0 1rem .75rem; flex-wrap: wrap; }
.workspace { font-size: .78rem; padding: .2rem .6rem; border-radius: 999px; background: var(--navy-2); color: #cfd6e4; }
.workspace.active { background: #fff; color: var(--navy); font-weight: 600; }
.workspace:hover { text-decoration: none; color: #fff; }
.workspace.active:hover { color: var(--navy); }

.nav-groups { padding: .25rem .6rem 1rem; flex: 1; }
.nav-group { margin-bottom: .7rem; }
.nav-group-title { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #8596b8; padding: .5rem .55rem .25rem; }
.nav-item-link {
    display: flex; align-items: center; gap: .55rem; padding: .36rem .55rem; border-radius: 7px;
    color: #d7deea; font-size: .9rem;
}
.nav-item-link:hover { background: var(--navy-2); color: #fff; text-decoration: none; }
.nav-item-link.active { background: var(--navy-3); color: #fff; font-weight: 600; }

.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.dot-live { background: #4ade80; }
.dot-preview { background: #fbbf24; }
.dot-planned { background: transparent; border: 1.5px solid #7d8db0; }
.sidebar-foot { padding: .8rem 1.1rem 1.1rem; display: flex; gap: .8rem; font-size: .72rem; color: #8596b8; border-top: 1px solid var(--navy-2); }
.legend { display: inline-flex; align-items: center; gap: .3rem; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    height: 60px; display: flex; align-items: center; gap: 1rem; padding: 0 1.5rem;
    background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5;
}
.topbar-context { flex: 1; display: flex; align-items: center; gap: .6rem; min-width: 0; }
.context-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.usermenu { display: flex; align-items: center; gap: .25rem; }
.user-chip { display: flex; align-items: center; gap: .55rem; color: var(--text); padding: .25rem .5rem; border-radius: 8px; }
.user-chip:hover { background: var(--bg); text-decoration: none; }
.avatar {
    width: 32px; height: 32px; border-radius: 50%; background: var(--red-soft); color: var(--red);
    display: grid; place-items: center; font-weight: 700; font-size: .8rem;
}
.user-text { display: flex; flex-direction: column; line-height: 1.15; }
.user-text small { color: var(--muted); font-size: .75rem; }
.content { padding: 1.75rem 2rem 3rem; max-width: 1320px; width: 100%; }

.nav-toggle { display: none; }
.nav-toggle-btn { display: none; font-size: 1.3rem; cursor: pointer; margin: 0; }

@media (max-width: 900px) {
    .sidebar { position: fixed; left: -260px; z-index: 20; transition: left .2s; }
    .nav-toggle:checked ~ .sidebar { left: 0; box-shadow: 0 0 40px rgba(0,0,0,.3); }
    .nav-toggle-btn { display: block; }
    .content { padding: 1.25rem 1rem 2rem; }
    .user-text { display: none; }
}

/* ---------------------------------------------------------------- Page primitives */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.4rem; flex-wrap: wrap; }
.page-header h1 { font-size: 1.6rem; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.page-sub { color: var(--muted); margin: .3rem 0 0; max-width: 72ch; }
.page-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .72rem; font-weight: 600; color: var(--red); margin-bottom: .2rem; }
.section-title { font-size: 1.05rem; font-weight: 700; margin: 1.6rem 0 .7rem; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 1rem; }
.mb { margin-bottom: .6rem; }
.text-bad { color: var(--bad) !important; }

.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 1.15rem 1.25rem; display: block;
}
.card h2 { font-size: 1rem; font-weight: 700; margin: 0 0 .7rem; }
.card h2.mt { margin-top: 1.4rem; }
.card h3 { font-size: 1rem; font-weight: 700; margin: .6rem 0 .2rem; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; margin-bottom: .6rem; }
.card-head h2 { margin: 0; }
.card-warn { border-color: #f1d49c; background: #fffaf0; }
a.card { color: inherit; }
a.card:hover { text-decoration: none; border-color: #c3cad8; }

/* Columns collapse on available width (not viewport), and children may shrink so wide tables scroll inside their card. */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: 1.1rem; align-items: start; }
.grid-2-wide-right { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.grid-2 > *, .stack > * { min-width: 0; }
.card:has(> .table.data), .card:has(> table) { overflow-x: auto; }
.stack { display: flex; flex-direction: column; gap: 1.1rem; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1rem; }
@media (max-width: 1100px) { .grid-2-wide-right { grid-template-columns: 1fr; } }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.stat {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .15rem; color: inherit;
}
a.stat:hover { text-decoration: none; border-color: #c3cad8; }
.stat-value { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.stat-value small { font-size: 1rem; color: var(--muted); font-weight: 600; }
.stat-value.small-value { font-size: 1.1rem; padding: .35rem 0; }
.stat-label { color: var(--muted); font-size: .84rem; }
.stat-note { font-size: .78rem; color: var(--warn); font-weight: 600; }
.stat-warn { border-left: 3px solid #e6a23c; }

.meter { display: block; height: 6px; border-radius: 99px; background: #edf0f5; overflow: hidden; margin-top: .4rem; }
.meter > span { display: block; height: 100%; background: var(--good); border-radius: 99px; }

.pill {
    display: inline-flex; align-items: center; gap: .25rem; padding: .08rem .5rem; border-radius: 999px;
    font-size: .74rem; font-weight: 600; white-space: nowrap; line-height: 1.5; vertical-align: middle;
}
.pill-good { background: var(--good-bg); color: var(--good); }
.pill-info { background: var(--info-bg); color: var(--info); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-bad { background: var(--bad-bg); color: var(--bad); }
.pill-muted { background: #eef0f4; color: #4b5565; }

.callout { background: #f6f8fb; border: 1px solid var(--border); border-radius: 8px; padding: .65rem .85rem; margin: .8rem 0; display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; }
.callout-warn { background: var(--warn-bg); border-color: #f1d49c; }
.callout-good { background: var(--good-bg); border-color: #b7e0c8; }
.planned-banner {
    border: 1px dashed #b9c2d3; background: repeating-linear-gradient(-45deg, #fafbfd, #fafbfd 10px, #f4f6fa 10px, #f4f6fa 20px);
    border-radius: 8px; padding: .7rem .9rem; margin-bottom: 1.1rem; color: #3d4757;
}

/* Lists */
.list { list-style: none; padding: 0; margin: 0; }
.list > li { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .6rem 0; border-top: 1px solid #eef0f4; }
.list > li:first-child { border-top: 0; }
.list.compact > li { padding: .35rem 0; justify-content: flex-start; }
.list.compact > li > .muted { min-width: 9.5rem; font-size: .85rem; }
.list > li.done { opacity: .6; }
.list-meta { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }
.list.selectable > li { padding: .5rem .5rem; margin: 0 -.5rem; border-radius: 6px; }
.list.selectable > li.selected { background: var(--info-bg); }
.list.selectable a { display: flex; flex-direction: column; color: var(--text); }
.feature-row { display: flex; align-items: center; gap: .85rem; color: inherit; }
a.feature-row:hover { text-decoration: none; }
.date-badge {
    width: 46px; flex-shrink: 0; text-align: center; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff;
}
.date-badge span { display: block; background: var(--red); color: #fff; font-size: .66rem; text-transform: uppercase; font-weight: 700; letter-spacing: .06em; padding: .1rem 0; }
.date-badge strong { display: block; font-size: 1.15rem; padding: .1rem 0 .15rem; }

/* Tables */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
.table.data { margin: 0; font-size: .9rem; }
.table.data th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: #fafbfc; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table-wrap .table.data th:first-child, .table-wrap .table.data td:first-child { padding-left: 1.1rem; }
.table.data td { vertical-align: middle; border-color: #eef0f4; }
.card .table.data th { background: transparent; }
.row-upcoming td { background: #fbfcff; }
.row-muted td { opacity: .55; }
.role-cell { max-width: 320px; }
.role-tag { display: inline-block; font-size: .76rem; background: #eef0f4; color: #3d4757; border-radius: 5px; padding: .05rem .4rem; margin: .1rem .2rem .1rem 0; }
.person-link { color: var(--text); font-weight: 500; white-space: nowrap; }
.person-link:hover { color: var(--info); }
.inline-form { margin: 0; }
.inline-form .form-select { width: auto; min-width: 130px; }

/* Filters */
.filters { display: flex; gap: .5rem; margin-bottom: .8rem; max-width: 560px; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.chip { font-size: .82rem; padding: .25rem .7rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.chip span { color: var(--muted); margin-left: .2rem; font-weight: 600; }
.chip:hover { text-decoration: none; border-color: #c3cad8; }
.chip.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.chip.active span { color: #b9c6e0; }
.chip-warn:not(.active) { border-color: #f1d49c; }

/* Facts */
.facts { display: grid; grid-template-columns: 8.5rem 1fr; gap: .35rem .75rem; margin: 0 0 .5rem; font-size: .92rem; }
.facts dt { color: var(--muted); font-weight: 500; }
.facts dd { margin: 0; }

/* Precincts */
.jp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 1rem; }
.precinct-list { list-style: none; padding: 0; margin: 0; }
.precinct-list li { display: flex; gap: .6rem; align-items: baseline; padding: .32rem 0; border-top: 1px solid #f0f2f5; font-size: .9rem; }
.precinct-code { font-family: ui-monospace, "Cascadia Mono", monospace; font-weight: 700; font-size: .82rem; padding: .05rem .4rem; border-radius: 5px; background: var(--good-bg); color: var(--good); }
.precinct-list li.vacant .precinct-code { background: var(--bad-bg); color: var(--bad); }

/* Meetings */
.motions { padding-left: 1.2rem; margin: 0; }
.motions li { padding: .55rem 0; border-top: 1px solid #eef0f4; }
.motions li:first-child { border-top: 0; }
.motion-head { display: flex; justify-content: space-between; align-items: center; }
.attendance { columns: 2; list-style: none; padding: 0; margin: 0; font-size: .9rem; }
.attendance li { padding: .2rem 0; break-inside: avoid; }

/* Events */
.event-card h3 { margin-top: .5rem; }
.event-flags { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .6rem; }
.pipeline { display: grid; grid-template-columns: repeat(5, 1fr); gap: .4rem; }
.pipeline-stage { border-radius: 8px; padding: .45rem .5rem; display: flex; flex-direction: column; align-items: center; font-size: .75rem; }
.pipeline-stage strong { font-size: 1.2rem; }
.readiness { list-style: none; padding: 0; margin: 0; }
.readiness li { display: flex; justify-content: space-between; padding: .4rem 0 .4rem 1.6rem; border-top: 1px solid #eef0f4; position: relative; font-size: .92rem; }
.readiness li:first-child { border-top: 0; }
.readiness li::before { content: "○"; position: absolute; left: .2rem; color: var(--muted); }
.readiness li.ok::before { content: "●"; color: var(--good); }
.readiness li.planned { color: var(--muted); }
.readiness li.planned::before { content: "◌"; }

/* State */
.county-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .6rem; }
.county-tile {
    background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: .65rem .75rem;
    color: inherit; display: flex; flex-direction: column; gap: .3rem; min-height: 92px; border-top: 3px solid transparent;
}
a.county-tile[href]:hover { text-decoration: none; box-shadow: var(--shadow); }
.county-tile:not([href]) { cursor: default; }
.county-name { font-weight: 700; }
.county-facts { display: flex; gap: .6rem; font-size: .78rem; color: var(--muted); }
.county-issue { font-size: .74rem; color: var(--warn); }
.county-tile .pill { align-self: flex-start; }
.health-healthy { border-top-color: var(--good); }
.health-needsattention { border-top-color: #e6a23c; }
.health-notonboarded { background: #f8f9fb; color: var(--muted); border-style: dashed; }

/* Planned module */
.workflow { padding-left: 1.3rem; margin: 0; }
.workflow li { padding: .35rem 0; }
.tag-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .35rem; }
.tag-list li { background: #eef0f4; border-radius: 6px; padding: .15rem .55rem; font-size: .84rem; }
.tag-list li.tbd { background: var(--warn-bg); color: var(--warn); }

.form-actions { display: flex; gap: .5rem; margin-top: 1rem; flex-wrap: wrap; }
.form-actions form { margin: 0; }
.review-form { margin-top: 1rem; border-top: 1px solid var(--border); padding-top: 1rem; }

/* ---------------------------------------------------------------- Auth screens */
.auth-shell { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 1rem; background: linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 55%, #3a1830 140%); }
.auth-card { width: 100%; max-width: 440px; background: var(--surface); border-radius: 14px; padding: 2rem 2rem 1.6rem; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.auth-brand { display: flex; align-items: center; gap: .6rem; color: var(--navy); font-weight: 700; margin-bottom: 1.4rem; }
.auth-brand:hover { text-decoration: none; }
.auth-title { font-size: 1.45rem; font-weight: 700; margin-bottom: .4rem; letter-spacing: -.01em; }
.auth-lede { color: var(--muted); margin-bottom: 1.3rem; }
.auth-help { color: var(--muted); font-size: .84rem; margin: 1.2rem 0 0; }
.auth-foot { color: #9fb0cf; font-size: .78rem; margin-top: 1rem; }
.auth-divider { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .8rem; margin: .4rem 0 1rem; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.code-input { font-family: ui-monospace, "Cascadia Mono", monospace; letter-spacing: .3em; font-size: 1.4rem; text-align: center; }
.enroll-steps { list-style: none; padding: 0; margin: 0 0 1.2rem; counter-reset: step; }
.enroll-steps li { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .9rem 0; border-top: 1px solid var(--border); }
.enroll-steps li > div { display: flex; flex-direction: column; }
.enroll-steps li span { color: var(--muted); font-size: .86rem; }
.enroll-steps li.done strong { color: var(--good); }
.step-status { color: var(--good) !important; font-weight: 600; white-space: nowrap; }
.enroll-steps .btn { white-space: nowrap; flex-shrink: 0; }
.outbox-item { border-top: 1px solid var(--border); padding: .7rem 0; }
.outbox-item pre { white-space: pre-wrap; font-size: .85rem; margin: .3rem 0 0; }

.qr-code { width: 200px; margin: .5rem 0 1rem; padding: 8px; background: #fff; border: 1px solid var(--border); border-radius: 8px; }
.qr-code svg { width: 100%; height: auto; display: block; }

/* Account management pages (template) inside the shell */
.manage-grid { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 1.1rem; align-items: start; }
.manage-nav { padding: .6rem; }
.manage-grid h3 { font-size: 1.1rem; font-weight: 700; }
@media (max-width: 900px) { .manage-grid { grid-template-columns: 1fr; } }
.content .nav-pills .nav-link { color: var(--text); padding: .4rem .6rem; font-size: .9rem; }
.content .nav-pills .nav-link.active { background: var(--navy); color: #fff; }

#blazor-error-ui {
    background: lightyellow; bottom: 0; box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); display: none;
    left: 0; padding: 0.6rem 1.25rem 0.7rem 1.25rem; position: fixed; width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }
