/* График работы и зарплата (AI-12781, ADR-205). Раскладка и цвета — из
   согласованного макета, токены — iiko.css. Префикс sch- у всех классов:
   в iiko.css уже есть .seg/.chip/.card с другим видом. */
:root {
  --sch-baker-bg: #fbe9df; --sch-baker: #b75d3f;
  --sch-cashier-bg: #e5eef6; --sch-cashier: #2f5f8a;
  --sch-weekend: #f9f5ec;
  --sch-warning-line: #e6c766;
}

.sch-body { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.sch-wide { width: 100%; }
/* индикатор загрузки — как на соседних экранах (.kr-loading) */
.sch-loading { min-height: 160px; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--ink-muted); font-size: 14px; }
.sch-loading .flow-loader-spinner { width: 22px; height: 22px; border-width: 2px; flex-shrink: 0; }
@media (prefers-reduced-motion: reduce) { .sch-loading .flow-loader-spinner { animation: none; } }
.sch-muted { color: var(--ink-muted); }

/* сегмент: вкладки, «Вся смена / На часы», «Не выдано / Всё выдано» */
.sch-seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-sunken); border-radius: var(--r-md); padding: 3px; gap: 3px; }
.sch-seg button { min-height: 40px; border: 0; border-radius: var(--r-sm); background: transparent; font: inherit; font-size: 14px; font-weight: 600; color: var(--ink-muted); cursor: pointer; padding: 4px 6px; line-height: 1.2; }
.sch-seg button small { display: block; font-weight: 500; font-size: 11px; }
.sch-seg button.is-on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.sch-tabs button { font-size: 15px; }

.sch-month { display: flex; align-items: center; justify-content: space-between; background: var(--surface); border: 1px solid var(--hairline-strong); border-radius: var(--r-lg); padding: 4px; }
.sch-month-title { font-weight: 700; font-size: 15px; text-align: center; }

.sch-sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex-shrink: 0; }
.sch-sw-baker { background: var(--sch-baker); }
.sch-sw-cashier { background: var(--sch-cashier); }

/* подсветка сотрудника */
.sch-who-bar { position: relative; display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.sch-who-bar::-webkit-scrollbar { display: none; }
/* мышью ленту тащат (AI-12840); во время перетаскивания текст не выделяется */
@media (hover: hover) and (pointer: fine) { .sch-who-bar { cursor: grab; } }
.sch-who-bar.is-dragging { cursor: grabbing; user-select: none; }
.sch-who-bar.is-dragging .sch-fchip { pointer-events: none; }
.sch-fchip { flex-shrink: 0; height: 34px; padding: 0 12px; border-radius: var(--r-full); border: 1px solid var(--hairline-strong); background: var(--surface); font: inherit; font-size: 13px; font-weight: 600; color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.sch-fchip.is-on { background: var(--ink); color: var(--ink-inverse); border-color: var(--ink); }
.sch-focus-sum { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--ink-muted); min-height: 20px; }
.sch-focus-sum b { color: var(--ink); }
/* AI-12868: выбран человек — сводка за месяц и «Редактировать профиль». Узко — кнопка
   уходит на свою строку и не сжимается, текст переносится, а не обрезается. */
.sch-focus-sum.is-person { flex-wrap: wrap; row-gap: 8px; }
.sch-fs-text { flex: 1 1 180px; min-width: 0; }
.sch-profile-btn { flex: none; white-space: nowrap; }
.sch-link { background: none; border: 0; color: var(--accent-deep); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; padding: 0; flex-shrink: 0; text-align: left; }
.sch-link-muted { color: var(--ink-muted); align-self: flex-start; }

/* пустой месяц */
.sch-empty { background: var(--surface); border: 1px dashed var(--hairline-strong); border-radius: var(--r-lg); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.sch-empty-t { font-weight: 800; font-size: 15px; }
.sch-empty-s { font-size: 13px; color: var(--ink-muted); line-height: 1.45; }

/* сетка: overflow clip, а не hidden — иначе обёртка станет контейнером
   прокрутки и шапка перестанет липнуть к верху экрана */
.sch-grid-wrap { background: var(--surface); border: 1px solid var(--hairline-strong); border-radius: var(--r-lg); overflow: clip; }
.sch-grid { border-collapse: separate; border-spacing: 0; width: 100%; table-layout: fixed; font-variant-numeric: tabular-nums; }
.sch-c-day { width: 42px; }
.sch-grid thead th { position: sticky; top: 0; z-index: 2; background: var(--surface); padding: 0; text-align: left; vertical-align: top; border-bottom: 1px solid var(--hairline-strong); }
.sch-grid th.sch-baker { box-shadow: inset 0 -2px 0 var(--sch-baker); }
.sch-grid th.sch-cashier { box-shadow: inset 0 -2px 0 var(--sch-cashier); }
.sch-th-btn { display: block; width: 100%; border: 0; background: none; font: inherit; color: inherit; text-align: left; padding: 8px 4px 7px; cursor: pointer; min-width: 0; }
.sch-g-name { font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.sch-g-sub { display: block; font-size: 11px; color: var(--ink-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sch-grid tbody td { border-bottom: 1px solid var(--hairline); padding: 4px 3px; vertical-align: top; }
.sch-grid tbody tr.is-we td { background: var(--sch-weekend); }
/* сегодня — вся строка зелёным, чтобы не сливалась с выходными (бежевыми) */
.sch-grid tbody tr.is-today td { background: var(--success-bg); }
.sch-day { padding: 7px 0 0 8px !important; }
.sch-d-num { font-size: 15px; font-weight: 700; line-height: 1.1; }
.sch-d-wd { font-size: 11px; color: var(--ink-muted); }
tr.is-we .sch-d-wd { color: var(--accent-deep); }
tr.is-today .sch-d-num { width: 26px; height: 26px; margin: -4px 0 2px -4px; border-radius: 50%; display: grid; place-items: center; background: var(--success); color: #fff; font-size: 14px; }
tr.is-today .sch-d-wd { color: var(--success); font-weight: 700; }
.sch-d-mark { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; font-size: 10px; line-height: 1; }
.sch-d-mark span { width: 16px; height: 16px; border-radius: 5px; display: grid; place-items: center; font-weight: 800; }
.sch-mk-goal { background: var(--success-bg); color: var(--success); }
.sch-mk-rec { background: var(--warning-bg); color: var(--warning); }
/* строка «сегодня» сама success-bg — метка «Ц» на ней белая с рамкой, иначе сливается */
tr.is-today .sch-mk-goal { background: var(--surface); box-shadow: inset 0 0 0 1px var(--success); }
.sch-d-paid { font-size: 10px; font-weight: 700; color: var(--success); margin-top: 3px; }
.sch-stack { display: flex; flex-direction: column; gap: 3px; }

.sch-ln { width: 100%; border: 0; border-radius: 8px; padding: 0; text-align: left; display: flex; flex-direction: column; font: inherit; color: inherit; background: transparent; overflow: hidden; }
.sch-baker .sch-pl { background: var(--sch-baker-bg); }
.sch-cashier .sch-pl { background: var(--sch-cashier-bg); }
.sch-pl { width: 100%; border: 0; margin: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; column-gap: 4px; padding: 4px 6px; min-height: 28px; }
.sch-pl + .sch-pl { border-top: 1px dashed rgba(127, 117, 100, .35); }
.sch-pl:focus-visible, .sch-ln:focus-visible, .sch-th-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.sch-pl-name { font-size: 12.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.sch-pl-time { font-size: 11px; color: var(--ink-muted); white-space: nowrap; }
.sch-pl-time.is-part { color: var(--ink); font-weight: 700; }
.sch-track { grid-column: 1 / -1; position: relative; height: 2px; margin: 3px 0 0; border-radius: 2px; background: rgba(127, 117, 100, .18); }
.sch-track i { position: absolute; top: 0; bottom: 0; border-radius: 2px; }
.sch-baker .sch-track i { background: var(--sch-baker); }
.sch-cashier .sch-track i { background: var(--sch-cashier); }
.sch-free { min-height: 28px; justify-content: center; padding: 0 6px; font-size: 11.5px; font-weight: 600; color: var(--warning); background: var(--warning-bg); box-shadow: inset 0 0 0 1px var(--sch-warning-line); cursor: pointer; }
.sch-free.is-soft { color: var(--ink-faint); background: transparent; box-shadow: inset 0 0 0 1px var(--hairline-strong); font-weight: 500; }
.sch-cell-plus { height: 22px; border: 1px dashed var(--hairline-strong); border-radius: 8px; background: transparent; color: var(--ink-faint); font: inherit; font-size: 15px; font-weight: 700; line-height: 1; cursor: pointer; }
.sch-cell-plus:hover, .sch-cell-plus:focus-visible { color: var(--accent-deep); border-color: var(--accent); }
.sch-pl, .sch-free { transition: opacity var(--dur), filter var(--dur); }
.sch-grid-wrap.is-focus .sch-pl:not(.is-hl), .sch-grid-wrap.is-focus .sch-free { opacity: .28; filter: grayscale(1); }
.sch-pl.is-hl { box-shadow: inset 0 0 0 2px var(--ink); border-radius: 8px; }
/* вид сотрудника (ADR-206): чужие смены, «свободно» и шапка не нажимаются */
.sch-pl.is-static, .sch-free.is-static, .sch-th-btn.is-static { cursor: default; }
.sch-grid-wrap.is-focus tr.has-hl .sch-d-num { text-decoration: underline; text-underline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .sch-pl, .sch-free { transition: none; } }

/* шиты */
.sch-grp-l { font-size: 11.5px; color: var(--ink-subtle); margin-top: 2px; }
.sch-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sch-chip { min-height: 36px; padding: 0 12px; border-radius: var(--r-full); border: 1px solid var(--hairline-strong); background: var(--surface); font: inherit; font-size: 13px; font-weight: 600; color: var(--ink); cursor: pointer; }
.sch-chip.is-on { background: var(--ink); color: var(--ink-inverse); border-color: var(--ink); }
.sch-chip:disabled { color: var(--ink-faint); cursor: default; }
.sch-chip.is-new { border-style: dashed; }
.sch-row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.sch-row2 .input { min-width: 0; }
.sch-who-box { border: 1px solid var(--hairline-strong); border-radius: var(--r-md); padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.sch-who-head { display: flex; justify-content: space-between; align-items: center; }
.sch-where { font-size: 13px; color: var(--ink); background: var(--surface-raised); border-radius: var(--r-md); padding: 10px 12px; line-height: 1.4; }
.sch-reason { font-size: 12px; color: var(--ink-muted); text-align: center; }
.sch-reason.is-error { color: var(--danger); }
/* Выдача суммой (AI-13082): подсказка под полем суммы — причина, почему выдать нельзя. */
[data-amount-hint].is-error { color: var(--danger); }
.sch-c-right .sch-c-s { text-align: right; }
.sch-warn { background: var(--warning-bg); color: var(--warning); border-radius: var(--r-md); padding: 10px 12px; font-size: 13px; line-height: 1.4; }

.sch-payline { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--surface-raised); border-radius: var(--r-md); padding: 8px 8px 8px 12px; font-size: 13.5px; min-height: 52px; }
.sch-payline .btn { flex-shrink: 0; }
.sch-c-s { display: block; font-size: 12px; color: var(--ink-muted); margin-top: 1px; font-weight: 400; }
.sch-paidbox { background: var(--success-bg); color: var(--success); border-radius: var(--r-md); padding: 10px 12px; font-weight: 600; font-size: 13.5px; display: flex; flex-direction: column; gap: 3px; }
.sch-pb-sub { font-weight: 500; font-size: 12.5px; opacity: .85; line-height: 1.35; }

.sch-calc { border: 1px solid var(--hairline-strong); border-radius: var(--r-md); padding: 4px 12px; }
.sch-c-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 8px 0; border-top: 1px solid var(--hairline); font-variant-numeric: tabular-nums; font-size: 14px; }
.sch-c-row:first-child, .sch-m-head + .sch-c-row { border-top: 0; }
.sch-c-row b { white-space: nowrap; }
.sch-c-row.is-total { font-size: 16px; font-weight: 800; }
.sch-c-row.is-ck { grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; cursor: pointer; }
.sch-c-row.is-ck input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--ink); }
.sch-c-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
/* Отменённая выдача (ADR-209 §8): в истории, но не выдана — сумма зачёркнута, строка приглушена. */
.sch-c-row.is-cancelled { color: var(--ink-muted); }
.sch-c-row.is-cancelled b { text-decoration: line-through; font-weight: 600; }
.sch-c-row .sch-c-s { overflow-wrap: anywhere; }
.sch-c-s.sch-c-cancel { color: var(--ink); }
.sch-c-right .sch-link { font-size: 12px; }
.sch-m-head { font-size: 12px; font-weight: 700; color: var(--ink-subtle); text-transform: uppercase; letter-spacing: .05em; padding: 10px 0 2px; }

.sch-rate { display: flex; align-items: center; gap: 6px; min-height: 48px; border: 1px solid var(--hairline-strong); background: var(--surface-raised); border-radius: var(--r-md); padding: 0 4px 0 12px; }
.sch-rate.is-edit { background: var(--surface); border-color: var(--ink); box-shadow: 0 0 0 3px var(--accent-soft); }
.sch-rate-text { flex: 1; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sch-rate-in { flex: 1; min-width: 0; height: 40px; border: 0; background: transparent; font: inherit; font-size: 16px; font-weight: 600; color: var(--ink); outline: none; font-variant-numeric: tabular-nums; }
.sch-rate-unit { font-size: 14px; color: var(--ink-muted); padding-right: 4px; white-space: nowrap; }
.sch-icon-btn { width: 40px; height: 40px; flex-shrink: 0; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink-muted); display: grid; place-items: center; cursor: pointer; }
.sch-icon-btn:hover { background: var(--surface-sunken); color: var(--ink); }
.sch-icon-btn.is-save { background: var(--ink); color: var(--ink-inverse); }

/* зарплата */
.sch-card { background: var(--surface); border: 1px solid var(--hairline-strong); border-radius: var(--r-lg); padding: 0 14px; }
.sch-card-empty { font-size: 13px; color: var(--ink-muted); padding: 14px 0; }
.sch-trow { display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 0; border: 0; border-top: 1px solid var(--hairline); background: none; font: inherit; color: inherit; text-align: left; font-variant-numeric: tabular-nums; cursor: pointer; }
.sch-trow:first-child { border-top: 0; }
.sch-t-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sch-t-name { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.sch-t-sub { font-size: 12px; color: var(--ink-muted); margin-top: 1px; }
.sch-t-h { font-weight: 700; font-size: 14px; text-align: right; white-space: nowrap; }
.sch-pill { font-size: 10.5px; font-weight: 600; color: var(--ink-muted); border: 1px solid var(--hairline-strong); border-radius: var(--r-full); padding: 1px 6px; white-space: nowrap; }
.sch-st-paid { font-size: 11.5px; font-weight: 600; border-radius: var(--r-full); padding: 2px 8px; background: var(--success-bg); color: var(--success); }
.sch-chev { color: var(--ink-faint); flex-shrink: 0; }
.sch-h3 { font-size: 15px; font-weight: 800; margin: 12px 0 4px; }
/* История выдач (ADR-209 §9): свёрнута, разворачивается заголовком — как «Состав накладной» */
.sch-hist { display: flex; flex-direction: column; gap: 8px; }
.sch-hist-toggle { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 48px; padding: 0 12px; border: 1px solid var(--hairline-strong); border-radius: var(--r-md); background: var(--surface-raised); color: var(--ink); font: inherit; font-size: 14px; font-weight: 600; text-align: left; cursor: pointer; }
.sch-hist-t { flex: 1; min-width: 0; }
.sch-hist-n { font-family: var(--font-mono); font-size: 12px; font-weight: 500; color: var(--ink-muted); padding: 2px 8px; background: var(--surface); border-radius: 6px; }
.sch-hist-caret { color: var(--ink-muted); flex-shrink: 0; transition: transform var(--dur-fast) var(--ease); }
.sch-hist-toggle[aria-expanded="true"] .sch-hist-caret { transform: rotate(180deg); }
.sch-hist-err { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--danger); }
.sch-hist-more { align-self: center; padding: 6px 0; }
.sch-hist-more:disabled { color: var(--ink-muted); cursor: default; }
.sch-calc.is-flat { border: 0; padding: 0; margin-bottom: 8px; }

/* «Моя зарплата»: три плитки */
.sch-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.sch-kpi { background: var(--surface); border: 1px solid var(--hairline-strong); border-radius: var(--r-lg); padding: 10px; min-width: 0; }
.sch-kpi-l { font-size: 11.5px; color: var(--ink-muted); }
.sch-kpi-v { font-size: 16px; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sch-kpi-v.is-small { font-size: 14px; }
.sch-kpi.is-due .sch-kpi-v { color: var(--warning); }
.sch-kpi.is-ok .sch-kpi-v { color: var(--success); }

/* Экран прижат к вьюпорту: прокручивается .app-scroll, шапка сетки липнет к
   его верху (как у остатков на складах) */
#screen-schedule.is-active.uses-shell { height: var(--vvh, 100dvh); max-height: var(--vvh, 100dvh); min-height: 0; }

/* AI-12840: шит смены — разделение, заметное «Убрать из смены» */
.sch-danger-text { color: var(--danger); }
.sch-danger-text:disabled { color: var(--ink-faint); }
.sch-seg button:disabled { opacity: .45; cursor: default; }

/* Крестик в клетке (AI-12840): строка смены — flex; время ужимается раньше имени;
   × визуально мелкий (ink-faint), зона нажатия 32×32 за счёт отступов строки. */
.sch-pl.has-x { display: flex; flex-wrap: wrap; align-items: center; column-gap: 3px; min-height: 32px; padding: 0 0 0 6px; }
.sch-pl.has-x .sch-pl-name { flex: 0 1 auto; min-width: 0; }
.sch-pl.has-x .sch-pl-time { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: clip; text-align: right; }
.sch-pl.has-x .sch-track { flex: 0 0 100%; margin: -6px 32px 5px 0; }
/* выданный день — крестика нет, и время не должно липнуть к краю: обычное поле справа */
.sch-x { flex: 0 0 32px; width: 32px; height: 32px; margin: 0; padding: 0 8px 0 0; border: 0; background: transparent; color: var(--ink-faint); font: inherit; font-size: 15px; line-height: 1; cursor: pointer; display: grid; place-items: center end; border-radius: 0 8px 8px 0; }
.sch-x:hover, .sch-x:focus-visible { color: var(--ink); }
.sch-x:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
/* выданный день (AI-12971): галочка в том же слоте 32 px, что крестик, — раскладка строки не меняется */
.sch-paid-ok { flex: 0 0 32px; width: 32px; height: 32px; padding: 0 8px 0 0; display: grid; place-items: center end; color: var(--success); font-size: 13px; font-weight: 700; line-height: 1; }

/* «Поставить ещё на дни» в шите смены (AI-13077): календарик месяца, 7 столбцов 1fr —
   на 320 px клетка ~38 px, без горизонтального скролла. Занятые дни не нажимаются:
   «уже в графике» — с точкой, «места заняты» — бледные; эта смена — в рамке. */
.sch-mcal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px 5px; }
.sch-mcal-w { text-align: center; font-size: 11px; font-weight: 600; color: var(--ink-muted); padding-bottom: 2px; }
.sch-mcal-d { position: relative; min-width: 0; height: 40px; border: 1.5px solid var(--ink-faint); border-radius: var(--r-sm); background: var(--surface); font: inherit; font-size: 14px; font-weight: 600; color: var(--ink); cursor: pointer; padding: 0; }
.sch-mcal-d.is-we { color: var(--accent-deep); }
/* Недоступные дни — без рамки и фона, только бледная цифра: нажимаемые (с рамкой) видны сразу (AI-13077, 15.10). */
.sch-mcal-d:disabled { cursor: default; background: transparent; border-color: transparent; color: var(--ink-faint); font-weight: 500; }
.sch-mcal-d.is-busy::after { content: ""; position: absolute; left: 50%; bottom: 5px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--ink-subtle); }
/* Выбранные и день самой смены выглядят одинаково (чёрные); день смены — ещё и с кольцом акцента. */
.sch-mcal-d.is-on, .sch-mcal-d.is-self, .sch-mcal-d.is-self:disabled { background: var(--ink); color: var(--ink-inverse); border-color: var(--ink); font-weight: 600; }
.sch-mcal-d.is-self { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.sch-mcal-d:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
