/* =========================================================
   CRM — стили. Цвета вынесены в переменные ниже.
   ========================================================= */
:root {
    --bg: #f3f4f6;
    --card: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --line: #e5e7eb;
    --accent: #2563eb;
    --accent-soft: #dbeafe;
    --danger: #dc2626;
    --side-bg: #111827;
    --side-text: #d1d5db;
    --side-active: #1f2937;
    --radius: 10px;

    /* цвета статусов */
    --st-new: #64748b;            --st-new-bg: #f1f5f9;
    --st-progress: #d97706;       --st-progress-bg: #fef3c7;
    --st-approval: #7c3aed;       --st-approval-bg: #ede9fe;
    --st-done: #16a34a;           --st-done-bg: #dcfce7;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font: 14px/1.45 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a.plain { color: inherit; }
h1, h2 { margin: 0; font-weight: 600; }
h2 { font-size: 16px; margin-bottom: 12px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.strong { font-weight: 700; }
.count { display: inline-block; min-width: 22px; padding: 0 6px; border-radius: 11px; background: var(--line); font-size: 12px; text-align: center; }

/* ---------- Каркас ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px; flex-shrink: 0;
    background: var(--side-bg); color: var(--side-text);
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: block; padding: 18px 20px; font-size: 18px; font-weight: 700; color: #fff; letter-spacing: .5px; }
.brand:hover { text-decoration: none; }
/* Блок пользователя вверху меню: иконка слева, справа в столбик «Профиль» и «Выход» */
.side-user { display: flex; align-items: center; gap: 14px; padding: 16px 20px 14px; border-bottom: 1px solid #1f2937; margin-bottom: 6px; }
.side-user-ava { flex: none; line-height: 0; }
.side-user-ava .ava { box-shadow: 0 0 0 2px rgba(255,255,255,.15); }
.side-user-links { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.side-user-name { color: #fff; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user-link { color: var(--side-text); font-size: 14px; padding: 2px 0; }
.side-user-link:hover { color: #fff; text-decoration: none; }
.side-user-link.active { color: #fff; font-weight: 600; }
.nav { display: flex; flex-direction: column; padding: 4px 10px; }
.nav-bottom { margin-top: auto; border-top: 1px solid #1f2937; padding: 10px; }
.nav-title { padding: 14px 10px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #6b7280; }
.nav-link {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 10px; border-radius: 6px; color: var(--side-text);
}
.nav-link:hover { background: var(--side-active); text-decoration: none; color: #fff; }
.nav-link.active { background: var(--side-active); color: #fff; font-weight: 600; }
.nav-badge {
    margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 10px;
    background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; text-align: center;
    animation: blink 1.2s ease-in-out infinite;
}
.nav-badge:empty { display: none; }
.nav-add { padding: 8px 10px; color: #9ca3af; font-size: 13px; }
.nav-add:hover { color: #fff; }
.nav-quick { display: flex; gap: 6px; padding: 0 10px 8px; }
.nav-quick input { flex: 1; min-width: 0; }
.nav-quick[hidden] { display: none; }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; flex-shrink: 0; vertical-align: middle; }
.nav .dot { margin-right: 0; }
.dot-home { background: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 24px; background: var(--card); border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-user { margin-left: auto; white-space: nowrap; color: var(--muted); }
.menu-toggle { display: none; border: 0; background: none; font-size: 22px; cursor: pointer; padding: 0 4px; }
.sidebar-backdrop { display: none; }
.content { padding: 20px 24px 40px; }

/* ---------- Элементы ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.narrow { max-width: 520px; }

.btn {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 7px 14px; border: 1px solid var(--line); border-radius: 6px;
    background: var(--card); color: var(--text); font: inherit; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #f9fafb; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1d4ed8; }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.wide { width: 100%; justify-content: center; }
.btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.link-btn { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 12px; padding: 0; }
.link-btn:hover { color: var(--danger); text-decoration: underline; }

input[type=text], input[type=password], input[type=number], input[type=search],
input[type=datetime-local], select, textarea {
    width: 100%; padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 6px;
    font: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type=color] { width: 44px; height: 34px; padding: 2px; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; }
.w-80 { width: 80px !important; }
textarea { resize: vertical; }

.form { max-width: 820px; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; margin-bottom: 4px; font-weight: 600; font-size: 13px; }
.field-row { display: flex; gap: 14px; }
.field-row .field { flex: 1; }
.check { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }
.form-actions { display: flex; gap: 8px; margin-top: 8px; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form input[type=text] { width: auto; flex: 1; min-width: 200px; }
form.inline { display: inline; }

.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; border: 1px solid; }
.flash-ok { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.flash-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.table tr:last-child td { border-bottom: 0; }
.table td input[type=text] { min-width: 180px; }
tr.inactive td { opacity: .55; }
tr.overdue td:first-child { border-left: 3px solid var(--danger); }
.tag-overdue { margin-left: 6px; padding: 1px 6px; border-radius: 4px; background: #fee2e2; color: var(--danger); font-size: 11px; font-weight: 600; }

/* ---------- Статусы ---------- */
.st-new            { --st: var(--st-new);      --st-bg: var(--st-new-bg); }
.st-in_progress    { --st: var(--st-progress); --st-bg: var(--st-progress-bg); }
.st-needs_approval { --st: var(--st-approval); --st-bg: var(--st-approval-bg); }
.st-done           { --st: var(--st-done);     --st-bg: var(--st-done-bg); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; background: var(--st-bg); color: var(--st); white-space: nowrap; }
.role { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 11px; background: #f3f4f6; color: var(--muted); }
.role-manager { background: #fef3c7; color: #92400e; }

/* ---------- Мигание новых задач ---------- */
@keyframes blink { 50% { opacity: .2; } }
.blink .chip-title, .blink-text {
    animation: blink 1s ease-in-out infinite;
    color: var(--danger) !important;
    font-weight: 700;
}
.chip.blink { border-left-color: var(--danger); }

/* ---------- Панель календаря ---------- */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.period { font-size: 16px; margin-left: 6px; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--card); }
.segmented a { padding: 7px 14px; color: var(--text); }
.segmented a + a { border-left: 1px solid var(--line); }
.segmented a.on { background: var(--accent); color: #fff; }
.segmented a:hover { text-decoration: none; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; font-size: 12px; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-item i { width: 12px; height: 12px; border-radius: 3px; background: var(--st-bg); border-left: 3px solid var(--st); }

/* ---------- Неделя ---------- */
.week {
    display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.day { background: var(--card); min-height: 340px; display: flex; flex-direction: column; }
.day.weekend { background: #fafafa; }
.day-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 13px; }
.day.today .day-head { background: var(--accent); color: #fff; }
.day.today .day-add { color: #fff; }
.day.past { background: #fafafa; }
.day.past .day-head { color: var(--muted); }
.day-caption { margin-left: 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; opacity: .85; }
.day-add { font-size: 18px; line-height: 1; color: var(--muted); padding: 0 4px; border-radius: 4px; }
.day-add:hover { background: rgba(0,0,0,.08); text-decoration: none; }
.day-body { flex: 1; padding: 6px; display: flex; flex-direction: column; gap: 6px; }
.day-empty { color: #d1d5db; text-align: center; margin-top: 10px; }

.chip {
    display: block; padding: 6px 8px; border-radius: 6px;
    border-left: 4px solid var(--st); background: var(--st-bg); color: var(--text);
    font-size: 13px; line-height: 1.3;
}
.chip:hover { text-decoration: none; filter: brightness(.96); }
.chip.mine { box-shadow: inset 0 0 0 1px var(--st); }
.chip-time { display: block; font-size: 11px; color: var(--muted); margin-bottom: 1px; }
.chip-title { display: block; font-weight: 600; word-break: break-word; }
.chip.st-done .chip-title { text-decoration: line-through; opacity: .65; }

/* ---------- Месяц ---------- */
.month {
    display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.month-head { background: #f9fafb; padding: 6px 8px; font-size: 12px; font-weight: 600; color: var(--muted); text-align: center; }
.mday { background: var(--card); min-height: 110px; padding: 4px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.mday.weekend { background: #fafafa; }
.mday.other { background: #f9fafb; }
.mday.other .mday-num { color: #d1d5db; }
.mday-num { font-size: 12px; font-weight: 600; color: var(--text); align-self: flex-end; padding: 1px 6px; border-radius: 10px; }
.mday.today .mday-num { background: var(--accent); color: #fff; }
.mday .chip { padding: 2px 6px; font-size: 12px; border-left-width: 3px; }
.mday .chip-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.more { font-size: 11px; color: var(--muted); padding-left: 4px; }

/* ---------- Карточка задачи ---------- */
.task-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.task-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.task-head h2 { font-size: 20px; margin: 0; }
.props { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; margin: 0 0 12px; }
.props dt { color: var(--muted); }
.props dd { margin: 0; }
.description { padding-top: 12px; border-top: 1px solid var(--line); white-space: normal; }

.status-buttons { display: flex; flex-direction: column; gap: 6px; }
.st-btn { justify-content: center; border-left: 4px solid var(--st); }
.st-btn.on { background: var(--st-bg); color: var(--st); border-color: var(--st); font-weight: 700; }

.assignee-status { list-style: none; margin: 0; padding: 0; }
.assignee-status li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.assignee-status li:last-child { border-bottom: 0; }

.comments { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.comment { padding: 8px 12px; border-radius: 8px; background: #f9fafb; border: 1px solid var(--line); }
.comment.kind-status, .comment.kind-system { background: none; border-style: dashed; font-size: 13px; color: var(--muted); }
.comment-meta { display: flex; gap: 8px; align-items: baseline; font-size: 12px; margin-bottom: 2px; }
.comment-meta form { margin-left: auto; }
.comment-form { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }

/* ---------- Выбор исполнителей ---------- */
.assignees { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 0 0 14px; }
.assignees legend { font-weight: 600; padding: 0 6px; }
.assignee-tools { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.assignee-tools input { flex: 1; min-width: 180px; width: auto; }
.assignee-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 12px; max-height: 320px; overflow-y: auto; }
.assignee { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 6px; cursor: pointer; }
.assignee:hover { background: #f9fafb; }
.assignee .role { margin-left: auto; }
.assignee.hidden { display: none; }

/* ---------- Иконки пользователей ---------- */
.ava {
    display: inline-block; flex-shrink: 0; vertical-align: middle;
    border-radius: 50%; object-fit: cover; background: #e5e7eb;
}
.ava-initials {
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; line-height: 1; letter-spacing: -.3px;
    user-select: none;
}
/* кольцо цвета статуса исполнителя */
.ava.ring { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--st); margin: 2px; }
.who { display: inline-flex; align-items: center; gap: 7px; vertical-align: middle; }
.chip-people { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 5px; }
.chip-people .ava.ring { box-shadow: 0 0 0 1.5px var(--st-bg), 0 0 0 3px var(--st); margin: 1.5px; }
.chip-more { font-size: 11px; color: var(--muted); align-self: center; padding-left: 2px; }
.mday .chip-people { margin-top: 2px; gap: 2px; }
.topbar-user { display: inline-flex; align-items: center; gap: 8px; }
.topbar-user:hover { text-decoration: none; }
/* Профиль: иконка слева, ФИО/логин/роль справа, под ними загрузка иконки */
.profile-head { display: flex; align-items: center; gap: 18px; margin-bottom: 16px; }
.profile-head > .ava { flex: none; }
.profile-logout { margin-top: 4px; }
.profile-info { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.profile-info h2 { margin: 0 0 2px; font-size: 18px; overflow-wrap: anywhere; }
.profile-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.profile-row .muted { min-width: 44px; font-size: 13px; }
.avatar-edit { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.avatar-edit-forms { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 220px; }
.avatar-edit-forms input[type=file] { flex: 1; min-width: 0; font-size: 13px; }
.comment-meta .ava { align-self: center; }

/* ---------- Telegram ---------- */
.tg-status.ok { color: var(--st-done); font-weight: 600; }
#telegram form.check { gap: 10px; }
#telegram .inline-form { margin-bottom: 10px; }
code { background: #f3f4f6; padding: 1px 5px; border-radius: 4px; font-size: 13px; word-break: break-all; }

/* ---------- Вход ---------- */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.auth-card { width: 100%; max-width: 360px; }
.auth-card h1 { text-align: center; margin-bottom: 18px; }

/* ---------- Мобильные ---------- */
@media (max-width: 1100px) {
    .task-layout { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
    .sidebar { position: fixed; left: 0; top: 0; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
    /* высота по видимой части экрана (без панелей браузера) + запас снизу под кнопки навигации телефона */
    .sidebar { height: 100vh; height: 100dvh; bottom: 0; }
    .nav-bottom { margin-top: 12px; padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
    body.sidebar-open .sidebar { transform: none; }
    body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 20; }
    .menu-toggle { display: block; }
    .topbar { padding: 12px 16px; }
    .topbar-user .role, .topbar-name { display: none; }
    .content { padding: 16px; }
    .week { grid-template-columns: 1fr; }
    .day { min-height: 0; }
    .day-empty { display: none; }
    .month .chip-title { font-size: 10px; }
    .field-row { flex-direction: column; gap: 0; }
    .props { grid-template-columns: 1fr; }
    .props dt { margin-top: 6px; }
    .table { display: block; overflow-x: auto; }
}

@media (prefers-reduced-motion: reduce) {
    .blink .chip-title, .blink-text, .nav-badge { animation-duration: 2.5s; }
}

/* ---------- Все задачи ---------- */
.dot-msg { background: transparent; border: 2px solid #60a5fa; border-radius: 3px; }
.dot-trip { background: transparent; border: 2px solid #fbbf24; border-radius: 2px; transform: rotate(45deg); width: 8px; height: 8px; }
.dot-all { background: transparent; border: 2px solid var(--side-text); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.status-tabs { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.status-tabs a {
    display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
    border: 1px solid var(--line); border-radius: 18px; background: var(--card); color: var(--text);
}
.status-tabs a:hover { text-decoration: none; border-color: #cbd5e1; }
.status-tabs a[class*="st-"]::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--st); }
.status-tabs a.tab-overdue { color: var(--danger); }
.status-tabs a.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.status-tabs a.on .count { background: rgba(255,255,255,.25); }
.filters { display: grid; grid-template-columns: 2fr repeat(5, minmax(120px, 1fr)) auto; gap: 12px; align-items: end; }
.filters .field { margin-bottom: 0; }
.filters input[type=date] {
    width: 100%; padding: 7px 10px; border: 1px solid #d1d5db; border-radius: 6px; font: inherit; background: #fff; color: var(--text);
}
.filters-actions { display: flex; gap: 8px; }
.people-row { display: inline-flex; flex-wrap: wrap; gap: 3px; align-items: center; }
.tag-mine { margin-left: 6px; padding: 1px 6px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 600; }
.pager { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; margin-top: 14px; }
/* Блок поиска: на компьютере всё в одной сетке, на телефоне поиск + кнопка «Фильтры» */
.filters-more { display: contents; }
.f-q > label > span { display: block; margin-bottom: 4px; font-weight: 600; font-size: 13px; }
.f-q-row { display: flex; gap: 8px; }
.f-q-row input { flex: 1; min-width: 0; }
.filters-toggle { display: none; }
.lbl-short { display: none; }
.filters-toggle .caret { font-size: 11px; transition: transform .15s; }
.filters.open .filters-toggle .caret { transform: rotate(180deg); }
@media (max-width: 1200px) {
    .filters { grid-template-columns: repeat(3, 1fr); }
    .filters .f-q { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
    /* статусы — в два столбика */
    .status-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; width: 100%; }
    .toolbar > .toolbar-group:first-child { width: 100%; }
    .status-tabs a { justify-content: flex-start; padding: 6px 10px; font-size: 13px; border-radius: 10px; min-width: 0; white-space: nowrap; }
    .status-tabs a .count { flex: none; margin-left: auto; }
    .status-tabs .lbl-full { display: none; }
    .status-tabs .lbl-short { display: inline; }
    .filters .f-sort { grid-column: 1 / -1; }
    /* поиск в одну строку, остальное — по кнопке */
    .filters { grid-template-columns: 1fr 1fr; padding: 12px; gap: 10px; }
    .f-q > label { display: none; }
    .filters-toggle { display: inline-flex; }
    .filters-more { display: none; }
    .filters.open .filters-more { display: contents; }
    .filters-actions { grid-column: 1 / -1; }
    .filters-actions .btn { flex: 1; justify-content: center; }
}

/* ---------- Удаление пользователя ---------- */
.danger-zone { border-color: #fecaca; }
.danger-zone h2 { color: var(--danger); }
.row-actions { text-align: right; }
.row-actions form.inline { margin-left: 4px; }

/* ---------- Карточка задачи: статус значками + комментарий сразу под задачей ---------- */
.reply-card { padding: 12px 16px; }
.status-icons { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.status-icons-label { font-size: 12px; font-weight: 600; color: var(--muted); margin-right: 4px; }
.st-icon {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 4px 12px 4px 4px; border: 1px solid var(--line); border-radius: 10px;
    background: #fff; cursor: pointer; font: inherit; line-height: 1.1;
}
.st-icon:hover { border-color: var(--st); background: var(--st-bg); }
.st-icon-img { width: 48px; height: 48px; flex: none; display: block; object-fit: contain; }
.st-icon-text { font-size: 13px; color: var(--text); white-space: nowrap; }
.st-icon.on { border-color: var(--st); background: var(--st-bg); box-shadow: inset 0 0 0 1px var(--st); }
.st-icon.on .st-icon-text { color: var(--st); font-weight: 700; }
.st-icon:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.reply-card .comment-form { flex-direction: row; align-items: flex-end; }
.reply-card .comment-form textarea { flex: 1; }
.small-note { font-size: 12px; font-weight: 400; margin-left: 6px; }
/* Телефон: подпись «Мой статус» сверху, три кнопки в одну линию, значок над подписью */
@media (max-width: 600px) {
    .reply-card { padding: 12px; }
    .status-icons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
    .status-icons-label { grid-column: 1 / -1; margin: 0 0 2px; }
    .st-icon { flex-direction: column; justify-content: center; gap: 4px; padding: 6px 2px; min-width: 0; }
    .st-icon-img { width: 36px; height: 36px; }
    .st-icon-text { font-size: 11px; }
    .reply-card .comment-form { flex-direction: column; align-items: stretch; }
    .reply-card .comment-form .btn { justify-content: center; }
}

/* ---------- Личные сообщения ---------- */
.new-chat { padding: 0; overflow: hidden; }
.new-chat summary { list-style: none; cursor: pointer; padding: 12px 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.new-chat summary::-webkit-details-marker { display: none; }
.new-chat summary::after { content: '▾'; margin-left: auto; color: var(--muted); transition: transform .15s; }
.new-chat[open] summary::after { transform: rotate(180deg); }
.new-chat summary:hover { background: #f9fafb; }
.new-chat-search { display: block; width: calc(100% - 24px) !important; margin: 0 12px 8px; }
.people-pick { max-height: 55vh; overflow-y: auto; border-top: 1px solid var(--line); padding: 4px 6px 6px; }
.people-pick a { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 8px; }
.people-pick a:hover { background: #f3f4f6; text-decoration: none; }
.people-pick a[hidden] { display: none; }
.people-pick a > .ava { flex: none; }
.people-pick-name { flex: 1; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people-pick-role { font-size: 12px; white-space: nowrap; }
.dialogs { padding: 6px; }
.dialog { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 8px; }
.dialog:hover { background: #f9fafb; text-decoration: none; }
.dialog + .dialog { border-top: 1px solid var(--line); }
.dialog > .ava { flex: none; }
.dialog-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dialog-top, .dialog-bottom { display: flex; align-items: center; gap: 8px; }
.dialog-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dialog-time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.dialog-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13px; }
.dialog.unread .dialog-text { color: var(--text); font-weight: 600; }
.dialog-badge { flex: none; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; text-align: center; line-height: 20px; }

.chat { display: flex; flex-direction: column; padding: 0; overflow: hidden; height: calc(100vh - 130px); height: calc(100dvh - 130px); min-height: 360px; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.chat-head > .ava { flex: none; }
.chat-head-info { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.chat-head-info b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head-info .small-note { margin: 0; }
.chat-log { flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; background: #f8fafc; }
.chat-empty { margin: auto; }
.msg { max-width: 78%; padding: 7px 10px 5px; border-radius: 12px; box-shadow: 0 1px 1px rgba(0,0,0,.04); overflow-wrap: anywhere; }
.msg-theirs { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg-mine { align-self: flex-end; background: var(--accent-soft); border: 1px solid #bfdbfe; border-bottom-right-radius: 4px; }
.msg-meta { font-size: 11px; color: var(--muted); text-align: right; margin-top: 2px; white-space: nowrap; }
.msg-read { color: var(--accent); }
.msg-day { align-self: center; margin: 6px 0; }
.msg-day span { display: inline-block; padding: 2px 10px; border-radius: 10px; background: #e5e7eb; color: #4b5563; font-size: 12px; }
.chat-form { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); background: var(--card); }
.chat-input { display: flex; gap: 6px; align-items: flex-end; }
.chat-input[hidden] { display: none; }
.chat-input textarea { flex: 1; resize: none; min-height: 40px; max-height: 160px; }
.chat-send { height: 40px; min-width: 46px; justify-content: center; font-size: 16px; }
.chat-send[hidden] { display: none; }
.chat-icon-btn {
    display: inline-flex; align-items: center; justify-content: center; flex: none;
    width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: #fff;
    font-size: 18px; cursor: pointer; user-select: none;
}
.chat-icon-btn:hover { background: #f3f4f6; }
.chat-icon-btn[hidden] { display: none; }
.chat-mic { border-color: #bfdbfe; background: var(--accent-soft); }
/* выбранный файл */
.chat-attach { position: relative; display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: #f9fafb; overflow: hidden; font-size: 13px; }
.chat-attach[hidden] { display: none; }
.chat-attach-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.chat-attach-x { border: 0; background: none; font-size: 18px; color: var(--muted); cursor: pointer; padding: 0 4px; }
.chat-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; display: none; }
.chat-progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.chat-attach.uploading .chat-progress { display: block; }
.chat.drag .chat-log { outline: 3px dashed var(--accent); outline-offset: -8px; background: var(--accent-soft); }
/* запись голосового */
.chat-rec { display: flex; align-items: center; gap: 10px; padding: 4px 2px; }
.chat-rec[hidden] { display: none; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); animation: blink 1s ease-in-out infinite; }
.rec-time { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 40px; }
.rec-hint { flex: 1; font-size: 13px; }
/* файлы в сообщениях */
.msg-img { display: block; margin: -3px -6px 4px; }
.msg-img img { display: block; max-width: 100%; max-height: 320px; border-radius: 8px; }
.msg-image { max-width: 320px; }
.msg-file { display: flex; align-items: center; gap: 10px; padding: 4px 0; color: inherit; min-width: 0; }
.msg-file:hover { text-decoration: none; }
.msg-file:hover b { text-decoration: underline; }
.msg-file-ico { flex: none; width: 40px; height: 40px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.msg-file-info { display: flex; flex-direction: column; min-width: 0; }
.msg-file-info b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.msg-file-info span { font-size: 12px; color: var(--muted); }
.msg-file-sub { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.msg-media { display: block; max-width: 100%; max-height: 320px; border-radius: 8px; }
.msg-audio { display: flex; align-items: center; gap: 6px; }
.msg-audio-ico { flex: none; }
.msg-audio audio { height: 36px; width: 230px; max-width: 100%; }
.msg-audio-dur { font-size: 12px; color: var(--muted); }
.msg-body + .msg-meta, .msg-audio + .msg-meta { margin-top: 2px; }
.msg-img + .msg-body, .msg-file + .msg-body, .msg-audio + .msg-body { margin-top: 4px; }
@media (max-width: 600px) {
    .msg-audio audio { width: 190px; }
    .msg-file-info b { max-width: 160px; }
}
.chat-disabled { padding: 12px 14px; margin: 0; border-top: 1px solid var(--line); }
@media (max-width: 900px) {
    .chat { height: calc(100vh - 100px); height: calc(100dvh - 100px); margin-bottom: 0; }
    .msg { max-width: 88%; }
}

/* ---------- Всплывающие уведомления (живое обновление) ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; flex-direction: column; gap: 10px; width: 340px; max-width: calc(100vw - 32px); pointer-events: none; }
.toast {
    position: relative; display: flex; flex-direction: column; gap: 3px; padding: 12px 34px 12px 14px;
    background: #fff; color: var(--text); border: 1px solid var(--line); border-left: 4px solid var(--accent);
    border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.15); pointer-events: auto;
    transform: translateX(120%); opacity: 0; transition: transform .3s ease, opacity .3s ease;
}
.toast:hover { text-decoration: none; background: #f9fafb; }
.toast.in { transform: none; opacity: 1; }
.toast.out { transform: translateX(120%); opacity: 0; }
.toast-task.mine { border-left-color: var(--danger); }
.toast-msg { border-left-color: #16a34a; }
.toast-head { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.toast-head .dot { margin-right: 2px; }
.toast-title { font-size: 15px; }
.toast-sub { font-size: 12px; color: var(--muted); }
.toast-row { display: flex; gap: 10px; align-items: flex-start; }
.toast-row > .ava { flex: none; }
.toast-col { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.toast-msg .toast-head { color: var(--text); font-weight: 700; font-size: 13px; }
.toast-text { font-size: 13px; overflow-wrap: anywhere; }
.toast-close { position: absolute; top: 6px; right: 8px; border: 0; background: none; font-size: 18px; line-height: 1; color: var(--muted); cursor: pointer; padding: 2px 4px; }
.toast-close:hover { color: var(--text); }
.live-flash { animation: liveflash .9s ease; }
@keyframes liveflash { 0% { opacity: .55; } 100% { opacity: 1; } }
@media (max-width: 600px) {
    .toasts { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); width: auto; max-width: none; }
    .toast { transform: translateY(150%); }
    .toast.in { transform: none; }
    .toast.out { transform: translateY(150%); }
}
@media (prefers-reduced-motion: reduce) {
    .toast, .toast.in, .toast.out { transition: opacity .2s; transform: none; }
    .live-flash { animation: none; }
}

/* ---------- Проверка работы постановщиком ---------- */
.assignee-status li { flex-direction: column; align-items: stretch; }
.assignee-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.assignee-st { display: inline-flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.approved { font-size: 11px; font-weight: 700; color: var(--st-done); white-space: nowrap; }
.assignee-review { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin-top: 6px; font-size: 12px; flex-wrap: wrap; }
.awaits-review { background: #faf5ff; margin: 0 -10px; padding: 8px 10px !important; border-radius: 8px; }
.review-btns { display: inline-flex; gap: 6px; }
.review-btns form { margin: 0; }
.btn.review-ok { color: #15803d; border-color: #bbf7d0; background: #f0fdf4; }
.btn.review-ok:hover { background: #dcfce7; }
.btn.review-no { color: var(--danger); border-color: #fecaca; background: #fff; }
.btn.review-no:hover { background: #fef2f2; }
/* блок «Проверьте работу» под задачей */
.review-card { border-color: #ddd6fe; background: #faf5ff; padding: 14px 16px; }
.review-card h2 { margin-bottom: 8px; }
.review-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 8px 0; }
.review-row + .review-row { border-top: 1px solid #e9d5ff; }
.review-row .who > span { display: flex; flex-direction: column; gap: 2px; }
.review-sub { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.review-card .review-btns .btn { padding: 7px 14px; font-size: 14px; }
@media (max-width: 600px) {
    .review-row .review-btns { width: 100%; }
    .review-row .review-btns form { flex: 1; }
    .review-row .review-btns .btn { width: 100%; justify-content: center; }
}
.approved .review-btns { margin-left: 4px; vertical-align: middle; }
.approved .btn.small { padding: 1px 6px; font-size: 11px; }
@media (max-width: 600px) {
    /* «Ждут вашей проверки» на телефоне — карточками вместо таблицы */
    .review-table thead { display: none; }
    .review-table tr { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
    .review-table tr:last-child { border-bottom: 0; }
    .review-table td { padding: 0; border: 0; }
    .review-table td:first-child { grid-column: 1 / -1; }
    .review-table td:last-child { grid-column: 1 / -1; }
    .review-table .review-btns { display: flex; }
    .review-table .review-btns form { flex: 1; }
    .review-table .review-btns .btn { width: 100%; justify-content: center; padding: 8px 10px; }
}

/* ---------- Статус + комментарий одной формой ---------- */
.status-form { flex-direction: column; align-items: stretch; gap: 8px; }
.reply-card .status-form { flex-direction: column; align-items: stretch; }
.status-form .status-icons { margin: 0; }
.status-form .comment-only { margin-left: auto; }
.status-form.need-comment textarea { border-color: var(--danger); outline: 2px solid #fecaca; }
.status-hint { color: var(--danger); font-size: 13px; font-weight: 600; }
.review-comment { flex-basis: 100%; margin-top: 4px; padding: 6px 10px; background: #fff; border: 1px solid #e9d5ff; border-radius: 8px; font-size: 13px; color: var(--text); overflow-wrap: anywhere; }
.review-table .review-comment { background: #f9fafb; border-color: var(--line); margin-top: 6px; }
@media (max-width: 600px) {
    .status-form .comment-only { grid-column: 1 / -1; margin: 0; justify-content: center; }
}

/* ---------- «Ознакомлен» ---------- */
.btn.ack-btn { color: #1d4ed8; border-color: #bfdbfe; background: var(--accent-soft); font-weight: 600; }
.btn.ack-btn:hover { background: #bfdbfe; }
.ack-under { margin-top: 6px; }
.ack-under .ack-form { margin: 0; }
.ack-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px dashed var(--line); }
.ack-row .ack-form { margin-left: 0; }
.ack-row .small-note { margin: 0; }

/* ---------- Списки задач на компьютере: раздел вертикально слева ---------- */
.task-list th.c-sec-h { width: 30px; padding: 0; }
.task-list td.c-sec {
    width: 30px; padding: 6px 4px; border-left: 4px solid var(--sec, var(--line));
    writing-mode: vertical-rl; transform: rotate(180deg); text-align: center; white-space: nowrap;
}
.task-list td.c-sec a { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .3px; }
.task-list td.c-sec .dot { margin: 0 0 5px 0; }
.task-list tr.overdue td.c-sec { border-left-color: var(--danger); }
.task-list tr.overdue td:first-child { border-left-width: 4px; }
.task-list.grouped .c-sec, .task-list.grouped .c-sec-h { display: none; }
.task-list.grouped tr.overdue td.c-title { border-left: 3px solid var(--danger); }

/* ---------- Списки задач: быстрая сортировка и карточки на телефоне ---------- */
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.list-head h2 { margin: 0; }
.sort-bar { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--card); }
.sort-bar a { padding: 6px 12px; font-size: 13px; color: var(--text); white-space: nowrap; }
.sort-bar a + a { border-left: 1px solid var(--line); }
.sort-bar a:hover { background: #f3f4f6; text-decoration: none; }
.sort-bar a.on { background: var(--accent); color: #fff; font-weight: 600; }
.task-list .t-ico, .task-list .t-sep { display: none; }
.group-row td { background: #f9fafb; font-weight: 700; font-size: 13px; padding-top: 10px; }
.group-row .count { margin-left: 4px; }

@media (max-width: 700px) {
    .task-list-card { padding: 12px; }
    .task-list-card .table-wrap { overflow: visible; }
    .list-head { flex-direction: column; align-items: stretch; }
    .sort-bar { display: grid; grid-template-columns: repeat(4, 1fr); }
    .sort-bar a { text-align: center; padding: 8px 4px; font-size: 12px; }

    /* таблица -> карточки: слева раздел вертикально, справа название + статус, ниже время, исполнители */
    .task-list, .task-list tbody { display: block; }
    .task-list thead { display: none; }
    .task-list tr {
        display: grid; grid-template-columns: auto minmax(0, 1fr) auto; column-gap: 10px; row-gap: 6px;
        grid-template-areas: "sec title st" "sec time time" "sec people author";
        padding: 10px 12px 10px 6px; margin-bottom: 8px; background: var(--card);
        border: 1px solid var(--line); border-left: 4px solid var(--sec, var(--line)); border-radius: 10px;
    }
    .task-list td { display: block; padding: 0; border: 0; min-width: 0; }
    .task-list tr.overdue { border-left-color: var(--danger); background: #fffafa; }
    .task-list tr.overdue td:first-child { border-left: 0; }
    /* раздел — вертикальной надписью снизу вверх, точка внизу */
    .task-list .c-sec {
        grid-area: sec; align-self: stretch; display: flex; align-items: center; justify-content: center;
        writing-mode: vertical-rl; transform: rotate(180deg);
        padding: 2px 0 !important; border-left: 1px solid var(--line) !important; white-space: nowrap;
        max-height: 160px; overflow: hidden;
    }
    .task-list .c-sec a { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; }
    .task-list .c-sec .dot { margin: 0 0 5px 0; }
    .task-list .c-title { grid-area: title; font-size: 15px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; align-self: center; }
    .task-list .c-title a { text-transform: none; }
    .task-list .c-title .tag-overdue, .task-list .c-title .tag-mine { font-weight: 600; vertical-align: middle; }
    .task-list .c-st { grid-area: st; justify-self: end; align-self: start; text-align: right; }
    .task-list .c-time { grid-area: time; font-size: 13px; color: var(--muted); white-space: normal; }
    .task-list .t-ico, .task-list .t-sep { display: inline; }
    .task-list .t-br { display: none; }
    .task-list .c-people { grid-area: people; align-self: center; }
    .task-list .c-author { grid-area: author; font-size: 12px; align-self: center; justify-self: end; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; }
    .task-list .ack-under { margin-top: 8px; }
    .task-list .ack-under .btn { padding: 6px 12px; font-size: 14px; }
    /* заголовок раздела при сортировке «По разделам» */
    .task-list tr.group-row { display: block; padding: 6px 2px 2px; margin: 10px 0 4px; background: none; border: 0; }
    .task-list tr.group-row td { background: none; font-size: 14px; padding: 0; }
    .task-list tr.group-row:first-child { margin-top: 0; }
    /* в группировке по разделам раздел уже в заголовке группы */
    .task-list.grouped tr:not(.group-row) { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "title st" "time time" "people author"; padding-left: 12px; }
    .task-list.grouped .c-sec { display: none; }
}

/* ---------- Создатель задачи: иконка + имя + «создал» ---------- */
.author { display: inline-flex; align-items: center; gap: 7px; max-width: 100%; }
.author > .ava { flex: none; }
.author-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.author-name { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.author-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
@media (max-width: 700px) {
    .task-list .c-author { max-width: 48vw; overflow: visible; }
}

/* ---------- Выезды ---------- */
.trip-day-pick input { width: auto; padding: 6px 8px; border: 1px solid #d1d5db; border-radius: 6px; font: inherit; background: #fff; }
.trip-day { margin-bottom: 18px; }
.trip-day-title { font-size: 15px; margin: 0 0 8px 2px; }
.trip-card {
    position: relative; display: flex; gap: 14px; padding: 12px 14px; margin-bottom: 8px;
    background: var(--card); border: 1px solid var(--line); border-left: 4px solid #f59e0b; border-radius: 10px;
}
.trip-card.past { opacity: .7; border-left-color: #cbd5e1; }
.trip-card:target { outline: 2px solid var(--accent); }
.trip-time { flex: none; width: 58px; text-align: center; display: flex; flex-direction: column; }
.trip-time b { font-size: 20px; line-height: 1.1; }
.trip-time span { font-size: 12px; color: var(--muted); }
.trip-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; padding-right: 30px; }
.trip-vehicle { font-weight: 700; font-size: 15px; }
.trip-route { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 20px; font-size: 13px; }
.trip-route li { position: relative; background: #fef3c7; color: #92400e; padding: 2px 8px; border-radius: 10px; }
.trip-route li + li::before { content: '→'; position: absolute; left: -16px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.trip-people { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: center; font-size: 13px; }
.trip-role { color: var(--muted); font-size: 12px; white-space: nowrap; }
.trip-pass { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.trip-person { display: inline-flex; align-items: center; gap: 5px; }
.trip-person.driver { font-weight: 600; }
.trip-person.manual > span:last-child { font-style: italic; }
.trip-note { font-size: 13px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 6px; }
.trip-edit { position: absolute; top: 10px; right: 10px; }
/* форма */
.trip-form .field > span small { font-weight: 400; margin-left: 4px; }
.multi { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.multi-row { display: flex; gap: 6px; }
.multi-row input { flex: 1; min-width: 0; }
.multi-del { flex: none; width: 36px; justify-content: center; color: var(--muted); }
@media (max-width: 600px) {
    .trip-card { gap: 10px; padding: 10px 12px; }
    .trip-time { width: 48px; }
    .trip-time b { font-size: 18px; }
    .trip-people { grid-template-columns: 1fr; gap: 3px; }
    .trip-role { margin-top: 2px; }
}

/* ---------- Окна справочников выездов ---------- */
.dict-dialog {
    width: 460px; max-width: calc(100vw - 24px); max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px);
    padding: 0; border: 0; border-radius: 12px; box-shadow: 0 20px 50px rgba(0,0,0,.3); color: var(--text);
}
.dict-dialog[open] { display: flex; flex-direction: column; }
.dict-dialog::backdrop { background: rgba(15, 23, 42, .5); }
.dict-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 8px; }
.dict-head h2 { margin: 0; }
.dict-close { border: 0; background: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 4px; }
.dict-close:hover { color: var(--text); }
.dict-add { display: flex; gap: 8px; align-items: flex-end; padding: 0 16px 10px; }
.dict-add textarea { flex: 1; resize: vertical; min-height: 42px; }
.dict-search { display: block; width: calc(100% - 32px) !important; margin: 0 16px 8px; }
.dict-list { list-style: none; margin: 0; padding: 0 8px 12px; overflow-y: auto; flex: 1; border-top: 1px solid var(--line); }
.dict-list li { display: flex; align-items: center; gap: 8px; padding: 8px; border-bottom: 1px solid var(--line); }
.dict-list li[hidden] { display: none; }
.dict-list li:last-child { border-bottom: 0; }
.dict-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.dict-uses { font-size: 11px; color: var(--muted); background: #f3f4f6; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.dict-del { border: 1px solid #fecaca; background: #fff; color: var(--danger); width: 30px; height: 30px; border-radius: 6px; font-size: 18px; line-height: 1; cursor: pointer; }
.dict-del:hover { background: #fef2f2; }
@media (max-width: 600px) {
    /* окно сверху экрана — клавиатура снизу его не закрывает */
    .dict-dialog { width: calc(100% - 16px); max-width: none; margin: 8px auto auto; border-radius: 12px; max-height: 70vh; max-height: 70dvh; }
    .dict-add { flex-direction: column; align-items: stretch; }
}

/* ---------- Раздел «Сеть» (net.php, net_device.php) ---------- */
.dot-net { background: transparent; border: 2px solid #34d399; border-radius: 50%; }
.net-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.net-tabs a { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--text); font-weight: 600; }
.net-tabs a:hover { text-decoration: none; border-color: #cbd5e1; }
.net-tabs a.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.net-tabs .count { font-size: 12px; padding: 0 7px; border-radius: 9px; background: var(--bg); color: var(--muted); }
.net-tabs a.on .count { background: rgba(255,255,255,.25); color: #fff; }
.net-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.net-head h2 { margin: 0; }
.nd { display: inline-block; width: 11px; height: 11px; border-radius: 50%; background: #64748b; vertical-align: middle; flex: none; }
.nd-on { background: #16a34a; box-shadow: 0 0 0 3px #dcfce7; }
.nd-off { background: #9ca3af; }
.nd-warn { background: #d97706; box-shadow: 0 0 0 3px #fef3c7; }
.nd-unknown { background: #cbd5e1; }
.nd-on-text { color: #15803d; font-weight: 600; }
.net-table td.c-dot { width: 22px; padding-right: 0; }
.net-table code { white-space: nowrap; }
.net-actions { white-space: nowrap; text-align: right; }
.net-other summary { cursor: pointer; font-weight: 600; }
.net-other .table { margin-top: 10px; }
.net-map { height: 520px; border-radius: 8px; border: 1px solid var(--line); background: #e5e7eb; z-index: 0; }
.net-map-small { height: 300px; margin-bottom: 14px; }
.net-map-card { padding: 10px; }
.net-legend { display: flex; flex-wrap: wrap; gap: 14px; padding: 8px 4px 0; }
.net-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.net-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.net-new h2 { margin-top: 0; }
.net-code { background: #0f172a; color: #e2e8f0; padding: 14px 16px; border-radius: 8px; overflow-x: auto; font: 12.5px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre; margin: 0; }
.net-btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.net-btns form { margin: 0; }
.net-tip { background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 8px; padding: 10px 12px; }
.net-warn { border-color: #fde68a; background: #fffbeb; }
.net-warn .net-code { margin: 8px 0 10px; }
.net-dev-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.net-dev-head h2 { margin: 0 0 4px; }
.net-facts { display: grid; grid-template-columns: repeat(2, minmax(150px, auto)); gap: 8px 24px; margin: 0; }
.net-facts dt { font-size: 12px; color: var(--muted); font-weight: 600; }
.net-facts dd { margin: 0; }
.net-secret { filter: blur(4px); cursor: pointer; transition: filter .15s; }
.net-secret.shown, .net-secret:focus { filter: none; }
@media (max-width: 760px) {
    .net-map { height: 60vh; }
    .net-map-small { height: 260px; }
    .net-facts { grid-template-columns: 1fr 1fr; width: 100%; }
    .net-tabs a { padding: 6px 11px; font-size: 13px; }
    .net-table, .net-table tbody { display: block; }
    .net-table thead, .net-table td.c-ext { display: none; }
    .net-table tr { display: grid; grid-template-columns: 16px 1fr auto; grid-template-areas: "dot name act" ". ip conn"; gap: 4px 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
    .net-table tr:last-child { border-bottom: 0; }
    .net-table td { padding: 0; border: 0; }
    .net-table td.c-dot { grid-area: dot; width: auto; }
    .net-table td.c-name { grid-area: name; min-width: 0; }
    .net-table td.c-ip { grid-area: ip; }
    .net-table td.c-conn { grid-area: conn; text-align: right; }
    .net-table td.c-act { grid-area: act; }
    .net-cfg tr { grid-template-areas: "name name act" "ip ip conn"; }
    .net-code { font-size: 11.5px; }
}
