:root {
  --bg: #f6f7f9; --surface: #fff; --text: #1d2330; --muted: #667085; --border: #e3e6eb;
  --accent: #2459d6; --accent-dark: #1a44a8; --danger: #c43d3d; --ok: #1f8a4c; --warn: #b26b00;
  --radius: 8px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--text); background: var(--bg); display: flex; flex-direction: column; min-height: 100vh; }
main { flex: 1; }
main.container { width: 100%; } /* в flex-колонке margin:auto иначе сжимает main по содержимому */
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; margin: 0 0 12px; }
h3 { margin: 0 0 8px; font-size: 17px; }
.container { max-width: 1120px; margin: 0 auto; padding: 24px 16px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.big { font-size: 28px; font-weight: 600; margin: 4px 0; }

.topbar { display: flex; align-items: center; gap: 24px; padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.brand-mark { background: var(--accent); color: #fff; border-radius: 6px; padding: 2px 6px; font-size: 13px; }
.mainnav { display: flex; gap: 4px; }
.mainnav a { padding: 6px 12px; border-radius: 6px; color: var(--text); }
.mainnav a.active, .mainnav a:hover { background: var(--bg); text-decoration: none; }
.usermenu { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.usermenu form { margin: 0; }

.banner { background: #eaf1ff; color: var(--accent-dark); text-align: center; padding: 8px 16px; font-size: 14px; }
.banner-warn { background: #fff4e0; color: var(--warn); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.narrow { max-width: 460px; margin: 24px auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-top: 16px; }
.two-col { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 800px) { .two-col { grid-template-columns: 1fr; } }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }

.btn { display: inline-block; background: var(--accent); color: #fff; border: 1px solid var(--accent); border-radius: 6px; padding: 9px 18px; font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--accent-dark); text-decoration: none; }
.btn-small { padding: 5px 12px; font-size: 14px; }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-ghost:hover { background: #eaf1ff; }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #fdecec; }
.btn-block { display: block; width: 100%; margin: 8px 0; }
button.link { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; }

.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; margin-bottom: 4px; font-size: 14px; }
.field-check label { font-weight: 400; display: flex; gap: 8px; align-items: flex-start; }
.field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea, .toolbar input, .toolbar select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font: inherit; background: #fff; }
.field input:focus, .field select:focus { outline: 2px solid #b9cdf7; border-color: var(--accent); }
.has-error input, .has-error select { border-color: var(--danger); }
.req { color: var(--danger); }
.help { color: var(--muted); font-size: 13px; margin-top: 2px; }
.error { color: var(--danger); font-size: 13px; margin-top: 2px; }

.messages { margin-bottom: 16px; }
.msg { padding: 10px 14px; border-radius: 6px; margin-bottom: 8px; background: #eaf1ff; }
.msg-success { background: #e6f5ec; color: var(--ok); }
.msg-error { background: #fdecec; color: var(--danger); }
.msg-info { background: #eaf1ff; }

.toolbar { display: flex; gap: 8px; margin-bottom: 12px; }
.toolbar input { max-width: 360px; }
.toolbar select { max-width: 180px; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; }
.table th, .table td.num, .table td.nowrap { white-space: nowrap; }
.table th { font-size: 13px; color: var(--muted); font-weight: 600; background: #fafbfc; }
.table tr:last-child td { border-bottom: 0; }
.tag { display: inline-block; background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 0 6px; margin-right: 4px; font-size: 12px; }
.status { font-size: 13px; font-weight: 600; }
.status-active { color: var(--ok); }
.status-invited { color: var(--warn); }
.status-dismissed { color: var(--muted); }
.pager { display: flex; gap: 16px; justify-content: center; margin-top: 12px; }

.hero { background: linear-gradient(180deg, #eaf1ff, var(--bg)); padding: 48px 0 24px; }
.hero h1 { font-size: 36px; max-width: 760px; line-height: 1.2; }
.lead { font-size: 18px; color: var(--muted); max-width: 680px; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.footer { text-align: center; padding: 24px; font-size: 13px; }

/* Этап 2 */
h2 { font-size: 20px; margin: 24px 0 12px; }
.card h2 { margin-top: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.narrow-left { max-width: 520px; }
.num { text-align: right; }
.table tr.muted td, .table tr.muted a { color: var(--muted); }
.row-error td { background: #fdf3f3; }
.text-danger { color: var(--danger); }
ul.plain { list-style: none; padding: 0; margin: 0 0 16px; }
ul.plain li { padding: 4px 0; border-bottom: 1px solid var(--border); }
form.inline { display: flex; justify-content: space-between; gap: 8px; margin: 0; }
button.small { font-size: 13px; }
.field ul { list-style: none; padding: 0; margin: 0; max-height: 220px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; }
.field ul li { padding: 4px 10px; }
.field ul label { font-weight: 400; display: flex; gap: 8px; margin: 0; }
.confirm-bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 12px; padding: 16px 24px; }
.yearnav { display: flex; gap: 16px; align-items: center; font-size: 18px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i.d { width: 14px; height: 14px; border-radius: 3px; display: inline-block; border: 1px solid var(--border); }
.months { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; margin-bottom: 16px; }
.month { padding: 12px; }
.month-head { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 14px; }
.cal { width: 100%; border-collapse: collapse; font-size: 13px; text-align: center; }
.cal th { color: var(--muted); font-weight: 400; font-size: 11px; padding: 2px; }
.cal td { padding: 3px 0; border-radius: 4px; }
.d-weekend { color: var(--danger); }
.d-holiday { background: #fbe3e3; color: var(--danger); font-weight: 600; }
.d-day_off { background: #fdeede; color: var(--warn); font-weight: 600; }
.d-short { background: #fff6d6; }
.d-own { outline: 2px solid var(--accent); outline-offset: -2px; }
.d-today { font-weight: 700; text-decoration: underline; }
i.d-holiday { background: #fbe3e3; } i.d-day_off { background: #fdeede; } i.d-short { background: #fff6d6; }
i.d-weekend { background: #fff; border-color: var(--danger) !important; } i.d-own { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Этап 3: таймшит */
.container-wide { max-width: 1280px; }
.weeknav { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.weeknav a { font-size: 18px; }
.weeknav a.small { font-size: 14px; }
.small { font-size: 13px; }
.danger { color: var(--danger) !important; }
.ts-summary { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.badge { display: inline-block; border-radius: 999px; padding: 3px 12px; font-size: 13px; font-weight: 600; background: var(--bg); border: 1px solid var(--border); }
.badge-submitted { background: #eaf1ff; color: var(--accent-dark); border-color: #c9d8fb; }
.badge-approved { background: #e6f5ec; color: var(--ok); border-color: #bfe3cd; }
.badge-rejected { background: #fdecec; color: var(--danger); border-color: #f3c4c4; }
.ts-grid th, .ts-grid td { padding: 6px 6px; vertical-align: middle; }
.ts-grid .ts-line-col { min-width: 240px; white-space: normal; padding-left: 12px; }
.ts-day { text-align: center !important; min-width: 72px; }
.ts-day span { font-weight: 400; }
.ts-off { background: #fbf3f3 !important; color: var(--danger) !important; }
.ts-today { box-shadow: inset 0 -3px 0 var(--accent); }
.ts-cell { position: relative; text-align: center; }
.ts-hours { width: 56px; padding: 6px 4px; text-align: center; border: 1px solid var(--border); border-radius: 6px; font: inherit; }
.ts-hours:focus { outline: 2px solid #b9cdf7; border-color: var(--accent); }
.ts-hours:disabled { background: transparent; border-color: transparent; color: var(--text); }
.ts-cbtn { position: absolute; top: 2px; right: 2px; border: 0; background: none; color: #c3c8d1; cursor: pointer; font-size: 11px; padding: 0 2px; }
.ts-cbtn:hover { color: var(--accent); }
.ts-cbtn.has-comment { color: var(--accent); }
.ts-error .ts-hours { border-color: var(--danger); background: #fdf3f3; }
.ts-err { color: var(--danger); font-size: 11px; line-height: 1.2; margin-top: 2px; white-space: normal; }
.ts-totals td { font-weight: 600; background: #fafbfc; }
.ts-norm td { font-size: 13px; }
.ts-empty { padding: 32px !important; }
.ts-add { margin: 16px 0; padding: 16px 20px; }
.ts-add-fields { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.ts-add-fields label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; flex: 1 1 200px; }
.ts-add-fields select { padding: 8px; border: 1px solid var(--border); border-radius: 6px; font: inherit; font-weight: 400; }
.ts-add-fields .btn { flex: 0 0 auto; }
.ts-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.comment-pop { position: absolute; z-index: 20; width: 280px; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(16,24,40,.12); padding: 10px; }
.comment-pop textarea { width: 100%; font: inherit; border: 1px solid var(--border); border-radius: 6px; padding: 6px; resize: vertical; }
.comment-pop-actions { display: flex; gap: 12px; align-items: center; margin-top: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.ts-off-cell { background: #fdf8f8; }

/* Этап 4: согласование */
.count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 12px; font-weight: 700; text-align: center; line-height: 20px; }
.lstat { font-size: 12px; font-weight: 600; white-space: nowrap; }
.lstat-ok { color: var(--ok); }
.lstat-wait { color: var(--warn); }
.lstat-bad { color: var(--danger); }
.reject-note { color: var(--danger); font-size: 12px; white-space: normal; margin-top: 2px; }
.row-mine td { background: #f7faff; }
.num-cell { min-width: 56px; }
.cell-comment { color: var(--accent); font-size: 11px; margin-left: 3px; cursor: help; }
.cell-comments { margin: 8px 0 0; display: grid; gap: 2px; }
.decide { margin-top: 16px; }
.decide textarea { width: 100%; font: inherit; border: 1px solid var(--border); border-radius: 6px; padding: 8px; margin: 6px 0 4px; }
.ts-log { margin-top: 16px; padding: 12px 20px; }
.ts-log summary { cursor: pointer; font-weight: 600; }
.ts-log ul { margin: 8px 0 0; }

/* Вид ввода «Неделя / Месяц» */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.weeknav .seg a { font-size: 14px; padding: 5px 14px; color: var(--muted); }
.weeknav .seg a + a { border-left: 1px solid var(--border); }
.weeknav .seg a.active { background: var(--accent); color: #fff; font-weight: 600; }
.weeknav .seg a:hover { text-decoration: none; }
.ts-period-note { margin: -4px 0 12px; }
.ts-locked { background: #f7f8fa; }
.ts-grid .ts-wk { border-left: 2px solid #dfe3ea; }
.ts-sheets { margin: 16px 0; padding: 16px 20px; }
.ts-sheets .table td { padding: 8px 6px; }
.right { text-align: right; }

/* Месяц: компактные ячейки, прокрутка вбок, проект закреплён слева, итог — справа */
.ts-month { font-size: 13px; }
.ts-month th, .ts-month td { padding: 4px 2px; }
.ts-month .ts-day { min-width: 36px; font-size: 12px; line-height: 1.2; }
.ts-month .ts-day span { color: var(--muted); font-size: 11px; }
.ts-month .ts-off span { color: inherit; }
.ts-month .ts-hours { width: 34px; padding: 5px 1px; font-size: 13px; }
.ts-month .ts-cbtn { top: 0; right: 0; font-size: 10px; }
.ts-month .ts-cbtn:not(.has-comment) { opacity: 0; }
.ts-month .ts-cell:hover .ts-cbtn, .ts-month .ts-cell:focus-within .ts-cbtn { opacity: 1; }
.ts-month .ts-line-col { position: sticky; left: 0; z-index: 2; background: var(--surface); min-width: 190px; max-width: 230px;
  box-shadow: 1px 0 0 var(--border); }
.ts-month thead .ts-line-col, .ts-month tfoot .ts-line-col { background: #fafbfc; }
.ts-month .ts-total-col { position: sticky; right: 0; z-index: 2; background: #fafbfc; min-width: 56px; box-shadow: -1px 0 0 var(--border); }
.ts-month td.num { font-size: 12px; }

/* Переключатель (радиокнопки) в формах */
.field div:has(> div > label > input[type=radio]) { display: flex; gap: 8px; flex-wrap: wrap; }
.field label:has(> input[type=radio]) { display: flex; gap: 8px; align-items: center; font-weight: 400; margin: 0;
  border: 1px solid var(--border); border-radius: 6px; padding: 8px 14px; cursor: pointer; background: var(--surface); }
.field label:has(> input[type=radio]:checked) { border-color: var(--accent); background: #eef3ff; font-weight: 600; }
