:root {
  color-scheme: light;
  --bg: #f6f7f3;
  --panel: #ffffff;
  --ink: #18201f;
  --muted: #66706d;
  --line: #dfe5df;
  --accent: #1f7a68;
  --accent-strong: #145c4f;
  --accent-soft: #e4f3ef;
  --warm: #b96435;
  --warm-soft: #fff0e7;
  --danger: #bd3b3b;
  --shadow: 0 16px 35px rgba(25, 31, 30, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  min-height: 40px;
  padding: 0 14px;
}

button:hover {
  background: var(--accent-strong);
}

input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
}

select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
}

input:focus,
select:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(31, 122, 104, 0.15);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 30%) minmax(0, 70%);
  height: 100vh;
  overflow: hidden;
}

.side-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) minmax(220px, 1fr);
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.panel-section {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
}

.employees-section {
  border-bottom: 1px solid var(--line);
}

.section-heading,
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 18px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.shift-form {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(76px, 0.7fr) minmax(76px, 0.7fr) minmax(86px, 0.8fr);
  gap: 8px;
}

.shift-form button {
  grid-column: 1 / -1;
}

.employee-list,
.shift-list {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  padding-right: 3px;
}

.employee-card,
.shift-card,
.assignment {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.employee-card {
  min-height: 46px;
  border-color: var(--person-border, var(--line));
  background: var(--person-bg, #fff);
  padding: 8px 9px 8px 12px;
  touch-action: none;
  user-select: none;
}

.employee-card.dragging-source {
  opacity: 0.4;
}

.employee-main {
  min-width: 0;
}

.employee-name,
.shift-name,
.assignment-name {
  display: block;
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.employee-name {
  color: var(--person-text, var(--ink));
}

.employee-hours,
.shift-time {
  color: var(--muted);
  font-size: 12px;
}

.icon-button {
  display: grid;
  flex: 0 0 32px;
  width: 32px;
  min-height: 32px;
  place-items: center;
  border: 1px solid transparent;
  background: transparent;
  color: var(--danger);
  padding: 0;
}

.icon-button:hover {
  border-color: #f2c6c6;
  background: #fff1f1;
}

.shift-card {
  border-color: var(--shift-border, var(--line));
  background: var(--shift-bg, #fff);
  padding: 10px 9px 10px 12px;
}

.shift-name {
  color: var(--shift-text, var(--ink));
}

.calendar-panel {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  overflow: hidden;
}

.week-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.week-controls button {
  min-width: 42px;
  background: #263331;
}

.week-controls select {
  width: auto;
  min-width: 126px;
}

.week-controls .reset-week {
  background: var(--danger);
}

.week-controls .reset-week:hover {
  background: #9c2929;
}

.totals-strip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 10px 12px;
}

.totals-title {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.totals-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.total-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  border: 1px solid var(--person-border, transparent);
  background: var(--person-bg, var(--accent-soft));
  color: var(--person-text, var(--accent-strong));
  font-size: 13px;
  font-weight: 700;
  padding: 7px 10px;
}

.calendar-grid {
  display: grid;
  min-height: 0;
  flex: 1;
  grid-template-columns: repeat(7, minmax(155px, 1fr));
  gap: 10px;
  overflow: auto;
  padding-bottom: 4px;
}

.day-column {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 8px;
}

.day-header {
  position: sticky;
  top: 0;
  z-index: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #263331;
  color: #fff;
  padding: 10px;
}

.day-name {
  display: block;
  font-weight: 800;
}

.day-date {
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
}

.slot {
  display: flex;
  min-height: 126px;
  flex-direction: column;
  gap: 8px;
  border: 1px dashed var(--shift-border, #cdd8d2);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--shift-bg, rgba(255, 255, 255, 0.76)), rgba(255, 255, 255, 0.86));
  padding: 9px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.slot.drop-target {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.slot-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  color: var(--shift-text, var(--muted));
  font-size: 12px;
  font-weight: 700;
}

.slot-assignments {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.assignment {
  min-height: 36px;
  background: var(--person-bg, var(--warm-soft));
  border-color: var(--person-border, #f1cfb9);
  padding: 6px 6px 6px 9px;
}

.assignment-name {
  color: var(--person-text, #63351d);
  font-size: 13px;
}

.empty-text {
  margin: auto 0;
  color: #8a9691;
  font-size: 12px;
  text-align: center;
}

.mobile-dock,
.mobile-sheet,
.drag-ghost {
  display: none;
}

.drag-ghost {
  position: fixed;
  z-index: 80;
  max-width: 220px;
  pointer-events: none;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  color: var(--ink);
  font-weight: 800;
  padding: 11px 13px;
  transform: translate(-50%, -50%);
}

@media (max-width: 820px) {
  body {
    padding-bottom: 66px;
  }

  .app-shell {
    display: block;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .side-panel {
    display: none;
  }

  .calendar-panel {
    min-height: calc(100vh - 66px);
    padding: 12px;
    overflow: visible;
  }

  .calendar-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .week-controls {
    width: 100%;
  }

  .week-controls button {
    flex: 1;
  }

  .totals-strip {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .calendar-grid {
    display: flex;
    flex-direction: column;
    overflow: visible;
  }

  .day-header {
    position: static;
  }

  .slot {
    min-height: 104px;
  }

  .mobile-dock {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 -10px 25px rgba(25, 31, 30, 0.08);
    padding: 10px;
  }

  .mobile-dock button {
    background: #263331;
  }

  .mobile-sheet.is-open {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: block;
  }

  .sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(18, 25, 24, 0.35);
  }

  .sheet-panel {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    max-height: 72vh;
    border-radius: 14px 14px 0 0;
    background: var(--panel);
    box-shadow: var(--shadow);
    overflow: hidden;
    padding-top: 18px;
  }

  .sheet-handle {
    position: absolute;
    top: 8px;
    left: 50%;
    width: 48px;
    height: 4px;
    border-radius: 999px;
    background: #c7d0ca;
    transform: translateX(-50%);
  }

  .sheet-close {
    position: absolute;
    top: 9px;
    right: 10px;
    width: 34px;
    min-height: 34px;
    background: transparent;
    color: var(--ink);
    font-size: 24px;
    padding: 0;
  }

  .sheet-close:hover {
    background: #eef2ef;
  }

  #sheetContent {
    max-height: calc(72vh - 18px);
    overflow: auto;
  }

  #sheetContent .panel-section {
    min-height: 360px;
  }

  .drag-ghost {
    display: block;
  }
}
