/* =====================================================================
   WorkMap — дизайн-система
   Идея: приборная панель диспетчерской службы. Тёмный «корпус» навигации,
   тёплая нейтральная бумага для контента, сигнальный красный как акцент
   (цвет индикатора тревоги), зелёный/жёлтый — статусные индикаторы,
   как лампочки на панели сигнализации. Заголовки — конденсированным
   промышленным начертанием (как на шильдиках оборудования), данные —
   моноширинным (координаты, даты, суммы).
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    --ink: #14171c;
    --ink-soft: #1f242c;
    --paper: #f3f2ee;
    --surface: #ffffff;
    --line: #e2e0d8;
    --text: #1c1f24;
    --text-muted: #6b7078;

    --accent: #e8432f;
    --accent-dark: #c7331f;
    --ok: #2f9e64;
    --ok-soft: #e4f5eb;
    --warn: #d98c1c;
    --warn-soft: #fbf0dc;
    --danger: #e8432f;
    --danger-soft: #fbe4e1;
    --closed: #8a8f98;
    --closed-soft: #eceef0;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --shadow: 0 1px 2px rgba(20,23,28,0.06), 0 4px 16px rgba(20,23,28,0.06);
    --shadow-lift: 0 8px 28px rgba(20,23,28,0.16);

    --font-display: 'Oswald', 'Arial Narrow', sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

    --nav-h: 58px;
    --tabbar-h: 66px;
    --safe-top: env(safe-area-inset-top, 0px);
}

@media (min-width: 861px) {
    :root { --tabbar-h: 0px; }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--paper);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: 0.01em;
    margin-top: 0;
    color: var(--ink);
}
h1 { font-size: 22px; text-transform: none; }
h2 { font-size: 16px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); font-weight: 600; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- top nav ---- */
.navbar {
    background: var(--ink);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--safe-top) 16px 0;
    height: calc(var(--nav-h) + var(--safe-top));
    box-sizing: border-box;
    position: sticky;
    top: 0;
    z-index: 1200;
    border-bottom: 3px solid var(--accent);
}

.navbar .brand {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 18px;
    letter-spacing: 0.02em;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
}
.navbar .brand:hover { text-decoration: none; }
.navbar .brand .dot { color: var(--accent); }
.navbar .brand .mark {
    width: 10px; height: 10px; border-radius: 2px; background: var(--accent);
    display: inline-block; transform: rotate(45deg);
}

.nav-links { display: flex; gap: 2px; align-items: center; }
.nav-links a {
    color: #c7ccd3; padding: 8px 12px; border-radius: var(--radius-sm);
    font-size: 13.5px; font-weight: 500;
}
.nav-links a:hover, .nav-links a.active { background: rgba(255,255,255,0.08); color: #fff; text-decoration: none; }
.nav-links a.active { color: var(--accent); }

.nav-avatar {
    width: 34px; height: 34px; border-radius: 50%; background: var(--accent);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display); font-weight: 600; font-size: 14px;
    text-decoration: none;
}
.nav-avatar:hover { text-decoration: none; filter: brightness(1.1); }

/* mobile-only nav shortcut, hidden on desktop */
.nav-mobile-only { display: none; }

/* ------------------------------------------------------------ bottom tabbar */
.tabbar {
    display: none;
    position: fixed; left: 0; right: 0; bottom: 0;
    height: var(--tabbar-h);
    background: var(--ink);
    border-top: 1px solid #2a2f38;
    z-index: 1200;
    padding-bottom: env(safe-area-inset-bottom, 0);
}
.tabbar-inner { display: flex; height: 100%; }
.tab-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; color: #8b909a; font-size: 10.5px; font-family: var(--font-display);
    text-transform: uppercase; letter-spacing: 0.03em; position: relative;
}
.tab-item:hover { text-decoration: none; color: #d5d8dd; }
.tab-item .tab-icon { font-size: 19px; line-height: 1; }
.tab-item.active { color: #fff; }
.tab-item.active::before {
    content: ''; position: absolute; top: 0; left: 24%; right: 24%; height: 3px;
    background: var(--accent); border-radius: 0 0 3px 3px;
}
.tab-icon-img { width: 22px; height: 22px; object-fit: contain; opacity: 0.65; display: block; }
.tab-item.active .tab-icon-img { opacity: 1; }

@media (max-width: 860px) {
    .tabbar { display: block; }
    .nav-links { display: none; }
    .nav-mobile-only { display: flex; align-items: center; gap: 10px; }
    body { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0)); }
    }

/* ---------------------------------------------------------------- layout --- */
.container { max-width: 1180px; margin: 0 auto; padding: 20px 16px 32px; }
.content-full { position: relative; }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.card-flush { padding: 0; overflow: hidden; }

/* accent left-bar variant, used for emphasis (signature motif) */
.card-accent { border-left: 3px solid var(--accent); }

/* --------------------------------------------------------------- buttons --- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid var(--line);
    background: var(--surface); color: var(--text); cursor: pointer;
    font-size: 13.5px; font-weight: 600; text-align: center; font-family: var(--font-body);
    transition: transform 0.06s ease, filter 0.15s ease, background 0.15s ease;
}
.btn:hover { background: #ebe9e3; text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dark); }
.btn-success { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn-success:hover { filter: brightness(0.92); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--danger-soft); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-fab {
    position: fixed; right: 18px; bottom: calc(var(--tabbar-h) + 18px);
    width: 54px; height: 54px; border-radius: 50%; background: var(--accent);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: 26px; box-shadow: var(--shadow-lift); border: none; z-index: 900;
}
.btn-fab:hover { background: var(--accent-dark); text-decoration: none; }
@media (min-width: 861px) { .btn-fab { display: none; } }

/* ---------------------------------------------------------------- forms --- */
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block; margin-bottom: 5px; font-weight: 600; font-size: 12.5px;
    color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em;
}
input[type=text], input[type=password], input[type=number], input[type=tel],
input[type=date], input[type=datetime-local], select, textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
    font-size: 14.5px; background: var(--surface); color: var(--text); font-family: var(--font-body);
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232,67,47,0.12);
}
textarea { resize: vertical; min-height: 80px; }
input[type=color] { width: 56px; height: 38px; padding: 2px; border: 1px solid var(--line); border-radius: var(--radius-sm); }

.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row > .col { flex: 1; min-width: 220px; }

/* --------------------------------------------------------------- tables --- */
table { width: 100%; border-collapse: collapse; }
table th, table td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13.5px; }
table th { color: var(--text-muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em; }
table tr:hover { background: #faf9f6; }

/* ---------------------------------------------------------------- badges --- */
.badge {
    display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px;
    font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
    white-space: nowrap; max-width: 100%;
}
.badge-label {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.badge-open { background: var(--warn-soft); color: var(--warn); }
.badge-overdue { background: var(--danger-soft); color: var(--danger); }
.badge-closed { background: var(--ok-soft); color: var(--ok); }
.badge-role { background: var(--closed-soft); color: var(--text-muted); }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------------------------------------------------------------- toasts --- */
.flash-stack {
    position: fixed; top: calc(var(--nav-h) + var(--safe-top) + 10px); left: 50%; transform: translateX(-50%);
    z-index: 2000; display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100vw - 32px));
}
.flash {
    padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 500;
    box-shadow: var(--shadow-lift); border-left: 4px solid transparent; background: var(--surface);
}
.flash-error { background: var(--danger-soft); color: var(--accent-dark); border-left-color: var(--accent); }
.flash-success { background: var(--ok-soft); color: #1c6b41; border-left-color: var(--ok); }

/* ------------------------------------------------------------------ misc --- */
.color-dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 6px; vertical-align: middle; box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(0,0,0,0.08); }

.search-bar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.search-bar input, .search-bar select { flex: 1; min-width: 160px; }

.pagination { display: flex; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 6px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 13px; font-family: var(--font-mono); }
.pagination .active { background: var(--accent); color: #fff; border-color: var(--accent); }

.msg-list { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.msg { background: var(--paper); border-radius: var(--radius); padding: 12px 14px; border: 1px solid var(--line); }
.msg .meta { font-size: 11.5px; color: var(--text-muted); margin-bottom: 4px; font-family: var(--font-mono); }

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

.muted { color: var(--text-muted); font-size: 13px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.page-header { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: nowrap; gap: 10px; margin-bottom: 14px; }
.page-header h1 { flex: 1 1 auto; min-width: 0; }
.page-header .btn-group { flex: none; }

@media (max-width: 860px) {
    .page-header { flex-wrap: wrap; }
    .page-header h1 { flex: 1 1 100%; }
}
/* ------------------------------------------------------------- full maps --- */
.map-full {
    position: fixed; top: calc(var(--nav-h) + var(--safe-top)); left: 0; right: 0; bottom: var(--tabbar-h);
    z-index: 1;
}
.map-full #map { width: 100%; height: 100%; border-radius: 0; border: none; }

.map-overlay-top {
    position: absolute; top: 12px; left: 12px; right: 12px; z-index: 500;
    display: flex; gap: 8px; flex-wrap: wrap;
}
.map-overlay-top input, .map-overlay-top select {
    background: var(--surface); box-shadow: var(--shadow); border: 1px solid var(--line);
    width: 200px;
}

@media (max-width: 860px) {
    .map-overlay-top input, .map-overlay-top select {
        width: 100%;
    }
}

.map-legend {
    position: absolute; bottom: 14px; left: 12px; background: var(--surface);
    padding: 10px 14px; border-radius: var(--radius); box-shadow: var(--shadow-lift);
    font-size: 12px; z-index: 500; max-height: 30vh; overflow-y: auto;
}

.map-unmapped-sheet {
    position: absolute; right: 12px; bottom: 14px; z-index: 500; background: var(--surface);
    border-radius: var(--radius); box-shadow: var(--shadow-lift); padding: 12px 14px;
    max-width: 280px; max-height: 40vh; overflow-y: auto; font-size: 12.5px;
}

/* embedded (non full-screen) maps used in forms and detail pages */
#form-map { width: 100%; height: 320px; border-radius: var(--radius); border: 1px solid var(--line); }
#view-map { width: 100%; height: 240px; border-radius: var(--radius); border: 1px solid var(--line); margin-top: 10px; }

/* --------------------------------------------------------- autocomplete --- */
.ac-wrap { position: relative; }
.ac-results {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lift);
    max-height: 260px; overflow-y: auto; z-index: 50; display: none;
}
.ac-results.open { display: block; }
.ac-item { padding: 10px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.hl { background: var(--paper); }
.ac-item .ac-name { font-weight: 600; font-size: 13.5px; }
.ac-item .ac-addr { font-size: 12px; color: var(--text-muted); }
.ac-selected-chip {
    display: inline-flex; align-items: center; gap: 8px; background: var(--paper);
    border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 12px; font-size: 13.5px;
}
.ac-selected-chip button { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 15px; }

/* -------------------------------------------------------------- modal ---- */
.modal-backdrop {
    display: none;
    position: fixed; inset: 0; background: rgba(20,23,28,0.5);
    z-index: 2500; align-items: center; justify-content: center; padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal {
    width: 100%; max-width: 420px; margin: 0; max-height: 82vh;
    display: flex; flex-direction: column; box-shadow: var(--shadow-lift);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.modal-close {
    background: none; border: none; font-size: 18px; cursor: pointer;
    color: var(--text-muted); line-height: 1; padding: 4px;
}
.modal-close:hover { color: var(--text); }
.modal-body { overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

.checkbox-list { display: flex; flex-direction: column; gap: 8px; }
.checkbox-item { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 13.5px; cursor: pointer; }
.checkbox-item input[type=checkbox] { width: auto; }

/* -------------------------------------------------------------- mobile ---- */
@media (max-width: 860px) {
    .row { flex-direction: column; }
    table:not(.matrix-table), table:not(.matrix-table) thead, table:not(.matrix-table) tbody,
    table:not(.matrix-table) th, table:not(.matrix-table) td, table:not(.matrix-table) tr { display: block; }
    table:not(.matrix-table) thead { display: none; }
    table:not(.matrix-table) tr { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; padding: 4px 2px; background: var(--surface); }
    table:not(.matrix-table) td { border: none; padding: 7px 10px; }
    table:not(.matrix-table) td::before { content: attr(data-label); font-weight: 600; color: var(--text-muted); display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.03em; }
    .container { padding: 14px 12px 24px; }

    .matrix-tablewrap {
        max-width: calc(100vw - 24px);
        max-height: calc(100vh - var(--nav-h) - var(--tabbar-h) - 130px);
    }
}
/* ------------------------------------------------------- row menu (⋮) ---- */
.row-menu { position: relative; display: inline-block; }
.row-menu-toggle { padding: 4px 9px; font-size: 16px; line-height: 1; }
/* position: fixed + координаты выставляются в JS (static/js/app.js) —
   иначе меню обрезается родительским .card{overflow-x:auto}, у которого
   overflow-y неявно тоже становится auto и режет всё, что вылезает за
   нижнюю границу карточки (актуально для последних строк таблицы). */
.row-menu-list {
    display: none; position: fixed;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lift); min-width: 190px; z-index: 3000; overflow: hidden;
}
.row-menu-list.open { display: block; }
.row-menu-list a, .row-menu-list button, .row-menu-list .row-menu-disabled {
    display: block; width: 100%; text-align: left; padding: 9px 14px; font-size: 13.5px;
    color: var(--text); background: none; border: none; cursor: pointer; font-family: var(--font-body);
}
.row-menu-list a:hover, .row-menu-list button:hover { background: var(--paper); text-decoration: none; }
.row-menu-list .row-menu-disabled { color: var(--closed); cursor: not-allowed; }

/* --------------------------------------------------------- msg count ---- */
.msg-count {
    display: inline-flex; align-items: center; gap: 3px; background: var(--paper);
    border: 1px solid var(--line); border-radius: 10px; padding: 1px 7px; font-size: 11px;
    font-family: var(--font-mono); color: var(--text-muted); margin-left: 6px; vertical-align: middle;
}

/* ------------------------------------------------------- overdue text --- */
.overdue-text { color: var(--danger); font-weight: 600;}

/* ---------------------------------------------------- mobile task list ---- */
.tasks-list-mobile { display: none; }

@media (max-width: 860px) {
    .tasks-list-desktop { display: none; }
    .tasks-list-mobile {
        display: block;
        background: var(--surface);
        border: 1px solid var(--line);
        border-radius: var(--radius);
        overflow: hidden;
    }
}

.mtask-row {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid var(--line);
    color: var(--text);
    text-decoration: none;
}
.mtask-row:last-child { border-bottom: none; }
.mtask-row:hover { background: #faf9f6; text-decoration: none; }
.mtask-row:active { background: #f3f2ee; }

.mtask-bar { width: 3px; flex: none; }
.mtask-bar-open { background: var(--ok); }
.mtask-bar-overdue { background: var(--danger); }
.mtask-bar-closed { background: var(--closed); }

.mtask-body {
    flex: 1; min-width: 0;
    padding: 10px 12px;
    display: flex; flex-direction: column; justify-content: center;
}
.mtask-title {
    /*font-size: 13px; */font-weight: 600; color: var(--ink);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mtask-sub {
    display: flex; align-items: center; min-width: 0;
    /*font-size: 12px;*/ color: var(--text-muted);
}
.mtask-sub-text {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.mtask-sub-sep { flex: none; padding: 0 5px; color: var(--closed); }
.mtask-sub-amount { flex: none; font-family: var(--font-mono); color: var(--ink); }
.mtask-sub-status { flex: none; display: inline-flex; align-items: center; font-size: 12px; }

.mtask-side {
    flex: none;
    padding: 10px 12px;
    display: flex; align-items: center; gap: 6px;
}
.mtask-date {
    /*font-size: 11px; */font-family: var(--font-mono); color: var(--text-muted);
    text-align: right; line-height: 1.3;
}
.mtask-bar-overdue + .mtask-body ~ .mtask-side .mtask-date { color: var(--danger); }

.mtask-empty { padding: 20px 12px; text-align: center; color: var(--text-muted); font-size: 13.5px; }
.mtask-date-overdue { color: var(--danger); }


/* ------------------------------------------ tasks table: фикс. раскладка --- */
.tasks-table, .objects-table { table-layout: fixed; }
.tasks-table th, .tasks-table td, .objects-table th, .objects-table td { font-size: 12px; padding: 7px 8px; vertical-align: middle; }

.cell-ellipsis {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cell-clamp2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
    min-height: calc(1.3em * 2);
    word-break: break-word;
}
.cell-clamp2 .msg-count { display: inline-flex; }

.cell-task {
    display: flex;
    align-items: flex-start;
    gap: 5px;
}
.cell-task-title {
    flex: 1 1 auto;
    min-width: 0;
}
.cell-task-badge {
    flex: none;
    margin-top: 1px;
}

/* ------------------------------------------------------- task info card --- */
.task-info { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.task-info-hero { border-radius: 0; padding: 16px 20px; }
.task-info-object { font-family: var(--font-display); font-size: 20px; font-weight: 600; color: var(--ink); }
.task-info-object a { color: var(--ink); }
.task-info-object a:hover { color: var(--accent-dark); }
.task-info-address { color: var(--text-muted); font-size: 13px; margin-top: 3px; }
.task-info-type {
    display: inline-block; margin-top: 8px; background: var(--paper); border: 1px solid var(--line);
    border-radius: 20px; padding: 3px 12px; font-size: 11.5px; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.03em;
}
.task-info-stats { display: flex; border-top: 1px solid var(--line); }
.task-info-stat { flex: 1; padding: 14px 20px; border-right: 1px solid var(--line); }
.task-info-stat:last-child { border-right: none; }
.task-info-stat-label {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted);
    font-weight: 600; margin-bottom: 3px;
}
.task-info-stat-value { font-size: 14.5px; color: var(--text); font-family: var(--font-mono); }
.task-info-stat-value.overdue { color: var(--danger); font-weight: 600; }
.task-info-people { display: flex; gap: 24px; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.task-info-person { display: flex; align-items: center; gap: 8px; }
.task-info-avatar {
    width: 26px; height: 26px; border-radius: 50%; color: #fff; display: flex; align-items: center;
    justify-content: center; font-size: 11px; font-weight: 700; font-family: var(--font-display); flex: none;
}
.task-info-person-name { font-size: 14px; color: var(--text); line-height: 1.2; }
.task-info-person-role {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted);
    font-weight: 600; line-height: 1.2;
}
.task-info-desc { padding: 14px 20px; border-top: 1px solid var(--line); background: var(--paper); }

.task-info-files-row { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 16px; }
.task-info-files-row > .task-info { flex: 1; min-width: 0; margin-bottom: 0; }
.task-info-files-row > .card { flex: 1; min-width: 0; margin-bottom: 0; }

@media (max-width: 860px) {
    .task-info-files-row { flex-direction: column; align-items: stretch; }
    .task-info-stat { border-right: none; border-bottom: 1px solid var(--line); }
    .task-info-stat:last-child { border-bottom: none; }
}

/* ------------------------------------------------------ task map popup --- */
.task-popup .leaflet-popup-content-wrapper { border-radius: var(--radius); }
.task-popup .leaflet-popup-content { margin: 0; width: 280px !important; }
@media (max-width: 600px) {
   /* .task-popup .leaflet-popup-content { width: min(280px, calc(100vw - 56px)) !important; }*/
}
.popup-obj { padding: 10px 28px 8px 14px; }
.popup-obj-name {
    font-family: var(--font-display); font-weight: 600; font-size: 14px; color: var(--ink);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.popup-obj-addr {
    display: block; font-size: 11.5px; color: var(--text-muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.popup-obj-addr:hover { color: var(--accent-dark); text-decoration: underline; }
.popup-task {
    display: block; padding: 8px 14px; border-top: 1px solid var(--line);
    color: inherit; text-decoration: none;
}
.popup-task:hover, .popup-task:active { background: var(--paper); text-decoration: none; }
.popup-task-title {
    font-size: 13px; font-weight: 600; color: var(--ink);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.popup-task-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 3px; }
.popup-task-assignee {
    display: flex; align-items: center; min-width: 0; font-size: 12px; color: var(--text-muted);
}
.popup-task-assignee .color-dot { flex: none; }
.popup-task-assignee .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.popup-task-date { flex: none; font-family: var(--font-mono); font-size: 11.5px; color: var(--text-muted); }

/* ------------------------------------------------------------- matrix --- */
.matrix-page { padding: 0; }
.matrix-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: none; }
.matrix-presets { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 3px; }
.matrix-presets button { border: none; background: none; padding: 5px 11px; font-size: 11.5px; font-weight: 600; border-radius: 4px; color: var(--text-muted); cursor: pointer; font-family: var(--font-body); }
.matrix-presets button:hover { background: var(--paper); }
.matrix-controls input[type=month] { width: 140px; padding: 7px 10px; }

.matrix-tablewrap {
    display: inline-block;
    /* .container: max-width 1180, padding 16px слева/справа (box-sizing:border-box).
       Пока viewport <= 1180 — контейнер не центрируется (margin=0), бридж не нужен.
       Когда viewport > 1180 — контейнер центрируется, обёртка смещена от левого края
       viewport на (VW-1180)/2 + 16, поэтому и margin-right, и max-width считаются
       именно от этого смещения, а не от «сырых» 100vw/50vw. */
    margin-right: min(0px, calc(590px - 50vw));
    max-width: min(calc(100vw - 32px), calc(50vw + 558px));
    overflow: auto; border: 1px solid var(--line); border-radius: 10px;
    background: var(--surface); max-height: calc(100vh - var(--nav-h) - 150px);
}
table.matrix-table { border-collapse: separate; border-spacing: 0; width: auto; font-size: 12.5px; }
.matrix-table th { position: sticky; top: 0; font-family: var(--font-display); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); font-weight: 600; padding: 9px 10px; text-align: left; border-bottom: 2px solid var(--line); background: var(--surface); white-space: nowrap; z-index: 3; }
.matrix-table td { padding: 5px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; height: 32px; }
.matrix-table .sticky { position: sticky; background: var(--surface); z-index: 2; }
.matrix-table th.sticky { z-index: 4; }
.matrix-table .sticky-1 { left: 0; width: 40px; }
.matrix-table .sticky-2 { left: 40px; min-width: 250px; max-width: 250px; white-space: normal; font-size: 11px; }
.matrix-table .sticky-3 { left: 290px; min-width: 250px; max-width: 250px; white-space: normal; color: var(--text-muted); font-size: 10px; }
.matrix-table .sticky-4 { left: 540px; min-width: 64px; max-width: 64px; color: var(--text-muted); font-size: 11.5px; }
.matrix-table .sticky-5 { left: 604px; color: var(--text-muted); font-size: 11.5px; }
.matrix-table .sticky-6 { left: 670px; border-right: 2px solid var(--line); }

.matrix-table tbody tr:hover td {
    box-shadow: inset 0 0 0 999px rgba(20, 23, 28, 0.035);
}
.matrix-table th:not(.sticky), .matrix-table td:not(.sticky) { border-right: 1px solid var(--line); }

.mx-av { width: 24px; height: 24px; border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-size: 10.5px; font-weight: 600; }
.mx-objname { font-weight: 600; color: var(--ink); /*font-size: 12.5px;*/ text-decoration: none; }
.mx-objname:hover { color: var(--ink); text-decoration: underline; cursor:pointer; }
.mx-amount { font-family: var(--font-mono); font-size: 12px; text-align: right; }

.mx-cell { width: 60px; text-align: center; cursor: pointer; color: var(--text-muted); user-select: none; }
.mx-cell:hover { background: var(--paper); }
.mx-cell.c-edo { background: #eaf3fb; }
.mx-cell.c-edo:hover { background: #dcecfb; }
.mx-cell.c-task { color: var(--ink); font-weight: 700; /*font-size: 14px;*/ }
.mx-cell.c-paid { background: var(--ok-soft); color: #1c6b41; font-weight: 700; }
.mx-cell.c-novisit { background: var(--closed-soft); color: var(--closed); cursor: not-allowed; }
.mx-cell.c-stop { background: var(--danger-soft); color: var(--accent-dark); font-weight: 700; font-size: 10px; cursor: not-allowed; }
.mx-cell.c-stopglobal { background: #f6d6d1; color: var(--accent-dark); cursor: not-allowed; }

.matrix-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 11px; color: var(--text-muted); align-items: center; }
.matrix-legend .sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; margin-right: 5px; vertical-align: -2px; }
.sw-edo { background: #eaf3fb; border: 1px solid #cfe4f5; }
.sw-task { background: var(--surface); border: 1px solid var(--line); }
.sw-paid { background: var(--ok-soft); }
.sw-novisit { background: var(--closed-soft); }
.sw-stop { background: var(--danger-soft); }
.sw-stopglobal { background: #f6d6d1; }

.ctx-menu { position: fixed; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-lift); min-width: 170px; z-index: 3000; overflow: hidden; }
.ctx-menu button { display: block; width: 100%; text-align: left; padding: 9px 14px; font-size: 13.5px; color: var(--text); background: none; border: none; cursor: pointer; font-family: var(--font-body); }
.ctx-menu button:hover { background: var(--paper); }
.ctx-menu button:disabled { color: var(--closed); cursor: not-allowed; }
.mx-check { color: var(--ok); }
.ctx-menu-sep { height: 1px; background: var(--line); margin: 4px 0; }
.ctx-menu-link { display: block; padding: 9px 14px; font-size: 13.5px; color: var(--text); text-decoration: none; }
.ctx-menu-link:hover { background: var(--paper); text-decoration: none; }

/* ---------------------------------------------------- matrix: доп. UI --- */
.mx-th-filter { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.mx-add-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 18px; height: 18px; border-radius: 50%; background: var(--ok);
    color: #fff; border: none; font-size: 13px; line-height: 1; cursor: pointer;
    vertical-align: middle; margin-left: 4px; padding: 0;
}
.mx-add-btn:hover { filter: brightness(0.92); }
.mx-noeng-star { color: var(--danger); font-size: 11px; cursor: help; margin-left: 2px; }
.load-more-wrap { display: flex; justify-content: center; margin: 4px 0 8px; }
@media (max-width: 860px) {
    .load-more-wrap { margin: 4px 0 70px; }
}

/* -------------------------------------------------------- install banner --- */
.install-banner {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    flex-wrap: wrap;
    background: var(--ink); color: #fff;
    padding: 10px 16px; font-size: 13px;
}
.install-banner .btn { flex: none; }

/* ------------------------------------------------------ file manager --- */
.file-add-btn {
    width: 20px; height: 20px; border: none; background: none;
    color: var(--text-muted); font-size: 16px; line-height: 1; font-weight: 700;
    cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
    padding: 0; flex: none;
}

.file-drop-static-hint {
    margin: -4px 0 10px;
    font-size: 12px;
}

.file-dropzone {
    position: relative; border: 1px dashed var(--line); border-radius: var(--radius);
    padding: 10px; transition: border-color 0.15s ease, background 0.15s ease;
}
.file-dropzone-active { border-color: var(--closed); background: var(--paper); }
.file-dropzone-disabled { pointer-events: none; }

.file-drop-hint {
    display: none; align-items: center; justify-content: center;
    position: absolute; inset: 0; background: rgba(20,23,28,0.04);
    border-radius: var(--radius); font-size: 12.5px; font-weight: 600; color: var(--text-muted);
    pointer-events: none; z-index: 5;
}

.file-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
    gap: 12px; min-height: 60px;
}

.file-icon-item {
    position: relative; display: flex; flex-direction: column; align-items: center;
    gap: 5px; padding: 8px 4px; border-radius: var(--radius-sm); text-align: center;
}
.file-icon-item:hover { background: var(--paper); }

.file-icon-link {
    display: flex; flex-direction: column; align-items: center; gap: 5px;
    text-decoration: none; color: var(--text); width: 100%;
}
.file-icon-link:hover { text-decoration: none; color: var(--text); }
.file-icon-glyph { font-size: 60px; line-height: 1; }
.file-icon-name {
    font-size: 10.5px; color: var(--text-muted); width: 100%;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.file-icon-remove {
    display: none; position: absolute; top: 2px; right: 2px;
    width: 18px; height: 18px; border-radius: 50%; border: none;
    background: var(--ink); color: #fff; font-size: 10px; line-height: 1;
    cursor: pointer; align-items: center; justify-content: center;
}
.file-icon-item:hover .file-icon-remove { display: flex; }
.file-icon-remove:hover { background: var(--accent); }

.files-pagination {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    margin-top: 10px;
}

/* ------------------------------------------------------- undo-toast ---- */
.file-undo-toast {
    position: fixed; right: 18px; bottom: calc(var(--tabbar-h) + 18px);
    background: var(--ink); color: #fff; border-radius: var(--radius);
    box-shadow: var(--shadow-lift); padding: 12px 14px; z-index: 2600;
    display: flex; align-items: center; gap: 12px; font-size: 13px;
    max-width: min(360px, calc(100vw - 36px));
}
.file-undo-text { flex: 1; }
.file-undo-btn { flex: none; }