/* Оттепель — интерфейс по Apple HIG.
   Тема следует настройке Telegram / системы (без ручного переключателя — dark-mode.md › Best practices).
   Все пары текст/фон ≥ 4,5:1 в обеих темах. Элементы управления ≥ 44×44. Текст ≥ 12 px, поля ввода 16 px. */

* { box-sizing: border-box; }

:root {
  /* Светлая: «талая вода» — холодный бирюзовый акцент; мёд — только премия (дни ×1,5, премии) */
  --bg: #F2F4F3;
  --surface: #FFFFFF;
  --surface-alt: #E8ECEB;
  --border: #D5DCDB;
  --ink: #172024;
  --ink-muted: #56636A;
  --accent: #1C6875;
  --on-accent: #FFFFFF;
  --accent-soft: #DDEEF0;
  --danger: #B3402E;
  --danger-bg: #F8E4E0;
  --gold: #855C12;
  --gold-bg: #F6EDD9;
  --gold-border: #E3D2A8;
  --green: #2D7550;
  --green-bg: #E0F0E6;
  --trainee-bg: #EEF2F2;
  --on-fill: #FFFFFF;
  --tab-bg: rgba(248, 249, 249, 0.94);
  --overlay: rgba(10, 16, 18, 0.42);
  --shadow: 0 1px 2px rgba(16, 24, 28, 0.06);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-rounded: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --tab-h: 56px;
  --safe-top: max(env(safe-area-inset-top, 0px), var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  color-scheme: light;
}

/* Пока скрипт не выставил тему — следуем системе */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111517; --surface: #1A2023; --surface-alt: #242B2F; --border: #313A3F;
    --ink: #EDF1F2; --ink-muted: #9CA8AE; --accent: #6CC0CC; --on-accent: #0D1A1D; --accent-soft: #183338;
    --danger: #F08C7C; --danger-bg: #3A2320; --gold: #E3B866; --gold-bg: #33291A; --gold-border: #5A4826;
    --green: #7FCB9C; --green-bg: #193126; --on-fill: #10161A; --trainee-bg: #20272B;
    --tab-bg: rgba(23, 28, 31, 0.94); --overlay: rgba(0, 0, 0, 0.55); --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111517; --surface: #1A2023; --surface-alt: #242B2F; --border: #313A3F;
  --ink: #EDF1F2; --ink-muted: #9CA8AE; --accent: #6CC0CC; --on-accent: #0D1A1D; --accent-soft: #183338;
  --danger: #F08C7C; --danger-bg: #3A2320; --gold: #E3B866; --gold-bg: #33291A; --gold-border: #5A4826;
  --green: #7FCB9C; --green-bg: #193126; --on-fill: #10161A; --trainee-bg: #20272B;
  --tab-bg: rgba(23, 28, 31, 0.94); --overlay: rgba(0, 0, 0, 0.55); --shadow: none;
  color-scheme: dark;
}

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding-inline: max(16px, env(safe-area-inset-left, 0px));
  padding-block: calc(var(--safe-top) + 12px) calc(var(--tab-h) + var(--safe-bottom) + 28px);
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 10px; }
[hidden] { display: none !important; }

.ico { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Экраны ---------- */
#app { max-width: 560px; margin: 0 auto; }
.screen { display: none; }
.screen.active { display: grid; gap: 16px; align-content: start; }
.large-title { font: 700 30px/1.15 var(--font); letter-spacing: -0.02em; margin: 8px 0 0; text-wrap: balance; }
.screen-sub { margin: -10px 0 0; color: var(--ink-muted); font-size: 15px; }
.stack { display: grid; gap: 20px; }
.empty { color: var(--ink-muted); font-size: 15px; text-align: center; padding: 28px 12px; background: var(--surface); border-radius: 14px; margin: 0; }
.loading { color: var(--ink-muted); font-size: 15px; text-align: center; padding: 28px 0; margin: 0; }
.error-box { background: var(--danger-bg); color: var(--danger); border-radius: 14px; padding: 14px 16px; font-size: 15px; display: grid; gap: 10px; }
.error-box button { justify-self: start; min-height: 44px; padding: 0 16px; border: 0; border-radius: 10px; background: var(--danger); color: var(--on-fill); font-weight: 600; }

/* Кнопка «назад» вне Telegram (в Telegram — системная в шапке) */
.back-btn { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding: 0 8px 0 0; margin: 0 0 -8px -6px; border: 0; background: none; color: var(--accent); font-size: 17px; justify-self: start; }

/* ---------- Нижняя панель вкладок ---------- */
.tab-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 4px max(8px, env(safe-area-inset-left, 0px)) calc(4px + var(--safe-bottom));
  background: var(--tab-bg);
  border-top: 1px solid var(--border);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  backdrop-filter: saturate(160%) blur(18px);
}
.tab {
  min-height: 48px; border: 0; background: none; color: var(--ink-muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.01em; border-radius: 10px;
}
.tab .ico { width: 24px; height: 24px; }
.tab.active { color: var(--accent); }
.tab.active .ico { stroke-width: 2.3; }
@media (prefers-reduced-transparency: reduce) { .tab-bar { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; } }

/* ---------- Списки в стиле iOS ---------- */
.group { display: grid; gap: 6px; }
.group-title { font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-muted); padding: 0 4px; margin: 0; }
.list { background: var(--surface); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.list > * + * { border-top: 1px solid var(--border); }

.row { display: flex; align-items: center; min-height: 60px; }
.row-main {
  flex: 1; min-width: 0; min-height: 60px; display: flex; align-items: center; gap: 12px;
  padding: 10px 4px 10px 16px; border: 0; background: none; text-align: left;
}
.row-main:active, .card-head:active, .action-btn:active, .upload-btn:active { background: var(--surface-alt); }
.row-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.row-title { font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-sub { font-size: 15px; color: var(--ink-muted); overflow-wrap: break-word; }
.nowrap { white-space: nowrap; }
.row-value { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

.icon-btn {
  width: 44px; height: 44px; flex: none; margin-right: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 22px; background: none; color: var(--ink-muted);
}
.icon-btn:active { background: var(--surface-alt); }

.badge { font-size: 12px; font-weight: 700; line-height: 1; padding: 4px 8px; border-radius: 20px; background: var(--ink-muted); color: var(--surface); white-space: nowrap; }
.badge.now { background: var(--green); }

/* Смены в карточке сотрудника: подписи вместо одного цвета */
.shifts { display: flex; gap: 6px; flex: none; }
.shift { min-width: 46px; display: grid; justify-items: center; padding: 4px 6px; border-radius: 10px; background: var(--surface-alt); }
.shift small { font-size: 12px; color: var(--ink-muted); line-height: 1.2; }
.shift b { font-size: 17px; font-variant-numeric: tabular-nums; line-height: 1.2; }

/* ---------- Кнопки ---------- */
.primary-btn, .secondary-btn {
  width: 100%; min-height: 50px; padding: 0 16px; border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 17px; font-weight: 600;
}
.primary-btn { border: 0; background: var(--accent); color: var(--on-accent); }
.secondary-btn { border: 0; background: var(--accent-soft); color: var(--accent); }
.primary-btn:active:not(:disabled), .secondary-btn:active:not(:disabled) { filter: brightness(0.92); }
.primary-btn:disabled, .secondary-btn:disabled { background: var(--surface-alt); color: var(--ink-muted); cursor: default; }
.primary-btn.done { background: var(--green); color: var(--on-fill); }
.secondary-btn.done { background: var(--green-bg); color: var(--green); }

/* ---------- Месяц / календарь ---------- */
.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--surface); border-radius: 14px; padding: 4px; box-shadow: var(--shadow); }
.month-nav.compact { background: var(--surface-alt); box-shadow: none; }
.nav-btn { width: 44px; height: 44px; border: 0; border-radius: 10px; background: none; color: var(--accent); display: inline-flex; align-items: center; justify-content: center; }
.nav-btn:active { background: var(--surface-alt); }
.month-label { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }

.screen > *, .sheet-body > * { min-width: 0; }
.weekdays { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; text-align: center; font-size: 12px; font-weight: 600; color: var(--ink-muted); margin-bottom: -10px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.calendar-day {
  height: 46px; min-width: 0; padding: 0; border: 0; border-radius: 12px;
  background: var(--surface); color: var(--ink); font-size: 17px; font-variant-numeric: tabular-nums;
  display: flex; align-items: center; justify-content: center; position: relative;
}
.calendar-day.today { box-shadow: inset 0 0 0 2px var(--accent); }
.calendar-day.marked { background: var(--accent); color: var(--on-accent); font-weight: 700; }
.calendar-day.marked::after { content: ""; position: absolute; bottom: 6px; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.calendar-day.empty { visibility: hidden; }
.calendar-day.pending { opacity: 0.6; }
/* Отпуск: период 1 — заливка, период 2 — рамка с ромбом. Различаются формой, не только цветом */
.calendar-day.p1 { background: var(--accent); color: var(--on-accent); font-weight: 700; }
.calendar-day.p2 { background: var(--surface-alt); color: var(--ink); font-weight: 700; box-shadow: inset 0 0 0 2px var(--ink-muted); }
.calendar-day.p2::after { content: ""; position: absolute; top: 5px; right: 5px; width: 6px; height: 6px; background: var(--ink-muted); transform: rotate(45deg); }
.calendar-day.p1.p2 { background: var(--accent); color: var(--on-accent); }

.mark { display: inline-block; width: 12px; height: 12px; margin-right: 8px; vertical-align: -1px; flex: none; }
.mark.p1 { border-radius: 4px; background: var(--accent); }
.mark.p2 { width: 10px; height: 10px; background: var(--ink-muted); transform: rotate(45deg); margin-left: 1px; }

.summary-card { background: var(--surface); border-radius: 14px; padding: 14px 16px; font-size: 15px; color: var(--ink-muted); box-shadow: var(--shadow); }
.summary-card b { color: var(--ink); font-size: 17px; }

/* ---------- Табель / премия: раскрывающиеся карточки ---------- */
.total-card { background: var(--surface); border-radius: 14px; padding: 14px 16px; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; box-shadow: var(--shadow); }
.total-card span { color: var(--ink-muted); font-size: 15px; }
.total-card b { font-size: 22px; font-variant-numeric: tabular-nums; }

.card { background: var(--surface); }
.card.trainee { background: var(--trainee-bg); }
.card-head {
  width: 100%; min-height: 60px; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px 10px 16px; border: 0; background: none; text-align: left;
}
.card-head .chev { width: 20px; height: 20px; color: var(--ink-muted); transition: transform .2s; }
.card.open .card-head .chev { transform: rotate(180deg); }
.card-total { font-size: 17px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.card-detail { display: none; padding: 0 16px 14px; }
.card.open .card-detail { display: grid; gap: 2px; }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 40px; font-size: 15px; }
.kv > span:first-child { color: var(--ink-muted); min-width: 0; display: flex; align-items: center; }
.kv > span:last-child, .kv b { font-variant-numeric: tabular-nums; text-align: right; }
.kv.strong { font-weight: 600; font-size: 17px; }
.kv.strong > span:first-child { color: var(--ink); }
.kv.sep { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 6px; }
.card.trainee .kv.sep { border-top-color: var(--border); }
.period-summary .kv { padding: 0 16px; min-height: 48px; }

.money-input {
  width: 128px; min-height: 44px; padding: 0 12px; text-align: right;
  font-size: 16px; font-variant-numeric: tabular-nums;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--ink);
}
.card.trainee .money-input { background: var(--surface); }
.save-state { font-size: 13px; color: var(--green); min-height: 18px; text-align: right; }
.save-state.err { color: var(--danger); }

/* Статистика: полоса доли + текст */
.share { height: 6px; border-radius: 3px; background: var(--surface-alt); overflow: hidden; margin-top: 6px; }
.share i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

/* ---------- Формы ---------- */
.field { display: grid; gap: 6px; }
.field-label { font-size: 15px; font-weight: 600; color: var(--ink); }
.field-input {
  width: 100%; min-height: 48px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--ink);
  font-size: 16px; /* меньше 16 px iOS зумит страницу при фокусе */
}
.field-input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.field-input.invalid { border-color: var(--danger); }
select.field-input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-muted) 50%), linear-gradient(135deg, var(--ink-muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
.field-hint { margin: 0; font-size: 13px; color: var(--ink-muted); }
.field-hint.center { text-align: center; margin-top: -8px; }
.field-error { margin: -2px 0 0; min-height: 18px; font-size: 13px; color: var(--danger); visibility: hidden; }
.field-error.on { visibility: visible; }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; padding: 3px; background: var(--surface-alt); border-radius: 12px; }
.seg { min-height: 44px; border: 0; border-radius: 9px; background: none; color: var(--ink); font-size: 15px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
.seg[aria-checked="true"] { background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* Переключатель iOS */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 6px 12px 6px 16px; font-size: 17px; cursor: pointer; }
.switch { appearance: none; -webkit-appearance: none; flex: none; width: 51px; height: 31px; border-radius: 16px; background: var(--surface-alt); position: relative; margin: 0; cursor: pointer; transition: background .2s; box-shadow: inset 0 0 0 1px var(--border); }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #FFFFFF; box-shadow: 0 2px 4px rgba(0,0,0,.25); transition: transform .2s; }
.switch:checked { background: var(--green); box-shadow: none; }
.switch:checked::after { transform: translateX(20px); }

/* ---------- Шторки ---------- */
.modal-overlay { position: fixed; inset: 0; z-index: 100; background: var(--overlay); display: flex; align-items: flex-end; justify-content: center; opacity: 0; pointer-events: none; transition: opacity .2s; }
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal-sheet {
  width: 100%; max-width: 560px; max-height: calc(100% - var(--safe-top) - 24px);
  background: var(--bg); color: var(--ink); border-radius: 14px 14px 0 0;
  display: flex; flex-direction: column;
  transform: translateY(100%); transition: transform .28s cubic-bezier(.2,.8,.2,1);
}
.modal-overlay.open .modal-sheet { transform: translateY(0); }
.modal-sheet.dragging { transition: none; }
.sheet-handle { display: flex; justify-content: center; padding: 6px 0 2px; touch-action: none; }
.grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--border); }
.sheet-bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 0 8px 6px; touch-action: none; }
.sheet-bar h2 { margin: 0; font-size: 17px; font-weight: 600; text-align: center; }
.bar-btn { min-height: 44px; padding: 0 8px; border: 0; background: none; color: var(--accent); font-size: 17px; justify-self: start; }
.bar-btn.strong { font-weight: 600; justify-self: end; }
.bar-btn:disabled { color: var(--ink-muted); cursor: default; }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; padding: 8px 16px calc(20px + var(--safe-bottom)); display: grid; gap: 18px; }

.action-sheet { width: 100%; max-width: 560px; padding: 0 8px calc(8px + var(--safe-bottom)); display: grid; gap: 8px; transform: translateY(100%); transition: transform .25s cubic-bezier(.2,.8,.2,1); }
.modal-overlay.open .action-sheet { transform: translateY(0); }
.action-group { background: var(--surface); border-radius: 14px; overflow: hidden; }
.action-group > * + * { border-top: 1px solid var(--border); }
.action-title { padding: 14px 16px; text-align: center; font-size: 13px; color: var(--ink-muted); }
.action-btn { width: 100%; min-height: 56px; border: 0; background: var(--surface); color: var(--accent); font-size: 19px; }
.action-btn.danger { color: var(--danger); }
.action-btn.cancel { border-radius: 14px; font-weight: 600; }

/* ---------- Тост ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-bottom) + 14px); z-index: 120;
  transform: translateX(-50%); max-width: calc(100% - 32px);
  background: var(--ink); color: var(--bg); border-radius: 14px; padding: 12px 16px;
  font-size: 15px; font-weight: 600; box-shadow: 0 6px 24px rgba(0,0,0,.2);
  display: flex; align-items: center; gap: 8px;
}
.toast.err { background: var(--danger); color: var(--on-fill); }

/* ---------- Премия ---------- */
.upload-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1px; background: var(--border); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.upload-card { min-width: 0; display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; background: var(--surface); min-height: 64px; }
.upload-icon { width: 36px; height: 36px; flex: none; border-radius: 10px; background: var(--surface-alt); color: var(--ink-muted); display: flex; align-items: center; justify-content: center; }
.upload-card.drop { background: var(--accent-soft); }
.upload-card.ready .upload-icon { background: var(--green-bg); color: var(--green); }
.upload-body { flex: 1; min-width: 0; }
.upload-title { font-size: 17px; font-weight: 600; }
.upload-filename { font-size: 13px; color: var(--ink-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-card.ready .upload-filename { color: var(--green); }
.upload-btn { min-height: 44px; padding: 0 14px; border: 0; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-size: 15px; font-weight: 600; flex: none; }

.pr-warn { background: var(--danger-bg); color: var(--danger); border-radius: 14px; padding: 14px 16px; font-size: 15px; line-height: 1.45; display: grid; gap: 12px; }
.pr-warn button { min-height: 44px; border: 0; border-radius: 10px; background: var(--danger); color: var(--on-fill); font-size: 15px; font-weight: 600; }

#prem-result { display: grid; gap: 16px; }
#prem-result:empty { display: none; }
.pr-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.pr-sum:last-child:nth-child(odd) { grid-column: 1 / -1; }
.pr-sum { background: var(--surface); border-radius: 14px; padding: 12px 14px; display: grid; gap: 4px; box-shadow: var(--shadow); }
.pr-sum-label { font-size: 13px; color: var(--ink-muted); font-weight: 600; }
.pr-sum-value { font: 700 24px/1.15 var(--font-rounded); letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.pr-sum-sub { font-size: 13px; color: var(--ink-muted); }
.pr-total { display: flex; justify-content: space-between; align-items: baseline; padding: 0 4px; font-size: 15px; color: var(--ink-muted); }
.pr-total b { color: var(--ink); font-size: 17px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pr-revenue { background: var(--surface); border-radius: 14px; padding: 12px 16px; display: grid; gap: 2px; box-shadow: var(--shadow); }
.pr-revenue .kv { min-height: 32px; }

/* Плитки плана — главный элемент экрана */
.pr-plans { display: grid; gap: 8px; }
.pr-tile { background: var(--surface); border-radius: 14px; padding: 14px 16px 4px; display: grid; gap: 8px; box-shadow: var(--shadow); }
.pr-tile-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.pr-tile-label { font-size: 17px; font-weight: 600; }
.pr-tile-label small { display: block; font-size: 13px; font-weight: 400; color: var(--ink-muted); }
.pr-pct { font: 700 15px/1 var(--font-rounded); padding: 6px 10px; border-radius: 20px; font-variant-numeric: tabular-nums; }
.pr-pct.ok { background: var(--green-bg); color: var(--green); }
.pr-pct.no { background: var(--surface-alt); color: var(--ink-muted); }
.pr-bar { height: 8px; background: var(--surface-alt); border-radius: 4px; overflow: hidden; }
.pr-bar-fill { height: 100%; border-radius: 4px; background: var(--green); transition: width .3s; }
.pr-bar-fill.short { background: var(--ink-muted); }
.pr-nums { display: flex; justify-content: space-between; gap: 10px; font-size: 15px; font-variant-numeric: tabular-nums; }
.pr-nums span:first-child b { font-weight: 700; }
.pr-status { color: var(--ink-muted); }
.pr-status.ok { color: var(--green); font-weight: 600; }
.pr-tile .switch-row { padding: 4px 0; border-top: 1px solid var(--border); font-size: 15px; min-height: 52px; }

.pr-note { font-size: 13px; color: var(--green); padding-top: 6px; }
.pr-lines .kv span:first-child { display: block; }
.pr-lines .kv label { display: block; }
.pr-lines .kv small { display: block; font-size: 13px; color: var(--ink-muted); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ===================== v3: дополнения ===================== */

/* «Другое»: строки с иконкой */
.row-icon { width: 34px; height: 34px; flex: none; border-radius: 9px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.chev-r { width: 20px; height: 20px; color: var(--ink-muted); margin-right: 8px; }

/* Смены: дни ×1,5 */
.shift .star { font-size: 12px; color: var(--gold); font-weight: 700; line-height: 1.1; }
.shift.has-star { background: var(--gold-bg); }

/* Календарь: вес дня, выходные, закрытые дни */
.weekdays .we { color: var(--accent); }
.calendar-day.weekend { background: var(--accent-soft); }
.calendar-day.half { background: var(--gold); color: var(--on-fill); font-weight: 700; flex-direction: column; gap: 0; line-height: 1.05; }
.calendar-day.half small { font-size: 11px; font-weight: 700; }
.calendar-day.half::after { display: none; }
.calendar-day.locked { opacity: 0.8; cursor: not-allowed; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--ink-muted); margin-top: -6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 5px; font-style: normal; }
.legend .lg-day { background: var(--accent); }
.legend .lg-half { width: auto; padding: 0 4px; background: var(--gold); color: var(--on-fill); font-size: 11px; font-weight: 700; }
.legend .lg-we { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--border); }
.lock-note { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--ink-muted); background: var(--surface-alt); border-radius: 12px; padding: 10px 14px; }
.lock-note .ico { width: 18px; height: 18px; }

/* Табель: плитки и итоги */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tile { background: var(--surface); border-radius: 14px; padding: 12px 14px; display: grid; gap: 2px; box-shadow: var(--shadow); }
.tile span { font-size: 13px; font-weight: 600; color: var(--ink-muted); }
.tile b { font: 700 22px/1.2 var(--font-rounded); font-variant-numeric: tabular-nums; }
.tile small { font-size: 13px; color: var(--ink-muted); }
.subtotal { display: flex; justify-content: space-between; gap: 12px; padding: 12px 16px; font-size: 15px; font-weight: 600; background: var(--surface-alt); }
.subtotal span:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; }
.floor-total { display: flex; justify-content: space-between; gap: 12px; padding: 4px 4px 0; font-size: 17px; font-weight: 700; }
.floor-total span:last-child { font-variant-numeric: tabular-nums; }
.sublabel { font-size: 13px; font-weight: 600; color: var(--ink-muted); padding: 10px 16px 4px; background: var(--surface); }
.ts-head { flex-direction: column; align-items: stretch; gap: 6px; }
.ts-top, .ts-bottom { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ts-top .row-title { flex: 1; min-width: 0; }
.ts-bottom .row-sub { flex: 1; min-width: 0; }
.kv > span:last-child { white-space: nowrap; }
.btn-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.btn-pair .secondary-btn, .btn-pair .primary-btn { font-size: 15px; padding: 0 10px; }

/* Утверждение */
.approve-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; min-height: 64px; }
.approve-row .row-text { flex: 1; }
.status-pill { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 700; padding: 3px 8px; border-radius: 20px; background: var(--surface-alt); color: var(--ink-muted); }
.status-pill.ok { background: var(--green-bg); color: var(--green); }
.status-pill .ico { width: 14px; height: 14px; stroke-width: 2.4; }
.small-btn { min-height: 44px; padding: 0 14px; border: 0; border-radius: 10px; font-size: 15px; font-weight: 600; background: var(--accent); color: var(--on-accent); flex: none; }
.small-btn.ghost { background: var(--accent-soft); color: var(--accent); }
.small-btn:disabled { background: var(--surface-alt); color: var(--ink-muted); }
.note { font-size: 13px; color: var(--ink-muted); padding: 0 4px; margin: 0; }

/* Премия: статус месяца */
.prem-state { background: var(--surface); border-radius: 14px; padding: 14px 16px; display: grid; gap: 12px; box-shadow: var(--shadow); }
.prem-state p { margin: 0; font-size: 15px; color: var(--ink-muted); }
.prem-state .row-title { font-size: 17px; }
.switch:disabled { opacity: .5; cursor: default; }
.money-input:disabled { background: var(--surface-alt); color: var(--ink-muted); }

/* План */
.plan-month .kv { padding: 0 16px; min-height: 56px; }
.plan-month .kv label { color: var(--ink); font-size: 15px; min-width: 0; }
.plan-month .money-input { width: 140px; }
.plan-month.unfilled .group-title::after { content: " · не заполнен"; text-transform: none; letter-spacing: 0; font-weight: 400; }

/* ===================== v4 ===================== */

/* Экран входа / нет доступа */
.gate { min-height: calc(100vh - 80px); display: grid; place-items: center; }
.gate-card { width: 100%; max-width: 400px; display: grid; gap: 14px; text-align: center; justify-items: center; }
.gate-card h1 { margin: 0; font: 700 30px/1.15 var(--font); }
.gate-card p { margin: 0; color: var(--ink-muted); font-size: 17px; }
.gate-logo { width: 64px; height: 64px; border-radius: 18px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; }
.gate-logo .ico { width: 30px; height: 30px; }
#gate-login { width: 100%; display: grid; gap: 12px; justify-items: center; margin-top: 8px; }
.tg-widget { min-height: 48px; display: grid; place-items: center; }
body.gated .tab-bar, body.gated #app { display: none; }

/* Табель: карточка утверждения в стиле Премии */
.approve-card .stage { display: flex; align-items: center; gap: 12px; min-height: 56px; }
.approve-card .stage + .stage { border-top: 1px solid var(--border); padding-top: 10px; }
.approve-card .stage .row-text { flex: 1; min-width: 0; }
.caption { font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-muted); margin: 4px 0 -4px; }

/* Статистика */
.stat-note { background: var(--gold-bg); color: var(--ink); border-radius: 12px; padding: 10px 14px; font-size: 15px; margin: 0; }

/* План: месяц */
.plan-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 4px; }
.plan-head .group-title { padding: 0; }
.plan-month .kv { padding: 8px 16px; min-height: 64px; align-items: center; }
.plan-month .kv > label { display: grid; gap: 4px; flex: 1; min-width: 0; }
.plan-fact { font-size: 13px; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.plan-fact b { font-weight: 700; }
.plan-fact .ok { color: var(--green); font-weight: 700; }
.plan-fact .no { color: var(--danger); font-weight: 700; }
.plan-bar { height: 5px; border-radius: 3px; background: var(--surface-alt); overflow: hidden; max-width: 200px; }
.plan-bar i { display: block; height: 100%; background: var(--green); }
.plan-bar i.short { background: var(--ink-muted); }
.plan-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 0 4px; font-size: 13px; color: var(--ink-muted); min-height: 20px; }
.plan-actions { display: flex; gap: 8px; }
.money-input:disabled { -webkit-text-fill-color: var(--ink); opacity: 1; background: transparent; border-color: transparent; }
.ok-text { color: var(--green); }
.stage .status-pill { margin-top: 2px; justify-self: start; width: fit-content; }
.status-pill { white-space: nowrap; }

/* ===================== v21: правки по аудиту HIG ===================== */

/* Пустые контейнеры табеля не добавляют отступов */
#ts-tiles:empty, #ts-approvals:empty { display: none; }

/* Персонал: на узком экране смены уходят под имя, должность и ставка видны целиком */
#employees-list .row-main { flex-wrap: wrap; row-gap: 8px; }
#employees-list .row-main > .row-text { flex: 1 1 150px; }
.ts-bottom { flex-wrap: wrap; row-gap: 6px; }
.ts-bottom .row-sub { flex: 1 1 140px; }

/* Табель: в карточке утверждения кнопка переносится, а не выталкивает статус за край */
.approve-card .stage { flex-wrap: wrap; row-gap: 8px; }
.approve-card .stage .row-text { flex: 1 1 160px; }
.approve-card .stage .small-btn { margin-left: auto; }

/* Отклик на нажатие */
.tab:active, .bar-btn:active:not(:disabled), .back-btn:active, .seg:active { opacity: 0.55; }
.small-btn:active:not(:disabled), .upload-btn:active, .pr-warn button:active, .error-box button:active { filter: brightness(0.92); }

/* Уведомления: нет связи — красный значок рядом с текстом «Не доходят» */
.row.warn .row-icon { background: var(--danger-bg); color: var(--danger); }
.row-main[aria-busy="true"] { cursor: progress; }

/* Широкий экран (браузер на компьютере): вкладки по центру, подсветка под мышью */
@media (min-width: 700px) {
  .tab-bar { grid-template-columns: repeat(5, minmax(0, 112px)); justify-content: center; }
}
@media (hover: hover) and (pointer: fine) {
  .row-main:hover, .card-head:hover, .action-btn:hover, .upload-btn:hover, .icon-btn:hover, .nav-btn:hover { background: var(--surface-alt); }
  .tab:hover { color: var(--ink); }
  .tab.active:hover { color: var(--accent); }
  .primary-btn:hover:not(:disabled), .secondary-btn:hover:not(:disabled), .small-btn:hover:not(:disabled) { filter: brightness(0.95); }
  .bar-btn:hover:not(:disabled), .back-btn:hover { opacity: 0.75; }
  .calendar-day:not(.empty):not(.locked):hover { box-shadow: inset 0 0 0 2px var(--border); }
  .calendar-day.today:hover { box-shadow: inset 0 0 0 2px var(--accent); }
  .calendar-day.p2:hover { box-shadow: inset 0 0 0 2px var(--ink-muted); }
}

/* Повышенный контраст в настройках системы */
@media (prefers-contrast: more) {
  :root { --ink-muted: #3E4A50; --border: #8D999E; }
  :root[data-theme="dark"] { --ink-muted: #C6D0D4; --border: #67747A; }
  .calendar-day.locked { opacity: 1; }
  .tab-bar { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .list, .month-nav, .tile, .pr-sum, .pr-tile, .prem-state, .total-card, .summary-card { box-shadow: 0 0 0 1px var(--border); }
}

/* Узкий экран (320): суммы в плитках не разрываются, плитки встают в столбик */
.tile b, .pr-sum-value { white-space: nowrap; }
@media (max-width: 359px) {
  .tiles, .pr-summary { grid-template-columns: minmax(0, 1fr); }
}
/* Отпуск: даты периода уходят на вторую строку, а не ломают подпись «Период 1» */
.period-summary .kv { flex-wrap: wrap; row-gap: 0; }
.period-summary .kv > span:first-child { flex: none; white-space: nowrap; }
.period-summary .kv > span:last-child { margin-left: auto; }
/* Шторка на невысоком экране: блоки не сжимаются до нуля, тело шторки прокручивается */
.sheet-body { grid-auto-rows: max-content; align-content: start; }

/* Выручка (Статистика) */
.rev-wd { color: var(--ink-muted); font-weight: 400; margin-left: 4px; }
.rev-miss { color: var(--danger); }
.rev-empty-day { min-height: 48px; opacity: .75; }
.rev-cats { margin: 2px 0 4px; font-size: 13px; color: var(--ink-muted); line-height: 1.45; }
.rev-note { margin: 0 0 4px; font-size: 13px; color: var(--ink-muted); font-style: italic; }
.rev-cat { min-height: 32px; }
.card-detail .share { margin-top: 0; margin-bottom: 6px; }
.ts-head .share { margin-top: 0; }

/* ---------- Мероприятия ---------- */
/* День с мероприятием: заливка и точка (не только цвет); если их несколько — число в углу */
.calendar-day.has-event { background: var(--accent); color: var(--on-accent); font-weight: 700; --ev-fill: var(--accent); }
.calendar-day.has-event::after { content: ""; position: absolute; bottom: 6px; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.calendar-day.has-event.past { background: var(--accent-soft); color: var(--accent); --ev-fill: var(--accent-soft); }
/* Сегодня на залитом дне: кольцо внутри заливки, иначе его не видно */
.calendar-day.has-event.today { box-shadow: inset 0 0 0 2px var(--ev-fill), inset 0 0 0 4px currentColor; }
/* Многодневное мероприятие — одна сплошная полоса: соседние дни срастаются через зазор сетки */
.calendar-day.ev-join { border-top-right-radius: 0; border-bottom-right-radius: 0; box-shadow: 5px 0 0 var(--ev-fill); }
.calendar-day.ev-joined { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.calendar-day.ev-join.today { box-shadow: 5px 0 0 var(--ev-fill), inset 0 0 0 2px var(--ev-fill), inset 0 0 0 4px currentColor; }
/* Последний день месяца: мероприятие продолжается в следующем — срезанный край есть, полосы в пустоту нет */
.calendar-day.ev-join:last-child { box-shadow: none; }
.calendar-day.ev-join.today:last-child { box-shadow: inset 0 0 0 2px var(--ev-fill), inset 0 0 0 4px currentColor; }
.calendar-day .ev-count { position: absolute; top: 4px; right: 6px; font-size: 11px; font-weight: 700; font-style: normal; line-height: 1; }
.legend .lg-ev { background: var(--accent); color: var(--on-accent); position: relative; }
.legend .lg-ev::after { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.legend .lg-ev.lg-past { background: var(--accent-soft); color: var(--accent); }
.legend .lg-today { background: var(--surface); box-shadow: inset 0 0 0 2px var(--accent); }
.ev-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.ev-when { color: var(--accent); font-weight: 600; }
.ev-range { padding: 12px 14px; font-size: 17px; font-weight: 600; }
.ev-range #ev-range-days { font-weight: 400; color: var(--ink-muted); white-space: nowrap; }
.weekdays.in-sheet { margin-bottom: 0; }
#ev-pick-grid[aria-disabled="true"] .calendar-day { pointer-events: none; }
textarea.field-input { padding: 12px 14px; min-height: 88px; resize: vertical; font-family: inherit; line-height: 1.4; display: block; }
.field-input:disabled { background: var(--surface-alt); color: var(--ink); opacity: 1; -webkit-text-fill-color: var(--ink); }
.secondary-btn.danger { background: var(--danger-bg); color: var(--danger); }
.ev-range > span:first-child { color: var(--ink); }

/* v0.24: версия и роль внизу «Другого»; скрытые стрелки месяца не сдвигают подпись */
.app-version { text-align: center; color: var(--ink-muted); font-size: 13px; padding: 8px 16px 0; }
.nav-btn.invisible { visibility: hidden; }

/* v0.28: Мероприятия — список по месяцам и карточка (вариант A) */
.ev-month { display: flex; justify-content: space-between; gap: 8px; }
.ev-month span:last-child { text-transform: none; letter-spacing: 0; font-weight: 500; font-variant-numeric: tabular-nums; }
.ev-row { gap: 12px; }
.ev-row .row-text { gap: 3px; }
.ev-row .row-title { font-size: 16px; }
.ev-row .row-sub { font-size: 14px; }
.ev-date { width: 46px; flex: none; display: flex; flex-direction: column; align-items: center; border-radius: 10px; background: var(--surface-alt); padding: 6px 0; line-height: 1.1; }
.ev-date b { font-size: 20px; }
.ev-date small { font-size: 12px; color: var(--ink-muted); }
.ev-row.is-today { background: var(--accent-soft); }
.ev-row.is-today .ev-date { background: var(--accent); color: var(--on-accent); }
.ev-row.is-today .ev-date small { color: var(--on-accent); }
.ev-amount { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; margin-left: auto; padding-left: 4px; }
.ev-pill { display: inline-flex; align-self: flex-start; justify-self: start; width: max-content; max-width: 100%; font-size: 12px; font-weight: 700; line-height: 1; padding: 4px 8px; border-radius: 20px; white-space: nowrap; }
.ev-pill.ok { background: var(--green-bg); color: var(--green); }
.ev-pill.gold { background: var(--gold-bg); color: var(--gold); }
.ev-pill.grey { background: var(--surface-alt); color: var(--ink-muted); }

#evv-body { gap: 14px; }
#evv-body .group-title { margin-bottom: -6px; }
.ev-head { display: grid; gap: 8px; padding: 0 4px; }
.ev-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.ev-title { margin: 0; font-size: 24px; line-height: 1.2; font-weight: 700; overflow-wrap: anywhere; }
.ev-chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ev-chip { display: flex; align-items: center; gap: 8px; min-width: 0; background: var(--surface); border-radius: 12px; padding: 10px 12px; font-size: 15px; box-shadow: var(--shadow); }
.ev-chip .ico { width: 18px; height: 18px; color: var(--accent); flex: none; }
.ev-chip span { min-width: 0; overflow-wrap: anywhere; }
.ev-acts { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.ev-act { border: 0; border-radius: 12px; background: var(--surface); color: var(--accent); min-height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow); }
.ev-act .ico { width: 22px; height: 22px; }
.ev-act:active { background: var(--surface-alt); }
.ev-important { display: flex; gap: 10px; background: var(--gold-bg); border-radius: 14px; padding: 12px 14px; color: var(--ink); font-size: 15px; }
.ev-important > .ico { width: 22px; height: 22px; color: var(--gold); flex: none; }
.ev-important div { display: grid; gap: 4px; min-width: 0; overflow-wrap: anywhere; }
.ev-box { padding: 0 16px; }
.ev-box .kv { min-height: 46px; }
.ev-box .kv .wrap { white-space: normal; overflow-wrap: anywhere; }
.ev-box .kv a { color: var(--accent); text-decoration: none; font-variant-numeric: tabular-nums; }
.ev-two-line { flex-direction: column; align-items: flex-start !important; }
.ev-two-line small { font-size: 13px; color: var(--ink-muted); }
.ev-rest-row b { font-size: 20px; color: var(--gold); }
.ev-menu { display: grid; gap: 10px; }
.ev-file { display: flex; align-items: center; gap: 12px; background: var(--surface); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); }
.ev-file .upload-icon { background: var(--green-bg); color: var(--green); }
.ev-file .row-text { min-width: 0; }
.ev-file-name { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.link-btn { border: 0; background: none; min-height: 44px; font-size: 15px; color: var(--accent); justify-self: center; }
.link-btn.danger { color: var(--danger); }
.ev-person { display: flex; align-items: center; gap: 12px; min-height: 54px; }
.ev-person .row-text { display: grid; font-size: 15px; }
.ev-person .row-sub { font-size: 13px; }
.ev-ava { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: none; }
.ev-cap-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: -6px; }
.ev-cap-row .group-title { margin: 0 !important; }
.ev-check { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; border: 0; background: none; padding: 0; font-size: 15px; text-align: left; color: var(--ink); }
.ev-check:disabled { color: var(--ink); opacity: 1; cursor: default; }
.ev-dot { width: 24px; height: 24px; border-radius: 50%; flex: none; box-sizing: border-box; border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; }
.ev-check.on .ev-dot { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.ev-dot .ico { width: 14px; height: 14px; }
.ev-notes { padding: 12px 16px; font-size: 15px; line-height: 1.4; white-space: pre-line; overflow-wrap: anywhere; }

/* Форма мероприятия */
.ev-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ev-form-cap { margin: 6px 4px -8px; font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-muted); }
.ev-rest { padding: 0 16px; min-height: 48px; }
.ev-rest b { font-size: 17px; color: var(--gold); }
.ev-staff-row span { display: grid; min-width: 0; }
.ev-staff-row small { font-size: 13px; color: var(--ink-muted); }
input[type="time"].field-input, input[type="date"].field-input { min-height: 48px; -webkit-appearance: none; appearance: none; }
#ev-money-err:not(.on) { display: none; }
