:root {
    --bg: #fafafa;
    --surface: #ffffff;
    --border: #e8e8ea;
    --text: #1a1a1a;
    --text-muted: #6b7280;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #dc2626;
    --success: #059669;
    --warning: #d97706;
    --radius: 8px;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 1px rgba(0, 0, 0, 0.02);
}

* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.navbar-inner {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 24px;
}
.brand {
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
}
.brand:hover { text-decoration: none; }
.nav-links { display: flex; gap: 4px; flex: 1; }
.nav-link {
    padding: 6px 12px;
    border-radius: 6px;
    color: var(--text-muted);
    font-weight: 500;
    transition: all 0.15s;
}
.nav-link:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav-link.active { background: #eef2ff; color: var(--primary); }
.nav-right { display: flex; align-items: center; gap: 12px; }
.user-info { color: var(--text-muted); font-size: 13px; }

.view-as-banner {
    background: #fef3c7;
    border-bottom: 1px solid #fde68a;
    padding: 8px 24px;
    text-align: center;
    font-size: 13px;
    color: #92400e;
}
.view-as-banner form { display: inline; margin-left: 12px; }

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 16px;
    flex-wrap: wrap;
}
.page-title {
    font-size: 22px;
    font-weight: 600;
    margin: 0;
    color: var(--text);
}
.page-subtitle { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.page-actions { display: flex; gap: 8px; align-items: center; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.card h2 {
    margin: 0 0 16px 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.grid {
    display: grid;
    gap: 16px;
}
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
/* Головна: блок «Останні зміни» ширший за сусідню картку. */
.grid-wide-left { grid-template-columns: 3fr 2fr; }
@media (max-width: 900px) {
    .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-cols-2 { grid-template-columns: 1fr; }
    .grid-wide-left { grid-template-columns: 1fr; }
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    transition: border-color 0.15s;
}
.stat-label {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}
.stat-value {
    font-size: 28px;
    font-weight: 600;
    color: var(--text);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    /* <button> не успадковує шрифт і висоту рядка, як <a>: без цього кнопка
       форми нижча за кнопку-посилання. */
    font-family: inherit;
    line-height: 1.5;
    justify-content: center;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: white; }
.btn-danger { color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; color: var(--danger); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
/* Неактивна кнопка — сіра і без наведення («Далі» без позначених, кнопка форми після відправки). */
.btn:disabled, .btn:disabled:hover {
    background: #f3f4f6;
    border-color: #e5e7eb;
    color: #9ca3af;
    cursor: default;
}
/* Форма з однією кнопкою (POST «Видалити») — в одному ряду з кнопками-посиланнями. */
.inline-form { display: inline-flex; margin: 0; }

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}
table th, table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
table th {
    background: var(--bg);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.04em;
}
table tr:last-child td { border-bottom: none; }
table tbody tr:hover { background: var(--bg); }

.filters {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    align-items: center;
    flex-wrap: wrap;
}
.filters input, .filters select {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    font-size: 13px;
    color: var(--text);
}
.filters input { min-width: 240px; }
.filters input:focus, .filters select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.filters-search, .filters-order {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Фільтри над списком (SPEC_UI_005): рядок під пошуком, обране — кольором. */
.filters-above { margin-top: -8px; }
.filters-field, .filters-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
}
.filters-check { color: var(--text); cursor: pointer; }
.filters-above input[type="date"], .filters-check input { min-width: 0; }
.filters-check input { margin: 0; }
.filters-field.is-set select, .filters-field.is-set input { border-color: var(--primary); color: var(--primary); }
.filters-check.is-set { color: var(--primary); }

/* Заголовок колонки: назва, сортування (SPEC_UI_006) і фільтр (SPEC_UI_005). */
.th-inner { display: inline-flex; align-items: center; gap: 4px; }
.sort-link { color: inherit; text-decoration: none; }
.sort-link:hover { text-decoration: underline; }
.sort-link.sorted { color: var(--primary); }

/* Фільтр у заголовку; положення переліку ставить column-filter.js. */
.col-filter { display: inline-block; }
.col-filter > summary {
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 5px;
    border: 1px solid transparent;
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    line-height: 1.3;
}
.col-filter > summary::marker { content: ''; }
.col-filter > summary::-webkit-details-marker { display: none; }
.col-filter > summary:hover,
.col-filter[open] > summary { background: var(--surface); border-color: var(--border); color: var(--text); }
.col-filter.active > summary { color: var(--primary); }
.col-filter-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-size: 10px;
    letter-spacing: 0;
}
.col-filter-menu {
    position: absolute;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    width: 300px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16), 0 2px 6px rgba(15, 23, 42, 0.08);
    /* Скидаємо стиль заголовка таблиці: перелік — звичайний текст. */
    text-transform: none;
    letter-spacing: normal;
    font-size: 13px;
    font-weight: 400;
    color: var(--text);
    white-space: normal;
    text-align: left;
    cursor: default;
}
.col-filter-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px 8px;
    font-weight: 600;
}
.col-filter-close {
    border: none;
    background: none;
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
}
.col-filter-close:hover { background: var(--bg); color: var(--text); }
.col-filter-search {
    margin: 0 12px 6px;
    padding: 6px 9px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
}
.col-filter-search:focus { outline: none; border-color: var(--primary); }
.col-filter-list { max-height: 264px; overflow-y: auto; padding: 2px 4px 6px; }
.col-filter-option {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 5px 8px;
    border-radius: 6px;
    cursor: pointer;
}
.col-filter-option:hover { background: var(--bg); }
.col-filter-option input { flex: none; margin: 2px 0 0; }
.col-filter-label { flex: 1; overflow-wrap: anywhere; }
.col-filter-option.is-empty .col-filter-label { font-style: italic; color: var(--text-muted); }
.col-filter-count { flex: none; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.col-filter-option.is-zero .col-filter-count { opacity: 0.55; }
.col-filter-none { padding: 6px 8px; color: var(--text-muted); }
.col-filter-menu [hidden] { display: none; }
.col-filter-actions {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
}

.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}
.form-control, .form-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    font-size: 13px;
    color: var(--text);
    font-family: inherit;
}
.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
textarea.form-control { resize: vertical; min-height: 70px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }

/* Сторінки дій (SPEC_UI_010 «Сторінки дій») */
.form-section { border: 0; margin: 0 0 8px; padding: 0; min-width: 0; }
.form-section legend {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    padding: 0;
}
/* Лінія — під групою, а не в рядку з підписом наступної: legend стоїть у верхній рамці fieldset.
   Лише якщо нижче є видима група: приховану за видом (kind-groups.js) лінія не відділяє,
   а під останньою видимою вже є лінія панелі кнопок. */
.form-section:has(~ .form-section:not([hidden])) {
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
    margin-bottom: 16px;
}
.form-grid .form-group:has(textarea) { grid-column: 1 / -1; }
/* Вибір вакансій (REQ_CAND_017, REQ_CAND_003): рядки таблиці й рамка в формі. */
.pick-status { color: var(--text-muted); font-size: 13px; }
.pick-status.is-set { color: var(--primary); font-weight: 500; }
.pick-table input[type="checkbox"], .pick-list input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--primary);
    cursor: pointer;
}
.pick-table tbody tr { cursor: pointer; }
.pick-table .pick-cell { width: 1%; padding-right: 0; }
.pick-table tbody tr:has(input:checked) { background: #eff6ff; }
.pick-table tbody tr:has(input:checked):hover { background: #dbeafe; }
.form-grid .form-group:has(> .pick-list) { grid-column: 1 / -1; }
.pick-list {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
}
.pick-list > summary {
    display: block;
    padding: 9px 14px;
    background: var(--bg);
    list-style: none;
    cursor: pointer;
}
.pick-list > summary:hover { background: #f3f4f6; }
.pick-list > summary::-webkit-details-marker { display: none; }
.pick-list > summary::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    margin: 0 12px 1px 2px;
    border: solid var(--text-muted);
    border-width: 0 2px 2px 0;
    transform: rotate(-45deg);
    transition: transform 0.15s;
}
.pick-list[open] > summary { border-bottom: 1px solid var(--border); }
.pick-list[open] > summary::before { margin-bottom: 3px; transform: rotate(45deg); }
.pick-list > summary:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.pick-list .check-list { max-height: 330px; overflow-y: auto; }
.pick-list .check-list > div + div { border-top: 1px solid var(--border); }
.pick-list .check-list label {
    display: grid;
    grid-template-columns: 16px minmax(0, 2fr) minmax(0, 3fr);
    gap: 12px;
    align-items: center;
    margin: 0;
    padding: 9px 14px;
    font-weight: 400;
    cursor: pointer;
}
.pick-list .check-list label:hover { background: var(--bg); }
.pick-list .check-list label:has(input:checked) { background: #eff6ff; }
.pick-list .check-list label:has(input:checked):hover { background: #dbeafe; }
.pick-path { color: var(--text-muted); }
.form-help { color: var(--text-muted); font-size: 12px; margin-top: 4px; }
/* Кнопки форми — праворуч під лінією, до країв картки; на довгій формі прилипають до
   низу екрана, а тінь (static/js/form-footer.js) — лише поки кінець форми нижче екрана. */
.form-footer {
    position: sticky;
    bottom: 0;
    z-index: 2;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin: 8px -20px -20px;
    padding: 14px 20px 16px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
}
.form-footer.is-stuck { box-shadow: 0 -8px 12px -10px rgba(0, 0, 0, 0.25); }
.form-footer-end { height: 1px; margin-top: -1px; }
.action-missing { margin: 12px 0; padding-left: 20px; }
.action-confirm { display: flex; gap: 8px; align-items: center; margin-top: 8px; font-weight: 500; }
/* Вибір штатної посади з пошуком (SPEC_POS_004) */
.picker { position: relative; }
.picker-list {
    position: absolute;
    z-index: 30;
    left: 0;
    right: 0;
    max-height: 280px;
    overflow-y: auto;
    margin: 4px 0 0;
    padding: 4px;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
.picker-list li { padding: 6px 8px; border-radius: 4px; cursor: pointer; font-size: 13px; }
.picker-list li:hover { background: var(--bg); }
.picker-list li.picker-empty { color: var(--text-muted); cursor: default; }
/* Підказка особи: друга лінія й попередження за статусом під полем (SPEC_REC_008) */
.picker-list .picker-details { display: block; color: var(--text-muted); font-size: 12px; }
.picker-warning { margin: 8px 0 0; }

/* Поле дати з кнопкою-календарем */
.date-field { position: relative; }
.date-field .js-date-input { padding-right: 38px; }
.date-field-btn {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    color: var(--text-muted);
    border-radius: 0 6px 6px 0;
}
.date-field-btn:hover { background: var(--bg); }
.date-cal {
    position: absolute;
    z-index: 30;
    top: calc(100% + 4px);
    left: 0;
    width: 252px;
    padding: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
/* Біля низу екрана чи над панеллю кнопок — угору (date-fields.js). */
.date-cal.date-cal-up { top: auto; bottom: calc(100% + 4px); }
.date-cal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.date-cal-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
}
.date-cal-title:hover:not(:disabled) { background: var(--bg); }
.date-cal-title:disabled { cursor: default; }
.date-cal-nav {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    color: var(--text);
}
.date-cal-nav:hover { background: var(--bg); }
.date-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}
.date-cal-wd {
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 4px 0;
}
.date-cal-day {
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: 12px;
    color: var(--text);
    cursor: pointer;
}
.date-cal-day.empty { cursor: default; }
.date-cal-day:not(.empty):hover { background: var(--bg); }
.date-cal-day.today { font-weight: 700; color: var(--primary); }
.date-cal-day.selected { background: var(--primary); color: #fff; }
.date-cal-day.selected:hover { background: var(--primary-hover); }
/* Сітка вибору місяця / року (3 колонки) */
.date-cal-cells {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding-top: 2px;
}
.date-cal-cell {
    padding: 10px 0;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text);
    cursor: pointer;
}
.date-cal-cell:hover { background: var(--bg); }
.date-cal-cell.selected { background: var(--primary); color: #fff; border-color: var(--primary); }
.date-cal-cell.selected:hover { background: var(--primary-hover); }

.field-section { margin-bottom: 24px; }
.field-section h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.detail-grid {
    display: grid;
    grid-template-columns: 240px 1fr;
    row-gap: 10px;
    column-gap: 16px;
}
.detail-grid dt {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    padding: 4px 0;
}
.detail-grid dd {
    margin: 0;
    padding: 4px 0;
    font-size: 13px;
    color: var(--text);
    word-break: break-word;
}
.detail-empty { color: #cbd5e1; font-style: italic; }

/* Шапка картки нового інтерфейсу: дві колонки полів, на вузькому екрані — одна. */
.person-head {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 0 32px;
}
.person-head .detail-grid { grid-template-columns: 180px 1fr; align-content: start; }

/* Групи полів блоку картки; прострочений документ підсвічений, колонки не зсуваються. */
.card-section + .card-section { margin-top: 12px; }
.card-document.is-expired {
    background: #fef2f2;
    border-left: 3px solid #dc2626;
    margin-left: -15px;
    padding: 8px 0 8px 12px;
}
.contact-links { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-left: 8px; }

/* Кнопки дій у блоках картки й вікно підтвердження (SPEC_UI_010, SPEC_ORG_007) */
.card-block-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.card-block-head h2 { margin: 0; padding: 0; border: 0; }
.card-block-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.confirm-dialog {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    max-width: 520px;
    box-shadow: var(--shadow);
}
.confirm-dialog::backdrop { background: rgba(15, 23, 42, 0.35); }
.confirm-dialog h2 { margin: 0 0 12px; font-size: 16px; }
.confirm-dialog ul { margin: 8px 0 16px; padding-left: 20px; }
.confirm-dialog p { margin: 0 0 12px; }
.confirm-dialog .dialog-field { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.confirm-dialog textarea { margin-bottom: 16px; }
.dialog-buttons { display: flex; justify-content: flex-end; gap: 8px; }

/* Картка вакансії: відмова у видаленні з кнопкою, форма посилання під переліком (SPEC_UI_011) */
.vacancy-refusal { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.link-form { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.link-form-buttons { display: flex; justify-content: flex-end; margin-top: 12px; }

/* Оргструктура: вкладені вузли згортаються (<details>), групи — як поля картки (SPEC_UI_012) */
.org-node + .org-node { margin-top: 4px; }
.org-tree > .org-node + .org-node { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.org-node-title {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}
.org-node-title::-webkit-details-marker { display: none; }
/* Шеврон замість трикутника браузера: вправо — згорнуто, вниз — розгорнуто */
.org-node-title::before {
    content: '';
    flex: none;
    width: 6px;
    height: 6px;
    margin: 0 2px 0 4px;
    border-right: 1.5px solid #9ca3af;
    border-bottom: 1.5px solid #9ca3af;
    transform: rotate(-45deg);
    transition: transform .15s;
}
.org-node[open] > .org-node-title::before { transform: translateY(-2px) rotate(45deg); }
.org-tree > .org-node > .org-node-title { font-size: 15px; }
.org-node-body { margin-left: 7px; padding: 0 0 4px 17px; border-left: 1px solid var(--border); }
.org-groups {
    display: grid;
    grid-template-columns: 104px 1fr;
    gap: 3px 12px;
    margin: 2px 0 8px;
    font-size: 13px;
}
.org-groups dt { color: #9ca3af; }
.org-groups dd { margin: 0; }
.org-staff { columns: 2; column-gap: 32px; max-width: 900px; }
/* Довга посада переноситься з відступом, щоб рядок не зливався з наступною особою */
.org-person { padding-left: 12px; text-indent: -12px; break-inside: avoid; }
.org-vacant { color: var(--warning); font-style: italic; }
.org-job-title { color: var(--text-muted); }
@media (max-width: 700px) {
    .org-groups { grid-template-columns: 1fr; gap: 0; }
    .org-groups dd + dt { margin-top: 6px; }
    .org-staff { columns: 1; }
}

/* Поля картки: підпис і значення — на одній лінії тексту, навіть коли в значенні
   вибір чи кнопка. */
.card-fields { align-items: baseline; }

/* Швидкі дії біля полів картки (SPEC_UI_010): кнопка чи вибір позначки в рядку значення. */
/* Відступ від значення — як у кнопок зв'язку біля телефону; вибір позначки — саме значення. */
.quick-action { gap: 6px; align-items: center; vertical-align: baseline; margin-left: 8px; }
.quick-action.quick-choice { margin-left: 0; }
/* .btn задає display, тож атрибут hidden сам кнопку «Зберегти» не ховає. */
.quick-action [hidden] { display: none; }
.quick-select { width: auto; height: 26px; padding: 0 24px 0 8px; font-size: 13px; }

/* Шлях у AD (SPEC_DATA_014): плашка — шлях і вбудована кнопка «Скопіювати шлях»;
   після копіювання кнопка на мить показує галочку й «Скопійовано». */
.ad-path {
    display: inline-flex;
    align-items: stretch;
    max-width: 100%;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #f8fafc;
    overflow: hidden;
    vertical-align: baseline;
}
.ad-path code {
    align-self: center;
    padding: 2px 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    color: var(--text);
    overflow-wrap: anywhere;
}
.btn-copy-path {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex: none;
    padding: 2px 9px;
    border: 0;
    border-left: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    font-family: inherit;
    font-size: 12px;
    white-space: nowrap;
    cursor: pointer;
}
.btn-copy-path:hover { background: #eff6ff; color: var(--primary); }
.btn-copy-path.is-done { background: #ecfdf5; color: var(--success); }
.btn-copy-path .icon-done, .btn-copy-path.is-done .icon-copy { display: none; }
.btn-copy-path.is-done .icon-done { display: inline; }

/* Запрошення в ботів (SPEC_LINK_007): чужа спроба під станом, посилання й QR-код при видачі;
   підказки HR у черзі звернень (SPEC_LINK_008). */
.invitation-warning { margin-top: 4px; font-size: 12px; color: #92400e; }
.link-request-mark { font-size: 12px; color: #92400e; }
.link-request-mark + .link-request-mark { margin-top: 4px; }
.link-request-note { margin-top: 12px; font-size: 13px; }
/* Особа й «Обрати» поруч, а не через усю ширину картки звернення (SPEC_LINK_008): таблиця
   за вмістом; відсоткова ширина колонки кнопок розтягнула б її на всю ширину. */
.employee-table.link-request-people { width: auto; min-width: 0; }
.link-request-people .card-row-actions { width: auto; }
/* Номери телефону в картці (SPEC_PERSON_013). */
.employee-table.phone-table { width: auto; min-width: 0; }
.phone-table .card-row-actions { width: auto; padding-right: 0; }
.phone-table .contact-links { margin-left: 0; }
.phone-table td { vertical-align: baseline; padding-left: 6px; padding-right: 6px; }
.phone-table td:first-child { padding-left: 0; }
.phone-table .btn { padding-left: 8px; padding-right: 8px; }
.phone-add { margin-top: 8px; }
/* Поле номера (SPEC_PERSON_013). */
.form-control.phone-input { width: calc(18ch + 26px); max-width: 100%; font-variant-numeric: tabular-nums; }
.phone-list-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0 8px; }
.phone-list-row + .phone-list-row { margin-top: 8px; }
.phone-list [hidden] { display: none; }
.phone-hint { flex-basis: 100%; margin-top: 4px; font-size: 12px; color: var(--text-muted); }
.phone-hint:empty { display: none; }
.phone-hint.is-warn { color: #92400e; }
.phone-hint.is-error { color: var(--danger); }
.invitation-link { margin: 12px 0; }
.invitation-qr svg { display: block; width: 225px; height: auto; background: #fff; }

/* Кнопки дій у рядках таблиць картки (SPEC_UI_010) */
.card-row-actions { white-space: nowrap; text-align: right; width: 1%; }
.card-row-actions .btn, .card-row-actions .inline-form { margin-left: 4px; }

/* Записи блоку «Працевлаштування»: поля, під ними — накази, договори й угоди. */
.card-record + .card-record { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 16px; }
.card-record-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}
/* Кнопки — праворуч і тоді, коли стану запису роль не бачить. */
.card-record-head .card-block-actions { margin-left: auto; }
.card-subtitle { font-size: 13px; font-weight: 600; margin: 16px 0 8px; }
/* Підзаголовок договору з кнопками праворуч. */
.card-subhead { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.card-subhead .card-block-actions { margin-left: auto; }
/* Договір, за яким рахується строк: спливає — жовтий, сплив — червоний (SPEC_EMPL_012). */
.card-contract.is-expiring,
.card-contract.is-expired { border-left: 3px solid; margin-left: -15px; padding: 4px 0 8px 12px; }
.card-contract.is-expiring { background: #fffbeb; border-left-color: #d97706; }
.card-contract.is-expired { background: #fef2f2; border-left-color: #dc2626; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    background: var(--bg);
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.badge-candidate { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.badge-employee { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.badge-rejected { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.badge-dismissed { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.badge-leave { background: #fff7ed; color: #9a3412; border-color: #fed7aa; }
/* Картка: стан запису з періодом і строк договору — після .badge, інакше він їх перекриє. */
.badge-state-active   { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.badge-state-pending  { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.badge-state-finished { background: #f1f5f9; color: #334155; border-color: #cbd5e1; }
/* Статуси вакансії (REQ_VAC_005) */
.badge-vacancy-open      { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.badge-vacancy-closed    { background: #f1f5f9; color: #334155; border-color: #cbd5e1; }
.badge-vacancy-cancelled { background: #fef3c7; color: #92400e; border-color: #fde68a; }
/* Стан звернення з бота (SPEC_LINK_008): відкрите — синім, прив'язане — зеленим, відхилене — сірим. */
.badge-request-open                 { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.badge-request-linked,
.badge-request-linked_by_invitation { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.badge-request-rejected             { background: #f1f5f9; color: #334155; border-color: #cbd5e1; }
.badge-term-expiring  { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.badge-term-expired   { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
/* Етапи кандидата у воронці найму */
.badge-stage-new          { background: #f1f5f9; color: #334155; border-color: #cbd5e1; }
.badge-stage-interviewing { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.badge-stage-polygraph    { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.badge-stage-hiring       { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }

/* Тимчасові статуси (відпустка/відрядження/лікарняний) */
.leave-card .leave-current { margin-bottom: 12px; }
.leave-current-item { margin-bottom: 4px; }
.leave-form .leave-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-top: 1px solid var(--border);
}
.leave-form .leave-check {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 150px;
    font-weight: 500;
}
.leave-form .leave-dates {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}
.leave-form .leave-dates label {
    display: flex;
    flex-direction: column;
    font-size: 12px;
    color: var(--text-muted);
    gap: 2px;
}
.leave-form button[type="submit"] { margin-top: 12px; }
.leave-history { margin-top: 16px; }
.leave-history summary { cursor: pointer; font-weight: 500; }
.leave-history table { margin-top: 8px; }

.badge-role-full      { background: #f3e8ff; color: #6b21a8; border-color: #e9d5ff; }
.badge-role-boss      { background: #fff7ed; color: #9a3412; border-color: #fed7aa; }
.badge-role-recruiter { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.badge-role-hr        { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.badge-role-security  { background: #fef3c7; color: #92400e; border-color: #fde68a; }

.stat-link {
    display: block;
    text-decoration: none;
    color: inherit;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}
/* Підсвічується лише картка з переходом: без нього картка не клікабельна (REQ_UI_012). */
.stat-link:hover {
    border-color: #d4d4d8;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.list-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}
.list-tab {
    padding: 8px 14px;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    font-size: 13px;
    text-decoration: none;
    margin-bottom: -1px;
}
.list-tab:hover { color: var(--text); text-decoration: none; }
.list-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 500;
}

.status-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.status-actions-label { font-weight: 500; color: var(--text-muted); font-size: 13px; }
.status-actions-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.status-actions-buttons form { margin: 0; }
.btn-status {
    padding: 6px 14px;
    font-size: 13px;
}
.btn-status-employee { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.btn-status-employee:hover { background: #d1fae5; }
.btn-status-rejected { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.btn-status-rejected:hover { background: #fde68a; }
.btn-status-dismissed { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.btn-status-dismissed:hover { background: #fecaca; }
.btn-status-candidate { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.btn-status-candidate:hover { background: #dbeafe; }

@keyframes fadeOutShrink {
    0%   { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
    50%  { opacity: 0.6; transform: translateY(-10px) scale(0.98); filter: blur(1px); }
    100% { opacity: 0; transform: translateY(-40px) scale(0.94); filter: blur(3px); }
}
.employee-detail.fading-out {
    animation: fadeOutShrink 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    pointer-events: none;
}

.status-actions-empty {
    background: var(--bg);
    border-style: dashed;
}

/* Позначка «Проблемний профіль» у картці: окремий блок над секціями полів.
   Підсвічування приглушене (пастельний фон + ліва смужка), у тон .badge-dismissed. */
.troubled-card { padding: 12px 16px; }
.troubled-card.is-troubled {
    background: #fef2f2;
    border-color: #fecaca;
    border-left: 3px solid #dc2626;
}
.troubled-form { display: flex; align-items: center; gap: 12px; margin: 0; }
.troubled-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}
.troubled-check input { width: 16px; height: 16px; cursor: pointer; }
.troubled-check-readonly { cursor: default; }
.troubled-check-readonly input { cursor: default; }

/* Рядок проблемного профілю у списку. Правило tbody tr:hover перебиває фон
   рядка, тому для підсвічених рядків потрібен власний :hover. */
tr.row-troubled { background: #fef2f2; }
tr.row-troubled:hover { background: #fee2e2; }

/* Панель дій кандидата: етап (ліворуч) + зміна статусу (праворуч) в одному блоці */
.actions-bar {
    display: flex;
    align-items: center;
    gap: 14px 28px;
    flex-wrap: wrap;
}
/* Кожна група (етап / статус) не стискається — кнопки лишаються рядком,
   а не переносяться по одній у стовпчик. Не влізло — переноситься вся група. */
.actions-col { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.actions-col-right { margin-left: auto; }

/* Кнопки етапу — кольорові пігулки, активна виділена */
.stage-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.stage-buttons form { margin: 0; }
.btn-stage { padding: 6px 14px; font-size: 13px; background: #fff; }
.btn-stage-interviewing { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.btn-stage-interviewing:hover { background: #dbeafe; }
.btn-stage-polygraph { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.btn-stage-polygraph:hover { background: #fde68a; }
.btn-stage-hiring { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.btn-stage-hiring:hover { background: #d1fae5; }
.btn-stage.is-active { font-weight: 600; box-shadow: inset 0 0 0 2px currentColor; }
.btn-stage-clear {
    padding: 6px 11px;
    font-size: 13px;
    color: var(--text-muted);
    background: #fff;
}
.btn-stage-clear:hover { background: var(--bg); color: #991b1b; }

.form-group-wide { grid-column: 1 / -1; }
.rate-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}
.rate-input {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0 10px;
}
.rate-label {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    min-width: 56px;
}
.rate-input input {
    border: none;
    background: transparent;
    padding: 8px 4px;
    flex: 1;
    min-width: 0;
    outline: none;
    font-size: 14px;
}
.rate-input:focus-within {
    border-color: var(--primary);
    background: var(--surface);
}

/* Штати — два чекбокси стовпчиком, поруч один з одним. */
.staff-units {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.staff-unit {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-weight: 400;
    cursor: pointer;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
}
.staff-unit input { margin: 0; }
.staff-unit:focus-within { border-color: var(--primary); background: var(--surface); }

.pagination {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
    margin-top: 16px;
}
.pagination-info { font-size: 13px; color: var(--text-muted); }

.table-scroll {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.table-scroll table { margin: 0; border: none; }
.employee-table {
    width: max-content;
    min-width: 100%;
}
.employee-table th,
.employee-table td {
    white-space: nowrap;
}
.cell-truncate {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.messages { margin-bottom: 16px; }
.message {
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 8px;
    font-size: 13px;
    border: 1px solid;
}
.message-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.message-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.message-info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.message-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}
.empty-state-title { font-weight: 500; color: var(--text); margin-bottom: 4px; }

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 20px;
}
.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    width: 100%;
    max-width: 360px;
    box-shadow: var(--shadow);
}
.login-card h1 {
    font-size: 18px;
    margin: 0 0 6px 0;
    text-align: center;
}
.login-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 24px;
}

.dropdown { position: relative; display: inline-block; }
.dropdown-toggle {
    cursor: pointer;
    user-select: none;
}
.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    min-width: 180px;
    z-index: 200;
    padding: 4px;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu form { margin: 0; }
.dropdown-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 7px 10px;
    border: none;
    background: none;
    color: var(--text);
    cursor: pointer;
    border-radius: 4px;
    font-size: 13px;
}
.dropdown-item:hover { background: var(--bg); }

.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.flex-row { display: flex; gap: 8px; align-items: center; }
