@font-face {
  font-family: "IBM Plex Sans";
  src: url("ibm-plex-sans.ttf") format("truetype");
  font-style: normal;
  font-weight: 100 700;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #eef2f7;
  --card: #fff;
  --line: #dce4ef;
  --line-strong: #a3b2c6;
  --text: #142033;
  --muted: #526279;
  --accent: #1d4ed8;
  --accent-dark: #1e40af;
  --accent-soft: #e9efff;
  --error: #a91929;
  --error-soft: #fff0f1;
  --ok: #145847;
  --ok-soft: #dff4eb;
  --attention: #85400c;
  --attention-soft: #fff2de;
  --radius: 12px;
  --shadow: 0 1px 2px #1b305a0a, 0 12px 32px -22px #142f5655;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font: 14px/1.45 "IBM Plex Sans", "Segoe UI", Arial, sans-serif;
}
a { color: var(--accent-dark); text-underline-offset: .16em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
:where(h1, h2, h3, p) { margin: 0; }
h1 { font-size: 24px; line-height: 1.2; font-weight: 650; letter-spacing: -.025em; }
h2 { font-size: 17px; line-height: 1.25; font-weight: 650; }
h3 { font-size: 14px; margin: 16px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--error); }
.ok { color: var(--ok); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  background: #f8faff;
  border-bottom: 1px solid #cfd9e8;
}
.topbar-inner {
  max-width: 1760px;
  min-height: 56px;
  margin: auto;
  padding: 5px clamp(12px, 1.7vw, 26px);
  display: flex;
  gap: clamp(12px, 2vw, 34px);
  align-items: center;
}
.brand {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  gap: 7px;
  color: var(--text);
  font-size: 16px;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}
.brand-icon {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--accent);
  display: grid;
  place-items: center;
}
.brand-icon::before {
  content: "";
  width: 12px;
  height: 11px;
  border: 1.5px solid white;
  border-top-width: 4px;
  border-radius: 2px;
}
.brand-dept { color: var(--muted); font-size: 13px; font-weight: 500; }
.primary-nav { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; }
.primary-nav a, .section-links a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 11px;
  border-radius: 7px;
  text-decoration: none;
  font-weight: 550;
  color: var(--muted);
  white-space: nowrap;
}
.primary-nav a:hover, .section-links a:hover { background: #eaf0f9; color: var(--text); }
.primary-nav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 650;
}
.user-menu { margin-inline-start: auto; }
.user-menu summary { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.department-menu { margin-inline-start: auto; }
.department-menu + .user-menu { margin-inline-start: 0; }
.department-menu summary { max-width: 170px; overflow: hidden; text-overflow: ellipsis; }
.department-menu a[aria-current="true"] { color: var(--accent-dark); background: var(--accent-soft); }
.department-label { font-weight: 650; color: var(--text); }
.menu { position: relative; flex: none; }
.menu summary::after { content: "⌄"; margin-inline-start: 8px; }
.menu-panel {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-end: 0;
  z-index: 16;
  min-width: max-content;
  display: grid;
  padding: 5px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 26px #142f5629;
}
.menu-panel a {
  padding: 9px 12px;
  min-height: 36px;
  color: var(--text);
  border-radius: 6px;
  text-decoration: none;
}
.menu-panel a:hover { background: var(--accent-soft); }

main { max-width: 1760px; margin: 0 auto; padding: 16px clamp(12px, 1.7vw, 26px) 0; }
footer { color: var(--muted); font-size: 12px; text-align: center; padding: 20px 12px; }
.card {
  margin-bottom: 12px;
  padding: clamp(14px, 1.55vw, 22px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  scroll-margin-top: 112px;
}
.card > h2 + *, .card > h1 + *, .card > p + *, .card > * + p { margin-top: 10px; }
.page-heading, .toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.page-heading p { margin-top: 4px; }
.inline, .inline-mini {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}
.inline-mini { display: inline-flex; gap: 5px; vertical-align: middle; }
label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}
input, select, textarea, button, .button { font: inherit; }
input:not([type="checkbox"], [type="radio"]), select, textarea {
  min-height: 36px;
  min-width: 0;
  padding: 5px 9px;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); margin: 0; }
input[type="color"] { width: 44px; padding: 3px 5px !important; }
textarea { resize: vertical; }
button, .button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 12px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  background: var(--accent);
  color: white;
  font-weight: 550;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
}
button:not(:disabled):hover, .button:hover { background: var(--accent-dark); }
button.secondary, .button.secondary {
  background: var(--card);
  color: var(--text);
  border-color: var(--line-strong);
}
button.secondary:not(:disabled):hover, .button.secondary:hover { background: #f1f5fb; }
button:disabled, button.secondary:disabled {
  cursor: default;
  color: var(--muted);
  border-color: var(--line);
  background: #edf1f7;
}
button.danger-text { color: var(--error); }
button.danger {
  background: var(--error);
  border-color: var(--error);
}
button.danger:not(:disabled):hover { background: #84111f; }
button.mini, .button.small { min-height: 32px; padding-inline: 9px; font-size: 12px; }
.icon-button { min-width: 36px; padding-inline: 0; font-size: 17px; line-height: 1; }
.year-field { width: 72px; }
.check-label { flex-direction: row; align-items: center; gap: 8px; min-height: 36px; }
.check-label input, .pick input { width: 16px; height: 16px; }
.page-notice, .fact-summary {
  padding: 10px 14px;
  background: #f0f5ff;
  border: 1px solid #c7d9ff;
  border-radius: 8px;
}
.page-notice { margin-bottom: 10px; }
.fact-summary { margin: 14px 0; }
.fact-summary.attention { background: var(--attention-soft); border-color: #ebd0a6; }
.fact-summary h2 { margin-bottom: 4px; }

.schedule-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px 20px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.schedule-context, .schedule-actions, .schedule-meta, .period-selector {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}
.schedule-actions, .period-selector { gap: 6px; }
.schedule-meta { margin-top: 5px; color: var(--muted); font-size: 13px; gap: 4px 13px; }
.schedule-meta strong { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 650; }
.status-pill {
  white-space: nowrap;
  border: 1px solid #cdd8ec;
  border-radius: 30px;
  padding: 2px 8px;
  background: #e6edf7;
  color: #354963;
  font-size: 12px;
  font-weight: 600;
}
.status-pill.imported { color: var(--accent-dark); background: var(--accent-soft); }
.status-pill.saved { color: var(--ok); background: var(--ok-soft); border-color: #b6dece; }

.schedule-surface {
  position: relative;
  isolation: isolate;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.grid-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: #fafcff;
  border-radius: var(--radius) var(--radius) 0 0;
}
#generation-toggle[aria-expanded="true"], #checks-toggle[aria-expanded="true"] {
  background: var(--accent-soft);
  border-color: #a4b9f6;
  color: var(--accent-dark);
}
.generation-panel {
  padding: 12px;
  background: #f0f5ff;
  border-top: 1px solid var(--line);
}
.generation-panel h2 + p { margin: 4px 0 9px; }
.generation-panel .error { margin-top: 6px; }
.generation-panel input[type="number"] { width: 72px; }
.generation-secondary { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.check-count {
  margin-left: 6px;
  min-width: 20px;
  padding: 0 4px;
  text-align: center;
  border-radius: 5px;
  font-size: 12px;
  background: #edf1f7;
}
.check-count.attention { background: var(--attention-soft); color: var(--attention); }
.checks-panel { padding: 10px 14px; background: #f9fbff; border-top: 1px solid var(--line); }
.checks-panel p + ul { margin-top: 6px; }
.issues { margin: 0; padding-inline-start: 21px; }
.issues li + li { margin-top: 3px; }
.issues .warn { color: var(--attention); }
.issues .error { color: var(--error); }
.issues .info { color: var(--muted); }
.density, .week-controls { display: inline-flex; align-items: center; gap: 4px; }
.density {
  margin-inline-start: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px;
  background: #eef2f8;
}
.density button {
  min-height: 30px;
  padding: 3px 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}
.density button:not(:disabled):hover { background: #e4ebf7; }
.density button[aria-pressed="true"] {
  background: var(--card);
  border-color: #c9d6ea;
  color: var(--accent-dark);
}
.week-controls { width: 100%; justify-content: space-between; }
.week-controls span { min-width: 0; text-align: center; font-weight: 600; }

.grid-scroll {
  max-height: max(225px, calc(100dvh - 246px));
  overflow: auto;
  border-block: 1px solid var(--line);
  scroll-padding: 40px 0 0 156px;
}
.grid-scroll:focus-visible { outline-offset: -2px; }
.grid {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  --shift-height: 36px;
}
.grid.comfortable { --shift-height: 46px; }
.grid th, .grid td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: center;
  padding: 0;
}
.grid tr > :last-child { border-right: 0; }
.grid tbody tr:last-child > * { border-bottom: 0; }
.grid thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 36px;
  background: #f0f4fa;
  font-weight: 650;
  white-space: nowrap;
}
.grid th.day {
  min-width: 29px;
  background: var(--day-fill);
  color: var(--day-ink);
}
.grid .day-number, .grid .wd { display: block; line-height: 1.15; }
.grid .wd { font-size: 11px; font-weight: 500; }
.grid .day-mark { position: absolute; top: 1px; right: 2px; font-size: 8px; }
.grid td.week-start, .grid th.week-start { border-left: 1px solid #b7c6db; }
.grid .sticky {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 152px;
  background: #f9fbfe;
  text-align: left;
  padding: 0 9px;
  box-shadow: 3px 0 4px -4px #1934577a;
}
.grid thead .sticky { z-index: 3; background: #f0f4fa; }
.grid .employee-entry { display: flex; align-items: center; gap: 6px; min-height: var(--shift-height); }
.grid .employee-identity { display: grid; gap: 1px; min-width: 0; }
.grid .fio { font-weight: 650; white-space: nowrap; }
.grid .employee-mode { color: var(--muted); font-size: 11px; line-height: 1; font-weight: 450; }
.grid .pick { display: none; }
.grid.picking .pick { display: grid; place-items: center; width: 24px; height: 30px; }
.grid .cell { height: var(--shift-height); min-width: 29px; }
.grid .shift {
  position: relative;
  width: 100%;
  height: var(--shift-height);
  min-height: 0;
  padding: 0 1px;
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 0;
  border-radius: 0;
  color: var(--shift-ink, var(--text));
  background: var(--shift-fill, var(--card));
  font-size: 12px;
  line-height: 1.12;
  white-space: nowrap;
}
.grid .shift:not(:disabled):hover { background: var(--shift-fill, var(--card)); box-shadow: inset 0 0 0 1px var(--accent); }
.grid .shift:focus-visible, .grid .shift.is-current { outline: 2px solid var(--accent); outline-offset: -2px; }
.grid .code { font-weight: 650; }
.grid .hours { font-size: 12px; font-weight: 450; font-variant-numeric: tabular-nums; }
.shift-lock {
  position: absolute;
  inset-inline-end: 2px;
  top: 3px;
  width: 7px;
  height: 6px;
  border: 1px solid currentColor;
  border-radius: 2px;
}
.shift-lock::before {
  content: "";
  position: absolute;
  left: 1px;
  right: 1px;
  top: -4px;
  height: 4px;
  border: 1px solid currentColor;
  border-radius: 3px 3px 0 0;
}
.cell.changed .shift {
  box-shadow: inset 0 0 0 1px var(--accent);
}
.cell.changed .shift::after {
  content: "";
  position: absolute;
  top: 2px;
  inset-inline-end: 2px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--cell-changed, var(--accent));
  outline: 1px solid var(--accent);
  box-shadow: 0 0 0 2px white;
}
.grid .summary-heading, .grid .total { min-width: 58px; padding-inline: 5px; }
.grid .total { background: #f8faff; white-space: nowrap; }
.grid .total-hours, .grid .total-days { display: block; }
.grid .total-days { color: var(--muted); font-size: 11px; line-height: 1; }
.grid .delta { font-weight: 600; }
.grid .over { color: var(--attention); }
.grid .active-column { border-inline-color: #91afe9; }
.grid .day.active-column, .grid .active-row .employee { box-shadow: inset 0 -2px 0 var(--accent); }
.grid .active-row .total { background: var(--accent-soft); }
.grid .grid-empty { padding: 28px 12px; color: var(--muted); }

.editbar {
  position: sticky;
  bottom: 0;
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
  background: #f8faff;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 7px 10px;
}
.editbar p { color: var(--muted); }
.hours-hint { display: block; margin-top: 3px; color: var(--muted); white-space: nowrap; }
.draft-recovery { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; margin: 8px 0; }
.draft-recovery h2 { font-size: 1rem; }
.draft-recovery p { color: var(--muted); }
.draft-recovery .edit-actions { flex-wrap: wrap; }
.editbar p[data-state="dirty"] { color: var(--attention); font-weight: 600; }
.editbar p[data-state="error"] { color: var(--error); font-weight: 600; }
.edit-actions { display: flex; gap: 6px; margin-inline-start: auto; }
.schedule-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  margin-top: 8px;
}
.schedule-details > summary { padding: 8px 11px; min-height: 36px; font-weight: 550; cursor: pointer; }
.schedule-details > :not(summary) { margin: 3px 11px 9px; }
.legend { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid var(--line);
  color: var(--chip-ink, var(--text));
  background: var(--chip-fill, var(--card));
  font-size: 12px;
}

dialog {
  color: var(--text);
  border: 1px solid #bfcde2;
  border-radius: var(--radius);
  padding: 0;
  box-shadow: 0 18px 52px #10204040;
}
dialog::backdrop { background: #14203355; }
.confirm-dialog { width: min(420px, calc(100% - 28px)); background: var(--card); }
.confirm-dialog form, .shift-editor form { padding: 15px; }
.confirm-dialog p { margin-top: 8px; color: var(--muted); white-space: pre-line; }
.dialog-actions, .editor-actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 14px; flex-wrap: wrap; }
.shift-editor {
  position: fixed;
  margin: 0;
  inset: var(--editor-top, 12px) auto auto var(--editor-left, 12px);
  width: min(340px, calc(100% - 24px));
  max-height: min(420px, calc(100dvh - 24px));
  background: #f7faff;
}
.shift-editor::backdrop { background: #14203324; }
.editor-heading { display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; }
.editor-heading p, #shift-current { margin-top: 2px; font-size: 13px; }
#shift-current { margin-bottom: 8px; }
#shift-options { margin: 0; border: 0; padding: 1px 3px 1px 1px; display: grid; gap: 3px; max-height: min(230px, 38dvh); overflow: auto; }
.shift-option {
  cursor: pointer;
  display: grid;
  grid-template-columns: 16px auto minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  min-height: 32px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: var(--text);
  font-size: 13px;
}
.shift-option:has(:checked) { border-color: #7397ef; background: var(--accent-soft); }
.shift-option:has(:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }
.shift-option-code {
  color: var(--shift-ink);
  background: var(--shift-fill);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 650;
  padding: 0 4px;
}
.shift-option-hours { font-variant-numeric: tabular-nums; white-space: nowrap; }
#shift-locked { margin-top: 8px; }

.table-scroll { max-width: 100%; overflow: auto; }
table.plain { border-collapse: collapse; width: 100%; }
.plain th, .plain td { border-bottom: 1px solid var(--line); padding: 7px 8px; text-align: left; }
.plain thead th { font-size: 13px; color: #40516a; font-weight: 650; background: #f0f4fa; }
.plain tbody th { font-weight: 600; min-width: 120px; }
.plain .num { text-align: right; font-variant-numeric: tabular-nums; }
.plain td.neg { color: var(--attention); font-weight: 650; }
.plain td.pos { color: var(--ok); }
.plain tr.inactive td { color: var(--muted); }
.plain tr.inactive input:not([type="hidden"]) { background: #f0f4fa; }
.table-subline { display: block; font-size: 12px; font-weight: 450; color: var(--muted); }
.period-line { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 7px; min-width: 205px; }
.facts-table { min-width: 610px; }
.facts-table .num { min-width: 64px; }
table.audit { font-size: 12px; }
table.audit td.small { max-width: 480px; overflow-wrap: anywhere; }
.section-links { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.section-links a { background: #eef3fb; }
.global-setting { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.global-setting .table-scroll { margin: 8px 0; }
.calendar-upload { display: grid; justify-items: start; gap: 8px; margin: 12px 0; }
.calendar-upload input[type="file"] { display: block; margin-top: 4px; max-width: 100%; }
.validation-note { color: var(--error); background: var(--error-soft); }
.color-preview { display: inline-flex; align-items: center; gap: 5px; margin-inline: 3px; font-size: 12px; white-space: nowrap; }
.color-preview-sample { border: 1px solid var(--line-strong); padding: 2px 4px; border-radius: 4px; font-weight: 600; }
.card.login { max-width: 390px; margin: min(10vh, 80px) auto; }
.card.login form { display: grid; gap: 11px; margin-top: 14px; }

@supports (backdrop-filter: blur(12px)) {
  @media (prefers-reduced-transparency: no-preference) and (prefers-contrast: no-preference) {
    .topbar, .shift-editor, .editbar {
      background: #f8faffed;
      backdrop-filter: blur(16px) saturate(125%);
    }
  }
}

@media (max-width: 700px) {
  .topbar-inner { flex-wrap: wrap; padding-block: 3px; gap: 0 6px; }
  .primary-nav { order: 2; flex: 1 0 100%; gap: 0; justify-content: space-between; }
  .primary-nav a { min-height: 44px; padding-inline: clamp(4px, 1.4vw, 10px); font-size: 13px; }
  .department-menu { margin-inline-start: 0; }
  .department-menu + .user-menu { margin-inline-start: auto; }
  .department-menu summary { max-width: 125px; }
  .user-menu summary { max-width: 168px; }
  main { padding-top: 12px; }
  .schedule-heading { align-items: flex-start; }
  .schedule-actions { width: 100%; }
  .period-selector { gap: 4px; }
  .period-selector select { max-width: 100px; }
  .period-selector .year-field { width: 65px; }
  .period-selector .icon-button { min-width: 38px; }
  .period-selector button { padding-inline: 7px; }
  .schedule-meta { gap: 3px 9px; font-size: 12px; }
  .schedule-context { gap: 4px 7px; }
  .grid-toolbar { padding: 6px; }
  .grid-scroll { max-height: max(225px, calc(100dvh - 320px)); scroll-padding-left: 104px; }
  .grid .sticky { min-width: 103px; padding-inline: 5px; }
  .grid .fio { white-space: normal; line-height: 1.1; }
  .grid .day, .grid .cell { min-width: 34px; }
  .grid.comfortable .day, .grid.comfortable .cell { min-width: 44px; }
  .grid, .grid.comfortable { --shift-height: 44px; }
  .grid.comfortable { --shift-height: 48px; }
  .density { margin-inline-start: 0; }
  .density button { min-height: 38px; }
  :where(.menu, .edit-actions, .week-controls, .period-line, .generation-panel, .dialog-actions, .editor-actions) :is(button, .button),
  .period-selector > :is(button, a), .card.login button { min-height: 44px; }
  .week-controls .icon-button, .period-line .icon-button { min-width: 44px; }
  .editbar { padding: 5px 6px; }
  .editbar p { font-size: 13px; }
  .shift-editor {
    width: 100%;
    max-width: none;
    max-height: 80dvh;
    inset: auto 0 0;
    border-radius: 14px 14px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  #shift-options { max-height: 43dvh; }
  .shift-option { min-height: 44px; }
}
