:root {
  --bg: #f6f7f5;
  --card: #ffffff;
  --text: #1c2321;
  --muted: #5f6b67;
  --line: #dfe4e1;
  --accent: #1b6446;
  --accent-bg: #e2efe8;
  --accent-ink: #ffffff;
  --target: #7a5a00;
  --target-bg: #fbf1d4;
  --gray-bg: #eceeed;
  --error: #b42318;
  --error-bg: #fdecea;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141917;
    --card: #1d2421;
    --text: #e6ebe8;
    --muted: #9aa6a1;
    --line: #2e3833;
    --accent: #5dbb8e;
    --accent-bg: #1d3329;
    --accent-ink: #0c1511;
    --target: #e3c062;
    --target-bg: #3a3017;
    --gray-bg: #29312d;
    --error: #ff8a80;
    --error-bg: #3d1f1c;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 48px; }
h1 { font-size: 1.6rem; margin: 0.2em 0 0.4em; }
h2 { font-size: 1.15rem; margin: 1.6em 0 0.5em; }
code { font-size: 0.9em; background: var(--gray-bg); padding: 1px 5px; border-radius: 4px; }
.lead { font-size: 1.05rem; max-width: 70ch; }
.muted { color: var(--muted); }
footer { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 16px; border-top: 1px solid var(--line); }

/* Шапка */
.top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.proto { margin-left: 8px; font-size: 0.75rem; font-weight: 600; color: var(--target); background: var(--target-bg); padding: 2px 6px; border-radius: 4px; }
.top nav { display: flex; flex-wrap: nowrap; white-space: nowrap; gap: 4px 14px; flex: 1 1 auto; }
.top nav a { color: var(--muted); text-decoration: none; padding: 4px 0; border-bottom: 2px solid transparent; }
.top nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.who { display: flex; align-items: center; gap: 10px; font-size: 0.9rem; color: var(--muted); margin: 0; }
.who span { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

button {
  font: inherit; cursor: pointer; border-radius: 6px; padding: 6px 14px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
}
button:hover { border-color: var(--muted); }

/* Вход */
.login { max-width: 400px; margin: 8vh auto 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 28px; }
.login h1 { font-size: 1.35rem; }
.login form { display: grid; gap: 14px; margin-top: 18px; }
.login label { display: grid; gap: 4px; font-size: 0.9rem; color: var(--muted); }
.login input { font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); }
.login button { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); padding: 10px; font-weight: 600; }
.error { color: var(--error); background: var(--error-bg); padding: 8px 12px; border-radius: 6px; }

/* Лента стадий */
.ribbon { list-style: none; padding: 0; margin: 20px 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.stage { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; }
.stage.working { border-color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }
.stage.backlog { opacity: 0.85; }
.stage-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; color: var(--text); text-decoration: none; }
.stage-head h2 { margin: 0; font-size: 1.05rem; flex: 1; }
.stage .n { width: 24px; height: 24px; border-radius: 50%; background: var(--gray-bg); display: inline-grid; place-items: center; font-size: 0.8rem; font-weight: 700; }
.stage p { margin: 10px 0 0; font-size: 0.93rem; }
.stage .src { color: var(--muted); font-size: 0.85rem; }
.stage .go { margin-top: auto; padding-top: 12px; font-weight: 600; text-decoration: none; }
.badge { display: inline-block; font-size: 0.75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.badge.ok { color: var(--accent); background: var(--accent-bg); }
.badge.target { color: var(--target); background: var(--target-bg); }
.badge.muted { color: var(--muted); background: var(--gray-bg); }
.legend { display: flex; gap: 8px; flex-wrap: wrap; }

.crumbs { color: var(--muted); font-size: 0.9rem; margin: 0; }
.notice { background: var(--target-bg); color: var(--target); padding: 12px 16px; border-radius: 8px; }

/* Таблицы */
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 0.93rem; }
th { font-size: 0.8rem; color: var(--muted); font-weight: 600; }

@media (max-width: 640px) {
  .top nav { flex-wrap: wrap; order: 3; flex-basis: 100%; }
  .who { margin-left: auto; }
  .who span { max-width: 160px; }
  h1 { font-size: 1.35rem; }
}

/* Проверка по ИНН */
.inn-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin: 16px 0 6px; }
.inn-form label { display: grid; gap: 4px; font-size: 0.9rem; color: var(--muted); }
.inn-form input { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--text); width: 220px; }
.inn-form button, #toCalc { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin: 14px 0; }
.card h2, .card h3 { margin: 0 0 6px; }
.card h3 { font-size: 1rem; }
.card p { margin: 6px 0; }
.grid2 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid2 .card { margin: 0; }
.small { font-size: 0.85rem; }
td.r, th.r { text-align: right; }
.cls { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; font-weight: 700; }
.cls-1 { background: var(--accent-bg); color: var(--accent); }
.cls-2 { background: var(--target-bg); color: var(--target); }
.cls-3 { background: var(--error-bg); color: var(--error); }
.stage .go2 { padding-top: 6px; font-size: 0.9rem; text-decoration: none; }

/* Рабочий стол и общие элементы новой оболочки */
body { font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
main.page { max-width: 1100px; margin: 0 auto; padding: 24px 20px 40px; }
.inn-form { display: grid; gap: 6px; margin: 12px 0 20px; max-width: 560px; }
.inn-form.big { max-width: 640px; }
.inn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.inn-row input { flex: 1 1 220px; font: inherit; font-size: 1.05rem; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); }
.inn-row button, .btn.primary, #toCalc { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; padding: 10px 16px; border-radius: 8px; }
.tasks { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); margin-bottom: 20px; }
.task { display: flex; flex-direction: column; gap: 6px; padding: 16px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; color: var(--text); text-decoration: none; }
.task:hover { border-color: var(--accent); }
.task span { color: var(--muted); font-size: 0.92rem; flex: 1; }
.task em { font-style: normal; color: var(--accent); font-weight: 600; }
.dash { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.panel h2 { font-size: 1rem; margin: 0 0 10px; }
.panel h3 { font-size: 0.9rem; margin: 14px 0 6px; color: var(--muted); }
.panel .big { font-size: 2rem; font-weight: 600; margin: 4px 0; }
.list { list-style: none; margin: 0; padding: 0; }
.list li a { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); color: var(--text); text-decoration: none; }
.list li:first-child a { border-top: 0; }
.list .score { font-weight: 600; color: var(--error); }
.zbar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--gray-bg); }
.zleg { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 0.85rem; color: var(--muted); margin: 8px 0 0; }
.zleg i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }
.z-red { background: #C0392B; } .z-yellow { background: #D9A21B; } .z-green { background: #2E8B57; } .z-grey { background: #8A948F; }
.next { margin: 18px 0; padding: 14px 16px; border-radius: 12px; background: var(--accent-bg); }
.next h2 { margin: 0 0 6px; font-size: 1rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.btn { display: inline-block; padding: 10px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--text); text-decoration: none; font-weight: 500; }

/* Дашборд */
.tiles4 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); margin: 16px 0; }
.tile { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; color: var(--text); text-decoration: none; }
.tile:hover { border-color: var(--accent); }
.tile span { color: var(--muted); font-size: 0.88rem; }
.tile b { font-size: 1.9rem; font-weight: 600; line-height: 1.2; }
.tile small { color: var(--muted); font-size: 0.82rem; }
.launch-panel h2 { margin-bottom: 8px; }
/* поля — по верхнему краю: ошибка под полем удлиняет только свою строку, соседние поля не съезжают */
.launch { display: grid; gap: 10px; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: start; }
.launch > .form-actions { align-self: start; padding-top: calc(0.875rem * 1.5 + 4px); }
@media (max-width: 560px) { .launch > .form-actions { padding-top: 0; } }
.launch button.cancel { background: var(--card); border-color: var(--line); color: var(--text); font-weight: 500; }
.launch .f { display: grid; gap: 4px; font-size: 0.88rem; color: var(--muted); }
.launch input, .launch select, .move select { font: inherit; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); min-width: 0; }
.launch button, .move button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; padding: 10px 16px; border-radius: 8px; }
@media (max-width: 1100px) { .launch { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .launch { grid-template-columns: 1fr; } }
.panel.wide { grid-column: span 2; }
@media (max-width: 900px) { .panel.wide { grid-column: auto; } }
.funnel { list-style: none; margin: 0 0 8px; padding: 0; }
.funnel a { display: grid; grid-template-columns: minmax(120px, 1.3fr) minmax(60px, 2fr) 28px minmax(64px, auto); gap: 10px; align-items: center; padding: 6px 0; color: var(--text); text-decoration: none; border-top: 1px solid var(--line); }
.funnel li:first-child a { border-top: 0; }
.funnel em { font-style: normal; font-size: 0.75rem; color: var(--muted); }
.funnel .fb { height: 10px; background: var(--gray-bg); border-radius: 5px; overflow: hidden; }
.funnel .fb i { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.funnel .fn { font-weight: 600; text-align: right; }
.funnel .fs { color: var(--muted); font-size: 0.85rem; text-align: right; }

/* Канбан */
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x proximity; }
main.page:has(.board) { max-width: none; }
.kcol { background: var(--gray-bg); border-radius: 12px; padding: 10px; min-height: 240px; scroll-snap-align: start; display: flex; flex-direction: column; gap: 8px; }
.kcol.over { outline: 2px dashed var(--accent); outline-offset: -2px; }
.kcol header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; padding: 2px 4px; }
.kcol header h2 { margin: 0; font-size: 0.95rem; flex: 1 1 auto; }
.kdrop { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.kcard { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; color: var(--text); text-decoration: none; cursor: pointer; }
.kcard[draggable] { cursor: grab; }
.kcard:hover { border-color: var(--accent); }
.kcard.dragging { opacity: 0.5; }
.kcard b { font-weight: 600; font-size: 0.93rem; }
.kcard.demo { border-style: dashed; }
.kcard b .cls { width: 22px; height: 22px; font-size: 0.8rem; margin-left: 4px; vertical-align: 1px; }
.kempty { padding: 8px 4px; }

/* Карточка сделки */
/* ряд стадий — индикатор хода сделки, не кнопки: без заливки, шаги через «›», текущая — жирная с подчёркиванием */
.stepper { list-style: none; padding: 0; margin: 14px 0 18px; display: flex; flex-wrap: wrap; gap: 4px 2px; cursor: default; }
.stepper li { display: flex; align-items: center; gap: 5px; padding: 2px 4px; color: var(--muted); font-size: 0.85rem; }
.stepper li + li::before { content: "›"; margin-right: 4px; color: var(--line); }
.stepper li span { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; border: 1px solid currentColor; font-size: 0.7rem; font-weight: 600; }
.stepper li.done { color: var(--accent); }
.stepper li.done span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.stepper li.now { color: var(--text); font-weight: 700; text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.stepper li.now span { background: var(--text); border-color: var(--text); color: var(--card); text-decoration: none; }
.move { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.move label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.9rem; }
.hist li { padding: 7px 0; border-top: 1px solid var(--line); }
.hist li:first-child { border-top: 0; }

/* Карточка сделки: клиент и правка */
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 14px; margin: 8px 0 12px; font-size: 0.92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
form.inline { display: inline; }
.comment { background: var(--gray-bg); padding: 8px 12px; border-radius: 8px; white-space: pre-wrap; }
details.edit summary { display: flex; align-items: baseline; gap: 10px; cursor: pointer; list-style: none; }
details.edit summary::-webkit-details-marker { display: none; }
details.edit summary h2 { margin: 0; }
.eform { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-top: 12px; }
.eform label { display: grid; gap: 4px; font-size: 0.88rem; color: var(--muted); }
.eform .wide { grid-column: 1 / -1; }
.eform input, .eform select, .eform textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); min-width: 0; }
.eform button { justify-self: start; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; padding: 9px 16px; border-radius: 8px; }
[aria-invalid="true"] { border-color: var(--error) !important; outline: 1px solid var(--error); }

/* Отказ по сделке */
.refuse { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.refuse summary { cursor: pointer; color: var(--error); font-weight: 500; }
.refuse .eform { margin-top: 10px; }
.refuse.stop { background: var(--error-bg); border: 0; border-radius: 8px; padding: 12px 14px; }
.refuse.stop p { margin: 0 0 4px; }
.eform button.danger { background: var(--card); border-color: var(--error); color: var(--error); }
.refused-note { background: var(--error-bg); color: var(--error); padding: 8px 12px; border-radius: 8px; }
.refused-reason { color: var(--error); }
.refused-list { margin-top: 16px; }
.refused-list summary { display: flex; align-items: baseline; gap: 10px; cursor: pointer; }
.refused-list summary h2 { margin: 0; }
.kgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; margin-top: 12px; }

/* Предупреждение о дубле по ИНН в форме новой сделки */
.launch .dups { grid-column: 1 / -1; }
.launch .dups p { margin: 0 0 6px; }
.launch .dups button { background: var(--card); border-color: var(--line); color: var(--text); font-weight: 500; }

/* Ошибка у поля формы */
.ferr { display: block; margin-top: 2px; color: var(--error); font-size: 0.85rem; }
[aria-invalid="true"] { border-color: var(--error) !important; }
.notice ul { margin: 4px 0 8px; padding-left: 20px; }
.notice p { margin: 0 0 6px; }

/* Сообщение об успехе, восстановленный черновик, отправка формы */
.toast { position: fixed; top: 16px; right: 16px; z-index: 50; display: flex; gap: 12px; align-items: flex-start; max-width: min(420px, calc(100vw - 32px)); padding: 12px 14px; border-radius: 10px; background: var(--card); color: var(--text); border: 1px solid var(--accent); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12); }
.toast button { border: 0; background: none; font-size: 1.2rem; line-height: 1; padding: 0 2px; cursor: pointer; color: var(--muted); }
.draft-note { background: var(--target-bg); color: var(--target); padding: 6px 10px; border-radius: 8px; margin: 0; }
.draft-note button { margin-left: 6px; padding: 2px 8px; }
form[aria-busy="true"] button[disabled] { opacity: 0.7; cursor: progress; }

/* Клиенты: строка клиента в сделке, поиск, таблицы списков */
.client-line { margin: -4px 0 10px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.search-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0 16px; }
.search-row input, .search-row select { font: inherit; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); min-width: 0; flex: 1 1 240px; max-width: 420px; }
.search-row select { flex: 0 1 200px; }
.search-row button { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; padding: 9px 16px; border-radius: 8px; }
.list-table { width: 100%; border-collapse: collapse; background: var(--card); }
.list-table th, .list-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.list-table th { font-size: 0.85rem; color: var(--muted); font-weight: 500; }
.list-table .r { text-align: right; }
.list-table tr.muted td { color: var(--muted); }
.empty { padding: 16px; background: var(--gray-bg); border-radius: 8px; }

/* Лента сделки */
.comment-form { display: grid; gap: 8px; margin: 8px 0 14px; }
.comment-form textarea { font: inherit; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); resize: vertical; }
.comment-form button { justify-self: start; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; padding: 9px 16px; border-radius: 8px; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: 8px 0; border-top: 1px solid var(--line); }
.feed li:first-child { border-top: 0; }
.feed li p { margin: 0 0 2px; white-space: pre-wrap; }
.feed li.sys p { color: var(--muted); font-size: 0.92rem; }
.feed li.comment p { background: var(--gray-bg); border-radius: 8px; padding: 8px 10px; color: var(--text); }
.feed li.taskrec p::before { content: "Задача · "; font-weight: 600; }

/* Задачи */
.todo-list { list-style: none; margin: 0; padding: 0; }
.todo-list li.todo { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 8px 0; border-top: 1px solid var(--line); }
.todo-list li.todo:first-child { border-top: 0; }
.todo-list .ttext { min-width: 0; overflow-wrap: anywhere; }
.due { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.due.overdue { color: var(--error); }
.due.today { color: var(--target); }
.due.done { color: var(--ok, var(--accent)); font-weight: 500; }
.todo-list li.done .ttext { color: var(--muted); text-decoration: line-through; }
.todo-list .done-btn { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.task-add summary, .tasks-done summary { cursor: pointer; color: var(--accent); font-weight: 500; margin-top: 10px; }
.tasks-done summary h2 { display: inline; }
.ktask { color: var(--muted); }
.ktask.overdue { color: var(--error); font-weight: 600; }
.ktask.today { color: var(--target); font-weight: 600; }
.overdue-n { color: var(--error); }
.comment-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; justify-content: space-between; }
.comment-row label { display: grid; gap: 4px; font-size: 0.88rem; color: var(--muted); }
.comment-row input { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); }
.seg-links { display: flex; gap: 4px; }
.seg-links a { padding: 6px 14px; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: var(--text); }
.seg-links a[aria-current="page"] { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); font-weight: 600; }
@media (max-width: 560px) { .todo-list li.todo { grid-template-columns: 1fr; } }

/* Ответственный */
.owner-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.owner-pass summary { cursor: pointer; color: var(--accent); font-size: 0.9rem; }
.owner-pass[open] { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-form select { font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); }

/* Сделки: переключатель вида, фильтры, список */
.viewbar { display: grid; gap: 8px; margin: 8px 0 12px; }
.filters-row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: end; }
.filters-row .f { display: grid; gap: 4px; font-size: 0.85rem; color: var(--muted); }
.filters-row input, .filters-row select { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); min-width: 0; }
.filters-row input { width: 220px; max-width: 100%; }
.filters-row button { padding: 8px 16px; border-radius: 8px; }
.deals-table th a { color: inherit; text-decoration: none; }
.deals-table th[aria-sort] a { color: var(--text); font-weight: 600; }
.deals-table tfoot td { font-weight: 600; border-bottom: 0; }
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { padding: 6px 0; border-top: 1px solid var(--line); }
ul.plain li:first-child { border-top: 0; }

/* Архив */
.archived-note { background: var(--gray-bg); padding: 8px 12px; border-radius: 8px; }
.archive-zone { padding-top: 10px; padding-bottom: 10px; }
.archive-zone button.danger { background: var(--card); border-color: var(--error); color: var(--error); }
.archive-zone button.primary-btn { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* Документы сделки */
.docs li { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.link-danger { border: 0; background: none; padding: 0; color: var(--error); font: inherit; font-size: 0.85rem; cursor: pointer; text-decoration: underline; }
.tiles-title { margin: 18px 0 0; font-size: 1rem; }
.set-caption { margin: 0; padding: 8px 12px; background: var(--accent-soft, var(--gray-bg)); border-radius: 8px; }
.tiles6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 640px) { .tiles6 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Подсказки к сокращениям */
abbr[title] { text-decoration: underline dotted; text-underline-offset: 3px; cursor: help; }

/* Одна рамка фокуса во всём портале и в модулях (та же — в оболочке app/shell.js) */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Читаемость: основной и числовой текст — не мельче 14 px (подписи-бейджи — 12,8 px) */
.small, .tile span, .tile small, .launch .f, .funnel .fs, .stepper li, .eform label, .ferr, th, .list-table th, .due,
.comment-row label, .filters-row .f, .link-danger, .zleg, .stage .src, footer { font-size: 0.875rem; }
.badge, .funnel em { font-size: 0.8rem; }

/* Телефон: зоны нажатия не меньше 44 px */
@media (max-width: 760px) {
  button, .btn, select, input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), summary, .crumbs a, .seg-links a, .link-danger { min-height: 44px; }
  .crumbs a, .link-danger, .owner-pass summary, details.edit summary, .task-add summary, .refuse summary, .more > summary, details.client-info > summary { display: inline-flex; align-items: center; }
  .link-danger { padding: 0 6px; }
}
.stepper li span { font-size: 0.8rem; width: 20px; height: 20px; }
@media (max-width: 760px) { .client-line a, .docs li > a, ul.plain li > a { display: inline-block; padding: 10px 0; } }
.stepper li::before { display: inline-block; text-decoration: none; }

/* Карточка сделки: примечание под рядом стадий — не больше трёх строк (полностью — в подсказке и в форме правки) */
.comment { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.eform .form-actions button.cancel { background: var(--card); border-color: var(--line); color: var(--text); font-weight: 500; }
#new-deal > summary, #new > summary { cursor: pointer; list-style: none; }
#new-deal > summary h2, #new > summary h2 { display: inline; }

/* Карточка сделки: слева — работа (стадия, задачи, лента), справа — сведения; уже 1200 px — одна колонка в том же порядке */
.deal-grid { display: grid; gap: 12px; }
.deal-main, .deal-side { display: grid; gap: 12px; align-content: start; min-width: 0; }
.deal-grid .panel.wide { grid-column: auto; }
@media (min-width: 1200px) { .deal-grid { grid-template-columns: minmax(0, 1fr) 320px; } }
.more { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.more > summary, details.client-info > summary { cursor: pointer; list-style: none; }
.more > summary { color: var(--muted); }
.more > summary::-webkit-details-marker { display: none; }
.more > summary::before, details.client-info > summary::before { content: "▸"; display: inline-block; width: 1em; color: var(--muted); }
.more[open] > summary::before, details.client-info[open] > summary::before { content: "▾"; }
.more[open] > summary { margin-bottom: 4px; }
.more .move, .more .refuse { margin-top: 10px; padding-top: 0; border-top: 0; }
.more .archive-form { margin-top: 14px; }
.archive-form button.danger { background: var(--card); border-color: var(--error); color: var(--error); }
details.client-info > summary { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; cursor: pointer; list-style: none; }
details.client-info > summary::-webkit-details-marker { display: none; }
details.client-info > summary h2 { margin: 0; }
details.client-info[open] > summary { margin-bottom: 10px; }
/* форма создания открывается только кнопкой «Создать сделку» над страницей; закрытой её не видно */
#new:not([open]), #new-deal:not([open]) { display: none; }
#new > summary, #new-deal > summary { pointer-events: none; }
#new > summary::-webkit-details-marker, #new-deal > summary::-webkit-details-marker { display: none; }
.ktask.stuck { color: var(--target); }

/* Карточка клиента: правка — раскрытие внутри панели «Клиент», сведения видны всегда */
.client-edit { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.client-edit > summary h3 { display: inline; margin: 0; color: var(--accent); font-size: 0.95rem; }
.client-edit[open] > summary { margin-bottom: 10px; }
[hidden] { display: none !important; }
