/* ============================================
   Bitrix Analyzer — общий стиль (v10.0)
   Один файл для всех страниц панели.
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@500;700;800&family=IBM+Plex+Sans:ital,wght@0,400;0,500;0,600;1,400&family=IBM+Plex+Mono:wght@400;500&display=swap');

* { box-sizing: border-box; }

:root {
    /* --- основные (те же имена, новые значения — чтобы не переписывать все правила) --- */
    --blue: #D9531E;        /* было #0052cc — тёплый ember-акцент вместо синего */
    --blue-dark: #B8410F;
    --purple: #2B6E6B;      /* было #6554c0 — глубокий тил вместо фиолетового */
    --purple-dark: #1F5250;
    --green: #3F7D4A;
    --green-dark: #2F5E38;
    --orange: #C17D14;
    --orange-dark: #9C6410;
    --red: #B23A2E;
    --red-dark: #8F2D23;
    --gray: #767C6E;
    --gray-dark: #565B4F;
    --ink: #181B18;
    --border: #DEE1D9;
    --bg: #F4F5F1;

    /* --- новые токены для более фактурных блоков --- */
    --accent: var(--blue);
    --accent-soft: #FBE7DC;
    --route: var(--purple);
    --route-soft: #DEEFEC;
    --success-soft: #E3F1E4;
    --warn-soft: #F7EBCF;
    --danger-soft: #F7DEDA;
    --line-strong: #C7CBC0;
    --surface: #ffffff;
    --surface-2: #F0F1EC;
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 6px;
    --shadow-card: 0 1px 2px rgba(24,27,24,.05), 0 10px 24px -14px rgba(24,27,24,.18);

    --font-display: 'Manrope', -apple-system, "Segoe UI", sans-serif;
    --font-body: 'IBM Plex Sans', -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    --font-mono: 'IBM Plex Mono', Consolas, "Courier New", monospace;
}

body {
    font-family: var(--font-body);
    background: var(--bg);
    margin: 0;
    padding: 0 20px 20px;
    color: var(--ink);
}

.container { max-width: 1400px; margin: 0 auto; }

h1 { font-family: var(--font-display); font-weight: 800; font-size: 23px; margin: 0; letter-spacing: -.01em; }
h2 { font-family: var(--font-display); font-weight: 700; font-size: 16px; margin: 0 0 12px; }

/* ---- Верхняя навигация ---- */
.topnav {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 14px 0;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.topnav .brand {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 800;
    color: var(--ink);
    margin-right: 16px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.topnav .brand-mark { width: 22px; height: 22px; flex: none; color: var(--accent); }
.topnav a {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 13px;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray);
    text-decoration: none;
    border-radius: 8px;
    transition: background .15s, color .15s;
}
.topnav a svg { width: 15px; height: 15px; flex: none; }
.topnav a:hover { background: var(--surface-2); color: var(--ink); }
.topnav a.active { background: var(--ink); color: #fff; }
/* Стили выпадающего меню лежат в partials/nav.php (чтобы не зависеть от кэша браузера) */
.topnav .nav-badge {
    background: rgba(0,0,0,.12);
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 11px;
}
.topnav a.active .nav-badge { background: rgba(255,255,255,.25); }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-card);
}
.row { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.row > .card { flex: 1; min-width: 280px; }

textarea {
    width: 100%;
    min-height: 200px;
    padding: 10px;
    font-family: var(--font-mono);
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    resize: vertical;
}
input[type=text], input[type=number], input[type=date], input[type=time], select {
    font-family: var(--font-body);
    padding: 7px 10px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    background: var(--surface);
    color: var(--ink);
}
input[type=text]:focus, input[type=number]:focus, input[type=date]:focus, input[type=time]:focus, select:focus {
    outline: 2px solid var(--route); outline-offset: 1px; border-color: var(--route);
}

button, .btn {
    display: inline-block;
    font-family: var(--font-body);
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    color: #fff;
    background: var(--blue);
    transition: background .15s, transform .08s;
}
button:active, .btn:active { transform: translateY(1px); }
button:hover, .btn:hover { background: var(--blue-dark); }
button.green  { background: var(--green); }   button.green:hover  { background: var(--green-dark); }
button.orange { background: var(--orange); }  button.orange:hover { background: var(--orange-dark); }
button.red    { background: var(--red); }     button.red:hover    { background: var(--red-dark); }
button.gray   { background: var(--gray); }    button.gray:hover   { background: var(--gray-dark); }
button.purple { background: var(--purple); }  button.purple:hover { background: var(--purple-dark); }
button.small  { padding: 6px 14px; font-size: 13px; }
button:disabled, .btn:disabled { background: var(--line-strong); color: var(--gray); cursor: not-allowed; }

.os-list { display: flex; flex-direction: column; gap: 8px; }
.os-row { display: flex; gap: 8px; align-items: center; }
.os-row input[type=text] { flex: 1; }
.os-row .remove-btn { position: static; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 15px; }

.message { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 20px; font-size: 14px; }
.message.success { background: var(--success-soft); color: var(--green-dark); }
.message.error   { background: var(--danger-soft); color: var(--red-dark); }
.message.info    { background: var(--route-soft); color: var(--purple-dark); }

.stats { display: flex; gap: 30px; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; }
.stat-label {
    font-size: 12px; color: var(--gray);
    text-transform: uppercase; letter-spacing: .5px;
    margin-bottom: 4px;
}
.stat-value { font-family: var(--font-mono); font-size: 20px; font-weight: 500; color: var(--ink); }
.stat-value a { color: inherit; text-decoration: none; border-bottom: 2px dashed var(--blue); }
.stat-value a:hover { color: var(--blue); }

.log {
    background: var(--ink); color: #d6d9cf;
    padding: 15px; border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 12px; line-height: 1.6;
    max-height: 600px; overflow-y: auto;
    white-space: pre-wrap; word-break: break-all;
}
.hint { font-size: 12px; color: var(--gray); margin-top: 8px; line-height: 1.5; }
code {
    background: var(--surface-2); padding: 2px 6px; border-radius: 3px;
    font-family: var(--font-mono); font-size: 12px;
}
.info-row { font-size: 13px; color: var(--gray); margin: 0 0 8px; }
.info-row strong { color: var(--ink); }
.warn { color: var(--orange-dark); font-weight: 600; }

.unmatched-item {
    border: 1px solid var(--border); border-radius: var(--radius-md);
    padding: 15px; margin-bottom: 15px; background: var(--surface-2);
}
.unmatched-item.csv-source { border-left: 4px solid var(--orange); }
.unmatched-text { font-size: 14px; font-weight: 600; margin-bottom: 8px; color: var(--ink); }
.unmatched-meta { font-size: 12px; color: var(--gray); margin-bottom: 12px; }
.unmatched-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }

.week-check-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 0; border-bottom: 1px solid var(--bg);
}
.week-check-row:last-child { border-bottom: none; }
.week-check-title { font-size: 13px; flex: 1; padding-right: 10px; }
.week-check-badge {
    background: var(--blue); color: #fff; font-weight: 600; font-size: 12px;
    padding: 3px 10px; border-radius: 12px; white-space: nowrap;
}
.week-total {
    margin-top: 12px; padding-top: 12px; border-top: 2px solid var(--border);
    display: flex; justify-content: space-between; font-weight: 600;
}

.week-nav { display: flex; gap: 10px; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }
.week-btn {
    display: inline-block; padding: 10px 18px; font-size: 14px; font-weight: 600;
    border-radius: var(--radius-sm); text-decoration: none; color: var(--blue);
    background: var(--surface); border: 2px solid var(--border); transition: all .15s;
}
.week-btn:hover { border-color: var(--blue); }
.week-btn.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.week-btn.disabled { opacity: 0.4; pointer-events: none; cursor: not-allowed; }

.auditors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}
.auditor-block {
    border: 1px solid var(--border); border-radius: var(--radius-md);
    padding: 16px; margin-bottom: 0; background: var(--surface-2);
}
.auditor-block.inactive { opacity: 0.65; background: var(--surface-2); }
.auditor-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border);
}
.auditor-name { font-family: var(--font-display); font-size: 16px; font-weight: 700; color: var(--ink); }
.auditor-id { font-family: var(--font-mono); font-size: 12px; color: var(--gray); margin-left: 8px; font-weight: 400; }
.auditor-meta { font-size: 12px; color: var(--gray); margin-top: 2px; }
.auditor-actions { display: flex; gap: 6px; }
.checks-list { margin: 0; padding: 0; }
.check-item { padding: 8px 0; border-bottom: 1px dashed var(--border); }
.check-item:last-child { border-bottom: none; }
.check-pizzeria { font-size: 14px; font-weight: 600; color: var(--ink); margin-bottom: 2px; }
.check-detail { font-size: 13px; color: var(--gray); padding-left: 16px; }
.date-link { color: var(--blue); text-decoration: none; border-bottom: 1px dashed var(--blue); transition: all .15s; }
.date-link:hover { color: var(--blue-dark); border-bottom-style: solid; }
.no-checks { font-size: 13px; color: var(--gray); font-style: italic; }

/* Задачи на контроле в ленте проверок аудитора */
.check-item.ct-item { display: flex; align-items: flex-start; gap: 8px; }
.ct-main { flex: 1; min-width: 0; }
.ct-x { margin: 0; flex-shrink: 0; }
.check-item.ct-idle { opacity: .55; }
.check-item.ct-done { background: var(--success-soft); border-radius: var(--radius-md); padding-left: 8px; padding-right: 8px; margin: 2px -8px; }
.ct-block { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); }
.ct-row { display: flex; align-items: center; gap: 6px; padding: 3px 0; font-size: 13px; min-width: 0; }
.ct-row form { margin: 0 0 0 auto; flex-shrink: 0; }
.ct-block details { margin-top: 4px; font-size: 12px; }
.ct-block details summary { cursor: pointer; color: var(--gray); }
.ct-add { display: flex; gap: 6px; margin-top: 8px; }
.ct-add input { flex: 1; min-width: 0; font-size: 13px; }

.badge { display: inline-block; font-size: 11.5px; font-weight: 700; letter-spacing: .02em; padding: 2px 9px; border-radius: 10px; margin-left: 8px; }
.badge-active { background: var(--success-soft); color: var(--green-dark); }
.badge-inactive { background: var(--surface-2); color: var(--gray); }

.auditor-tag {
    display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600;
    padding: 2px 6px 2px 8px; border-radius: 10px; margin: 2px 4px 2px 0;
    background: var(--route-soft); color: var(--purple-dark);
}
.auditor-tag form { display: inline-flex; line-height: 1; }
.tag-remove-btn {
    padding: 0; margin: 0; border: none; background: none;
    color: inherit; opacity: .55; font-weight: 700; cursor: pointer;
    font-size: 13px; line-height: 1;
}
.tag-remove-btn:hover { opacity: 1; color: var(--red); background: none; }

/* ---- Редактируемая таблица (матрица контактов) ---- */
.matrix-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-md); }
table.matrix-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.matrix-table th {
    position: sticky; top: 0; z-index: 5;
    background: var(--ink); color: #fff;
    font-family: var(--font-display); font-weight: 700;
    text-align: left; padding: 9px 10px; white-space: nowrap;
}
table.matrix-table td {
    border: 1px solid var(--border);
    font-family: var(--font-mono);
    padding: 6px 10px; vertical-align: top;
    min-width: 90px;
}
table.matrix-table td[contenteditable="true"] { cursor: text; }
table.matrix-table td[contenteditable="true"]:focus {
    outline: 2px solid var(--route); outline-offset: -2px; background: var(--route-soft);
}
table.matrix-table tr:nth-child(even) { background: var(--surface-2); }
table.matrix-table tr.row-hidden { display: none; }
table.matrix-table td.col-del { min-width: auto; width: 34px; text-align: center; padding: 6px; }
.row-del-btn {
    border: none; background: none; color: var(--gray);
    font-size: 15px; font-weight: 700; cursor: pointer; padding: 2px 6px;
}
.row-del-btn:hover { color: var(--red); }
.matrix-toolbar {
    display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
    margin-bottom: 14px;
}
.matrix-toolbar input[type=text] { min-width: 260px; }

/* ---- Поиск по группам (замена длинного select) ---- */
.group-search-wrapper { position: relative; display: inline-block; min-width: 300px; }
.group-search-input {
    width: 100%; padding: 7px 10px; border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm); font-size: 13.5px; background: var(--surface);
}
.group-search-input:focus { outline: none; border-color: var(--route); }
.group-search-input-empty { border-color: var(--red); }
.group-search-dropdown {
    position: absolute; top: calc(100% + 2px); left: 0; right: 0; z-index: 20;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    max-height: 260px; overflow-y: auto;
}
.group-search-item { padding: 8px 12px; font-size: 13px; cursor: pointer; }
.group-search-item:hover { background: var(--surface-2); }
.group-search-empty { padding: 8px 12px; font-size: 13px; color: var(--gray); font-style: italic; }

/* ============================================
   "Назначить проверку" — часовой мост, ростер соисполнителей
   ============================================ */
.eyebrow {
    font-family: var(--font-mono); font-size: 11px; letter-spacing: .12em;
    text-transform: uppercase; color: var(--route);
    display: flex; align-items: center; gap: 8px; margin-bottom: 4px;
}
.eyebrow::before { content: ""; width: 14px; height: 1.5px; background: var(--route); display: inline-block; }

.card-title-icon {
    font-family: var(--font-display); font-weight: 700; font-size: 15px;
    display: flex; align-items: center; gap: 8px; margin: 0 0 4px;
}
.card-title-icon svg { width: 16px; height: 16px; color: var(--route); flex: none; }

.bridge {
    display: flex; align-items: stretch; gap: 0;
    margin: 16px 0 4px;
    border-radius: var(--radius-md); overflow: hidden;
    border: 1px solid var(--border);
}
.zone { flex: 1; padding: 13px 16px; display: flex; flex-direction: column; gap: 3px; background: var(--surface-2); }
.zone-city { background: var(--route-soft); }
.zone-kicker { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--gray); font-weight: 700; }
.zone-city .zone-kicker { color: var(--route); }
.zone-time { font-family: var(--font-mono); font-size: 19px; font-weight: 500; font-variant-numeric: tabular-nums; line-height: 1.2; }
.zone-place { font-size: 12.5px; color: var(--gray); }
.bridge-link {
    flex: none; width: 48px; display: flex; align-items: center; justify-content: center;
    background: var(--surface); position: relative;
}
.bridge-link svg { width: 18px; height: 18px; color: var(--route); }

.title-line {
    font-family: var(--font-mono); font-size: 13px;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 10px 12px; color: var(--gray); margin-bottom: 16px; word-break: break-word;
}

.section-label {
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
    color: var(--gray); margin: 18px 0 6px;
}
.section-label:first-of-type { margin-top: 4px; }

.roster { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.person {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; background: var(--surface);
    transition: opacity .15s;
}
.roster .person + .person { border-top: 1px solid var(--border); }
.person.person-exec { background: var(--accent-soft); border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: 4px; }
.person.excluded { opacity: .5; }
.avatar {
    width: 32px; height: 32px; border-radius: 50%; flex: none;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display); font-weight: 700; font-size: 12px;
    background: var(--route-soft); color: var(--route);
}
.person-exec .avatar { background: var(--accent); color: #fff; }
.person-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.person-name { font-size: 13.5px; font-weight: 600; }
.person-meta { font-size: 11.5px; color: var(--gray); font-family: var(--font-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.role-pill {
    flex: none; font-size: 10.5px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
    padding: 3px 9px; border-radius: 999px; background: var(--route-soft); color: var(--route);
    white-space: nowrap; max-width: 38%; overflow: hidden; text-overflow: ellipsis;
}
.role-pill.exec { background: var(--accent); color: #fff; }
.remove-btn {
    flex: none; width: 24px; height: 24px; border-radius: 50%;
    border: 1px solid var(--line-strong); background: var(--surface); color: var(--gray);
    font-size: 14px; line-height: 1; cursor: pointer; padding: 0;
    display: flex; align-items: center; justify-content: center;
    transition: background .12s, color .12s, border-color .12s;
}
.remove-btn:hover { background: var(--red); border-color: var(--red); color: #fff; }
.person.excluded .remove-btn { background: var(--success-soft); border-color: var(--green); color: var(--green-dark); }

.observers-strip {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: var(--radius-sm);
    background: var(--success-soft); color: var(--green-dark);
    font-size: 13px; font-weight: 600;
}
.observers-strip svg { width: 16px; height: 16px; flex: none; }

.notice {
    font-size: 13.5px; line-height: 1.65; color: var(--gray);
    background: var(--surface-2);
    border-left: 3px solid var(--route);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 14px 16px;
}
.notice strong { color: var(--ink); }
.notice u { text-decoration-color: var(--route); text-underline-offset: 2px; }

/* ---- Список ID задач (панель — "Задачи для анализа") ---- */
.id-chips { border: 1px solid var(--border); border-radius: var(--radius-md); max-height: 260px; overflow-y: auto; }
.id-chip { display: flex; align-items: center; gap: 10px; padding: 7px 10px; background: var(--surface); }
.id-chip + .id-chip { border-top: 1px solid var(--border); }
.id-chip-id { font-family: var(--font-mono); font-weight: 600; font-size: 12.5px; color: var(--ink); flex: none; }
.id-chip-name {
    flex: 1; min-width: 0; font-size: 12px; color: var(--gray);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    user-select: none; cursor: default;
}
.id-chip-empty { flex: 1; font-size: 12px; color: var(--gray); font-style: italic; }
