/* ===== Цвета: светлая и тёмная тема ===== */
:root, [data-theme="light"] {
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #f0f2f5; --hover: #f5f7fa;
  --border: #e3e6ea; --border-strong: #cfd4da;
  --text: #111827; --muted: #6b7280; --faint: #9ca3af;
  --accent: #4f46e5; --accent-text: #ffffff; --accent-soft: #eef0ff;
  --ok: #15803d; --ok-soft: #e7f6ec; --warn: #b45309; --warn-soft: #fdf3e1;
  --bad: #b91c1c; --bad-soft: #fdeaea; --info: #1d4ed8; --info-soft: #e8efff;
  --pink: #be185d; --pink-soft: #fde9f3;
  /* рамки-полутона: посчитаны заранее (color-mix старые iPhone и Android не понимают) */
  --info-line: #9eb1e4; --pink-line: #d69eb9; --bad-line: #d08b8d; --accent-line: #a09ee8;
  --info-edge: rgba(29, 78, 216, .3); --pink-edge: rgba(190, 24, 93, .3);
  --slot-a: #4f46e5; --slot-b: #16a34a; --slot-c: #ea580c;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0d1016; --surface: #151922; --surface-2: #1c212c; --hover: #1a1f29;
  --border: #262c38; --border-strong: #353d4c;
  --text: #e6e8ec; --muted: #8e97a8; --faint: #5f6878;
  --accent: #8b8cf8; --accent-text: #0d1016; --accent-soft: rgba(139, 140, 248, .14);
  --ok: #4ade80; --ok-soft: rgba(74, 222, 128, .12); --warn: #fbbf24; --warn-soft: rgba(251, 191, 36, .12);
  --bad: #f87171; --bad-soft: rgba(248, 113, 113, .13); --info: #7aa7ff; --info-soft: rgba(122, 167, 255, .13);
  --pink: #f472b6; --pink-soft: rgba(244, 114, 182, .13);
  --info-line: #43577e; --pink-line: #6e4464; --bad-line: #854b52; --accent-line: #53578e;
  --info-edge: rgba(122, 167, 255, .3); --pink-edge: rgba(244, 114, 182, .3);
  --slot-a: #8b8cf8; --slot-b: #4ade80; --slot-c: #fb923c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

/* ===== База ===== */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
a, button, label, summary, input, select { touch-action: manipulation; }
/* Плавную смену страниц (@view-transition) убрали: движок Safari (WebKit) на ней падал на узких экранах */
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
html, body { margin: 0; }
body { font: 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text);
  background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: none; }
.tasks-t .org-name:hover, .tasks-t .c-id a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 650; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 600; margin: 24px 0 10px; }
h3 { font-size: 15px; font-weight: 600; margin: 0 0 6px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.ok { color: var(--ok); } .bad { color: var(--bad); } .warn { color: var(--warn); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 10px; }

/* ===== Поля и кнопки ===== */
input, select, textarea {
  font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 8px; padding: 7px 10px; outline: none; min-height: 34px;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { width: 100%; resize: vertical; }
input[type=checkbox], input[type=radio] { min-height: 0; width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.btn, button {
  font: inherit; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px; padding: 6px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap;
  color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); text-decoration: none;
  transition: background .12s, border-color .12s, opacity .12s, transform .08s;
}
.btn:active, button:active { transform: scale(.97); }
button:disabled, .btn.disabled { opacity: .45; cursor: default; pointer-events: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-ok:hover, .btn-danger:hover { opacity: .9; background: inherit; }
[data-theme="dark"] .btn-ok, [data-theme="dark"] .btn-danger { color: #0d1016; }
.btn-ok:hover { background: var(--ok); } .btn-danger:hover { background: var(--bad); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-soft-danger { color: var(--bad); }
.btn-lg { min-height: 44px; padding: 10px 20px; font-size: 15px; }
.btn-sm { min-height: 28px; padding: 3px 10px; font-size: 13px; }
.icon-btn { min-height: 32px; width: 32px; padding: 0; }
kbd { font: 600 11px/1 ui-monospace, monospace; padding: 3px 5px; border-radius: 4px; background: rgba(255,255,255,.22); }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
label.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }

@media (hover: hover) {
  .btn:hover, button:hover { background: var(--hover); text-decoration: none; }
  .btn-primary:hover { background: var(--accent); opacity: .9; }
  .btn-ghost:hover { background: var(--surface-2); }
  .t tbody tr:hover td { background: var(--hover); }
  .sidebar a.nav:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
  .tabs a:hover { color: var(--text); text-decoration: none; }
}

/* ===== Карточки, плашки, сообщения ===== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); }
.card + .card { margin-top: 12px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 6px; font-size: 11.5px;
  font-weight: 550; white-space: nowrap; background: var(--surface-2); color: var(--muted); line-height: 1.6; }
.chip-info { background: var(--info-soft); color: var(--info); }
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-bad { background: var(--bad-soft); color: var(--bad); }
.chip-accent { background: var(--accent-soft); color: var(--accent); }
.g { display: inline-flex; width: 22px; height: 22px; align-items: center; justify-content: center; border-radius: 6px;
  font-weight: 700; font-size: 12px; }
.g-m { background: var(--info-soft); color: var(--info); } .g-f { background: var(--pink-soft); color: var(--pink); }
.g-any { background: var(--surface-2); color: var(--muted); }
.tz { display: inline-block; background: var(--warn-soft); color: var(--warn); font-weight: 600; border-radius: 6px; padding: 1px 7px; font-size: 12.5px; }
.ref-link { color: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; white-space: nowrap; }
.ref-list { display: flex; flex-direction: column; gap: 6px; }
.ref-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.ref-ph { width: 44px; height: 44px; border-radius: 8px; border: 1px dashed var(--border-strong); display: grid; place-items: center; opacity: .55; }
.ref-act { display: flex; gap: 4px; }
@media (max-width: 760px) { .ref-row { grid-template-columns: 44px minmax(0, 1fr); } .ref-act { grid-column: 2; margin-top: -6px; } .ref-act:empty { display: none; } .ref-act .btn-sm { padding-left: 0; } }
.ref-row img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); flex: none; }
.ref-row > a:first-child { display: block; line-height: 0; }
.ref-row form { margin: 0; }
.ref-add input[type=file] { display: none; }
.flash { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 50; background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 10px; box-shadow: var(--shadow-lg); animation: fade 4s forwards; }
@keyframes fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }
.error { background: var(--bad-soft); color: var(--bad); padding: 10px 12px; border-radius: 8px; }
.notice { background: var(--warn-soft); color: var(--warn); padding: 8px 12px; border-radius: 8px; }
.empty { padding: 48px 16px; text-align: center; color: var(--muted); }

/* статусы заданий */
.st-pool { background: var(--surface-2); color: var(--muted); }
.st-assigned { background: var(--accent-soft); color: var(--accent); }
.st-active { background: var(--info-soft); color: var(--info); }
.st-review { background: var(--warn-soft); color: var(--warn); }
.st-accepted { background: var(--ok-soft); color: var(--ok); }
.st-rejected, .st-failed, .st-problem { background: var(--bad-soft); color: var(--bad); }

/* ===== Каркас кабинета менеджера ===== */
.layout { display: grid; grid-template-columns: 224px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 16px 12px; display: flex;
  flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { font-weight: 700; font-size: 17px; padding: 4px 10px 16px; display: flex; align-items: center; gap: 8px; color: var(--text); }
.sidebar .brand img { width: 26px; height: 26px; }
.sidebar a.nav { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.sidebar a.nav.on { background: var(--accent-soft); color: var(--accent); }
.sidebar a.nav .count { margin-left: auto; font-size: 11.5px; font-weight: 700; padding: 0 7px; border-radius: 999px;
  background: var(--bad); color: #fff; line-height: 18px; }
.sidebar a.nav .count.warn { background: var(--warn); }
.sidebar .bottom { margin-top: auto; border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.sidebar .me { padding: 0 10px; font-size: 13px; }
.content { padding: 24px 28px 96px; min-width: 0; max-width: 1600px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }

/* ===== Таблицы ===== */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: auto; box-shadow: var(--shadow); }
table.t { border-collapse: separate; border-spacing: 0; width: 100%; }
.t th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em;
  padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 1; }
.t td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.t tr:last-child td { border-bottom: 0; }
.t .num { text-align: right; font-variant-numeric: tabular-nums; }
.t.compact td, .t.compact th { padding: 7px 12px; }

/* ===== Сводная ===== */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .search { min-width: 240px; flex: 1; max-width: 380px; }
.datepick { display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; background: var(--surface); }
.datepick a { padding: 6px 10px; color: var(--muted); }
.datepick a:hover { background: var(--surface-2); text-decoration: none; }
.datepick input { border: 0; border-radius: 0; min-height: 32px; box-shadow: none !important; }
.tabs { display: flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: 10px; flex-wrap: wrap; margin-bottom: 14px; width: fit-content; }
.tabs a { padding: 6px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; display: inline-flex; gap: 6px; align-items: center; }
.tabs a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tabs a .n { font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }

.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin-bottom: 18px; }
.person { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; }
.person.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.person .top { display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px; flex: none; }
.person .name { font-weight: 600; color: var(--text); }
.person .stats { display: flex; gap: 10px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.progress { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; display: flex; }
.progress i { display: block; height: 100%; }
.progress .p-ok { background: var(--ok); } .progress .p-review { background: var(--warn); } .progress .p-bad { background: var(--bad); }
.person form { display: flex; gap: 6px; }
.person form input { width: 88px; min-height: 28px; padding: 3px 8px; }

.group-head td { background: var(--surface-2) !important; font-weight: 600; padding: 8px 12px; cursor: pointer; user-select: none; }
.group-head .caret { display: inline-block; transition: transform .15s; color: var(--muted); width: 14px; }
.group-head.closed .caret { transform: rotate(-90deg); }
tr.task-row { cursor: pointer; }
tr.task-row.sel td { background: var(--accent-soft) !important; }
tr.task-row td.check { width: 36px; }
.org-name { font-weight: 600; }
.org-sub { color: var(--muted); font-size: 12.5px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 420px; }
.thumb-sm { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; display: block; border: 1px solid var(--border); }
.ext { color: var(--faint); }

.actionbar { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%) translateY(120%); z-index: 20;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg);
  padding: 10px 12px; display: flex; gap: 8px; align-items: center; transition: transform .18s; flex-wrap: wrap; max-width: 96vw; }
.actionbar.show { transform: translateX(-50%) translateY(0); }
.actionbar .count { font-weight: 600; padding: 0 6px; }
.repeat-date { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); white-space: nowrap; }
.repeat-date input { width: auto; }

/* ===== Проверка ===== */
.review { display: grid; grid-template-columns: minmax(320px, 1fr) minmax(320px, 1.3fr); gap: 20px; align-items: start; }
.review-photo { background: #000; border-radius: 12px; overflow: hidden; display: block; }
.review-photo img { width: 100%; max-height: 80vh; object-fit: contain; display: block; }
.review dl { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; margin: 14px 0; }
.review dt { color: var(--muted); }
.review dd { margin: 0; }
.review-buttons { display: flex; gap: 10px; margin-top: 18px; }
.review-buttons button { flex: 1; }
@media (max-width: 900px) { .review { grid-template-columns: 1fr; } }

/* ===== Формы и прочее ===== */
.form-grid { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.orgform { display: grid; grid-template-columns: 1fr 1.4fr 1.4fr; gap: 6px; }
.orgform input { width: 100%; }
.thumb { max-width: 220px; max-height: 220px; border-radius: 8px; display: block; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.steps li { counter-increment: s; display: flex; gap: 10px; }
.steps li::before { content: counter(s); width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  font-weight: 700; font-size: 12px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 5px; font-size: 12.5px; font-family: inherit; font-weight: 600; }
details summary { cursor: pointer; color: var(--muted); }

/* ===== Вход ===== */
body.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-box { width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; padding: 28px; }
.login-box .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.login-box .brand img { width: 32px; height: 32px; }
.theme-corner { position: fixed; top: 12px; right: 12px; }

/* ===== Доработки: фильтры с несколькими значениями ===== */
details.ms { position: relative; }
details.ms > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; min-height: 34px;
  padding: 6px 12px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text); white-space: nowrap; }
details.ms > summary::-webkit-details-marker { display: none; }
details.ms > summary::after { content: "▾"; color: var(--faint); font-size: 11px; }
details.ms.has > summary { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.ms-pop { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; min-width: 220px; max-height: 340px; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 8px;
  display: flex; flex-direction: column; gap: 2px; }
.ms-pop label.check { padding: 6px 8px; border-radius: 6px; white-space: nowrap; }
.ms-pop label.check:hover { background: var(--surface-2); }
.ms-actions { position: sticky; bottom: -8px; background: var(--surface); padding-top: 6px; margin-top: 4px; border-top: 1px solid var(--border); }
.ms-actions button { width: 100%; }

/* ===== Таблица заданий ===== */
.tasks-t .c-id { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.tasks-t .c-id a { color: var(--muted); font-weight: 600; }
.tasks-t .c-cust { white-space: nowrap; font-weight: 500; }
.tasks-t .c-org { min-width: 220px; }
.tasks-t .org-name { color: var(--text); }
.tasks-t .c-text { min-width: 240px; }
.tasks-t .c-text .g { float: left; margin: 0 6px 0 0; }
.tasks-t .c-text .tz { display: inline-block; margin-top: 4px; }
.kind-dot { font-weight: 600; }
.kind-dot.k-yandex { color: #b7791f; } .kind-dot.k-google { color: #2563eb; } .kind-dot.k-uslugi { color: #c2410c; } .kind-dot.k-site { color: #15803d; }
[data-theme="dark"] .kind-dot.k-yandex { color: #fcd34d; } [data-theme="dark"] .kind-dot.k-google { color: #93c5fd; }
[data-theme="dark"] .kind-dot.k-uslugi { color: #ff9a80; } [data-theme="dark"] .kind-dot.k-site { color: #86efac; }
.big-tabs { margin-bottom: 10px; }
.people.single { grid-template-columns: minmax(260px, 420px); }
.progress.mini { height: 4px; margin-top: 4px; width: 60px; margin-left: auto; }
.link-row { cursor: pointer; }
.person .quick { display: flex; gap: 6px; }
.person a.top:hover { text-decoration: none; }
.modal-admin { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 16px; animation: fade-in .15s; }
.modal-admin > * { animation: slide-up .2s ease-out; }
.archived { opacity: .75; }

/* ===== Мобильная версия кабинета: шторка слева и компактные строки ===== */
.mobilebar { display: none; }
.drawer-close { display: none; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .mobilebar { display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 40; height: 52px; padding: 0 10px;
    background: var(--surface); border-bottom: 1px solid var(--border); }
  .mobilebar-title { font-weight: 650; font-size: 16px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: 270px; height: 100vh; z-index: 70; flex-direction: column; flex-wrap: nowrap;
    padding: 14px 12px; transform: translateX(-105%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  .sidebar .bottom { margin-top: auto; border-top: 1px solid var(--border); padding-top: 12px; flex-direction: column; }
  .drawer-close { display: inline-flex; }
  .drawer-overlay { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(0,0,0,.45); z-index: 65; opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.drawer-open .sidebar { transform: none; }
  body.drawer-open .drawer-overlay { opacity: 1; pointer-events: auto; }
  .content { padding: 12px 10px 110px; }
  .page-head { gap: 8px; margin-bottom: 12px; }
  .page-head h1 { display: none; }
  .page-head .avatar + h1 { display: block; font-size: 18px; }
  .hint-desktop { display: none; }

  .people { display: flex; overflow-x: auto; gap: 8px; padding-bottom: 4px; scroll-snap-type: x mandatory; }
  .people .person { min-width: 250px; scroll-snap-align: start; }
  .people.single .person { min-width: 0; width: 100%; }
  .tabs { width: auto; overflow-x: auto; flex-wrap: nowrap; }
  .tabs a { white-space: nowrap; }
  .toolbar .search { min-width: 0; max-width: none; flex-basis: 100%; }

  /* Строка задания — компактная карточка в 3–4 короткие строки */
  .tasks-t thead { display: none; }
  .tasks-t, .tasks-t tbody { display: block; }
  .tasks-t tr.task-row { display: grid; grid-template-columns: 26px auto 1fr auto;
    grid-template-areas: "check id cust status" "check org org photo" "check text text photo" "check user user photo";
    column-gap: 8px; row-gap: 1px; padding: 8px 10px; border-bottom: 1px solid var(--border); align-items: center; }
  .tasks-t tr.task-row td { display: block; padding: 0; border: 0; min-width: 0; background: none !important; }
  .tasks-t tr.task-row.sel { background: var(--accent-soft); }
  .tasks-t td.check { grid-area: check; align-self: start; padding-top: 2px; width: auto; }
  .tasks-t .c-id { grid-area: id; font-size: 12.5px; }
  .tasks-t .c-cust { grid-area: cust; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
  .tasks-t .c-status { grid-area: status; justify-self: end; }
  .tasks-t .c-org { grid-area: org; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .tasks-t .c-org .org-sub { display: inline; margin-left: 4px; font-size: 12px; }
  .tasks-t .c-text { grid-area: text; min-width: 0; font-size: 13px; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .tasks-t .c-text .clamp { display: inline; }
  .tasks-t .c-text .tz { font-size: 11.5px; padding: 0 5px; }
  .tasks-t .c-user { grid-area: user; font-size: 12.5px; color: var(--muted); }
  .tasks-t .c-photo { grid-area: photo; align-self: center; }
  .tasks-t .c-photo .thumb-sm { width: 44px; height: 44px; }
  .actionbar { left: 8px; right: 8px; transform: translateY(130%); max-width: none; bottom: 10px; }
  .actionbar.show { transform: none; }
  .actionbar select { flex: 1; min-width: 0; }
}

/* Переключатель «аккаунт включён / выключен» */
.switch { gap: 8px; padding-left: 6px; color: var(--muted); }
.switch .knob { width: 30px; height: 18px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .15s; flex: none; }
.switch .knob::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff;
  transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch.on { color: var(--ok); }
.switch.on .knob { background: var(--ok); }
.switch.on .knob::after { transform: translateX(12px); }
tr.row-off td { opacity: .55; }
tr.row-off td:last-child { opacity: 1; }

/* Техничка и Сотрудники на телефоне — карточками */
@media (max-width: 900px) {
  .page-head h1 + .muted { display: none; }
}
.sheet .field-line { margin: 0; }

/* Инструкции */
.instr-layout { display: grid; grid-template-columns: 1fr minmax(320px, 520px); gap: 16px; align-items: start; }
.instr-item.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.instr-body { margin-top: 6px; white-space: pre-line; }
.instr-form { position: sticky; top: 16px; }
@media (max-width: 900px) { .instr-layout { grid-template-columns: 1fr; } .instr-form { position: static; order: -1; } }

.kind-ico { width: 14px; height: 14px; vertical-align: -2px; margin-right: 3px; }
@media (max-width: 900px) {
  .sidebar { height: auto; height: 100dvh; }  /* старые iPhone: высота по top/bottom */
  body.drawer-open { overflow: hidden; }
}
.modal-admin { height: 100dvh; overscroll-behavior: contain; }

/* ===== Этап 2: расписание, деньги, вход через Telegram ===== */
.week-label { padding: 0 10px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.group-title { margin: 20px 0 10px; font-size: 16px; }
.tabs .dot-new { background: var(--warn); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 0 6px; line-height: 17px; }

/* расписание у менеджера */
.sched-t td.num, .sched-t th.num { text-align: center; min-width: 52px; }
.sched-t .today { background: var(--accent-soft) !important; }
.sched-t .was { display: block; font-size: 10.5px; color: var(--faint); white-space: nowrap; font-weight: 400; }
.sched-t td.new { color: var(--warn); font-weight: 700; }
.sched-t .c-note { min-width: 160px; max-width: 320px; font-size: 13px; color: var(--muted); }
.sched-t .c-who { position: sticky; left: 0; background: var(--surface); z-index: 1; }

/* сводная: «По расписанию» */
.ms-pop.right { left: auto; right: 0; gap: 6px; min-width: 240px; }
.dist-line { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; }

/* деньги */
.money-in { width: 80px; text-align: right; }
.money-in.no-rate { border-color: var(--bad); }
.money-t td { vertical-align: middle; }
.money-t .money-in { min-height: 30px; padding: 3px 8px; }
.money-card { max-width: 620px; display: flex; flex-direction: column; gap: 8px; }
.money-card + .money-card { margin-top: 12px; }
.m-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.m-row.m-total { border-top: 1px solid var(--border); padding-top: 8px; font-size: 16px; }
.m-row.m-total b { font-size: 20px; }
.m-add, .m-set { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.m-set > span:first-child { flex: 1; min-width: 170px; }
.m-set input[type=date] { width: auto; }
form.inline { display: inline; }
.link-btn { min-height: 0; padding: 0 4px; font-size: 12px; color: var(--faint); }
.inline-edit { display: inline-block; margin-left: 6px; }
.inline-edit summary { font-size: 12px; }
.inline-edit form { margin-top: 6px; }
@media (max-width: 900px) {
  .money-t thead { display: none; }
  .money-t, .money-t tbody, .money-t tfoot { display: block; }
  .money-t tr { display: grid; grid-template-columns: auto 1fr auto auto; gap: 4px 12px; padding: 10px 12px;
    border-bottom: 1px solid var(--border); align-items: end; }
  .money-t td, .money-t td.num { display: block; padding: 0; border: 0; text-align: left; }
  .money-t .c-who { grid-column: 1 / -1; }
  .money-t td.c-cnt, .money-t tfoot, .money-t td.c-act:empty { display: none; }
  .money-t td .small.muted { display: none; }
  .money-t td[data-l]::before { content: attr(data-l); display: block; font-size: 11px; color: var(--faint); }
}
.money-in.wide { width: 120px; text-align: left; }

/* вход через Telegram */
.login-box > form { gap: 14px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: 12.5px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.tg-btn { background: #2aabee; border-color: #2aabee; color: #fff; gap: 8px; }
.tg-btn svg { width: 20px; height: 20px; }
@media (hover: hover) { .tg-btn:hover { background: #229ed9; } }
.tg-code { font-size: 34px; font-weight: 800; letter-spacing: .2em; font-variant-numeric: tabular-nums; }

/* ===== Доработки 03.12 (вечер): лаконичнее, без «съехавших» элементов ===== */
[hidden] { display: none !important; }
.m-only { display: none !important; }

/* тихие статусы: цветная точка + текст, без заливки */
span.mini { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); white-space: nowrap; font-weight: 500; }
span.mini::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--dot, var(--faint)); flex: none; }
.mi-info { --dot: var(--info); } .mi-ok { --dot: var(--ok); } .mi-warn { --dot: var(--warn); } .mi-bad { --dot: var(--bad); }
summary .mini { margin-left: 8px; }
.meta-line { display: inline-flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* сотрудник: аватар + имя (+ подпись снизу) */
.who { display: flex; align-items: center; gap: 10px; min-width: 0; color: inherit; }
.who-name { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.who-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.staff-t .c-now span.mini { margin: 2px 12px 2px 0; }

/* сводная: общий срез дня */
.day-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; margin-bottom: 12px; max-width: 560px; position: relative; }
.ds { background: var(--surface); padding: 10px 14px 12px; display: flex; flex-direction: column; gap: 2px; }
.ds span { font-size: 12px; color: var(--muted); }
.ds b { font-size: 22px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.ds b small { font-size: 13px; color: var(--faint); font-weight: 500; }
.ds-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--surface-2); }
.ds-bar i { display: block; height: 100%; background: var(--ok); }
.badge { display: inline-flex; min-width: 20px; height: 20px; padding: 0 6px; align-items: center; justify-content: center;
  border-radius: 999px; background: var(--accent); color: var(--accent-text); font-size: 12px; font-weight: 700; }

/* организации: карточки с подписанными полями */
.org-list { display: flex; flex-direction: column; gap: 10px; }
.org-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; display: flex;
  flex-direction: column; gap: 8px; }
.org-card.err { border-color: var(--bad-line); }
.org-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.org-url { color: var(--muted); word-break: break-all; }
.org-fields { display: grid; grid-template-columns: 1fr 1.3fr 1.3fr auto; gap: 8px; align-items: end; }
.org-fields input { width: 100%; }
.org-actions { display: flex; gap: 6px; }
.org-meta { color: var(--muted); }
.org-sub .kind-dot + .org-meta::before { content: ""; margin-left: 6px; }

/* колокольчик уведомлений */
.bell { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px;
  border-radius: 10px; color: var(--muted); }
.bell svg { width: 22px; height: 22px; }
.bell.has { color: var(--text); }
.bell span { position: absolute; top: 2px; right: 0; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px;
  background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.sidebar .side-bell { margin-left: auto; margin-right: 4px; }
@media (max-width: 900px) { .sidebar .side-bell { display: none; } }
.notes { display: flex; flex-direction: column; gap: 6px; max-width: 760px; }
.notes-day { font-size: 12px; color: var(--faint); font-weight: 600; margin: 10px 0 2px; }
.note { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: start; padding: 10px 12px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.note.new { border-color: var(--accent-line); background: var(--accent-soft); }
.note-ico { font-size: 16px; line-height: 1.3; }
.note-time { font-size: 12px; color: var(--faint); white-space: nowrap; }
.note-text { min-width: 0; overflow-wrap: anywhere; white-space: pre-line; }
.broadcast { max-width: 760px; display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.broadcast-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.broadcast-sent { border-top: 1px solid var(--border); padding-top: 6px; display: flex; flex-direction: column; }
.bs-row { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; font-size: 13px; }
.bs-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bs-meta { color: var(--faint); white-space: nowrap; font-size: 12px; }
@media (max-width: 600px) {
  .broadcast-foot .btn-primary { width: 100%; }
  .bs-row { flex-direction: column; gap: 0; }
  .bs-text { white-space: normal; overflow-wrap: anywhere; }
}

/* история в карточке задания: дата и время одной строкой */
.hist { display: flex; flex-direction: column; }
.hist-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.hist-row:last-child { border-bottom: 0; }
.hist-time { font-size: 12px; color: var(--faint); white-space: nowrap; }

/* техничка: список и карточка сотрудника */
.users-t td { vertical-align: middle; }
.users-t .c-access { white-space: nowrap; }
.users-t .c-access .mini + .mini { margin-left: 10px; }
.user-form { max-width: 760px; display: flex; flex-direction: column; gap: 14px; }
.user-form + .user-form { margin-top: 12px; }
.user-form h3 { margin: 0; }
.form-cols { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.form-cols .field.wide { grid-column: 1 / -1; }
.form-cols input, .form-cols select { width: 100%; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.set-row:last-child { border-bottom: 0; padding-bottom: 0; }
.set-row:first-child { padding-top: 0; }
.archive-block { margin: 14px 0; }
.archive-block summary { font-weight: 600; margin-bottom: 8px; }
.card.conn { margin-bottom: 10px; max-width: 900px; }
.card.conn + .card.conn { margin-top: 0; }
.code-input { font-size: 28px; text-align: center; letter-spacing: .4em; font-weight: 700; min-height: 56px; }

@media (max-width: 900px) {
  .m-only { display: inline-flex !important; }
  /* сотрудники: имя сверху, ниже — сделано и тихие статусы одной строкой */
  .staff-t thead { display: none; }
  .staff-t, .staff-t tbody { display: block; }
  .staff-t tr { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; padding: 10px 12px;
    border-bottom: 1px solid var(--border); align-items: center; }
  .staff-t td, .staff-t td.num { display: block; padding: 0 !important; border: 0; }
  .staff-t .c-who { grid-column: 1; }
  .staff-t .c-done { grid-column: 2; text-align: right; white-space: nowrap; }
  .staff-t .c-done .progress.mini { margin-left: auto; }
  .staff-t .c-now { grid-column: 1 / -1; display: flex !important; flex-wrap: wrap; gap: 2px 0; }
  .staff-t td.c-now:empty, .staff-t td.c-total, .staff-t td.c-left, .staff-t td.c-acc, .staff-t td.c-rej, .staff-t td.c-fail,
  .staff-t td.c-last, .staff-t td.c-go { display: none; }
  .staff-t .c-done .m-only { margin-left: 4px; }

  /* организации */
  .org-fields { grid-template-columns: 1fr; }
  .org-actions .btn-primary { flex: 1; }

  /* «По расписанию» — окошко снизу экрана, не уезжает за край */
  details.dist-pop[open] .ms-pop { position: fixed; left: 10px; right: 10px; bottom: 10px; top: auto; z-index: 80; min-width: 0;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, .35); }

  /* техничка */
  .users-t thead { display: none; }
  .users-t, .users-t tbody { display: block; }
  .users-t tr { display: grid; grid-template-columns: 1fr auto auto; gap: 4px 10px; padding: 10px 12px; border-bottom: 1px solid var(--border);
    align-items: center; }
  .users-t td { display: block; padding: 0; border: 0; }
  .users-t .c-login, .users-t .c-role, .users-t .c-instr { display: none; }
  .users-t .c-access { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
  .users-t .c-access .mini + .mini { margin-left: 0; }
  .form-cols { grid-template-columns: 1fr; }
  .set-row .btn-sm { flex: none; }

  .day-stats { max-width: none; }
  .ds { padding: 8px 10px 10px; }
  .ds b { font-size: 19px; }
  .hist-row { gap: 8px; }
}

/* Расписание у менеджера: имя закреплено слева, на телефоне неделя помещается в экран */
.sched-t th.c-who { position: sticky; left: 0; z-index: 2; background: var(--surface); }
.sched-t .c-who .nm { display: block; white-space: nowrap; }
.sched-t .c-who .role-l { display: block; font-size: 11px; color: var(--faint); font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sched-t th.num { white-space: nowrap; }
.sched-t th.num .dn { display: block; font-size: 11px; font-weight: 400; color: var(--faint); letter-spacing: 0; }
.sched-t tr.note-row { display: none; }
@media (max-width: 900px) {
  .sched-t { font-size: 13px; width: 100%; }
  .sched-t th, .sched-t td { padding: 8px 3px; }
  .sched-t td.num, .sched-t th.num { min-width: 0; width: 34px; }
  .sched-t .c-who { padding-left: 10px; padding-right: 6px; }
  .sched-t .c-who .nm, .sched-t .c-who .role-l { max-width: 104px; overflow: hidden; text-overflow: ellipsis; }
  .sched-t .c-total, .sched-t .c-note { display: none; }
  .sched-t tr.note-row { display: table-row; }
  .sched-t tr.note-row td { padding: 0 10px 8px; font-size: 12px; color: var(--muted); }
  .sched-t tr:has(+ tr.note-row) td { border-bottom: 0; }
}

/* Деньги: колонка «Инструктору», вкладки неделя / день */
.money-t .d-only { margin-top: 2px; }
.m-head { font-weight: 600; }
@media (max-width: 900px) {
  .money-t tr { grid-template-columns: 1fr 1fr auto; align-items: end; }
  .money-t td.c-rate { grid-column: 1; }
  .money-t td.c-prate { grid-column: 2; }
  .money-t td.c-sum { grid-column: 1; }
  .money-t td.c-due { grid-column: 2; }
  .money-t td.c-act { grid-column: 3; }
  .money-t .d-only { display: none; }
}
@media (max-width: 900px) {
  .money-t tr { align-items: start; }
  .m-set > span:first-child { flex-basis: 100%; min-width: 0; }
  .m-set.m-line > span:first-child { flex: 1; flex-basis: auto; }
}

.review-photo.no-photo { display: flex; align-items: center; justify-content: center; min-height: 160px; color: var(--muted);
  background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: 12px; }
.staff-t th { white-space: nowrap; }
.actionbar { visibility: hidden; transition: transform .18s, visibility .18s; }
.actionbar.show { visibility: visible; }
.m-set > .muted.small { width: 18px; text-align: center; }
/* Выпадающие фильтры на телефоне — окошком снизу экрана, во всю ширину: ничего не уходит за край */
@media (max-width: 900px) {
  details.ms[open] .ms-pop { position: fixed; left: 10px; right: 10px; bottom: 10px; top: auto; z-index: 80; min-width: 0;
    max-height: 60vh; max-height: 60dvh; box-shadow: 0 -8px 32px rgba(0, 0, 0, .35); }
  details.ms .ms-pop label.check { white-space: normal; }
}

/* Сотрудники → Таблицы */
.sheets-t { table-layout: fixed; width: 100%; }
.sheets-t .c-open { text-align: right; width: 170px; white-space: nowrap; }
.sheets-t .who-name b, .sheets-t .who-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 760px) { .sheets-t .c-open { width: 128px; } }

/* Уведомления в Telegram: какие присылать */
.tg-kinds { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.tg-kinds label { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.tg-row { align-items: flex-start; }

/* ===== Узкие экраны (iPhone SE и маленькие Android, 320–360 px): ничего не вылезает за край ===== */
select, input, textarea { max-width: 100%; }
.review > * { min-width: 0; }
.review dd { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 900px) { .review { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 380px) { .review dl { grid-template-columns: 92px minmax(0, 1fr); gap: 8px; } }
/* Телефон и планшет: мелкие раскрывашки и ✕ — с запасом под палец */
@media (pointer: coarse) {
  details > summary { padding-top: 7px; padding-bottom: 7px; }
  .link-btn { min-width: 36px; min-height: 36px; }
}
/* iPhone приближает страницу, если шрифт в поле меньше 16 px, — на телефонах поля 16 px */
@media (pointer: coarse) {
  input:not([type=checkbox]):not([type=radio]), select, textarea { font-size: 16px; }
}
