@font-face {
  font-family: 'MTS Wide';
  src: url('/fonts/MTSWide-Medium.ttf') format('truetype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'MTS Text';
  src: url('/fonts/MTSText-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'MTS Text';
  src: url('/fonts/MTSText-Medium.ttf') format('truetype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  --red: #ff0032;
  --ink: #0b0b0d;
  --muted: #71757c;
  --line: #e7e8ea;
  --line-strong: #c9cbd0;
  --surface: #f7f7f8;
  --weekend: #f4f4f5;
  --radius: 12px;
  --label-w: 232px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: #fff;
  color: var(--ink);
  font-family: 'MTS Text', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .brand-title, .year, .empty h2 {
  font-family: 'MTS Wide', 'MTS Text', sans-serif;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.muted { color: var(--muted); }
.logo { width: 100%; height: 100%; display: block; }
[data-logo] { display: inline-flex; width: 34px; height: 34px; flex: none; }

/* ---------- login ---------- */

.boot { min-height: 100vh; }

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1100px 420px at 50% -8%, rgba(255, 0, 50, 0.07), transparent 70%),
    #fff;
}

.login-card {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 24px 60px -32px rgba(11, 11, 13, 0.35);
}

.login-logo { width: 44px; height: 44px; }
.login-card h1 { margin: 6px 0 0; font-size: 30px; }
.login-card p { margin: -10px 0 6px; }

/* ---------- layout ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-title { font-size: 20px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.toolbar {
  position: sticky;
  top: 63px;
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.switcher {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.switcher-label {
  min-width: 108px;
  text-align: center;
  font-weight: 500;
  font-size: 14px;
}
.switcher-label.year { font-size: 16px; min-width: 70px; }

.nav {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.nav:hover { background: var(--surface); color: var(--red); }

.scope {
  display: flex;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 10px;
  gap: 2px;
}
.scope button {
  border: 0;
  border-radius: 8px;
  background: transparent;
  padding: 5px 14px;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
}
.scope button:hover { color: var(--ink); }
.scope button[aria-selected='true'] { background: var(--ink); color: #fff; }

.legend {
  display: flex;
  gap: 16px;
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
  flex-wrap: wrap;
}
.legend span { display: inline-flex; align-items: center; gap: 7px; }

.swatch {
  width: 16px;
  height: 12px;
  border-radius: 3px;
  --c: #24262b;
}
.swatch.type-vacation { background: var(--c); }
.swatch.type-vacation.draft { background: color-mix(in srgb, var(--c) 45%, #fff); }
.swatch.type-sick {
  background: repeating-linear-gradient(135deg, var(--c) 0 3px, #fff 3px 6px);
  box-shadow: inset 0 0 0 1px var(--c);
}
.swatch.type-dayoff { background: #fff; box-shadow: inset 0 0 0 1.5px var(--c); }

/* ---------- buttons ---------- */

.btn {
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  padding: 8px 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.btn:hover { border-color: var(--ink); }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: #d90029; border-color: #d90029; }
.btn-ghost { border-color: transparent; color: var(--muted); }
.btn-ghost:hover { border-color: var(--line-strong); color: var(--ink); }
.btn-danger { border-color: transparent; color: var(--red); }
.btn-danger:hover { border-color: var(--red); }
.btn-block { width: 100%; }

/* ---------- chart ---------- */

.chart { padding: 20px 24px 64px; }

.chart-head {
  position: sticky;
  top: 115px;
  z-index: 20;
  display: grid;
  grid-template-columns: var(--label-w) 1fr;
  background: #fff;
  border-bottom: 1px solid var(--line-strong);
}

.head-label {
  display: flex;
  align-items: flex-end;
  padding: 0 12px 8px 4px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.head-track { position: relative; height: 40px; }

.tick {
  position: absolute;
  bottom: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding-bottom: 6px;
  border-left: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
}
.tick.month-start { border-left-color: var(--line-strong); }
.tick > b { font-weight: 500; color: var(--ink); padding-left: 6px; font-size: 12px; white-space: nowrap; }
.tick > i { font-style: normal; padding-left: 6px; font-size: 10px; }
.tick.compact > b { padding-left: 0; text-align: center; }
.tick.compact > i { padding-left: 0; text-align: center; }
.tick.weekend > b { color: var(--muted); }

.head-track.with-weeks .tick { justify-content: flex-start; padding: 6px 0 0; }
.week-tick {
  position: absolute;
  bottom: 5px;
  padding-left: 4px;
  font-size: 10px;
  color: var(--muted);
  border-left: 1px solid var(--line-strong);
  height: 14px;
  line-height: 14px;
}

.row {
  display: grid;
  grid-template-columns: var(--label-w) 1fr;
  border-bottom: 1px solid var(--line);
  min-height: 44px;
}
.row:hover .row-label { background: var(--surface); }

.row-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 4px;
  cursor: pointer;
  border-radius: 8px 0 0 8px;
}
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.row-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-total { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }

.row-track { position: relative; }

.cell {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px solid var(--line);
}
.cell.month-start { border-left-color: var(--line-strong); }
.cell.week-start { border-left-color: var(--line-strong); }
.cell.weekend { background: var(--weekend); }

.bar {
  position: absolute;
  z-index: 2;
  top: 8px;
  bottom: 8px;
  min-width: 3px;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  overflow: hidden;
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  transition: filter 0.15s, transform 0.15s;
  --c: #24262b;
}
.bar:hover { filter: brightness(0.92); transform: translateY(-1px); }
.bar span { padding: 0 8px; white-space: nowrap; }

.bar.type-vacation { background: var(--c); }
.bar.type-vacation.draft {
  background: color-mix(in srgb, var(--c) 45%, #fff);
  color: var(--ink);
}
.bar.type-sick {
  background: repeating-linear-gradient(135deg, var(--c) 0 4px, #fff 4px 9px);
  box-shadow: inset 0 0 0 1px var(--c);
  color: var(--ink);
}
.bar.type-sick span { text-shadow: 0 0 4px #fff, 0 0 4px #fff, 0 0 4px #fff; }
.bar.type-dayoff {
  background: #fff;
  box-shadow: inset 0 0 0 1.5px var(--c);
  color: var(--ink);
}

.today-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: var(--red);
  pointer-events: none;
  z-index: 1;
}
.row-track .today-line::before { content: none; }
.today-line::before {
  content: '';
  position: absolute;
  top: -3px;
  left: 50%;
  transform: translateX(-50%);
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
}

.empty {
  display: grid;
  place-items: center;
  gap: 6px;
  padding: 80px 24px;
  text-align: center;
  color: var(--muted);
}
.empty h2 { margin: 0; color: var(--ink); font-size: 20px; }

/* ---------- dialogs ---------- */

.dialog {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0;
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  box-shadow: 0 30px 80px -40px rgba(11, 11, 13, 0.5);
}
#period-dialog { width: min(560px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(11, 11, 13, 0.32); }
.dialog form { display: flex; flex-direction: column; gap: 16px; padding: 24px; }
.dialog h2 { margin: 0; font-size: 20px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; color: var(--muted); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.field > span em { font-style: normal; color: var(--line-strong); }

textarea {
  font: inherit;
  color: var(--ink);
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  width: 100%;
  resize: vertical;
  min-height: 44px;
}
textarea:focus { outline: 2px solid var(--red); outline-offset: -1px; border-color: var(--red); }

input[type='text'], input[type='password'], input[type='date'], select, .field input {
  font: inherit;
  color: var(--ink);
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--red); outline-offset: -1px; border-color: var(--red); }

.dialog form:focus { outline: none; }
.btn:focus-visible,
.nav:focus-visible,
.tab:focus-visible,
.day:focus-visible,
.segmented button:focus-visible,
.palette button:focus-visible,
.scope button:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.segmented.segmented-2 { grid-template-columns: repeat(2, 1fr); }
.segmented button {
  font: inherit;
  padding: 9px 4px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}
.segmented button[aria-pressed='true'] { border-color: var(--ink); background: var(--ink); color: #fff; }

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 168px;
  overflow-y: auto;
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: inherit;
  padding: 7px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}
.tab:hover { border-color: var(--ink); color: var(--ink); }
.tab[aria-pressed='true'] { background: var(--ink); border-color: var(--ink); color: #fff; }
.tab .dot { width: 8px; height: 8px; }

.calendar {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px 10px;
}
.calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.calendar-title { font-weight: 500; }
.calendar-months { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; margin-top: 6px; }
.calendar-month-name { font-size: 12px; color: var(--muted); padding-bottom: 4px; }
.calendar-weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.calendar-weekdays span { text-align: center; font-size: 11px; color: var(--muted); padding-bottom: 4px; }

.day {
  position: relative;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
}
.day.blank { visibility: hidden; }
.day.weekend { color: var(--muted); }
.day:hover:not(.busy):not(.edge) { background: var(--surface); border-radius: 8px; }
.day.in-range { background: rgba(255, 0, 50, 0.1); }
.day.edge { background: var(--red); color: #fff; border-radius: 8px; }
.day.busy { color: var(--line-strong); text-decoration: line-through; cursor: not-allowed; }
.day.is-today::after {
  content: '';
  position: absolute;
  bottom: 3px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--red);
}
.day.edge.is-today::after { background: #fff; }

.calendar-summary { margin: 8px 0 0; font-size: 13px; color: var(--muted); }

.palette { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.palette button {
  height: 30px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}
.palette button[aria-pressed='true'] { outline: 2px solid var(--ink); outline-offset: 2px; }

.dialog-actions { display: flex; align-items: center; gap: 8px; }
.spacer { flex: 1; }

.form-error {
  margin: 0;
  color: var(--red);
  font-size: 13px;
}

@media (max-width: 559px) {
  .calendar-months { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  :root { --label-w: 142px; }
  .topbar, .toolbar, .chart { padding-left: 14px; padding-right: 14px; }
  .topbar { flex-wrap: wrap; row-gap: 10px; }
  .topbar-actions { width: 100%; }
  .topbar-actions .btn { flex: 1; padding: 8px 10px; }
  .legend { margin-left: 0; width: 100%; gap: 12px; }
  .toolbar { position: static; }
  .chart-head { position: static; }
  .row-total { display: none; }
  .row-name { font-size: 13px; }
}
