/* Стили страницы timesheet. Общие компоненты — в css/panel.css, сюда только своё. */

.tbl .ts-name { min-width: 240px; }

/* Поповер периода: две даты рядом, пресеты, «Показать». */
.ts-period { display: flex; flex-direction: column; gap: 12px; }
.ts-period__dates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.ts-presets { display: flex; flex-wrap: wrap; gap: 12px; }
.ts-period__foot { display: flex; justify-content: flex-end; }

/* Шторка «Смены по дням». */
.ts-days { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* Уход: время и как поставлен (сам / авто при закрытии смены / авто по времени). */
.ts-leave { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }

/* ── Гибкий график и часы (FLEX_CONTRACT.md §7, §12.2) ── */

.ts-tabs { margin-bottom: 16px; }
.ts-badges { display: inline-flex; flex-wrap: wrap; gap: 4px; }

/* Правила учёта и легенда сетки — под таблицей, мелко, но читаемо. */
.ts-rules, .ts-legend {
  display: flex; flex-wrap: wrap; align-items: flex-start; gap: 4px 16px;
  margin-top: 12px; color: var(--color-text-2);
}
.ts-rules .icon { flex: none; margin-top: 2px; }
.ts-rules span { flex: 1 1 240px; min-width: 0; overflow-wrap: anywhere; }
.ts-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.ts-mark { display: inline-block; min-width: 12px; font-weight: 700; color: var(--color-accent-ink); text-align: center; }

/* Сетка «дни × сотрудники». Своя прокрутка по обеим осям — иначе липкая
   шапка не держится: обёртка с overflow-x стала бы её контейнером. */
.ts-grid-wrap { max-height: calc(100vh - 260px); min-height: 240px; overflow: auto; overscroll-behavior: contain; }
.ts-grid-wrap:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -2px; }
.ts-grid { width: max-content; min-width: 100%; }
.ts-grid th, .ts-grid td { height: 48px; padding: 0 4px; border-bottom: 1px solid var(--color-border); }
.ts-grid tbody tr:last-child > * { border-bottom: 0; }
.ts-grid .ts-g__name {
  position: sticky; left: 0; z-index: 2; min-width: 200px; max-width: 240px; padding: 0 12px 0 16px;
  background: var(--color-surface); text-align: left; border-right: 1px solid var(--color-border);
  font-weight: 600; color: var(--color-text); white-space: normal; overflow-wrap: anywhere;
}
.ts-grid thead .ts-g__name { z-index: 3; color: var(--color-text-2); }
.ts-grid .ts-g__d { min-width: 56px; text-align: center; line-height: 16px; }
.ts-g__dn { display: block; color: var(--color-text); }
.ts-g__wd { display: block; font-weight: 400; }
.ts-grid .is-today { background: var(--color-accent-soft); }
.ts-grid thead .is-today { background: var(--color-accent-soft); }
.ts-grid .ts-g__c { text-align: center; }
.ts-grid .ts-g__c.is-empty { cursor: pointer; }
@media (hover: hover) { .ts-grid .ts-g__c.is-empty:hover { background: var(--color-bg); } }
.ts-grid .ts-g__sum { min-width: 72px; padding: 0 12px; white-space: nowrap; }
.ts-grid tbody tr[aria-current="true"] > * { background: var(--color-accent-soft); }

.ts-cell {
  position: relative; display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  width: 52px; height: 44px; padding: 0; border: 0; border-radius: var(--radius-xs);
  background: transparent; color: var(--color-text); font: inherit; font-variant-numeric: tabular-nums; cursor: pointer;
}
@media (hover: hover) { .ts-cell:hover { background: var(--color-surface-2); } }
.ts-cell.is-decision { background: var(--color-err-soft); color: var(--color-err); }
.ts-cell__v { line-height: 18px; }
.ts-cell__m { line-height: 16px; font-weight: 700; color: var(--color-accent-ink); letter-spacing: 1px; }
.ts-cell.is-decision .ts-cell__m { color: var(--color-err); }

/* Шторка: сводка, действия, отметки по дням. */
.ts-days__bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.ts-days__daytotal { color: var(--color-text-2); margin-top: 8px; }
.ts-sess-list { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.ts-sess-day { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.ts-sess-day__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.ts-sess-day__head h3 { font: 600 16px/24px var(--font-display); }
.ts-sess-day__sum { color: var(--color-text-2); font-variant-numeric: tabular-nums; }
.ts-sess {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 4px 12px;
  padding: 12px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-surface);
}
.ts-sess.is-decision { border-color: var(--color-err); }
.ts-sess.is-voided { background: var(--color-surface-2); }
.ts-sess.is-voided .ts-sess__time { color: var(--color-text-2); text-decoration: line-through; }
.ts-sess__main { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ts-sess__time { font-weight: 600; font-variant-numeric: tabular-nums; }
.ts-sess__old { color: var(--color-text-2); font-weight: 400; }
.ts-sess__sub { color: var(--color-text-2); overflow-wrap: anywhere; }
.ts-sess__hours { padding-top: 2px; font-variant-numeric: tabular-nums; }
.ts-sess__acts { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px 8px; margin: 4px -8px -4px; }

/* Модалки правки и история. */
.ts-adj { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.ts-adj__intro { color: var(--color-text-2); overflow-wrap: anywhere; }
.ts-hist__list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 12px; }
.ts-hist__item { display: flex; flex-direction: column; gap: 4px; padding-bottom: 12px; border-bottom: 1px solid var(--color-border); }
.ts-hist__item:last-child { border-bottom: 0; padding-bottom: 0; }
.ts-hist__head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; }
.ts-hist__reason { overflow-wrap: anywhere; }

@media (max-width: 767px) {
  .ts-grid-wrap { max-height: calc(100vh - 200px); }
  .ts-grid .ts-g__name { min-width: 128px; max-width: 150px; padding-left: 12px; }
}
@media (forced-colors: active) {
  .ts-grid tbody tr[aria-current="true"] > * { outline: 2px solid Highlight; outline-offset: -2px; }
  .ts-cell.is-decision { border: 1px solid CanvasText; }
}
