:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --ink: #162033;
    --muted: #657087;
    --line: #dfe5ef;
    --accent: #2367d1;
    --accent-dark: #174a9c;
    --success: #177245;
    --danger: #b42318;
    --warning: #9a6700;
    --radius: 12px;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--bg); font-size: 15px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.min-width-zero { min-width: 0; }
h1, h2, p, dd { overflow-wrap: anywhere; }
.topbar { background: #102341; color: white; position: sticky; top: 0; z-index: 10; box-shadow: 0 2px 8px #10234122; }
.topbar-inner { max-width: 1500px; margin: 0 auto; min-height: 64px; padding: 0 28px; display: flex; align-items: center; gap: 24px; }
.brand { font-size: 18px; font-weight: 750; color: white; white-space: nowrap; }
.nav { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; flex: 1; }
.nav a { color: #dce8ff; padding: 9px 10px; border-radius: 7px; font-size: 14px; }
.nav a:hover { background: #ffffff16; color: white; text-decoration: none; }
.userbox { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.userbox small { color: #b8c8e5; display: block; }
.link-button { background: none; border: 0; color: #dce8ff; cursor: pointer; padding: 8px; }
.container { max-width: 1500px; margin: 0 auto; padding: 30px 28px 60px; }
.narrow { max-width: 760px; }
h1 { font-size: 28px; margin: 0 0 8px; letter-spacing: -.02em; }
h2 { font-size: 20px; margin: 0 0 16px; }
.lead { margin: 0 0 26px; color: var(--muted); }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 24px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.card { min-width: 0; max-width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: 0 2px 8px #2134510a; margin-bottom: 20px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.stats-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.stat strong { font-size: 30px; display: block; }
.stat span { color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; align-items: end; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.actions-end { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
label { font-weight: 650; font-size: 14px; }
input, select, textarea { width: 100%; max-width: 100%; min-width: 0; border: 1px solid #bcc7d8; border-radius: 8px; padding: 10px 12px; font: inherit; color: var(--ink); background: white; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid #2367d122; border-color: var(--accent); }
.help { color: var(--muted); font-size: 13px; }
.help-warning { color: #9a6700; font-weight: 700; }
.choice-card { display: flex; gap: 12px; align-items: flex-start; padding: 14px;
    border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; cursor: pointer; }
.choice-card input { width: auto; margin-top: 4px; }
.choice-card span { display: grid; gap: 4px; }
.choice-card small { color: var(--muted); line-height: 1.35; }
.assignment-form { display: grid; gap: 6px; min-width: 230px; }
.assignment-form small { color: var(--muted); }
.btn { display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 8px; padding: 10px 15px; font-weight: 700; cursor: pointer; background: var(--accent); color: white; line-height: 1.1; }
.btn:hover { background: var(--accent-dark); color: white; text-decoration: none; }
.btn-secondary { background: white; border-color: #b8c3d4; color: var(--ink); }
.btn-secondary:hover { background: #eef3fa; color: var(--ink); }
.btn-danger { background: var(--danger); }
.btn-small { padding: 7px 10px; font-size: 13px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: white; }
.table-scroll-shell { min-width: 0; }
.table-scroll-dock { display: none; position: fixed; bottom: 0; z-index: 30; height: 18px;
    overflow-x: auto; overflow-y: hidden; background: #e4eaf3; border: 1px solid #b8c3d4;
    box-shadow: 0 -2px 8px #10234122; }
.table-scroll-dock.is-visible { display: block; }
.table-scroll-dock-content { height: 1px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: #edf2f9; font-size: 13px; color: #42506a; text-transform: uppercase; letter-spacing: .025em; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8faff; }
.number { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.badge { display: inline-flex; border-radius: 999px; padding: 4px 9px; background: #e8eef8; color: #30435f; font-size: 12px; font-weight: 750; }
.badge-success { background: #dff5e9; color: var(--success); }
.badge-danger { background: #fde7e5; color: var(--danger); }
.badge-warning { background: #fff0c7; color: var(--warning); }
.flash { border-radius: 9px; padding: 13px 15px; margin-bottom: 18px; border: 1px solid; }
.flash-success { color: #0e5b36; background: #e5f7ed; border-color: #b9e4cc; }
.flash-error { color: #8b1d15; background: #fff0ef; border-color: #f1c4c0; }
.banner { padding: 14px 16px; border-radius: 9px; margin: 14px 0 20px; background: #fff4d8; color: #755000; border: 1px solid #f0d591; }
.banner-danger { background: #fff0ef; color: #8b1d15; border-color: #f1c4c0; }
.banner-warning { background: #fff4d8; color: #755000; border-color: #f0d591; }
.banner-success { background: #e5f7ed; color: #0e5b36; border-color: #b9e4cc; }
.call-blocked-row { background: #fff8f7; }
.call-blocked-row:hover { background: #fff0ef; }
.table-note { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.inline-form { display: inline-flex; align-items: center; gap: 8px; margin: 2px; }
.inline-form input, .inline-form select { width: auto; min-width: 120px; }
.meta { min-width: 0; display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 8px 16px; }
.meta-wide { grid-template-columns: minmax(180px, 260px) minmax(0, 1fr); }
.meta dt { color: var(--muted); }
.meta dd { min-width: 0; margin: 0; overflow-wrap: anywhere; word-break: break-word; }
.form-spaced { margin-top: 18px; }
.center-link { margin-top: 18px; text-align: center; }
.checkbox { display: flex; flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
.checkbox input { width: auto; margin: 0; }
.comment-form { display: grid; gap: 12px; }
.comment-list { display: grid; gap: 12px; margin-top: 18px; }
.comment { border: 1px solid var(--line); border-radius: 9px; padding: 14px; background: #f8faff; }
.comment p { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
.comment-private { background: #fff8e7; border-color: #efd79c; }
.comment-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.comment-head time { margin-left: auto; color: var(--muted); font-size: 13px; }
.methodology { margin-top: 20px; color: var(--muted); }
.methodology h2 { color: var(--ink); }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(135deg, #0d2243, #244f88); }
.login-card { width: min(430px, 100%); background: white; padding: 34px; border-radius: 16px; box-shadow: 0 24px 60px #07132655; }
.login-card h1 { margin-bottom: 6px; }
.login-card form { display: grid; gap: 17px; margin-top: 24px; }
.login-card .btn { width: 100%; padding: 12px; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; }
.pager-actions { display: flex; gap: 8px; min-width: 180px; }
.pager-actions:last-child { justify-content: flex-end; }
.registry-summary { color: var(--muted); margin: -4px 0 12px; }
#stages { scroll-margin-top: 86px; }
.stage-create { padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.stage-list { display: grid; gap: 12px; }
.stage-item { display: grid; grid-template-columns: minmax(160px, 1.5fr) repeat(2, minmax(90px, .7fr)) auto auto;
    gap: 10px; align-items: end; padding: 14px; border: 1px solid var(--line);
    border-radius: 9px; background: #f8faff; }
.stage-active { min-height: 41px; }
.compact-empty { padding: 18px 10px; }
@media (max-width: 980px) {
    .topbar-inner { align-items: flex-start; flex-direction: column; padding-top: 15px; padding-bottom: 15px; gap: 8px; }
    .stats, .stats-4, .grid-2 { grid-template-columns: 1fr; }
    .form-grid, .filter-grid { grid-template-columns: 1fr; }
    .field.full { grid-column: auto; }
    .page-head { flex-direction: column; }
    .pager { flex-direction: column; }
    .pager-actions { min-width: 0; justify-content: center; }
    .pager-actions:last-child { justify-content: center; }
    .stage-item { grid-template-columns: 1fr 1fr; }
    .stage-name { grid-column: 1 / -1; }
    #stages { scroll-margin-top: 270px; }
}
@media (max-width: 600px) {
    .container { padding: 22px 14px 50px; }
    .card { padding: 16px; }
    .meta, .meta-wide { grid-template-columns: minmax(0, 1fr); gap: 3px; }
    .meta dt { margin-top: 9px; }
    .stage-item { grid-template-columns: minmax(0, 1fr); }
    .stage-name { grid-column: auto; }
}
