/* ТЕХНО-БУ · панель. Свой CSS без сборки. Светлая тема, акцент #29b6f6. */
:root {
  --accent: #29b6f6;
  --accent-strong: #0288d1;   /* текст/кнопки на белом: контраст лучше, чем у #29b6f6 */
  --accent-soft: #e3f4fd;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --line: #e2e7ee;
  --text: #1c2430;
  --muted: #667085;
  --ok: #1b8a4b;      --ok-bg: #e5f6ec;
  --warn: #9a6400;    --warn-bg: #fff4dc;
  --err: #c62828;     --err-bg: #fdeaea;
  --info: #0277bd;    --info-bg: #e3f2fd;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --topbar-h: 56px;
  --nav-w: 240px;
  --bottombar-h: 60px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; display: flex; align-items: center; gap: .5rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
p { margin: 0 0 .75rem; }
code { font: .85em/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 .3em; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.wrap { word-break: break-word; }
.inline { display: inline; margin: 0; }
.hidden, [hidden] { display: none !important; }
.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
ul.plain { margin: 0; padding-left: 1.1rem; }

/* ---------- каркас ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--topbar-h); z-index: 30;
  display: flex; align-items: center; gap: .75rem; padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 800; letter-spacing: .02em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
/* логотип в шапке панели — картинка (static/logo.png, копия логотипа сайта), рядом слово «панель» */
.brand-logo { display: block; height: 24px; width: auto; }
.topbar .brand-sub { padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); font: 700 .78rem/1.5 var(--font); letter-spacing: .03em; }
/* текстовый логотип остаётся на страницах входа и первого запуска (login.html, setup.html) */
.brand-mark { color: var(--text); }
.brand-mark::first-letter { color: var(--accent); }
.brand-sub { color: var(--muted); font-weight: 500; }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: .5rem; min-width: 0; }
.user-name { color: inherit; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 30vw; }
.burger { display: none; background: none; border: 0; padding: 8px; margin-left: -8px; color: var(--text); cursor: pointer; border-radius: var(--radius-sm); }
.burger:hover { background: var(--surface-2); }

.sidenav {
  position: fixed; top: var(--topbar-h); bottom: 0; left: 0; width: var(--nav-w); z-index: 20;
  background: var(--surface); border-right: 1px solid var(--line);
}
.sidenav { display: flex; flex-direction: column; }
.sidenav-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 12px 10px 24px; }

/* поиск по разделам над меню (panel.js); без JS поле скрыто — меню работает как обычно */
.nav-search { position: relative; flex: none; padding: 12px 10px 4px; }
.nav-search-ico { position: absolute; left: 21px; top: 23px; width: 17px; height: 17px; color: var(--muted); pointer-events: none; }
.nav-search .nav-search-input { min-height: 38px; padding: 7px 34px 7px 34px; font-size: 15px; background: var(--surface-2); border-color: var(--line); }
.nav-search .nav-search-input:focus { background: #fff; border-color: var(--accent); }
.nav-kbd { position: absolute; right: 18px; top: 21px; min-width: 20px; padding: 0 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: #fff; color: var(--muted); font: 600 .72rem/18px var(--font); text-align: center; pointer-events: none; }
.nav-search.has-q .nav-kbd { display: none; }
.nav-item.nav-hit { outline: 2px solid rgba(41, 182, 246, .45); outline-offset: -2px; }
.nav-noresult { margin: 8px 6px; color: var(--muted); font-size: .85rem; }
.is-searching .nav-chev { visibility: hidden; }
.nav-item {
  display: flex; align-items: center; gap: .7rem; padding: 9px 12px; margin-bottom: 2px;
  color: var(--text); border-radius: var(--radius-sm); font-weight: 500;
}
.nav-item:hover { background: var(--surface-2); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent-strong); }
.nav-item .ico { color: var(--muted); }
.nav-item.active .ico { color: var(--accent-strong); }
.nav-sep { height: 1px; background: var(--line); margin: 10px 4px; }
.nav-backdrop { display: none; }

.main { padding: 24px; max-width: 1280px; }
.has-nav .main { margin-left: var(--nav-w); padding-top: calc(var(--topbar-h) + 24px); }
.bottombar { display: none; }

/* ---------- компоненты ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head p { margin: 0; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.card.narrow { max-width: 520px; }
.card-alert { border-color: #f3c7c7; background: #fffafa; }
.card-alert h2 { color: var(--err); }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: .75rem; }
.spacer { flex: 1; }

.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat-label { color: var(--muted); font-size: .85rem; }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.2; margin-top: 2px; }
.stat-sub { font-size: .85rem; color: var(--muted); }

.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.tile { display: flex; flex-direction: column; gap: .6rem; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--text); font-weight: 600; min-height: 104px; }
.tile:hover { border-color: var(--accent); text-decoration: none; }
.tile-ico { width: 28px; height: 28px; color: var(--accent-strong); }

/* кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 40px; padding: 8px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: 600 .95rem/1.2 var(--font); cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid rgba(41, 182, 246, .45); outline-offset: 1px; }
.btn-primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn-primary:hover { background: #0277bd; }
.btn-danger { background: var(--surface); border-color: #f0b4b4; color: var(--err); }
.btn-danger:hover { background: var(--err-bg); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: .85rem; }
.btn-block { width: 100%; }
.btn[disabled], .btn.htmx-request { opacity: .6; pointer-events: none; }

/* формы */
.form { display: grid; gap: 14px; }
.form-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.field { display: grid; gap: 4px; align-content: start; }   /* r8: в ряду .form-row поле без подсказки не растягивается — поля ввода на одной высоте */
.field-label { font-weight: 600; font-size: .9rem; display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.req { color: var(--err); }
.hint { color: var(--muted); font-size: .82rem; }
.field-error { color: var(--err); font-size: .85rem; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--err); }
input[type=text], input[type=password], input[type=search], input[type=email], input[type=tel], input[type=number],
input[type=url], input[type=date], input[type=datetime-local], input[type=time], input:not([type]), select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid #cfd6df; border-radius: var(--radius-sm);
  background: #fff; color: var(--text); font: 16px/1.3 var(--font); /* 16px — iOS не зумит поле */
}
textarea { min-height: 96px; resize: vertical; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; accent-color: var(--accent-strong); vertical-align: middle; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; cursor: pointer; }
.form-actions { display: flex; gap: .5rem; flex-wrap: wrap; padding-top: 4px; }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input[type=search], .toolbar select { width: auto; flex: 1 1 220px; min-width: 0; max-width: 100%; }

/* таблицы: на телефоне прокручиваются по горизонтали */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { background: var(--surface-2); font-weight: 600; color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafcfe; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table td.wrap { max-width: 420px; }

/* бейджи */
.badge { display: inline-flex; align-items: center; gap: .25rem; padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600; line-height: 1.5; white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-err { background: var(--err-bg); color: var(--err); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-muted { background: #eef1f5; color: var(--muted); }

/* сообщения */
.flash { position: relative; padding: 12px 46px 12px 14px; border-radius: var(--radius-sm); margin-bottom: 12px; border: 1px solid transparent; }
.flash-ok { background: var(--ok-bg); color: #145c33; border-color: #bfe6cf; }
.flash-error { background: var(--err-bg); color: #8e1c1c; border-color: #f3c7c7; }
.flash-warn { background: var(--warn-bg); color: #6d4700; border-color: #f1dca8; }
.flash-info { background: var(--info-bg); color: #01579b; border-color: #bcdcf5; }
.flash-x { position: absolute; top: 2px; right: 2px; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border: 0; background: none; font-size: 20px; line-height: 1; padding: 0; cursor: pointer; color: inherit; opacity: .6; }  /* 6c: тап-цель 40×40 */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; max-width: min(92vw, 520px); padding: 12px 16px; border-radius: var(--radius-sm); background: #263238; color: #fff; box-shadow: 0 6px 24px rgba(0,0,0,.2); }

/* пустое состояние */
.empty { text-align: center; padding: 40px 16px; background: var(--surface); border: 1px dashed #cfd6df; border-radius: var(--radius); color: var(--muted); }
.empty-ico { width: 40px; height: 40px; color: #b0bac6; margin-bottom: 8px; }
.empty-title { font-weight: 700; color: var(--text); font-size: 1.05rem; }
.empty-text { max-width: 460px; margin: 4px auto 0; }
.empty-actions { margin-top: 16px; display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; }

/* вкладки и постраничка */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tab { padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--accent-strong); border-bottom-color: var(--accent-strong); }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 12px 0 20px; }

/* вход */
.auth-page .main { margin: 0 auto; max-width: none; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-box { width: 100%; max-width: 420px; }
.auth-brand { font-size: 1.2rem; font-weight: 800; margin-bottom: 12px; }

/* ---------- группы меню (base.html, core/navgroups.py) ---------- */
.nav-group { margin-bottom: 2px; }
.nav-group-head {
  display: flex; align-items: center; gap: .7rem; padding: 9px 12px; border-radius: var(--radius-sm);
  font-weight: 700; color: var(--text); cursor: pointer; list-style: none; user-select: none;
}
.nav-group-head::-webkit-details-marker { display: none; }
.nav-group-head:hover { background: var(--surface-2); }
.nav-group-head .ico { color: var(--muted); }
.nav-group[data-active] > .nav-group-head .ico:first-child { color: var(--accent-strong); }
.nav-chev { margin-left: auto; width: 16px; height: 16px; transition: transform .15s ease; }
.nav-group[open] > .nav-group-head .nav-chev { transform: rotate(90deg); }
.nav-group-items { padding: 2px 0 6px; }
.nav-item.nav-sub { padding-left: 22px; font-weight: 500; }
.nav-item.nav-sub .ico { width: 18px; height: 18px; }
/* подписи разделов меню «Работа» / «Управление» (navgroups.SECTIONS) — текст, не кнопка */
.nav-section { margin: 14px 12px 4px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.sidenav.is-searching .nav-section { display: none; }

/* ---------- способы оплаты (раунд 6, R1; макросы — templates/_pay.html модуля pos) ----------
   Цвета — только для способов оплаты (просьба владельца): Наличные зелёный, Карта синий, Рассрочка жёлтый, Кредит красный.
   Только точки, сегменты полос и чипы — больше цветов нет. */
:root {
  --pay-cash: #16a34a;        /* Наличные — зелёный. На белом 3,3:1 (≥ 3:1 для графики) */
  --pay-card: #2563eb;        /* Карта — синий. 5,2:1 */
  --pay-installment: #eab308; /* Рассрочка — жёлтый. На белом 1,9:1 → всегда с кромкой: */
  --pay-installment-edge: #a16207; /* 4,9:1 — inset-кромка 1 px у сегмента и точки */
  --pay-credit: #dc2626;      /* Кредит — красный. 4,8:1 */
  --pay-tradein: #98a2b3;     /* Трейд-ин — серый (виден только если ≠ 0) */
  --pay-unknown: #d0d5dd;     /* Не указано — светло-серый со штриховкой */
}
.pay-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; vertical-align: middle;
           margin-right: 4px; background: var(--pay-c); }
.pay-cash { --pay-c: var(--pay-cash); }       .pay-card { --pay-c: var(--pay-card); }
.pay-installment { --pay-c: var(--pay-installment); }
.pay-installment.pay-dot, .pay-bar .pay-installment { box-shadow: inset 0 0 0 1px var(--pay-installment-edge); }
.pay-credit { --pay-c: var(--pay-credit); }   .pay-tradein { --pay-c: var(--pay-tradein); }
.pay-unknown { --pay-c: var(--pay-unknown); }
.pay-unknown.pay-seg { background-image: repeating-linear-gradient(45deg, transparent 0 3px, rgba(0,0,0,.12) 3px 5px); }
.pay-bar { display: flex; gap: 2px; height: 12px; border-radius: 6px; overflow: hidden; background: var(--line); }
.pay-bar.pay-bar-sm { height: 6px; border-radius: 3px; }
.pay-seg { background: var(--pay-c); min-width: 3px; }          /* ненулевой сегмент виден даже при 0,3 % */
.pay-legend { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 12px; margin-top: 8px; font-size: .9rem; }
@media (min-width: 900px) { .pay-legend { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.pay-legend .zero { color: var(--muted); }
.pay-chip { display: inline-flex; align-items: center; gap: 2px; padding: 2px 8px; border-radius: 999px;
            background: var(--surface-2); border: 1px solid var(--line); color: var(--text); font-size: .8rem; }
.pay-wide { grid-column: 1 / -1; }                                /* плитка «Оплата» на всю строку */
@media print { .pay-bar, .pay-dot { display: none; } }            /* товарный чек — без цвета */

/* ---------- таблица → карточки на телефоне (A14): <table class="table table-cards">, у ячеек data-label ----------
   ≤ 600 px строка таблицы становится карточкой: «Подпись ........ значение». Ячейка без data-label — во всю ширину
   (например название или кнопки). Класс tc-title — заголовок карточки, tc-hide-sm — не показывать на телефоне. */
@media (max-width: 600px) {
  .table-wrap:has(> .table-cards) { overflow-x: visible; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .table-cards tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
  .table-cards tbody tr:last-child { border-bottom: 0; }
  .table-cards td { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 3px 0;
                    border: 0; text-align: right; max-width: none; overflow-wrap: anywhere; }
  .table-cards td[data-label]::before { content: attr(data-label); flex: none; max-width: 45%; color: var(--muted);
                                        font-size: .82rem; font-weight: 600; text-align: left; }
  .table-cards td:not([data-label]), .table-cards td.tc-title { display: block; text-align: left; }
  .table-cards td.tc-title { font-weight: 600; padding-bottom: 4px; }
  .table-cards td:empty, .table-cards .tc-hide-sm { display: none; }
  .table-cards td.num { white-space: normal; }
}

/* ---------- шапка страницы с компактными кнопками (A15) ----------
   {% call page_head("Отчёт", "…", compact=True) %} или <div class="page-actions page-actions-compact">:
   на телефоне кнопки не растягиваются на всю ширину и стоят в один ряд; второстепенные — мельче шрифтом,
   но не ниже 40 px (под палец). */
.page-actions-compact { align-items: center; }

/* ---------- плашка «Смена не открыта» (раунд 6b, G1: base.html, текст — модуль смен) — серая, без цвета ---------- */
.shift-block { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 16px; padding: 10px 14px;
               background: #eef1f5; border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--text); }
.shift-block > .ico { flex: none; color: var(--muted); }
.shift-block > span { flex: 1 1 220px; min-width: 0; }
.shift-block .btn { flex: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- «Мои дела» доской (раунд 6b, 12.8 D): колонки по дням, белый стиль ----------
   Разметка — modules/dashboard/templates/_board.html (Сводка и /dashboard/tasks). ПК — 3 дня в ряд,
   телефон — один день (стрелки ‹ › листают). Цвет — только красная точка у сломанного для клиентов. */
.tb-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.tb-head h2 { margin: 0; font-size: 1.05rem; display: flex; align-items: center; gap: 8px; }
.tb-nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.tb-arrow { min-width: 36px; font-size: 1.3rem; line-height: 1; }
.tb-all { margin-left: 6px; font-weight: 600; }
.tb-days { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: start; }
.tb-day { min-width: 0; display: flex; flex-direction: column; padding: 12px; background: var(--surface);
          border: 1px solid var(--line); border-radius: var(--radius-sm); }
.tb-day-today { border-color: #bfd8ea; }
.tb-day-title { margin: 0 0 6px; font-size: .95rem; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.tb-list { list-style: none; margin: 0 0 10px; padding: 0; }
.tb-item { display: flex; align-items: flex-start; gap: 8px; padding: 7px 0; border-top: 1px solid var(--line); }
.tb-item:first-child { border-top: 0; }
.tb-form { margin: 0; flex: none; }
/* ☐: квадрат рисует ::before, сама кнопка — зона нажатия (на телефоне 40×40 при том же квадрате 22×22, см. ≤820 px) */
.tb-check { position: relative; width: 22px; height: 22px; margin-top: 1px; padding: 0; display: grid; place-items: center;
            cursor: pointer; border: 0; border-radius: 6px; background: none; color: #fff; }
.tb-check::before { content: ""; position: absolute; inset: 0; border: 1.5px solid #9aa4b2; border-radius: 5px; background: #fff; }
.tb-check:hover::before { border-color: var(--accent-strong); }
.tb-check .ico { position: relative; width: 15px; height: 15px; }
.tb-done .tb-check::before { background: var(--accent-strong); border-color: var(--accent-strong); }
.tb-dot { flex: none; width: 8px; height: 8px; margin: 8px 7px 0; border-radius: 50%; background: #c3cad4; }
.tb-dot-err { background: var(--err); }
.tb-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; }
.tb-title { font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.tb-title a { color: var(--text); border-bottom: 1px dashed #b8c0cc; }
.tb-title a:hover { color: var(--accent-strong); text-decoration: none; }
.tb-done .tb-title, .tb-done .tb-title a { color: var(--muted); font-weight: 500; text-decoration: line-through; }
.tb-meta { font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; }
.tb-go { margin-top: 0; }
.tb-foot { align-self: stretch; display: flex; align-items: center; justify-content: space-between; gap: 4px 6px;
  flex-wrap: wrap; margin-top: 4px; }
.tb-by { margin-left: auto; font-size: .75rem; color: var(--muted); white-space: nowrap; }
.tb-add-lbl { flex: none; align-self: center; font-size: .85rem; color: var(--muted); }
.tb-x { width: 28px; height: 28px; padding: 0; display: grid; place-items: center; cursor: pointer;
        border: 0; border-radius: 6px; background: none; color: var(--muted); }
.tb-x:hover { background: var(--surface-2); color: var(--text); }
.tb-x .ico { width: 16px; height: 16px; }
.tb-empty { margin: 0 0 10px; color: var(--muted); font-size: .85rem; }
.tb-more { margin: -4px 0 10px; font-size: .85rem; font-weight: 600; }
.tb-add { margin-top: auto; padding-top: 10px; border-top: 1px dashed var(--line); display: flex; flex-direction: column; gap: 6px; }
.tb-add input[type=text], .tb-add select { min-height: 36px; padding: 6px 10px; }
.tb-add-main, .tb-add-row { display: flex; gap: 6px; min-width: 0; }
.tb-add-main .tb-add-title { flex: 1 1 auto; min-width: 0; }
.tb-add-row select { flex: 1 1 0; min-width: 0; }
.tb-add-btn { flex: none; min-width: 40px; min-height: 36px; padding: 4px 8px; }
.tb-add-btn .ico { width: 18px; height: 18px; }

/* ---------- «Что происходит»: живая лента событий справа ---------- */
:root { --ctx-w: 320px; }
.ctx-bell {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--text); cursor: pointer;
}
.ctx-bell:hover { background: var(--surface-2); }
.ctx-count {
  position: absolute; top: 3px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--err); color: #fff; font: 700 .7rem/18px var(--font); text-align: center;
}
/* телефон: галочки и «свои даты» — зона нажатия во всю строку не ниже 40 px (раунд 6b, доработка) */
@media (max-width: 820px) {
  .check, .pt-check { display: flex; min-height: 44px; width: 100%; align-items: center; }
  .check input[type=checkbox], .pt-check input[type=checkbox] { width: 22px; height: 22px; flex: none; margin: 0; }
  details.pos-dates > summary { display: flex; align-items: center; min-height: 40px; }
}

/* 12.8 F3: новые заявки — красный кружок на колокольчике (слева снизу, чтобы не спорить со счётчиком ленты)
   и верхний пункт ленты «Заявки с сайта» */
.bell-leads {
  position: absolute; bottom: 2px; left: 1px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--err); color: #fff; font: 700 .7rem/18px var(--font); text-align: center;
}
a.ctx-bell { text-decoration: none; }
/* 12.8 F3a: маленькая аккуратная плашка с отступами (не налезает на заголовок ленты); число — в кружке: 0 серый, >0 красный */
.ctx-leads { display: flex; align-items: center; gap: .5rem; min-height: 40px; margin: 8px 12px; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  color: var(--text); font-weight: 600; font-size: .92rem; text-decoration: none; }
.ctx-leads:hover { background: var(--surface-2); text-decoration: none; }
.ctx-leads .ico { color: var(--muted); }
.ctx-leads-t { flex: 1 1 auto; }
.ctx-leads-n { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--err); color: #fff;
  font: 700 .78rem/22px var(--font); text-align: center; }
.ctx-leads-0 { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--line); font: 700 .78rem/20px var(--font); text-align: center; }
.ctx {
  position: fixed; top: var(--topbar-h); right: 0; bottom: 0; width: var(--ctx-w); z-index: 20;
  display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--line);
}
.ctx-head { display: flex; align-items: center; gap: .5rem; padding: 12px 12px 10px 16px; border-bottom: 1px solid var(--line); }
.ctx-title { display: flex; align-items: center; gap: .5rem; font-weight: 700; }
.ctx-title .ico { color: var(--accent-strong); }
.ctx-status { margin-left: auto; font-size: .75rem; color: var(--ok); white-space: nowrap; }
.ctx-status::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; margin-right: 5px; vertical-align: 1px; }
.ctx-status.is-off { color: var(--muted); }
.ctx-close { border: 0; background: none; padding: 6px; border-radius: var(--radius-sm); color: var(--muted); cursor: pointer; }
.ctx-close:hover { background: var(--surface-2); color: var(--text); }
.ctx-filter { position: relative; margin-left: 2px; }
.ctx-filter[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent-strong); }
.ctx-filter-dot { position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); border: 1px solid #fff; }
/* переключатели «какие события показывать» — в ленте и в «Мой профиль» */
.ctx-prefs { flex: none; max-height: 55%; overflow-y: auto; padding: 10px 14px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.ctx-prefs-title { margin: 0 0 8px; font-weight: 700; font-size: .85rem; }
.ctx-prefs-note { margin: 10px 0 0; font-size: .78rem; color: var(--muted); }
.ctx-muted-note { margin: 0; padding: 8px 16px; font-size: .78rem; color: var(--muted); border-bottom: 1px solid var(--line); }
.ctx-muted-note button { border: 0; background: none; padding: 0; color: var(--accent-strong); font: inherit; cursor: pointer; text-decoration: underline; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 4px 12px 4px 8px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: .85rem; font-weight: 600; cursor: pointer; user-select: none; }
.chip input { width: 16px; height: 16px; margin: 0; }
.chip:has(input:not(:checked)) { color: var(--muted); background: transparent; border-style: dashed; text-decoration: line-through; }
.chip:has(input:focus-visible) { outline: 3px solid rgba(41, 182, 246, .45); outline-offset: 1px; }
.ctx-list { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.ctx-empty { margin: 0; padding: 24px 16px; color: var(--muted); font-size: .9rem; text-align: center; }
.ctx-all { display: block; padding: 12px 16px; border-top: 1px solid var(--line); font-weight: 600; }
.ctx-backdrop { display: none; }

/* событие (и в колонке, и на странице «Все события») */
.ev-list { list-style: none; margin: 0; padding: 0; }
.ev-list.card { padding: 0; overflow: hidden; }
.ev + .ev { border-top: 1px solid var(--line); }
.ev-link { display: flex; gap: 10px; padding: 10px 14px; color: var(--text); }
a.ev-link:hover { background: var(--surface-2); text-decoration: none; }
.ev-ico { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--info-bg); color: var(--info); }
.ev-ico .ico { width: 17px; height: 17px; }
.ev-ok .ev-ico { background: var(--ok-bg); color: var(--ok); }
.ev-warn .ev-ico { background: var(--warn-bg); color: var(--warn); }
.ev-err .ev-ico { background: var(--err-bg); color: var(--err); }
.ev-body { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ev-title { font-weight: 600; font-size: .92rem; line-height: 1.3; overflow-wrap: anywhere; }
.ev-text { font-size: .85rem; color: var(--text); opacity: .85; overflow-wrap: anywhere; }
.ev-meta { font-size: .78rem; color: var(--muted); }
.ev-new { animation: ev-flash 3s ease-out; }
@keyframes ev-flash { from { background: var(--accent-soft); } to { background: transparent; } }
.ev-list-page .ev-link { padding: 12px 16px; }

/* широкий экран: колонка справа всегда видна, бережём место под содержимое */
@media (min-width: 1200px) {
  .has-ctx .main { margin-right: var(--ctx-w); }
  body.ctx-collapsed .ctx { display: none; }
  body.ctx-collapsed.has-ctx .main { margin-right: 0; }
}
/* меньше 1200 px: лента выезжает справа по колокольчику */
@media (max-width: 1199px) {
  .ctx {
    top: 0; width: min(92vw, 380px); z-index: 45; transform: translateX(105%); transition: transform .2s ease;
    box-shadow: 0 0 24px rgba(0, 0, 0, .15); padding-bottom: env(safe-area-inset-bottom);
  }
  body.ctx-open .ctx { transform: none; }
  body.ctx-open .ctx-backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 44; }
  body.ctx-open { overflow: hidden; }
}
@media print { .ctx, .ctx-bell { display: none !important; } .has-ctx .main { margin-right: 0; } }

/* ---------- планшет ---------- */
@media (max-width: 1024px) {
  :root { --nav-w: 210px; }
  .main { padding: 20px; }
}

/* ---------- телефон: меню выезжает, снизу — панель быстрых разделов ---------- */
@media (max-width: 820px) {
  .burger { display: inline-flex; }
  .hide-sm { display: none; }
  .user-role { display: none; }
  .sidenav { transform: translateX(-105%); transition: transform .2s ease; width: min(84vw, 300px); bottom: 0; box-shadow: 0 0 24px rgba(0,0,0,.15); z-index: 40; }
  body.nav-open .sidenav { transform: none; }
  body.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 35; }
  body.nav-open { overflow: hidden; }
  .has-nav .main { margin-left: 0; padding: calc(var(--topbar-h) + 16px) 16px calc(var(--bottombar-h) + 24px + env(safe-area-inset-bottom)); }
  .bottombar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: calc(var(--bottombar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .bb-item {
    flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--muted); font: 600 .7rem/1.1 var(--font); background: none; border: 0; padding: 6px 2px; cursor: pointer;
  }
  /* подписи короткие (navgroups.MOBILE_TITLES, ≤ 9 букв) — без многоточий; длинная своя подпись переносится */
  .bb-item span { max-width: 100%; text-align: center; overflow-wrap: anywhere; display: -webkit-box;
                  -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .bb-item:hover { text-decoration: none; }
  .bb-item.active { color: var(--accent-strong); }
  .bb-item .ico { width: 22px; height: 22px; }
  .grid-2 { grid-template-columns: 1fr; }
  h1 { font-size: 1.3rem; }
  .card { padding: 16px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; }
  /* компактные кнопки шапки: не растягиваются; не влезли в ряд — вторая переносится (раньше уходила за край) */
  .page-actions.page-actions-compact { flex-wrap: wrap; min-width: 0; max-width: 100%; }
  .page-actions.page-actions-compact .btn { flex: 0 1 auto; min-width: 0; max-width: 100%; white-space: normal;
                                            text-align: center; }
  .page-actions.page-actions-compact .btn:not(.btn-primary) { min-height: 40px; padding: 4px 10px; font-size: .85rem; }
  /* палец: на телефоне ни одна кнопка и поле не ниже 40 px (маленькие кнопки — тот же шрифт, только выше) */
  .btn-sm { min-height: 40px; }
  .tb-arrow { min-width: 40px; }
  .tb-all { display: inline-flex; align-items: center; min-height: 40px; }
  .tb-check { width: 40px; height: 40px; margin: -8px -9px -10px; }   /* занимает те же 22×22, нажимается 40×40 */
  .tb-check::before { inset: 9px; }
  .tb-x { width: 40px; height: 40px; margin: -6px; }                  /* занимает те же 28×28 */
  .tb-add input[type=text], .tb-add select { min-height: 40px; }
  .tb-add-btn { min-height: 40px; }
  /* доска дел: одна колонка — день, с которого начинается доска; ‹ › листают по дню */
  .tb-days { grid-template-columns: minmax(0, 1fr); }
  .tb-day:not(:first-child) { display: none; }
  .tb-day { padding: 0; border: 0; }
  .shift-block .btn { width: 100%; }
  .toast { bottom: calc(var(--bottombar-h) + 16px); }
}
@media (max-width: 420px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* узкий телефон: логотип чуть меньше, имя сотрудника прячем (профиль — в меню «Настройки → Мой профиль») */
  .brand-logo { height: 20px; }
  .topbar { gap: .5rem; }
  .user-name { display: none; }
}
@media (max-width: 340px) {
  .topbar .brand-sub { display: none; }
}
@media print {
  .topbar, .sidenav, .bottombar { display: none !important; }
  .has-nav .main { margin: 0; padding: 0; }
}

/* 12.8 F8/F9: шапка слева от колокольчика — время (МСК), погода, «сегодня заработал(а)» */
.tbi { display: flex; align-items: center; gap: 12px; min-width: 0; margin-right: 4px; color: var(--muted); font-size: .85rem; white-space: nowrap; }
.tbi-time { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }
.tbi-tz { margin-left: 3px; color: var(--muted); font-size: .7rem; font-weight: 600; }
.tbi-weather { display: inline-flex; align-items: center; gap: 4px; }
.tbi-weather .ico { width: 18px; height: 18px; }
.tbi-weather b { color: var(--text); font-weight: 600; }
.tbi-earned { color: var(--ok, #2e7d32); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.tbi-earned .tbi-earned-w { font-weight: 400; }
@media (max-width: 900px) { .tbi-city, .tbi-earned-w { display: none; } .tbi { gap: 8px; } }
@media (max-width: 600px) {
  .tbi { font-size: .78rem; gap: 6px; margin-right: 0; } .tbi-tz, .tbi-weather .ico { display: none; }
  .tbi-earned { flex: none; }
  .topbar .brand-sub { display: none; }       /* на телефоне место нужнее времени и «заработал» */
}
@media (max-width: 360px) { .tbi-weather { display: none; } }

/* 12.8 F11: непрочитанные события, а лента закрыта — на колокольчике мягко мигает «!» (без звука);
   при «уменьшить движение» — просто красная точка */
.bell-bang { display: none; position: absolute; top: 3px; left: 5px; width: 15px; height: 15px; border-radius: 50%;
  background: var(--err); color: #fff; font: 800 .7rem/15px var(--font); text-align: center; pointer-events: none; }
.ctx-bell.bell-alert .bell-bang { display: block; animation: bell-blink 1.6s ease-in-out infinite; }
@keyframes bell-blink { 0%, 100% { opacity: 1; } 50% { opacity: .2; } }
@media (prefers-reduced-motion: reduce) {
  .ctx-bell.bell-alert .bell-bang { animation: none; width: 9px; height: 9px; top: 6px; left: 6px; font-size: 0; }
}

/* r6c (исправления на телефоне 390 px): ни один список и ни одна кнопка не шире экрана; мелкое нажимаемое — под палец (≥ 40 px) */
select { max-width: 100%; }                 /* длинный пункт списка не растягивает сам список (было: «Все виды» на /activity — 417 px при 390) */
@media (max-width: 600px) {
  .btn { max-width: 100%; white-space: normal; text-align: center; }   /* длинная подпись переносится, а не уезжает за край */
  .table-wrap .btn { white-space: nowrap; }  /* в прокручиваемых таблицах — как было, в одну строку */
}
@media (max-width: 820px) {
  .chip { min-height: 40px; }               /* галочки «что показывать» в ленте (⚙) и в «Мой профиль» */
}

/* р7 (staff): «Непроведённые чеки N» — вторая строка-плашка под «Резерв и заявки» в ленте (тот же маленький стиль) */
.ctx-leads + .ctx-unposted { margin-top: -2px; }
.ctx-unposted .ico { color: var(--muted); }

/* night1: ссылка «← Все настройки» / «← Интеграции и ключи» над страницами без своего пункта меню (base.html) */
.crumb-back { display: inline-flex; align-items: center; gap: 4px; margin: 0 0 10px; font-size: .875rem; color: var(--muted);
  text-decoration: none; min-height: 32px; }
.crumb-back:hover { color: var(--accent); text-decoration: none; }

/* ---------- r8-layout (владелец 20.10: «чтобы пункты не съезжали») ----------
   1) Форма без сетки .form (обычный блок): поля, строка кнопок и подсказка друг под другом — с отступом 12 px,
      а не вплотную (img/05 «Скидка клиента»: подпись «Артикул» прилипала к подсказке, кнопки — к полю).
      Только формы без класса — формы-строки модулей (flex/grid со своим gap) не задеты; «Скидка клиента» (.ds-form)
      раскладывает свой модуль discounts (r8-pricing: .ds-apply .field, .ds-btns), чтобы отступы не сложились дважды. */
:where(form:not([class])) > .field ~ :is(.field, .row, .form-actions) { margin-top: 12px; }
/* r8-fix-layout: поля/строки полей прямо в карточке (карточки внутри form.form: /users/<id>, «Выставить», настройки) — ровный зазор 14px; карточки-grid (.by-block, .pb-side, .cb-accept) не трогаем; карточка блочная, поля с собственным margin-bottom схлопываются, двойного нет */
:where(form.form:not(.cb-accept) .card:not(.by-block, .pb-side)) > :where(.field, .form-row, fieldset.field) ~ :is(.field, .form-row, fieldset.field, .check) { margin-top: 14px; }
/* r8-layout 2) Ряд кнопок шапки страницы (.page-actions): «прозрачная» кнопка рядом с обычными — с той же рамкой и фоном.
   Раньше на телефоне она растягивалась без рамки, и подпись висела посередине пустого места («Справочник смен», «Все расходы»). */
.page-actions .btn-ghost { border-color: var(--line); background: var(--surface); }   /* и внутри .page-actions-compact */
.page-actions .btn-ghost:hover { background: var(--surface-2); }

/* r8-layout 3) Кнопки шапки во ВЛОЖЕННОМ <span class="page-actions-compact"> (так написано, например, в «Отделениях»):
   у span не было ни flex, ни промежутка — кнопки слипались без зазора. Теперь — ряд с промежутком 8 px, как у .page-actions. */
.page-actions > .page-actions-compact { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; min-width: 0; max-width: 100%; }

/* 20.10 (владелец: «по уведомлениям плохо» — 4 значка налезали друг на друга): на колокольчике ОДИН кружок.
   Число = всё, что ждёт действия: новые заявки и резервы + непроведённые чеки + «На утверждение».
   Нет таких — но есть новые события ленты: маленькая красная точка. Новое — кружок мягко мигает (как раньше «!»).
   Разбивка по пунктам — внутри колокольчика. */
.ctx-bell[data-ctx-toggle] .bell-leads, .ctx-bell[data-ctx-toggle] .bell-appr,
.ctx-bell[data-ctx-toggle] .ctx-count, .ctx-bell[data-ctx-toggle] .bell-bang { display: none !important; }
.bell-total { position: absolute; top: 2px; right: 1px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--err); color: #fff; font: 700 .7rem/18px var(--font); text-align: center; pointer-events: none;
  box-shadow: 0 0 0 2px var(--surface); }
.bell-total[hidden] { display: none; }
.bell-total.is-dot { min-width: 10px; width: 10px; height: 10px; padding: 0; top: 7px; right: 7px; font-size: 0; }
.ctx-bell.bell-alert .bell-total { animation: bell-blink 1.6s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .ctx-bell.bell-alert .bell-total { animation: none; } }
