:root {
  --bg: #f4f5f8; --surface: #fff; --surface-2: #f8f9fb; --line: #e3e6ec; --line-2: #d3d8e1;
  --ink: #1a2133; --ink-2: #4a5468; --muted: #7a8396;
  --side: #17213b; --side-ink: #c9d0e0; --side-hi: #fff;
  --accent: #b8435a; --accent-ink: #fff; --accent-soft: #fbe9ec;
  --brand: #c85164; --danger: #c93a3a; --danger-soft: #fbeaea; --ok: #23865a; --ok-soft: #e5f4ec; --warn: #b8730d; --warn-soft: #fdf2df;
  --st-idea: #8e97a8; --st-review: #4f7bd8; --st-approval: #b8730d; --st-active: #23865a; --st-done: #5b3fc4; --st-paused: #b9bec9;
  --s-todo: #8e97a8; --s-in_progress: #2f55d4; --s-review: #c98a12; --s-done: #23865a;
  --radius: 10px; --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 2px 8px rgba(20, 30, 60, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f131c; --surface: #171c27; --surface-2: #1c2230; --line: #262d3d; --line-2: #323b4f;
    --ink: #e7eaf1; --ink-2: #b4bccc; --muted: #8590a6;
    --side: #0b0e15; --side-ink: #a9b2c6;
    --accent: #e8899a; --accent-ink: #1a0d11; --accent-soft: #3a1d25;
    --danger: #ef6b6b; --danger-soft: #3a1d22; --ok: #4fc08b; --ok-soft: #173126; --warn: #e3a43e; --warn-soft: #3a2b12;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f131c; --surface: #171c27; --surface-2: #1c2230; --line: #262d3d; --line-2: #323b4f;
  --ink: #e7eaf1; --ink-2: #b4bccc; --muted: #8590a6; --side: #0b0e15; --side-ink: #a9b2c6;
  --accent: #e8899a; --accent-ink: #1a0d11; --accent-soft: #3a1d25; --danger: #ef6b6b; --danger-soft: #3a1d22;
  --ok: #4fc08b; --ok-soft: #173126; --warn: #e3a43e; --warn-soft: #3a2b12; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; line-height: 1.25; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; }
h3 { font-size: 13px; margin: 16px 0 6px; color: var(--ink-2); }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.block { display: block; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.boot { padding: 40px; color: var(--muted); }

/* кнопки и поля */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.small { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.wide { width: 100%; height: 40px; }
.icon-btn { border: 0; background: none; color: inherit; cursor: pointer; width: 34px; height: 34px; border-radius: 8px; display: inline-grid; place-items: center; font-size: 16px; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 20px; height: 20px; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; font-size: 13px; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 10px; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
textarea { resize: vertical; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; flex: none; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; color: var(--ink); font-size: 13.5px; cursor: pointer; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px 12px; margin: 0; min-width: 0; }
legend { font-size: 12.5px; font-weight: 600; color: var(--ink-2); padding: 0 4px; }

/* вход */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, #a83f52, #c85164 55%, #d9737f); }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.form-err { color: var(--danger); font-size: 13px; min-height: 0; margin: 0; }
.form-err:empty { display: none; }

/* бренд */
.brand { display: flex; align-items: center; gap: 10px; }
.brand b { display: block; font-size: 15px; }
.brand small { display: block; font-size: 11.5px; opacity: .7; line-height: 1.3; }
.brand.big b { font-size: 18px; }
.logo { flex: none; width: 36px; height: 36px; border-radius: 9px; background: var(--brand); display: grid; place-items: center; }
.logo img { width: 62%; height: auto; display: block; }
.auth-logo { width: 128px; height: 128px; border-radius: 50%; object-fit: cover; align-self: center; }
.auth-title { text-align: center; margin-bottom: 4px; }
.auth-title b { display: block; font-size: 19px; }
.auth-title small { display: block; color: var(--muted); font-size: 12.5px; }

/* каркас */
.shell { display: flex; min-height: 100vh; }
.side { width: 240px; flex: none; background: var(--side); color: var(--side-ink); padding: 18px 12px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.side .brand { padding: 0 8px; color: var(--side-hi); }
.side nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--side-ink); font-weight: 500; }
.side nav a svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.side nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: var(--side-hi); }
.side nav a.active { background: rgba(255,255,255,.1); color: var(--side-hi); }
.side .me { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; color: var(--side-hi); }
.side .me:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.side .me.active { background: rgba(255,255,255,.1); }
.side .me b { display: block; font-size: 13px; }
.side .me small { display: block; font-size: 11.5px; color: var(--side-ink); }
.side > .btn { color: var(--side-ink); border-color: rgba(255,255,255,.15); }
.side > .btn:hover { background: rgba(255,255,255,.06); }
.main-wrap { flex: 1; min-width: 0; }
.topbar { display: none; }
#main { padding: 28px 32px 48px; max-width: 1480px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 + .chips { margin-top: 8px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back { display: inline-block; margin-bottom: 10px; font-size: 13px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); font-size: 11.5px; font-weight: 600; text-align: center; margin-left: 6px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid2 > .card { margin-bottom: 0; }
.grid2 + .grid2, .grid2 + .card { margin-top: 16px; }
.empty { padding: 18px; text-align: center; color: var(--muted); border: 1px dashed var(--line-2); border-radius: 8px; }
.empty p { margin-bottom: 8px; }
.empty p:last-child { margin: 0; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: var(--ink); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.kpi:hover { border-color: var(--line-2); text-decoration: none; }
.kpi span { font-size: 12.5px; color: var(--muted); }
.kpi b { font-size: 28px; font-variant-numeric: tabular-nums; line-height: 1.2; margin: 4px 0 2px; }
.kpi small { color: var(--muted); font-size: 12px; }
.kpi.warn b { color: var(--danger); }

/* этапы и статусы */
.stagebar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; gap: 2px; background: var(--surface-2); }
.seg { display: block; height: 100%; min-width: 4px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 10px 0 4px; font-size: 12.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot, .sdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.st-idea { --c: var(--st-idea); } .st-review { --c: var(--st-review); } .st-approval { --c: var(--st-approval); }
.st-active { --c: var(--st-active); } .st-done { --c: var(--st-done); } .st-paused { --c: var(--st-paused); }
.dot.st-idea, .seg.st-idea, .dot.st-review, .seg.st-review, .dot.st-approval, .seg.st-approval, .dot.st-active, .seg.st-active,
.dot.st-done, .seg.st-done, .dot.st-paused, .seg.st-paused { background: var(--c); }
.s-todo { background: var(--s-todo); } .s-in_progress { background: var(--s-in_progress); } .s-review { background: var(--s-review); } .s-done { background: var(--s-done); }

.chips { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.chip { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 11.5px; font-weight: 500; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
a.chip:hover { text-decoration: none; border-color: var(--line-2); }
.chip.min { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.chip.hot { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.off { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.chip[class*="st-"] { background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--c); border-color: transparent; }
.stage-sel { width: auto; height: 26px; padding: 0 8px; font-size: 12.5px; font-weight: 600; color: var(--c); border-color: color-mix(in srgb, var(--c) 40%, transparent); background: color-mix(in srgb, var(--c) 10%, var(--surface)); }
.due { font-size: 12px; color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.due.late { color: var(--danger); font-weight: 600; }

/* аватары */
.av { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-size: 9.5px; font-weight: 700; color: #fff; flex: none; letter-spacing: .02em; }
.av.md { width: 30px; height: 30px; font-size: 11px; }
.av.c0 { background: #4f6bd8; } .av.c1 { background: #23865a; } .av.c2 { background: #b8730d; } .av.c3 { background: #8a4fc4; }
.av.c4 { background: #c93a6a; } .av.c5 { background: #1f8a9a; } .av.c6 { background: #5b6478; } .av.c7 { background: #a85a2a; }
.av.more { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line-2); }
.avs { display: inline-flex; }
.avs .av { box-shadow: 0 0 0 2px var(--surface); }
.avs .av + .av { margin-left: -6px; }
.person { display: inline-flex; align-items: center; gap: 6px; margin: 0 10px 4px 0; }

/* списки задач и проектов */
.tlist, .plist, .alist { list-style: none; margin: 0; padding: 0; }
.tline { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 6px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; font: inherit; color: inherit; cursor: pointer; border-radius: 0; }
.tlist li:last-child .tline { border-bottom: 0; }
.tline:hover { background: var(--surface-2); }
.tl-main { flex: 1; min-width: 0; }
.tl-main b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-main small { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plist li { border-bottom: 1px solid var(--line); }
.plist li:last-child { border: 0; }
.plist a { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 9px 2px; color: inherit; }
.plist a b { font-weight: 500; }
.plist.small li { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 6px 0; font-size: 13px; }

/* тулбар */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; align-items: center; }
.toolbar input[type=search] { width: 240px; }
.toolbar select { width: auto; max-width: 220px; }
.seg-ctl { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; margin-left: auto; }
.seg-ctl button { border: 0; background: var(--surface); padding: 7px 12px; font: inherit; color: var(--ink-2); cursor: pointer; }
.seg-ctl button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* доски */
.board { display: grid; grid-template-columns: repeat(6, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.board.tasks { grid-template-columns: repeat(4, minmax(240px, 1fr)); }
.col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); min-height: 120px; display: flex; flex-direction: column; }
.col.over { border-color: var(--accent); background: var(--accent-soft); }
.col header { display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-weight: 600; font-size: 13px; }
.col header .count { margin-left: auto; }
.col-body { display: flex; flex-direction: column; gap: 8px; padding: 0 8px 10px; }
.pcard, .tcard { display: flex; flex-direction: column; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; color: var(--ink); box-shadow: var(--shadow); text-align: left; font: inherit; cursor: pointer; width: 100%; }
.pcard:hover, .tcard:hover { border-color: var(--line-2); text-decoration: none; }
.pcard.hot, .tcard.hot { border-left: 3px solid var(--warn); }
.pcard b, .tcard b { font-weight: 600; font-size: 13.5px; line-height: 1.35; }
.pcard.dragging, .tcard.dragging { opacity: .45; }
.pmeta, .tmeta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); }
.tmeta .avs { margin-left: auto; }
.lead { display: inline-flex; align-items: center; gap: 6px; }
.prog { display: flex; align-items: center; gap: 8px; }
.prog small { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
progress { appearance: none; -webkit-appearance: none; flex: 1; height: 5px; border: 0; border-radius: 3px; background: var(--line); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--line); border-radius: 3px; }
progress::-webkit-progress-value { background: var(--ok); border-radius: 3px; }
progress::-moz-progress-bar { background: var(--ok); border-radius: 3px; }

/* таблицы */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.dim td { opacity: .55; }
.tbl td a { color: var(--ink); }
.tbl td a:hover { color: var(--accent); }
.tbl td.chips { display: table-cell; }
.tbl td.chips .chip { margin: 0 4px 4px 0; }
.st { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.users .person { margin: 0; align-items: flex-start; }
.users td:first-child { min-width: 300px; }
.users td:nth-child(3) { min-width: 180px; }

/* карточка проекта */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.prose { color: var(--ink); line-height: 1.55; overflow-wrap: anywhere; }
.facts dl, dl.facts { margin: 0; }
.facts dt { font-size: 12px; color: var(--muted); margin-top: 12px; }
.facts dt:first-child { margin-top: 0; }
.facts dd { margin: 4px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
dl.facts.inline { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; margin: 14px 0; }
dl.facts.inline dt { margin: 0; padding-top: 2px; }
dl.facts.inline dd { margin: 0; }

.comment { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.comment > div { flex: 1; min-width: 0; }
.comment p { margin: 4px 0 0; overflow-wrap: anywhere; }
.c-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.c-head .link { margin-left: auto; color: var(--muted); }
.c-form { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; align-items: flex-end; }
.alist li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.alist li:last-child { border: 0; }
.alist li > div { min-width: 0; overflow-wrap: anywhere; }
.alist small { display: block; font-size: 11.5px; margin-top: 2px; }
.alist.compact li { padding: 6px 0; font-size: 12.5px; }

/* министерства */
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.mgrid .card { margin: 0; }
.people-row { display: flex; flex-wrap: wrap; margin: 10px 0; font-size: 13px; }
.mstats { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink-2); padding-top: 10px; border-top: 1px solid var(--line); }
.mstats b { color: var(--ink); }
.roles-help summary { cursor: pointer; font-weight: 600; }
.roles-help dl { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; margin: 12px 0 0; }
.roles-help dt { font-weight: 600; } .roles-help dd { margin: 0; color: var(--ink-2); }

/* модальное окно */
dialog { border: 0; padding: 0; border-radius: 14px; background: var(--surface); color: var(--ink); width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: 0 24px 60px rgba(0,0,0,.3); }
dialog.wide { width: min(760px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(10, 15, 30, .45); }
#modal-body { padding: 22px; }
.form { display: flex; flex-direction: column; gap: 12px; }
.form h2 { font-size: 18px; margin-bottom: 2px; }
.form .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.form-actions.left { justify-content: flex-start; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px 12px; max-height: 210px; overflow-y: auto; padding: 2px; }
.picker { display: flex; flex-direction: column; gap: 8px; }
.creds { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 12px; font: 13px/1.6 ui-monospace, Menlo, monospace; white-space: pre-wrap; user-select: all; margin: 0; overflow-wrap: anywhere; }
.task-view .tv-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.task-view h2 { font-size: 19px; line-height: 1.3; margin: 0 0 8px; }
.task-view .comments { box-shadow: none; padding: 14px 0 0; border: 0; border-top: 1px solid var(--line); border-radius: 0; margin: 16px 0 8px; }
.task-view details { margin-top: 8px; }
.task-view summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.status-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 14px; }
.stbtn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border: 1px solid var(--line-2); background: var(--surface); border-radius: 8px; font: inherit; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.stbtn.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.stbtn:disabled { cursor: default; opacity: .6; }
.stbtn.on:disabled { opacity: 1; }

#toast { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom)); left: 50%; transform: translate(-50%, 20px); background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 8px; font-size: 13.5px; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 50; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--danger); color: #fff; }

/* адаптив */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .side { position: fixed; z-index: 30; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .side.open { transform: none; }
  .topbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20; height: calc(52px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left)); background: var(--surface); border-bottom: 1px solid var(--line); }
  .topbar b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #main { padding: 16px max(16px, env(safe-area-inset-right)) calc(40px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  .side { padding-top: calc(18px + env(safe-area-inset-top)); padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  .grid2 { grid-template-columns: 1fr; }
  .toolbar input[type=search] { width: 100%; }
  .toolbar select { flex: 1 1 140px; max-width: none; }
  .seg-ctl { margin-left: 0; }
  .page-head .actions { width: 100%; }
  .board, .board.tasks { grid-template-columns: repeat(var(--cols, 6), 80vw); scroll-snap-type: x mandatory; }
  .board.tasks { --cols: 4; }
  .col { scroll-snap-align: start; }
  dl.facts.inline { grid-template-columns: 1fr; gap: 2px; }
  dl.facts.inline dd { margin-bottom: 8px; }
  #modal-body { padding: 18px 16px; }
  .roles-help dl { grid-template-columns: 1fr; }
}
@media (max-width: 480px) { .kpis { grid-template-columns: 1fr 1fr; gap: 8px; } .kpi b { font-size: 22px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
