/* «ЗП сотрудников ИЗИ» (Нургыз 13.11.2026) — izi-payroll.js (window.IZP), раздел #iziPayrollTab.
   Таблица как лист Excel: шапка и колонки «№ / Сотрудник» закреплены, расчётные ячейки подкрашены, ввод — прямо в ячейке.
   Группы колонок: начисление — синий, удержания — янтарный, выплата — зелёный. Статусы всегда с подписью. */
.izp {
    --izp-acc: #2563eb; --izp-ded: #d97706; --izp-pay: #16a34a; --izp-bad: #dc2626;
    --izp-line: var(--border-light, #e8eaed); --izp-soft: var(--surface-bg, #f8f9fa);
    --izp-calc: color-mix(in srgb, var(--primary-color, #074783) 4.5%, var(--card-bg, #fff));
    --izp-radius: 12px; --izp-grp-h: 28px;
    position: relative; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 12px;
    padding: 18px 22px 22px; overflow-y: auto; color: var(--text-color, #202124); font-variant-numeric: tabular-nums;
    transition: opacity .15s;
}
body[data-theme="dark"] .izp { --izp-acc: #93c5fd; --izp-ded: #fbbf24; --izp-pay: #4ade80; --izp-bad: #fca5a5; --izp-soft: rgba(255, 255, 255, .04); }
.izp > * { flex-shrink: 0; }
.izp.is-busy { opacity: .6; pointer-events: none; }
.izp-loading, .izp-locked { margin: 60px auto; display: flex; align-items: center; gap: 10px; color: var(--text-muted, #5f6368); font-size: 14px; }
.izp-loading.is-error { color: var(--izp-bad); flex-wrap: wrap; justify-content: center; }
.izp-locked { flex-direction: column; text-align: center; gap: 8px; }
.izp-locked b { font-size: 16px; color: var(--text-color, #202124); }
.izp-spin { display: inline-block; width: 18px; height: 18px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--primary-color, #074783) 22%, transparent); border-top-color: var(--primary-color, #074783); animation: izpSpin .8s linear infinite; }
@keyframes izpSpin { to { transform: rotate(360deg); } }
.izp-link { border: 0; background: none; padding: 0; font: inherit; font-weight: 600; color: var(--primary-color, #074783); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); white-space: nowrap; }
.izp-link:hover { text-decoration-color: currentColor; }
.izp-dim { color: var(--text-muted, #5f6368); font-weight: 400; }

/* ---------- шапка */
.izp-head { display: flex; align-items: center; justify-content: space-between; gap: 12px 18px; flex-wrap: wrap; }
.izp-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.izp-title h2 { margin: 0; font-size: 20px; font-weight: 700; line-height: 1.2; letter-spacing: -.01em; }
.izp-title span:not(.izp-logo) { display: block; margin-top: 2px; font-size: 12.5px; color: var(--text-muted, #5f6368); }
.izp-logo { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; border-radius: 12px; flex: none;
    color: var(--izp-pay); background: color-mix(in srgb, var(--izp-pay) 12%, var(--card-bg, #fff)); }
.izp-head-r { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.izp-btn { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--border-color, #dadce0);
    background: var(--card-bg, #fff); color: var(--text-color, #202124); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
    transition: background .15s, border-color .15s, box-shadow .15s; }
.izp-btn:hover:not(:disabled) { background: var(--hover-bg, #f1f3f4); }
.izp-btn:focus-visible { outline: 2px solid var(--primary-color, #074783); outline-offset: 1px; }
.izp-btn:disabled { opacity: .5; cursor: default; }
.izp-btn-primary { background: var(--primary-color, #074783); border-color: var(--primary-color, #074783); color: #fff; }
.izp-btn-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--primary-color, #074783) 88%, #000); box-shadow: 0 2px 8px var(--primary-glow, rgba(7, 71, 131, .22)); }
.izp-icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 0; border-radius: 8px; background: none; color: var(--text-muted, #5f6368); cursor: pointer; }
.izp-icon-btn:hover { background: var(--hover-bg, #f1f3f4); color: var(--text-color, #202124); }
.izp-people { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 12px 0 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
    color: var(--text-muted, #5f6368); background: var(--izp-soft); border: 1px solid var(--izp-line); cursor: default; }
.izp-av-stack { display: inline-flex; }
.izp-av { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; font-size: 9.5px; font-weight: 700; color: #fff;
    background: var(--primary-color, #074783); box-shadow: 0 0 0 2px var(--card-bg, #fff); }
.izp-av + .izp-av { margin-left: -6px; background: #0d9488; }

/* ---------- месяцы */
.izp-months { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 4px; scrollbar-width: thin; }
.izp-m { position: relative; flex: 0 0 auto; min-width: 78px; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 7px 10px 6px;
    border-radius: 10px; border: 1px solid var(--izp-line); background: var(--card-bg, #fff); cursor: pointer; font: inherit; color: var(--text-color, #202124);
    transition: border-color .15s, background .15s, box-shadow .15s; }
.izp-m:hover { border-color: color-mix(in srgb, var(--primary-color, #074783) 45%, transparent); }
.izp-m:focus-visible { outline: 2px solid var(--primary-color, #074783); outline-offset: 1px; }
.izp-m-name { font-size: 11.5px; font-weight: 600; color: var(--text-muted, #5f6368); text-transform: uppercase; letter-spacing: .03em; }
.izp-m-name small { font-size: 10px; opacity: .8; }
.izp-m-n { font-size: 13.5px; font-weight: 700; line-height: 1.25; }
.izp-m.is-empty .izp-m-n { color: var(--text-secondary, #9ca3af); font-weight: 600; }
.izp-m.is-future { border-style: dashed; }
.izp-m.active { background: var(--primary-color, #074783); border-color: var(--primary-color, #074783); color: #fff; box-shadow: 0 2px 8px var(--primary-glow, rgba(7, 71, 131, .2)); }
.izp-m.active .izp-m-name, .izp-m.active .izp-m-n { color: #fff; }
.izp-m-dot { position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: #f59e0b; box-shadow: 0 0 0 2px var(--card-bg, #fff); }
.izp-m.active .izp-m-dot { box-shadow: 0 0 0 2px var(--primary-color, #074783); }

/* ---------- итоги */
.izp-kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.izp-kpi { --k: var(--primary-color, #074783); position: relative; display: flex; flex-direction: column; gap: 3px; min-width: 0; padding: 12px 14px 11px;
    border-radius: var(--izp-radius); border: 1px solid var(--izp-line); background: var(--card-bg, #fff); overflow: hidden; }
.izp-kpi::before { content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--k); pointer-events: none; }
.izp-kpi-l { font-size: 12px; font-weight: 600; color: var(--text-muted, #5f6368); }
.izp-kpi b { font-size: 22px; line-height: 1.15; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.izp-kpi b small { font-size: 12px; font-weight: 600; color: var(--text-muted, #5f6368); }
.izp-kpi-s { font-size: 11.5px; color: var(--text-muted, #5f6368); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.izp-kpi.k-emp { --k: #64748b; }
.izp-kpi.k-acc { --k: var(--izp-acc); }
.izp-kpi.k-ded { --k: var(--izp-ded); }
.izp-kpi.k-pay { --k: var(--primary-color, #074783); }
.izp-kpi.k-left { --k: #f59e0b; background: color-mix(in srgb, #f59e0b 6%, var(--card-bg, #fff)); }
.izp-kpi.k-left.is-empty { --k: #94a3b8; background: var(--card-bg, #fff); }
.izp-kpi.k-left.is-done { --k: var(--izp-pay); background: color-mix(in srgb, var(--izp-pay) 7%, var(--card-bg, #fff)); }
.izp-progress { display: block; height: 5px; margin: 3px 0 1px; border-radius: 999px; background: color-mix(in srgb, var(--k) 18%, transparent); overflow: hidden; }
.izp-progress i { display: block; height: 100%; border-radius: inherit; background: var(--izp-pay); transition: width .35s ease; }

/* ---------- плашки */
.izp-banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 9px 12px; border-radius: 10px; font-size: 13px; line-height: 1.45; border: 1px solid var(--izp-line); background: var(--izp-soft); color: var(--text-color, #202124); }
.izp-banner > svg { flex: none; color: var(--text-muted, #5f6368); }
.izp-banner > span { flex: 1 1 320px; min-width: 0; }
.izp-banner.is-carry { background: color-mix(in srgb, var(--primary-color, #074783) 6%, var(--card-bg, #fff)); border-color: color-mix(in srgb, var(--primary-color, #074783) 25%, transparent); }
.izp-banner.is-carry > svg { color: var(--primary-color, #074783); }
.izp-banner.is-norm { padding: 7px 12px; font-size: 12.5px; color: var(--text-muted, #5f6368); }
.izp-banner.is-norm b { color: var(--text-color, #202124); }

/* ---------- пустой месяц */
.izp-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 44px 20px; border-radius: var(--izp-radius);
    border: 1px dashed var(--border-color, #dadce0); background: var(--card-bg, #fff); }
.izp-empty-ic { display: inline-flex; align-items: center; justify-content: center; width: 64px; height: 64px; border-radius: 18px; margin-bottom: 4px;
    color: var(--primary-color, #074783); background: color-mix(in srgb, var(--primary-color, #074783) 8%, var(--card-bg, #fff)); }
.izp-empty b { font-size: 16px; }
.izp-empty > span { max-width: 520px; font-size: 13px; color: var(--text-muted, #5f6368); line-height: 1.5; }
.izp-empty-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }

/* ---------- таблица */
/* высота — по строкам, но не выше окна: длинный список листается внутри (шапка, «Сотрудник» и итог закреплены) */
.izp-table-wrap { flex: 0 0 auto; max-height: calc(100vh - 150px); overflow: auto; border: 1px solid var(--izp-line); border-radius: var(--izp-radius); background: var(--card-bg, #fff); scrollbar-width: thin; }
.izp-table { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.izp-table th, .izp-table td { border-bottom: 1px solid var(--izp-line); border-right: 1px solid color-mix(in srgb, var(--izp-line) 60%, transparent); background: var(--card-bg, #fff); }
.izp-table thead th { position: sticky; z-index: 2; background: var(--izp-soft); background-color: color-mix(in srgb, var(--surface-bg, #f8f9fa) 100%, var(--card-bg, #fff)); }
.izp-groups th { top: 0; height: var(--izp-grp-h); padding: 0 10px; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted, #5f6368); text-align: left; white-space: nowrap; }
.izp-groups th.izp-g { border-top: 3px solid transparent; }
/* подпись группы не уезжает, пока видна хоть одна её колонка */
.izp-groups th:not(.g-emp) .izp-g-label { position: sticky; left: 278px; display: inline-block; }
.izp-groups th.g-acc { border-top-color: var(--izp-acc); color: var(--izp-acc); }
.izp-groups th.g-ded { border-top-color: var(--izp-ded); color: var(--izp-ded); }
.izp-groups th.g-pay { border-top-color: var(--izp-pay); color: var(--izp-pay); }
.izp-groups th.g-emp { border-top-color: #94a3b8; }
.izp-cols th { top: var(--izp-grp-h); padding: 7px 10px; font-size: 11.5px; font-weight: 700; color: var(--text-muted, #5f6368); text-align: right; line-height: 1.25; vertical-align: bottom; white-space: normal; }
.izp-cols th.c-employee_name, .izp-cols th.c-job_title, .izp-cols th.c-comment, .izp-cols th.c-status { text-align: left; }
.izp-cols th.is-calc { color: var(--text-color, #202124); }
.izp-fx { margin-left: 4px; font-style: italic; font-family: Georgia, 'Times New Roman', serif; font-weight: 400; color: var(--primary-color, #074783); opacity: .7; }
.izp-table th.c-num { top: 0; left: 0; z-index: 4; width: 46px; min-width: 46px; text-align: center; vertical-align: middle; font-size: 11.5px; color: var(--text-muted, #5f6368); }
.izp-table td { padding: 0; height: 40px; vertical-align: middle; }
.izp-table td.c-num { position: sticky; left: 0; z-index: 1; width: 46px; min-width: 46px; text-align: center; }
.izp-table td.c-employee_name, .izp-cols th.c-employee_name { position: sticky; left: 46px; z-index: 1; box-shadow: 1px 0 0 var(--izp-line), 6px 0 8px -6px rgba(15, 23, 42, .12); }
.izp-cols th.c-employee_name { z-index: 3; }
.izp-table tbody tr:hover td { background: color-mix(in srgb, var(--primary-color, #074783) 2.5%, var(--card-bg, #fff)); }
.izp-table tbody tr.is-focus td { background: color-mix(in srgb, var(--primary-color, #074783) 4%, var(--card-bg, #fff)); }
.izp-table tbody tr.is-saved td { background: color-mix(in srgb, var(--izp-pay) 8%, var(--card-bg, #fff)); transition: background .4s; }
.izp-table tbody td.is-calc { background: var(--izp-calc); }
.izp-table tbody tr:hover td.is-calc { background: color-mix(in srgb, var(--primary-color, #074783) 6%, var(--card-bg, #fff)); }

/* ширины колонок */
.c-employee_name { min-width: 220px; }
.c-job_title { min-width: 185px; }
.c-rate { min-width: 72px; }
.c-base_salary { min-width: 124px; }
.c-salary_by_rate, .c-accrued, .c-to_pay, .c-left { min-width: 118px; }
.c-norm_days, .c-worked_days { min-width: 82px; }
.c-bonus, .c-other_deductions, .c-advance, .c-paid { min-width: 110px; }
.c-pn, .c-sv { min-width: 96px; }
.c-status { min-width: 124px; }
.c-comment { min-width: 230px; }
.c-act { width: 40px; min-width: 40px; }

/* ячейки ввода */
.izp-in { display: block; width: 100%; height: 39px; box-sizing: border-box; margin: 0; padding: 0 10px; border: 1px solid transparent; border-radius: 0; background: transparent;
    font: inherit; font-size: 13px; color: var(--text-color, #202124); text-align: right; font-variant-numeric: tabular-nums; outline: 0;
    transition: border-color .12s, box-shadow .12s, background .12s; }
.izp-in.t-text { text-align: left; }
.izp-in::placeholder { color: var(--text-secondary, #b0b6bf); }
.izp-in:hover { border-color: color-mix(in srgb, var(--primary-color, #074783) 22%, transparent); }
.izp-in:focus { position: relative; z-index: 2; background: var(--card-bg, #fff); border-color: var(--primary-color, #074783); box-shadow: 0 0 0 3px var(--primary-glow, rgba(7, 71, 131, .14)); border-radius: 4px; }
.izp-in.is-bad, .izp-in.is-bad:focus { border-color: var(--izp-bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--izp-bad) 18%, transparent); }
textarea.izp-in { height: auto; min-height: 39px; padding: 10px; line-height: 1.4; resize: none; overflow: hidden; white-space: pre-wrap; }
.izp-in[data-f="employee_name"] { font-weight: 600; }
.izp-in::-webkit-calendar-picker-indicator { display: none !important; }   /* стрелка datalist в Chrome */
.izp-calc { display: block; padding: 0 10px; text-align: right; font-weight: 600; white-space: nowrap; }
td.c-to_pay .izp-calc { font-weight: 700; color: var(--primary-color, #074783); }
tr.st-unpaid td.c-left .izp-calc, tr.st-partial td.c-left .izp-calc { color: #b45309; }
tr.st-paid td.c-left .izp-calc { color: var(--izp-pay); }
td.c-left .izp-calc.is-over, tr.st-paid td.c-left .izp-calc.is-over { color: var(--izp-bad); font-size: 12px; }
body[data-theme="dark"] tr.st-unpaid td.c-left .izp-calc, body[data-theme="dark"] tr.st-partial td.c-left .izp-calc { color: #fbbf24; }

/* статус */
.izp-st { display: inline-flex; align-items: center; gap: 5px; margin: 0 10px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.izp-st::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.izp-st.s-paid { color: #15803d; background: color-mix(in srgb, #16a34a 13%, var(--card-bg, #fff)); }
.izp-st.s-partial { color: #b45309; background: color-mix(in srgb, #f59e0b 16%, var(--card-bg, #fff)); }
.izp-st.s-unpaid { color: #b91c1c; background: color-mix(in srgb, #dc2626 11%, var(--card-bg, #fff)); }
.izp-st.s-none { color: var(--text-muted, #5f6368); background: var(--izp-soft); }
.izp-st.s-none::before { display: none; }
body[data-theme="dark"] .izp-st.s-paid { color: #4ade80; }
body[data-theme="dark"] .izp-st.s-partial { color: #fbbf24; }
body[data-theme="dark"] .izp-st.s-unpaid { color: #fca5a5; }

/* номер = ручка перетаскивания */
.izp-grip { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 26px; border-radius: 6px; font-size: 12px; font-weight: 600;
    color: var(--text-muted, #5f6368); cursor: grab; user-select: none; }
.izp-grip { position: relative; transition: padding .12s, background .12s; }
.izp-row:hover .izp-grip { padding-left: 9px; background: var(--izp-soft); box-shadow: inset 0 0 0 1px var(--izp-line); color: var(--text-color, #202124); }
.izp-row:hover .izp-grip::before { content: ''; position: absolute; left: 4px; top: 50%; width: 5px; height: 9px; transform: translateY(-50%); opacity: .5;
    background-image: radial-gradient(circle, currentColor 0.9px, transparent 1.15px); background-size: 3px 3px; }
.izp-grip:active { cursor: grabbing; }
tr.is-dragging td { opacity: .45; }
.izp-del { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; margin: 0 5px; border: 0; border-radius: 7px; background: none;
    color: var(--text-muted, #5f6368); cursor: pointer; opacity: 0; transition: opacity .12s, background .12s, color .12s; }
.izp-row:hover .izp-del, .izp-del:focus-visible { opacity: 1; }
.izp-del:hover { background: color-mix(in srgb, var(--izp-bad) 12%, transparent); color: var(--izp-bad); }
@media (hover: none) { .izp-del { opacity: 1; } }
tr.is-saving .izp-grip { animation: izpPulse .9s ease-in-out infinite; }
@keyframes izpPulse { 50% { opacity: .35; } }

/* итоговая строка закреплена снизу */
.izp-table tfoot td { position: sticky; bottom: 0; z-index: 2; height: 42px; padding: 0 10px; border-top: 2px solid var(--izp-line); border-bottom: 0;
    background: color-mix(in srgb, var(--surface-bg, #f8f9fa) 100%, var(--card-bg, #fff)); font-weight: 700; text-align: right; white-space: nowrap; }
.izp-table tfoot td.c-employee_name { left: 46px; z-index: 3; text-align: left; }
.izp-table tfoot td.c-num { left: 0; z-index: 3; }
.izp-table tfoot td.c-status { text-align: left; font-size: 12px; }
.izp-table tfoot td.c-to_pay span { color: var(--primary-color, #074783); }

.izp-foot { display: flex; align-items: flex-start; gap: 8px; font-size: 12px; line-height: 1.5; color: var(--text-muted, #5f6368); }
.izp-foot svg { flex: none; margin-top: 2px; }

/* ---------- журнал */
.izp-log { position: fixed; top: 0; right: 0; bottom: 0; z-index: 1300; width: 400px; max-width: 92vw; display: flex; flex-direction: column;
    background: var(--card-bg, #fff); border-left: 1px solid var(--izp-line); box-shadow: -12px 0 32px rgba(15, 23, 42, .14);
    transform: translateX(105%); transition: transform .22s ease; }
.izp-log.is-open { transform: none; }
.izp-log-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 14px 12px 18px; border-bottom: 1px solid var(--izp-line); }
.izp-log-head b { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; }
.izp-log-list { flex: 1; overflow-y: auto; padding: 4px 18px 20px; }
.izp-log-empty { display: flex; justify-content: center; padding: 40px 18px; color: var(--text-muted, #5f6368); font-size: 13px; }
.izp-log-day { position: sticky; top: 0; padding: 12px 0 6px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted, #5f6368); background: var(--card-bg, #fff); }
.izp-log-item { display: grid; grid-template-columns: 42px 1fr; gap: 8px; padding: 7px 0; border-bottom: 1px solid color-mix(in srgb, var(--izp-line) 70%, transparent); font-size: 12.5px; line-height: 1.45; }
.izp-log-t { color: var(--text-muted, #5f6368); font-size: 12px; }
.izp-log-by { font-weight: 700; color: var(--primary-color, #074783); }

@media (max-width: 1200px) { .izp-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 720px) {
    .izp { padding: 14px 12px 18px; }
    .izp-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .izp-people-txt { display: none; }
    .izp-table td.c-employee_name, .izp-cols th.c-employee_name, .izp-table tfoot td.c-employee_name { position: static; box-shadow: none; }
}
#iziPayrollTab.active { min-height: 0; }
