:root {
  color-scheme: dark;
  --bg: #131314;
  --sidebar: #171719;
  --panel: #1b1b1e;
  --raised: #242428;
  --field: #161618;
  --line: #333337;
  --line-soft: #29292d;
  --muted: #b2b0b5;
  --text: #f7f6f7;
  --red: #ed4239;
  --red-button: #c92922;
  --red-hover: #dd352c;
  --red-text: #ff968e;
  --red-surface: #392222;
  --radius: 12px;
  font: 16px/1.45 "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box }
[hidden] { display: none !important }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  display: grid;
  grid-template-columns: 229px minmax(0, 1fr);
  min-height: 100vh;
}
button, input, select, textarea { font: inherit }
button, select, summary { cursor: pointer }
button {
  min-height: 36px;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--raised);
  color: var(--text);
  font-size: .875rem;
  font-weight: 600;
  transition: background-color .15s, border-color .15s, color .15s;
}
button:hover { background: #303035; border-color: #4a494e }
button:disabled { opacity: .48; cursor: default }
:focus-visible { outline: 2px solid var(--red-text); outline-offset: 3px }
a { color: var(--red-text) }
.skip-link {
  position: fixed;
  z-index: 20;
  top: 12px;
  left: 12px;
  padding: 8px 14px;
  background: var(--raised);
  border-radius: 8px;
  transform: translateY(-180%);
}
.skip-link:focus { transform: none }

.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 20px 14px 14px;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 3px 18px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 1.23rem;
  font-weight: 820;
  line-height: 1.12;
  letter-spacing: -.045em;
}
.brand span { color: var(--red-text) }
.brand-mark { display: block; flex: none; object-fit: contain }
.brand small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 500;
  letter-spacing: 0;
}
nav { display: grid; gap: 10px; margin-top: 16px; overflow: auto }
.nav-group { min-width: 0; border-bottom: 1px solid var(--line-soft); padding-bottom: 8px }
.nav-group summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 38px;
  border-radius: 7px;
  padding: 7px 8px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 670;
  list-style: none;
}
.nav-group summary::-webkit-details-marker { display: none }
.nav-group summary::after {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
}
.nav-group[open] summary::after { transform: rotate(45deg) }
.nav-group summary:hover { color: var(--text); background: var(--raised) }
.nav-items { display: grid; gap: 3px }
nav button {
  position: relative;
  width: 100%;
  min-height: 39px;
  padding: 6px 9px;
  border-color: transparent;
  background: transparent;
  color: #d4d1d5;
  text-align: left;
}
nav button span {
  display: inline-grid;
  place-items: center;
  width: 22px;
  margin-right: 4px;
  color: var(--muted);
  font-size: 1.05rem;
}
nav button.active { background: var(--red-surface); border-color: #563430; color: #fff2f0 }
nav button.active span { color: var(--red-text) }
nav button.active::before {
  position: absolute;
  left: -1px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--red);
  content: "";
}
#account {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 16px;
  color: var(--muted);
  font-size: .86rem;
}
.account-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
  padding: 7px 8px 7px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}
.account-avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--red-surface);
  color: var(--red-text);
  font-weight: 750;
}
.account-info { display: grid; min-width: 0; line-height: 1.25; gap: 2px }
.account-info > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.account-info strong { color: var(--text) }
.account-info span { font-size: .75rem }
.account-profile button { flex: none }

main { width: 100%; min-width: 0; max-width: 1680px; margin: 0 auto; padding: 34px clamp(22px, 3.2vw, 52px) 40px }
h1, h2, p { margin-top: 0 }
h1 {
  margin-bottom: 8px;
  font-size: clamp(2rem, 3.3vw, 3.15rem);
  font-weight: 790;
  line-height: 1.02;
  letter-spacing: -.052em;
}
h2 { margin-bottom: 12px; font-size: 1.14rem; font-weight: 700; letter-spacing: -.018em }
p { color: var(--muted); line-height: 1.55 }
.page-heading { margin-bottom: 22px }
.page-heading p { margin: 0; max-width: 65ch }
.schedule-heading {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  padding: 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-left: 3px solid var(--red);
  border-radius: var(--radius);
  background:
    repeating-linear-gradient(135deg, transparent 0 11px, #ed42390a 11px 12px, transparent 12px 24px) right / 34% 100% no-repeat,
    linear-gradient(104deg, #2a2021, #1b1b1e 50%, #201b1e);
}
.schedule-heading > * { position: relative }
.schedule-heading .page-heading { margin-bottom: 0 }
.panel, .card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius) }
.panel { margin-top: 14px; padding: 19px }
.card { padding: 17px }
.card h2 { margin-bottom: 8px }
.card p { margin: 12px 0 }
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px }
.toolbar { display: flex; align-items: end; gap: 10px; flex-wrap: wrap }
.primary, a.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--red-button);
  border-radius: 8px;
  background: var(--red-button);
  color: #fff;
  font-size: .9rem;
  font-weight: 730;
  text-decoration: none;
}
.primary:hover, a.primary:hover { background: var(--red-hover); border-color: var(--red-hover) }
.toolbar .primary { margin-left: auto }
.hint, .muted { color: var(--muted); font-size: .875rem }
.pill {
  display: inline-block;
  border: 1px solid #414148;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--raised);
  color: #e4e1e5;
  font-size: .8rem;
}
label { display: grid; gap: 6px; min-width: 0; color: var(--muted); font-size: .875rem }
input, select, textarea {
  min-height: 38px;
  max-width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--field);
  color: var(--text);
}
input:is([type=checkbox], [type=radio]) { min-height: auto; accent-color: var(--red-button) }
textarea { resize: vertical }
.form-stack { display: grid; gap: 9px }
.inline-check { display: inline-flex; align-items: center; gap: 6px }
.small-action, .date { white-space: nowrap }
.spaced { margin: 14px 0 }
.empty { margin: 0; padding: 28px 12px; color: var(--muted); text-align: center }
.missing { color: #ffb391 }
.notice {
  padding: 10px 12px;
  border: 1px solid #6c4636;
  border-radius: 8px;
  background: #392923;
  color: #ffd1af;
}
#status:not(:empty) { margin-bottom: 14px }
.login { max-width: 530px; margin: 10vh auto 0 }
.login .panel { padding: 23px }

dialog {
  width: min(555px, calc(100% - 24px));
  max-height: 90dvh;
  padding: 22px;
  border: 1px solid #454349;
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
}
dialog::backdrop { background: #000a }
dialog form { display: grid; gap: 12px }
dialog p { margin-bottom: 0 }
fieldset { margin: 0; padding: 10px; border: 1px solid var(--line); border-radius: 8px; font-size: .875rem }
fieldset label { display: flex; align-items: center; gap: 6px }
#edit-error { color: #ff9a91 }
#edit-error:empty { display: none }

.table { max-width: 100%; overflow: auto; scrollbar-color: #55525a var(--field) }
table { width: 100%; border-collapse: collapse; text-align: left }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle }
th { color: var(--muted); font-size: .875rem; font-weight: 680 }
tbody tr:last-child > * { border-bottom: 0 }
tbody tr:hover { background: #252429 }
.people td:first-child { min-width: 190px }
.person-link {
  display: block;
  width: 100%;
  min-height: 30px;
  overflow: hidden;
  padding: 3px 0;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.person-link:hover { background: transparent; color: var(--red-text) }
.phone { color: var(--red-text); white-space: nowrap }

.archive-header, .archive-status { display: flex; flex-wrap: wrap; align-items: center; gap: 9px }
.archive-header { justify-content: space-between; margin-bottom: 11px }
.archive-header h2 { margin: 0 }
.archive-header .hint { margin: 4px 0 0 }
.calendar-kicker { margin: 0 0 3px; color: var(--muted); font-size: .83rem; font-weight: 600 }
.calendar-summary { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 13px }
.summary-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--field);
  color: var(--muted);
  font-size: .83rem;
}
.calendar-summary strong { font-variant-numeric: tabular-nums }
.summary-open { background: var(--red-surface); border-color: #663e3a; color: #ffbdb6 }
.summary-open:hover { background: #48292a; border-color: #9d5752 }
.archive-toggle {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--field);
}
.archive-toggle button { min-width: 67px; min-height: 32px; padding: 4px 10px; border-color: transparent; background: transparent; color: var(--muted) }
.archive-toggle button:hover { color: var(--text); background: var(--raised) }
.archive-toggle [aria-pressed=true], .archive-stores [aria-pressed=true] {
  border-color: #6f3a36;
  background: var(--red-surface);
  color: #fff1ef;
}
.archive-stores {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 13px;
  padding: 1px 0;
}
.archive-stores button, .archive-status > span { display: inline-flex; align-items: center; gap: 6px }
.archive-stores button { min-height: 32px; padding: 3px 8px; white-space: nowrap; background: var(--field) }
.archive-stores button:hover { background: var(--raised) }
.archive-stores .shift-tile, .archive-status .shift-tile { width: 24px; height: 23px; font-size: .72rem }
.archive-status { margin-top: 12px; color: var(--muted); font-size: .83rem }
.archive-panel .table {
  max-height: clamp(340px, 62vh, 720px);
  border: 1px solid var(--line);
  border-radius: 9px;
}
.shift-matrix {
  --name-column: 158px;
  --date-column: 41px;
  min-width: max-content;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: center;
}
.shift-matrix th, .shift-matrix td {
  height: 37px;
  min-width: var(--date-column);
  padding: 2px 3px;
  border-right: 1px solid var(--line-soft);
}
.shift-matrix thead th {
  position: sticky;
  z-index: 2;
  top: 0;
  height: 43px;
  background: #252529;
  border-bottom-color: #414147;
}
.shift-matrix tr > :first-child {
  position: sticky;
  z-index: 1;
  left: 0;
  width: var(--name-column);
  min-width: var(--name-column);
  max-width: var(--name-column);
  padding: 3px 9px;
  background: #202023;
  text-align: left;
  box-shadow: 3px 0 6px #0002;
}
.shift-matrix thead tr > :first-child { z-index: 3; background: #252529 }
.shift-matrix tbody tr:hover > :first-child { background: #2b292d }
.shift-matrix tr > :last-child { border-right: 0 }
.shift-date {
  display: grid;
  gap: 2px;
  line-height: 1.1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.shift-date small { color: var(--muted); font-size: .72rem; text-transform: uppercase }
.shift-date.weekend, .shift-date.weekend small { color: var(--red-text) }
.shift-tile {
  display: inline-grid;
  place-items: center;
  width: 29px;
  height: 29px;
  border-radius: 5px;
  color: #141316;
  font-size: .77rem;
  font-weight: 800;
  vertical-align: middle;
}
.shift-tile.shift-dim { opacity: .32 }
.shift-button { min-height: 0; padding: 0; border: 0; border-radius: 5px; background: transparent; line-height: 1 }
.shift-button:hover { background: transparent }
.shift-button:hover .shift-tile, .shift-button.replaced .shift-tile { box-shadow: inset 0 0 0 2px #fff }
.store-1 { background: #89d1a3 }
.store-2 { background: #eacc70 }
.store-3 { background: #bea9ef }
.store-4 { background: #fa8a86 }
.store-5 { background: #eab297 }
.store-6 { background: #9a593b; color: #fff }
.store-7 { background: #8db5ef }
.store-8 { background: #b2b8c3 }
.store-9 { background: #526cad; color: #fff }
.store-10 { background: #7bd9d4 }
.store-11 { background: #e8a1cf }
.store-extra { background: hsl(var(--store-hue) 66% 69%) }
.absence { background: #444348; color: #f4f3f5 }
.absence.day-off { background: #303035; color: #b5b3bb }
.absence.urgent-off { background: #563e27; color: #ffdb9e }
.archive-panel details summary { color: var(--muted); font-size: .875rem }
.archive-panel details[open] summary { margin-bottom: 9px }
.period-nav {
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 7px;
  margin: 15px 0 2px;
}
.period-nav > button { min-width: 36px; min-height: 38px; padding: 4px 7px; font-size: 1.3rem; line-height: 1 }
.period-select { gap: 3px; max-width: calc(100% - 86px); text-align: center }
.period-select select { text-align: center; font-size: .86rem }
.period-actions { display: flex; justify-content: flex-end; margin-top: 12px }
.danger { border-color: #6a3d3a; background: #342324; color: #ffb5ae }
.danger:hover { border-color: #9d5752; background: #48292a }
#generate { scroll-margin-top: 16px }

@media (max-width: 940px) {
  body { grid-template-columns: 195px minmax(0, 1fr) }
  .sidebar { padding-inline: 9px }
  main { padding-inline: 20px }
}
@media (max-width: 740px) {
  body { display: block }
  .sidebar {
    position: static;
    height: auto;
    display: grid;
    grid-template-columns: minmax(0,1fr) auto;
    align-items: center;
    padding: 9px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .brand { padding: 0; border: 0 }
  .brand-mark { width: 44px; height: 44px }
  nav { grid-row: 2; grid-column: 1 / -1; gap: 0; margin-top: 6px; overflow: visible }
  .nav-group { padding-bottom: 3px; border-bottom-color: var(--line-soft) }
  .nav-items { grid-template-columns: repeat(2, minmax(0, 1fr)) }
  #account { margin-bottom: 12px }
  #account .pill { font-size: .73rem }
  main { padding: 18px 12px 28px }
  .panel { padding: 12px }
  .schedule-heading { padding: 15px; flex-wrap: wrap }
  .schedule-heading h1 { font-size: 2rem }
  .schedule-heading p { font-size: .875rem }
  .toolbar .primary { margin-left: 0 }
  .archive-stores { flex-wrap: nowrap; overflow: auto; padding: 3px 3px 8px; scrollbar-width: thin }
  .archive-stores button { flex: none }
  .shift-matrix { --name-column: 121px; --date-column: 38px }
  .shift-matrix tr > :first-child { padding-inline: 6px }
  .person-link { font-size: .83rem }
  .table { overscroll-behavior-x: contain }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important }
}
