:root {
  --ink: #4f5156;
  --ink-soft: #696c72;
  --line: #8a8d92;
  --paper: #fffefb;
  --paper-warm: #f7f4ee;
  --primary: rgb(187, 89, 178);
  --primary-light: rgb(248, 238, 247);
  --complementary: rgb(89, 187, 98);
  --complementary-light: rgb(238, 248, 239);
  --danger: #b94b5f;
  --shadow: 0 4px 14px rgba(79, 81, 86, 0.1);
}

html,
body {
  min-width: 320px;
}

body.bg-soft {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 5%, rgba(187, 89, 178, 0.08), transparent 25rem),
    var(--paper-warm);
  font-family: "Segoe UI", "Noto Sans", Arial, sans-serif;
}

#week-content {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(100%, 1920px);
  min-height: 100vh;
  margin-inline: auto;
  padding: 0.65rem 3.1rem 0.8rem;
}

.week-title {
  flex: 0 0 auto;
  margin-bottom: 0.55rem;
}

.week-toolbar {
  display: grid;
  grid-template-columns: minmax(175px, 1fr) auto minmax(175px, 1fr);
  align-items: center;
  gap: 1rem;
  min-height: 58px;
  padding: 0.25rem 0.6rem;
  border-bottom: 2px solid rgba(79, 81, 86, 0.28);
}

.week-heading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  min-width: 0;
}

.week-heading h1 {
  color: var(--ink);
  font-weight: 800;
  white-space: nowrap;
}

.brand-logo {
  width: 76px;
  height: 52px;
  object-fit: contain;
  flex: 0 0 auto;
}

.week-actions {
  display: flex;
  align-items: center;
}

.week-actions-end {
  justify-content: flex-end;
}

.desktop-week-actions,
.week-actions-end {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mobile-week-menu {
  display: none;
}

.menu-toggle {
  min-width: 44px;
  font-size: 1.35rem;
  line-height: 1;
}

.btn-brand-secondary,
.btn-brand-primary {
  min-height: 38px;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  font-weight: 700;
  color: var(--ink);
  box-shadow: 0 2px 5px rgba(79, 81, 86, 0.08);
}

.btn-brand-secondary {
  background: var(--primary-light);
  border-color: rgba(187, 89, 178, 0.55);
}

.btn-brand-primary {
  background: var(--complementary-light);
  border-color: rgba(89, 187, 98, 0.65);
}

.btn-brand-secondary:hover,
.btn-brand-secondary:focus,
.btn-brand-primary:hover,
.btn-brand-primary:focus {
  color: #313338;
  border-color: var(--ink);
  filter: brightness(0.97);
}

#week-grid-frame,
#week-grid {
  min-height: 0;
}

#week-grid-frame {
  flex: 1 1 auto;
}

.day-stack {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  height: 100%;
}

.day-row {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  margin-bottom: 0 !important;
}

.day-card {
  position: relative;
  overflow: hidden;
  background: var(--paper);
  border: 1px solid var(--line);
  border-left-width: 8px;
  border-radius: 0.25rem;
  box-shadow: var(--shadow);
}

.day-card::before {
  position: absolute;
  inset: 0 0 auto 0;
  height: 5px;
  content: "";
  background: var(--day-accent);
}

.day-accent-0 {
  --day-accent: var(--primary);
  --day-light: var(--primary-light);
  border-left-color: var(--primary);
}

.day-accent-1 {
  --day-accent: var(--complementary);
  --day-light: var(--complementary-light);
  border-left-color: var(--complementary);
}

.day-accent-2 {
  --day-accent: var(--primary);
  --day-light: var(--primary-light);
  border-left-color: var(--primary);
}

.day-accent-3 {
  --day-accent: var(--complementary);
  --day-light: var(--complementary-light);
  border-left-color: var(--complementary);
}

.day-accent-4 {
  --day-accent: var(--primary);
  --day-light: var(--primary-light);
  border-left-color: var(--primary);
}

.compact-day-body {
  display: grid;
  gap: 0.45rem;
  height: 100%;
  padding: 0.58rem 0.65rem 0.5rem !important;
}

.day-main-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.7rem;
  align-items: start;
  padding: 0.2rem 0.25rem 0.25rem;
  border-radius: 0.25rem;
  background: linear-gradient(90deg, var(--day-light), rgba(255, 255, 255, 0.2));
}

.day-main-left {
  min-width: 0;
}

.day-main-header-row,
.bottom-label-row {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.day-main-header-row {
  margin-bottom: 0.25rem;
}

.day-main-right {
  display: grid;
  align-content: start;
  justify-items: end;
  min-width: 160px;
  text-align: right;
}

.weekday-big {
  color: var(--ink);
  font-size: clamp(1.02rem, 1.25vw, 1.3rem);
  font-weight: 800;
  line-height: 1.05;
}

.date-big {
  color: var(--ink-soft);
  font-size: clamp(0.86rem, 1vw, 1.05rem);
  font-weight: 700;
  white-space: nowrap;
}

.compact-section-label {
  align-self: center;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 800;
  white-space: nowrap;
}

.section-label-large {
  font-size: 1rem;
}

.compact-bottom-grid,
.compact-bottom-grid.single-column {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 0.45rem;
}

.bottom-cell {
  min-width: 0;
  min-height: 0;
  padding: 0.35rem 0.45rem;
  background: #fff;
  border: 1px solid rgba(79, 81, 86, 0.38);
  border-radius: 0.25rem;
}

.bottom-label-row {
  margin-bottom: 0.22rem;
}

.shift-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.shift-list-primary {
  gap: 0.36rem;
}

.shift-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-width: 0;
  max-width: 100%;
  padding: 0.18rem 0.48rem;
  background: #fff;
  border: 1px solid rgba(79, 81, 86, 0.42);
  border-radius: 0.32rem;
}

.shift-pill-primary {
  padding: 0.2rem 0.52rem;
  background: var(--day-light);
  border-color: var(--day-accent);
}

.shift-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  color: #35373b;
  font-size: clamp(0.84rem, 0.95vw, 1rem);
  font-weight: 800;
  line-height: 1.15;
  text-overflow: ellipsis;
}

.shift-time {
  flex: 0 0 auto;
  color: var(--ink-soft);
  font-size: clamp(0.78rem, 0.85vw, 0.9rem);
  font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
}

.tiny-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  color: var(--danger);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
  background: transparent;
  border: 0;
  border-radius: 50%;
}

.tiny-remove:hover,
.tiny-remove:focus {
  color: #fff;
  background: var(--danger);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1;
  background: var(--complementary-light);
  border-color: var(--complementary);
  border: 1px solid rgba(79, 81, 86, 0.45);
  border-radius: 50%;
}

.icon-btn:hover,
.icon-btn:focus {
  filter: brightness(0.94);
}

.day-card.today {
  outline: 3px solid rgba(187, 89, 178, 0.5);
  outline-offset: 1px;
}

.day-card.outside-month {
  opacity: 0.68;
  filter: saturate(0.7);
}

.template-mode .day-card {
  border-style: dashed;
}

.template-mode .week-heading h1 {
  color: var(--complementary);
}

.touch-select {
  min-height: 50px;
  font-size: 1rem;
}

.modal-content {
  overflow: hidden;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 0.7rem;
}

.modal-header {
  background: var(--primary-light);
  border-bottom-color: rgba(79, 81, 86, 0.25);
}

.modal-title,
.form-label {
  font-weight: 800;
}

.btn-success {
  color: #26382a;
  background: var(--complementary-light);
  border-color: var(--complementary);
}

.side-week-arrow {
  position: fixed;
  top: 50%;
  z-index: 15;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 54px;
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 800;
  text-decoration: none;
  background: var(--primary-light);
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  box-shadow: var(--shadow);
  transform: translateY(-50%);
}

.side-week-arrow:hover,
.side-week-arrow:focus {
  color: #303236;
  background: rgba(187, 89, 178, 0.24);
}

.side-week-arrow-left {
  left: 5px;
}

.side-week-arrow-right {
  right: 5px;
}

@media (min-width: 700px) and (min-height: 600px) {
  #week-content {
    height: 100vh;
    height: 100dvh;
    min-height: 600px;
    overflow: hidden;
  }

  #week-grid-frame {
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  #week-grid {
    flex: 1 1 auto;
    height: 100%;
  }

  .day-stack {
    gap: clamp(0.2rem, 0.55vh, 0.4rem);
  }

  .compact-day-body {
    gap: clamp(0.2rem, 0.55vh, 0.4rem);
    padding: clamp(0.26rem, 0.7vh, 0.5rem) 0.55rem !important;
  }

  .day-main-row {
    gap: 0.45rem;
    padding-block: clamp(0.08rem, 0.3vh, 0.18rem);
  }

  .day-main-header-row,
  .bottom-label-row {
    margin-bottom: 0.12rem;
  }

  .bottom-cell {
    padding: clamp(0.18rem, 0.45vh, 0.3rem) 0.4rem;
  }

  .shift-pill,
  .shift-pill-primary {
    padding-block: 0.12rem;
  }
}

@media (max-width: 699px), (max-height: 599px) {
  #week-content {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .day-stack {
    height: auto;
  }

  .day-row {
    min-height: 150px;
    margin-bottom: 0.55rem !important;
  }
}

@media (min-width: 700px) and (max-width: 900px) {
  #week-content {
    padding-inline: 2.7rem;
  }

  .week-toolbar {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 0.4rem;
    padding-inline: 0.3rem;
  }

  .brand-logo {
    width: 56px;
    height: 42px;
  }

  .week-heading {
    gap: 0.4rem;
  }

  .week-heading h1 {
    font-size: 1.05rem;
  }

  .week-actions .btn {
    max-width: 100%;
    padding: 0.35rem 0.45rem;
    font-size: 0.76rem;
    line-height: 1.15;
    white-space: normal;
  }
}

@media (max-width: 900px) {
  .desktop-week-actions,
  .desktop-logout,
  .desktop-template-save {
    display: none;
  }

  .mobile-week-menu {
    display: block;
  }

  .mobile-week-menu .dropdown-menu {
    min-width: 15rem;
  }
}

@media (max-width: 699px) {
  #week-content {
    padding-inline: 2.7rem;
  }

  .week-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .week-heading {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .week-actions-start,
  .week-actions-end {
    grid-row: 2;
  }

  .compact-bottom-grid,
  .compact-bottom-grid.single-column {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 620px) {
  #week-content {
    padding: 0.45rem 2.25rem 0.8rem;
  }

  .week-toolbar {
    grid-template-columns: 1fr;
    gap: 0.45rem;
  }

  .week-heading {
    grid-column: 1;
  }

  .brand-logo {
    width: 58px;
    height: 42px;
  }

  .week-actions-start,
  .week-actions-end {
    grid-row: auto;
    justify-content: stretch;
  }

  .week-actions .btn,
  .week-actions form,
  .week-actions form .btn {
    width: 100%;
  }

  .day-main-row {
    grid-template-columns: 1fr;
  }

  .day-main-right {
    grid-row: 1;
    grid-template-columns: auto auto;
    justify-content: space-between;
    justify-items: start;
    min-width: 0;
    text-align: left;
  }

  .compact-bottom-grid,
  .compact-bottom-grid.single-column {
    grid-template-columns: 1fr;
  }

  .shift-pill {
    width: 100%;
  }

  .shift-name {
    flex: 1 1 auto;
  }

  .side-week-arrow {
    width: 32px;
    height: 48px;
  }
}

@media (min-width: 1700px) and (min-height: 900px) {
  #week-content {
    padding-top: 0.9rem;
    padding-bottom: 1rem;
  }

  .week-toolbar {
    min-height: 72px;
  }

  .brand-logo {
    width: 96px;
    height: 64px;
  }

  .week-heading h1 {
    font-size: 1.75rem;
  }

  .day-stack {
    gap: 0.6rem;
  }

  .compact-day-body {
    padding: 0.7rem 0.8rem 0.62rem !important;
  }

  .btn-brand-secondary,
  .btn-brand-primary {
    min-height: 46px;
    font-size: 1rem;
  }

  .icon-btn {
    width: 34px;
    height: 34px;
  }
}
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.login-card {
  width: min(100%, 28rem);
  padding: 2rem;
  border-radius: 1rem;
  background: #fff;
  box-shadow: 0 0.75rem 2.5rem rgb(0 0 0 / 12%);
}
