:root {
  color-scheme: light;
  --ink: #231f20;
  --muted: #68737d;
  --line: #d9e2dd;
  --panel: #ffffff;
  --panel-soft: #f6f9f7;
  --page: #eef4f1;
  --nav: #ffffff;
  --nav-soft: #e6f3ec;
  --accent: #00863e;
  --accent-strong: #006b32;
  --accent-soft: #dff2e8;
  --amber: #bf6a02;
  --red: #b42318;
  --blue: #1674a5;
  --shadow: 0 12px 30px rgba(0, 67, 31, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--page);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 100vh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  min-width: 0;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  background: var(--nav);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  grid-column: 1;
  grid-row: 1;
  flex: 0 0 auto;
}

.brand h1,
.brand p,
.section-head h3,
.topbar h2 {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
}

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

.nav-list {
  display: flex;
  align-items: center;
  gap: 6px;
  grid-column: 1 / -1;
  grid-row: 2;
  min-width: 0;
  overflow-x: auto;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbf9;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #345244;
  background: transparent;
  text-align: left;
  white-space: nowrap;
}

.nav-item svg,
.icon-button svg,
.primary-button svg,
.ghost-button svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.nav-item.active,
.nav-item:hover {
  color: var(--accent-strong);
  border-color: #b8dfca;
  background: var(--accent-soft);
}

.role-switch {
  display: grid;
  gap: 6px;
  grid-column: 3;
  grid-row: 1;
  min-width: 430px;
  color: var(--muted);
  font-size: 13px;
}

.role-switch label {
  color: var(--muted);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbf9;
}

.segmented button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  color: #345244;
  background: transparent;
}

.segmented button.active {
  color: #ffffff;
  background: var(--accent);
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar,
.section-head,
.status-strip,
.toolbar,
.dialog-actions {
  display: flex;
  align-items: center;
}

.topbar,
.section-head {
  justify-content: space-between;
  gap: 18px;
}

.topbar {
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.topbar h2 {
  font-size: 30px;
}

.month-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button,
.ghost-button,
.primary-button,
.small-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.icon-button {
  width: 40px;
  padding: 0;
  border-color: var(--line);
  background: var(--panel);
}

.primary-button {
  padding: 0 14px;
  color: #ffffff;
  background: var(--accent);
}

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

.ghost-button,
.small-button {
  padding: 0 12px;
  color: var(--ink);
  border-color: var(--line);
  background: #ffffff;
}

.danger-button {
  padding: 0 12px;
  color: #ffffff;
  background: var(--red);
}

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

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

.muted-label {
  color: var(--muted);
  font-weight: 500;
}

fieldset {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

legend {
  padding: 0 6px;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

.weekday-picker {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.weekday-picker label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.weekday-picker input {
  width: auto;
  min-height: auto;
}

.dialog-subgrid {
  display: grid;
  gap: 12px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.table-check {
  color: var(--ink);
  font-size: 13px;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 82px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  color: var(--accent);
  background: #dff4ef;
}

.metric-icon.warning {
  color: var(--amber);
  background: #fff2d7;
}

.metric strong {
  display: block;
  font-size: 24px;
}

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

.alert-panel {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid #f3c66f;
  border-radius: 8px;
  color: #7a4100;
  background: #fff8e6;
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.section-head {
  margin-bottom: 12px;
}

.section-head.compact {
  align-items: flex-start;
  margin-bottom: 14px;
}

.section-head h3 {
  font-size: 18px;
}

.section-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.toolbar {
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar label {
  min-width: 150px;
}

.relocation-toolbar {
  justify-content: flex-end;
}

.relocation-toolbar input,
.relocation-toolbar select {
  width: auto;
  min-width: 160px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #475467;
  background: var(--panel-soft);
  font-size: 12px;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.date-column,
.date-cell {
  position: sticky;
  left: 0;
  z-index: 2;
  width: 132px;
  min-width: 132px;
  background: #ffffff;
}

th.date-column {
  z-index: 3;
  background: var(--panel-soft);
}

.date-cell strong,
.date-cell span {
  display: block;
}

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

.schedule-cell {
  width: 230px;
  min-width: 230px;
}

.cell-shift {
  display: grid;
  gap: 7px;
  min-height: 118px;
  padding: 10px;
  border: 1px solid #dbe5e2;
  border-radius: 8px;
  background: #f9fcfb;
}

.cell-shift + .cell-shift {
  margin-top: 8px;
}

.cell-shift.uncovered {
  border-color: #f1d391;
  background: #fff9eb;
}

.cell-shift.closed {
  border-color: #d7dde5;
  background: #f3f5f7;
}

.cell-line {
  min-width: 0;
  color: #344054;
  font-size: 13px;
  line-height: 1.25;
}

.person-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.person-line strong {
  min-width: 0;
  color: var(--ink);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.person-line .small-button {
  min-height: 28px;
  padding: 0 8px;
  margin-left: auto;
  font-size: 12px;
}

.split-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel-column {
  display: grid;
  gap: 16px;
}

.panel form,
form.panel {
  display: grid;
  gap: 13px;
}

.wide {
  min-width: 0;
}

.form-grid {
  display: grid;
  gap: 10px;
}

.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.person-card,
.list-item {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.person-card h4,
.list-item h4 {
  margin: 0 0 4px;
}

.quota-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.quota {
  padding: 10px;
  border-radius: 8px;
  background: #ffffff;
}

.quota b {
  display: block;
  font-size: 17px;
}

.quota span {
  color: var(--muted);
  font-size: 12px;
}

.quota-matrix {
  display: grid;
  gap: 4px;
}

.quota-matrix strong {
  font-size: 16px;
}

.quota-matrix span {
  color: var(--muted);
  font-size: 12px;
}

.stack-list {
  display: grid;
  gap: 10px;
}

.my-shift-list {
  display: grid;
  gap: 10px;
}

.my-shift-card {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.my-shift-card.closed {
  background: #f7f8fa;
}

.my-shift-card.uncovered {
  border-color: #f1d391;
  background: #fffaf0;
}

.my-shift-date {
  display: grid;
  align-content: center;
  gap: 3px;
  padding: 10px;
  border-radius: 8px;
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.my-shift-date strong {
  font-size: 17px;
}

.my-shift-date span {
  color: #345244;
  font-size: 12px;
  font-weight: 700;
}

.my-shift-main {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.my-shift-main h4 {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.my-shift-detail {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: #344054;
  font-size: 14px;
}

.my-shift-detail svg {
  width: 16px;
  height: 16px;
  color: var(--accent);
  flex: 0 0 auto;
}

.my-shift-action {
  justify-self: start;
  min-height: 34px;
}

.request-table-wrap {
  margin-bottom: 12px;
}

.request-cell-action {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.request-cell-action .small-button {
  min-height: 30px;
}

.subsection-label {
  color: #344054;
  font-size: 13px;
  font-weight: 800;
}

.stack-spacer {
  min-height: 1px;
}

.compact-list {
  gap: 8px;
}

.list-item {
  display: grid;
  gap: 8px;
}

.compact-item {
  padding: 10px;
}

.list-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--accent-strong);
  background: #dff4ef;
  font-size: 12px;
  font-weight: 800;
}

.pill.warning {
  color: #8a4b00;
  background: #fff0cf;
}

.pill.closed {
  color: #344054;
  background: #e9edf2;
}

.pill.blue {
  color: #194da7;
  background: #e4edff;
}

.form-notice {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 13px;
}

.timeline {
  display: grid;
  gap: 10px;
}

.log-entry {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

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

.total-row td {
  border-top: 2px solid var(--accent);
  background: #f2faf5;
}

.empty-state {
  display: grid;
  min-height: 120px;
  place-items: center;
  gap: 8px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.empty-state svg {
  width: 32px;
  height: 32px;
}

dialog {
  width: min(480px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 70px rgba(18, 52, 59, 0.28);
}

dialog::backdrop {
  background: rgba(18, 32, 42, 0.38);
}

.dialog-content {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.dialog-content h3,
.dialog-content p {
  margin: 0;
}

.dialog-actions {
  justify-content: flex-end;
  gap: 8px;
}

.hidden,
body.viewer .manager-only,
body.staff .manager-only,
body:not(.admin) .admin-only,
body:not(.viewer) .user-only {
  display: none !important;
}

@media (max-width: 980px) {
  .app-header {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .brand,
  .role-switch,
  .nav-list {
    grid-column: 1;
  }

  .brand {
    grid-row: 1;
  }

  .role-switch {
    grid-row: 2;
  }

  .nav-list {
    grid-row: 3;
    width: 100%;
  }

  .role-switch {
    min-width: 0;
  }

  .status-strip,
  .split-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .main,
  .app-header {
    padding: 18px;
  }

  .brand {
    grid-column: 1;
    grid-row: auto;
    width: 100%;
  }

  .role-switch {
    grid-column: 1;
    grid-row: auto;
    width: 100%;
    min-width: 0;
  }

  .topbar,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar,
  .month-controls {
    width: 100%;
  }

  .relocation-toolbar input,
  .relocation-toolbar select,
  .toolbar select,
  .month-controls input {
    width: 100%;
    min-width: 0;
  }

  .form-grid.two,
  .form-grid.three,
  .weekday-picker,
  .quota-grid {
    grid-template-columns: 1fr;
  }

  .log-entry {
    grid-template-columns: 1fr;
  }

  .my-shift-card {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px;
  }

  .my-shift-date {
    grid-template-columns: auto 1fr;
    align-items: baseline;
    align-content: center;
  }

  .my-shift-main .list-row {
    align-items: flex-start;
  }

  body.viewer .status-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .app-header,
  .topbar,
  .status-strip,
  .alert-panel,
  .section-head .toolbar,
  .manager-only,
  .admin-only,
  .small-button,
  .ghost-button,
  .danger-button,
  dialog {
    display: none !important;
  }

  .main {
    padding: 0;
  }

  .view {
    display: none !important;
  }

  body[data-print-view="schedule"] #scheduleView,
  body[data-print-view="relocations"] #relocationsView {
    display: block !important;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
    box-shadow: none;
  }

  table {
    width: 100%;
    min-width: 0;
    font-size: 11px;
  }

  th {
    position: static;
  }
}
