/* Три оформления. Компактный список используется также для старых учётных записей. */
:root, :root[data-style="compact"] {
    color-scheme: light;
    --bg: #f5f7fb; --card: #fff; --text: #192942; --muted: #63748a;
    --line: #e0e7f1; --accent: #285bd4; --accent-soft: #eaf1ff;
    --side-bg: #17263e; --side-text: #d4def0; --side-active: #2c4266;
    --radius: 12px; --control-bg: #fff; --hover: #eef3fa; --on-accent: #fff;
    --soft-bg: #f0f4fa; --shadow: none;
}
:root[data-style="cards"] {
    --bg: #f1f6f2; --card: #fff; --text: #17382c; --muted: #60776c;
    --line: #dbe7df; --accent: #146747; --accent-soft: #e1f3e8;
    --side-bg: #153d30; --side-text: #d9ece1; --side-active: #2b5746;
    --radius: 18px; --control-bg: #fff; --hover: #edf5ef; --on-accent: #fff;
    --soft-bg: #e9f3ec; --shadow: 0 4px 16px #183a2a06;
}
:root[data-style="graphite"] {
    color-scheme: dark;
    --bg: #15191f; --card: #20262f; --text: #eff4fc; --muted: #acb9cc;
    --line: #36404e; --accent: #b5c0ff; --accent-soft: #30374f;
    --side-bg: #1a2028; --side-text: #d1dbea; --side-active: #343d56;
    --radius: 18px; --control-bg: #252d38; --hover: #303949; --on-accent: #1b2441;
    --soft-bg: #29323e; --shadow: none; --danger: #ff9d9d;
    --st-new: #c6d1e4; --st-new-bg: #344051;
    --st-progress: #ffd18e; --st-progress-bg: #493820;
    --st-approval: #d4c2ff; --st-approval-bg: #403156;
    --st-done: #9ce8b5; --st-done-bg: #234333;
}
body { font-family: Inter, Roboto, "Segoe UI", sans-serif; }
.card { box-shadow: var(--shadow); }
.topbar h1 { letter-spacing: -.45px; }
input[type=text], input[type=password], input[type=number], input[type=search],
input[type=datetime-local], input[type=date], input[type=color], select, textarea,
.filters input[type=date] { background: var(--control-bg); color: var(--text); border-color: var(--line); }
.btn:hover, .dialog:hover, .people-pick a:hover, .new-chat summary:hover,
.sort-bar a:hover, .toast:hover { background: var(--hover); }
.btn.primary, .btn.primary:hover, .sort-bar a.on, .status-tabs a.on, .net-tabs a.on,
.segmented a.on, .mday.today .mday-num, .day.today .day-head {
    background: var(--accent); border-color: var(--accent); color: var(--on-accent);
}
.group-row td, code, .chat-attach { background: var(--soft-bg); }
.toast, .review-comment, .review-table .review-comment, .st-icon { background: var(--card); color: var(--text); }
.review-card, .awaits-review { background: var(--accent-soft); border-color: var(--line); }
.task-list tr.overdue { background: var(--card); }
.btn.ack-btn { color: var(--accent); border-color: var(--line); background: var(--accent-soft); }
.btn.ack-btn:hover { background: var(--hover); }
.sidebar .side-user, .sidebar .nav-bottom { border-color: #ffffff20; }
.sidebar .nav-title { color: #b1c2d5; }
.appearance-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.appearance-option { position: relative; display: flex; flex-direction: column; gap: 7px; padding: 13px;
    border: 1px solid var(--line); border-radius: 12px; background: var(--card); cursor: pointer; min-width: 0; }
.appearance-option:has(input:checked) { border-color: var(--accent); outline: 1px solid var(--accent); }
.appearance-option-title { display: flex; align-items: start; gap: 7px; font-weight: 600; font-size: 13px; }
.appearance-option input { margin: 3px 0 0; accent-color: var(--accent); flex-shrink: 0; }
.appearance-option p { margin: 0; color: var(--muted); font-size: 12px; }
.appearance-preview { height: 66px; border-radius: 8px; display: grid; gap: 5px; padding: 9px; }
.appearance-preview i { display: block; border-radius: 4px; height: 12px; }
.appearance-preview.compact { background: #edf3ff; }
.appearance-preview.compact i { background: #d0def7; border-left: 3px solid #285bd4; border-radius: 1px; }
.appearance-preview.cards { background: #e4f2e9; }
.appearance-preview.cards i { background: #fff; border-left: 3px solid #146747; }
.appearance-preview.graphite { background: #15191f; }
.appearance-preview.graphite i { background: #343d55; border-left: 3px solid #b5c0ff; }
.app-settings-links { display: grid; gap: 8px; }
.app-settings-links a { padding: 12px 0; display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); }
:root[data-style="graphite"] .tag-overdue { background: #492f35; }
:root[data-style="graphite"] .flash-ok { background: #234333; color: #b1f2c8; border-color: #40694e; }
:root[data-style="graphite"] .flash-error { background: #4b2c34; color: #ffc2c6; border-color: #75414b; }
:root[data-style="graphite"] .btn.review-ok { background: #234333; color: #a9efc1; border-color: #40694e; }
:root[data-style="graphite"] .btn.review-no, :root[data-style="graphite"] .btn.danger { background: var(--card); color: var(--danger); border-color: #75414b; }
:root[data-style="graphite"] .chat-log { background: var(--bg); }
:root[data-style="graphite"] .msg-theirs { background: var(--soft-bg); color: var(--text); }
:root[data-style="graphite"] .msg-mine { background: var(--accent-soft); border-color: var(--line); }
:root[data-style="graphite"] .msg-day span { background: var(--soft-bg); color: var(--muted); }
:root[data-style="graphite"] .chat-icon-btn, :root[data-style="graphite"] .dict-del { background: var(--card); color: var(--text); }
:root[data-style="graphite"] .day, :root[data-style="graphite"] .day.weekend,
:root[data-style="graphite"] .day.past, :root[data-style="graphite"] .mday,
:root[data-style="graphite"] .mday.weekend, :root[data-style="graphite"] .mday.other { background: var(--card); }
:root[data-style="graphite"] .month-head, :root[data-style="graphite"] .comment,
:root[data-style="graphite"] .dict-uses { background: var(--soft-bg); }
:root[data-style="graphite"] .assignee:hover { background: var(--hover); }
:root[data-style="graphite"] .net-tip, :root[data-style="graphite"] .net-warn { background: var(--soft-bg); border-color: var(--line); }
.crm-app .layout { min-height: 100vh; min-height: 100dvh; }
.crm-app .topbar { padding: 18px 16px 12px; border: 0; background: var(--bg); align-items: center; }
.crm-app .topbar h1 { font-size: 26px; font-weight: 700; white-space: normal; line-height: 1.2; }
.crm-app .topbar-user { display: none; }
.crm-app .content { padding: 12px 16px 24px; }
.crm-app .menu-toggle { display: block; color: var(--text); }
.crm-app .sidebar { position: fixed; left: 0; top: 0; height: 100vh; height: 100dvh;
    z-index: 30; transform: translateX(-100%); transition: transform .2s; }
.crm-app.sidebar-open .sidebar { transform: none; }
.crm-app.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 20; background: #0006; }
.crm-app .card { padding: 16px; }
.crm-app .narrow { max-width: none; }
.crm-app .chat { height: calc(100dvh - 100px); }
.crm-app .profile-logout { display: none; }
@media (max-width: 700px) {
    .appearance-options { grid-template-columns: 1fr; }
    .appearance-option { display: grid; grid-template-columns: 78px 1fr; column-gap: 12px; }
    .appearance-preview { grid-row: 1 / 3; }
    .appearance-option p { grid-column: 2; }
    .task-list tr {
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas: "sec st" "title title" "time time" "people author";
        padding: 14px; border-left-width: 1px;
    }
    .task-list td.c-sec { writing-mode: horizontal-tb; transform: none; display: block;
        width: auto; max-height: none; padding: 0 !important; border: 0 !important; }
    .task-list td.c-sec a { font-size: 11px; text-transform: none; letter-spacing: 0; }
    .task-list .c-sec .dot { margin: 0 4px 0 0; }
    .task-list .c-title { margin-top: 3px; font-size: 15px; line-height: 1.5; }
    .task-list .c-title > a { color: var(--text); }
    .task-list .c-time { font-size: 12px; }
    :root[data-style="compact"] .task-list tr { padding: 15px 0; margin: 0; border: 0;
        border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; }
    :root[data-style="compact"] .task-list .c-title { font-weight: 600; }
    :root[data-style="compact"] .card:has(.task-list) { border: 0; background: transparent; box-shadow: none; padding-left: 0; padding-right: 0; }
    :root[data-style="cards"] .task-list tr { padding: 16px; margin-bottom: 12px; border-radius: 17px; border-left: 3px solid var(--sec, var(--accent)); }
    :root[data-style="graphite"] .task-list tr { background: var(--card); border-color: var(--line); border-radius: 17px; }
    .task-list tr.group-row { display: block; padding: 10px; margin: 0; background: var(--soft-bg); border: 0; }
    .crm-app .btn, .crm-app .status-tabs a { min-height: 40px; }
    .crm-app .profile-logout { display: none; }
}
@media (prefers-reduced-motion: reduce) { .crm-app .sidebar { transition: none; } }

/* Уведомление старых Android-клиентов. Вся полоса ведёт на актуальный APK. */
.app-update-notice { position: sticky; top: 0; z-index: 45; background: var(--accent); color: var(--on-accent); }
.app-update-notice a { display: flex; justify-content: center; align-items: center; gap: 6px 16px; flex-wrap: wrap;
    padding: 13px 18px; color: inherit; text-align: center; line-height: 1.5; min-height: 48px; }
.app-update-notice a:hover { text-decoration: underline; }
.app-update-notice strong { font-size: 14px; }
.app-update-notice span { font-size: 13px; }
.auth-card .app-update-notice { position: static; border-radius: 10px; margin: 0 0 16px; }
.auth-card .app-update-notice a { flex-direction: column; padding: 13px 12px; }
.app-open-links { display: flex; align-items: center; justify-content: center; gap: 4px; }
.app-open-links a:first-child { flex: 1; }
.app-open-links a:last-child { font-size: 12px; padding-left: 10px; padding-right: 14px; }

/* The Android WebView already ends above native navigation. Let the chat fill it. */
.crm-app.crm-chat { height: 100vh; height: 100dvh; overflow: hidden; }
.crm-app.crm-chat .layout { height: 100%; min-height: 0; }
.crm-app.crm-chat .main { display: flex; flex-direction: column; height: 100%; min-height: 0; min-width: 0; }
.crm-app.crm-chat .topbar { display: none; }
.crm-app.crm-chat .content { display: flex; flex-direction: column; flex: 1; min-height: 0; padding: 0; }
.crm-app.crm-chat .chat.card { flex: 1; width: 100%; height: auto; min-height: 0; margin: 0;
    padding: 0; border: 0; border-radius: 0; box-shadow: none; }
.crm-app.crm-chat .chat-head { flex: none; padding: 10px 12px; background: var(--card); }
.crm-app.crm-chat .chat-head-info b { font-size: 16px; }
.crm-app.crm-chat .chat-log { min-height: 0; padding: 12px; background: var(--bg); overscroll-behavior: contain; }
.crm-app.crm-chat .chat-form { flex: none; margin: 0; padding: 8px 10px; }
.crm-app.crm-chat .chat-input { align-items: flex-end; }
.crm-app.crm-chat .chat-input textarea { min-width: 0; min-height: 42px; max-height: 120px; font-size: 16px; }
.crm-app.crm-chat .msg { flex-shrink: 0; max-width: 86%; }
.crm-app.crm-chat .msg-day { flex-shrink: 0; }
.crm-app.crm-chat .msg-image { max-width: min(86%, 320px); }
.crm-app.crm-chat .msg-img img { max-height: 260px; object-fit: contain; }
.crm-app.crm-chat .chat-icon-btn { width: 42px; height: 42px; }
.crm-app.crm-chat .chat-send { min-height: 42px; }
