:root {
  color-scheme: light;
  --ink: #1f2933;
  --muted: #607080;
  --line: #d7dde3;
  --paper: #f6f8fa;
  --panel: #ffffff;
  --accent: #126e82;
  --accent-dark: #0c4f61;
  --ok: #1f7a3f;
  --warn: #a85c00;
  --bad: #b42318;
  --soft-warn: #fff4df;
  --soft-bad: #ffefed;
  --soft-ok: #eaf7ef;
  font-family: "Segoe UI", Roboto, Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #eef4f6 0, #f8fafb 280px);
  color: var(--ink);
}

body:not(.signed-out) {
  padding-left: 248px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.file-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}

button:hover,
.file-button:hover {
  background: var(--accent-dark);
}

.danger-button {
  border-color: var(--bad);
  background: #fff;
  color: var(--bad);
}

.danger-button:hover {
  background: var(--soft-bad);
  color: var(--bad);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  background: #fff;
  color: var(--ink);
}

select[multiple] {
  min-height: 150px;
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 24px;
  padding: 24px clamp(16px, 3vw, 36px);
  background: #113946;
  color: #fff;
}

.topbar h1 {
  margin: 0 0 6px;
  font-size: clamp(1.5rem, 2.5vw, 2.15rem);
  letter-spacing: 0;
}

.topbar p {
  margin: 0;
  color: #d8e7eb;
}

.status-card {
  display: grid;
  align-content: center;
  min-width: 250px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.08);
}

.status-card .label {
  color: #c1d9df;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.status-card strong {
  font-size: 1.25rem;
}

.approval-card {
  min-width: 280px;
}

.auth-band {
  position: sticky;
  top: 0;
  z-index: 11;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px clamp(16px, 3vw, 36px);
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.auth-band > div {
  display: grid;
  gap: 2px;
}

.auth-band .label {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.auth-band strong {
  font-size: 1rem;
}

.auth-band span:last-child {
  color: var(--muted);
  font-size: 0.85rem;
}

.auth-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.auth-form input {
  width: min(220px, 38vw);
}

.login-view {
  display: none;
  min-height: calc(100vh - 180px);
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

.login-card {
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(17, 57, 70, 0.12);
}

.login-card h2 {
  margin: 8px 0;
  font-size: 1.8rem;
}

.login-card p {
  margin: 0;
  color: var(--muted);
}

.account-request-panel {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.account-request-panel summary {
  cursor: pointer;
  color: var(--accent-dark);
  font-weight: 800;
}

.account-request-panel .control-grid {
  margin-top: 14px;
}

body.signed-out .tabs,
body.signed-out .sidebar-toggle,
body.signed-out main > .view,
body.signed-out .status-card {
  display: none !important;
}

body.signed-out #loginView {
  display: flex;
}

body.staff-session .tabs button:not(#portalTab),
body.staff-session main > .view:not(#portalView),
body.manager-session #approveBtn,
body.manager-session #overrideBtn,
body.manager-session #rejectBtn,
body.manager-session .approval-card,
body.manager-session #approvalQueue,
body.staff-session .approval-card,
body.staff-session .status-card,
body.signed-out .approval-card {
  display: none !important;
}

body.staff-session #portalTab {
  display: inline-flex;
}

.approval-queue {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.approval-queue button {
  min-height: 28px;
  padding: 4px 8px;
  border-color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.12);
  font-size: 0.78rem;
}

.approval-queue span {
  color: #c1d9df;
  font-size: 0.82rem;
}

.tabs {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: grid;
  align-content: start;
  width: 248px;
  gap: 6px;
  padding: 18px 12px;
  border-right: 1px solid var(--line);
  background: #102f3a;
  box-shadow: 10px 0 28px rgba(17, 57, 70, 0.12);
}

.tabs button {
  justify-content: start;
  border-color: rgba(255, 255, 255, 0.14);
  background: transparent;
  color: #d8e7eb;
  text-align: left;
}

.tabs button.active {
  border-color: rgba(255, 255, 255, 0.32);
  background: var(--accent);
  color: #fff;
}

.sidebar-toggle {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 30;
  width: 40px;
  padding: 0;
}

body.sidebar-collapsed {
  padding-left: 72px;
}

body.sidebar-collapsed .tabs {
  width: 72px;
  padding-top: 60px;
}

body.sidebar-collapsed .tabs button {
  justify-content: center;
  overflow: hidden;
  text-indent: -999px;
}

@media (max-width: 760px) {
  body:not(.signed-out),
  body.sidebar-collapsed {
    padding-left: 0;
  }

  .tabs {
    position: static;
    width: auto;
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
    padding: 10px 12px;
    border-right: 0;
  }

  .sidebar-toggle {
    display: none;
  }

  body.sidebar-collapsed .tabs {
    width: auto;
    padding-top: 10px;
  }

  body.sidebar-collapsed .tabs button {
    text-indent: 0;
  }
}

.staff-actions button.active {
  background: var(--accent-dark);
}

main {
  display: grid;
  gap: 18px;
  padding: 18px clamp(12px, 2.5vw, 30px) 30px;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 18px;
}

.home-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(280px, 0.7fr);
  gap: 18px;
}

.home-grid .panel:last-child {
  grid-column: 1 / -1;
}

.controls-band,
.panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  padding: 16px;
  box-shadow: 0 8px 24px rgba(17, 57, 70, 0.05);
}

.control-grid,
.rule-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
}

.control-grid.compact {
  grid-template-columns: repeat(2, minmax(180px, 1fr));
}

.wide-field {
  grid-column: 1 / -1;
}

.rule-grid {
  grid-template-columns: repeat(3, minmax(150px, 1fr));
}

.panel-subsection {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.panel-subsection h3 {
  margin: 0;
  font-size: 0.98rem;
}

.opening-hours-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(120px, 1fr));
  gap: 10px;
}

.opening-hours-day {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfd;
}

.opening-hours-day strong {
  grid-column: 1 / -1;
  font-size: 0.86rem;
}

.opening-hours-day input {
  min-width: 0;
}

.action-row,
.staff-rota-tools,
.staff-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin-top: 14px;
}

.staff-rota-tools,
.staff-actions {
  margin-top: 0;
}

.staff-rota-tools select {
  width: 220px;
}

.inline-control {
  min-width: 210px;
}

.inline-check {
  min-height: 38px;
  align-items: center;
}

.file-button input {
  display: none;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 1.12rem;
}

.hint,
.note {
  color: var(--muted);
  font-size: 0.88rem;
}

.note {
  margin: 12px 0 0;
}

.text-link {
  display: inline-block;
  margin-top: 12px;
  color: var(--accent-dark);
  font-weight: 700;
}

.saved-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 10px;
}

.saved-item {
  display: grid;
  gap: 10px;
  min-height: 110px;
  border-color: var(--line);
  background: #fbfcfd;
  color: var(--ink);
  text-align: left;
  white-space: normal;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.saved-item:hover {
  background: #eef7fa;
}

.saved-main {
  display: grid;
  gap: 3px;
}

.saved-main small,
.template-item small {
  color: var(--muted);
}

.saved-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 8px;
}

.saved-actions button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 6px 10px;
}

.saved-actions label {
  flex: 1 1 170px;
  min-width: 160px;
}

.weather-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 8px;
}

.weather-day {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: #fbfcfd;
}

.weather-day span {
  font-size: 1.1rem;
  font-weight: 800;
}

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

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

.document-item {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfd;
}

.document-item span {
  color: var(--muted);
  font-size: 0.88rem;
}

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

.request-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfd;
}

.request-item.is-reviewed {
  opacity: 0.78;
}

.request-item div {
  display: grid;
  gap: 3px;
}

.request-item span,
.request-item small {
  color: var(--muted);
}

.request-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.staff-home-panel {
  background: #f8fcfd;
}

.staff-home-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 10px;
}

.news-item {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: #fbfcfd;
}

.manager-update-item {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

.manager-update-item div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.manager-update-item .small {
  min-height: 32px;
  padding: 6px 10px;
}

.news-item a {
  color: var(--accent-dark);
  font-weight: 800;
  text-decoration: none;
}

.news-item a:hover {
  text-decoration: underline;
}

.event-form {
  margin-bottom: 8px;
}

.event-calendar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.portal-calendar-toolbar {
  display: grid;
  grid-template-columns: minmax(92px, auto) 1fr minmax(92px, auto);
  align-items: center;
  gap: 10px;
  margin: 4px 0 12px;
}

.portal-calendar-toolbar strong {
  text-align: center;
  font-size: 1rem;
}

.portal-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 14px;
}

.portal-calendar > strong {
  color: var(--muted);
  font-size: 0.76rem;
  text-align: center;
}

.portal-calendar-empty,
.portal-day {
  min-height: 92px;
}

.portal-day {
  display: grid;
  align-content: start;
  justify-items: start;
  gap: 4px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 8px;
  white-space: normal;
  text-align: left;
}

.portal-day:hover {
  background: #eef7f9;
  color: var(--ink);
}

.portal-day.is-selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.portal-day.has-submission {
  border-color: #7a9f35;
  background: #f1f8e7;
}

.portal-day span {
  font-weight: 800;
}

.portal-day small {
  display: inline-block;
  max-width: 100%;
  border-radius: 4px;
  padding: 2px 4px;
  background: #dcefc5;
  color: #3d5d0f;
  font-size: 0.68rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.event-month {
  display: grid;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfd;
}

.event-month > strong {
  font-size: 0.9rem;
}

.calendar-weekdays,
.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.calendar-weekdays span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-align: center;
}

.calendar-day {
  display: grid;
  place-items: center;
  min-height: 26px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.calendar-day.has-event {
  border-color: #6fb7c8;
  background: #e5f5f8;
  color: var(--accent-dark);
}

.calendar-day.empty {
  visibility: hidden;
}

.event-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.event-item {
  display: grid;
  grid-template-columns: minmax(110px, 0.7fr) minmax(160px, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-left: 4px solid #8ba4ad;
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfd;
}

.event-item.is-live {
  border-left-color: var(--bad);
  background: var(--soft-bad);
}

.event-item.is-soon {
  border-left-color: var(--warn);
  background: var(--soft-warn);
}

.event-item.is-past {
  opacity: 0.68;
}

.event-date-block,
.event-main {
  display: grid;
  gap: 3px;
}

.event-date-block span,
.event-main span,
.event-main small {
  color: var(--muted);
  font-size: 0.82rem;
}

.event-item button {
  min-height: 32px;
  padding: 6px 10px;
}

.news-item span {
  color: var(--muted);
  font-size: 0.78rem;
}

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

.template-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.template-builder-grid {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.template-day {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  overflow: hidden;
}

.template-day-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: #edf2f4;
}

.template-day-heading button {
  min-height: 32px;
  padding: 5px 10px;
}

.template-lines {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.template-line {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) repeat(3, minmax(92px, 0.7fr)) auto;
  gap: 8px;
  align-items: end;
}

.template-line button {
  min-height: 38px;
}

.template-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}

.template-item > div:first-child {
  display: grid;
  gap: 3px;
}

.template-item span {
  color: var(--muted);
}

.template-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.staff-detail {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 10px;
}

.staff-detail.is-archived {
  opacity: 0.72;
  background: #f3f4f4;
}

.staff-detail summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}

.staff-detail summary strong {
  font-size: 1.04rem;
}

.staff-detail summary span {
  color: var(--muted);
}

.staff-detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.staff-search {
  min-width: 260px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.staff-search select {
  min-width: 180px;
}

.store-eligibility {
  display: grid;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fbfcfd;
}

.store-eligibility legend {
  padding: 0 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.check-label input {
  width: auto;
  min-height: auto;
}

.coverage-toggle {
  align-self: end;
  border-color: var(--line);
  background: #fff;
  color: var(--accent-dark);
}

.coverage-toggle:hover {
  background: #eef7fa;
}

.coverage-toggle.is-excluded {
  border-color: var(--warn);
  background: var(--soft-warn);
  color: var(--warn);
}

.archive-toggle {
  align-self: end;
  border-color: var(--bad);
  background: #fff;
  color: var(--bad);
}

.archive-toggle:hover {
  background: var(--soft-bad);
  color: var(--bad);
}

.archive-toggle.is-restore {
  border-color: var(--ok);
  background: var(--soft-ok);
  color: var(--ok);
}

.unavailability-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.unavailability-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfcfd;
}

.unavailability-item div {
  display: grid;
  gap: 2px;
}

.unavailability-item span {
  color: var(--muted);
}

.unavailability-item small {
  color: var(--muted);
}

.import-preview {
  margin-top: 12px;
  overflow-x: auto;
}

.import-preview-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: #fff;
}

.import-preview-table th,
.import-preview-table td {
  padding: 6px 8px;
  font-size: 0.84rem;
}

.demand-grid,
.rota-grid {
  overflow-x: auto;
}

.demand-table,
.stock-table,
.rota-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  border: 1px solid var(--line);
  padding: 7px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #edf2f4;
  color: #314653;
  font-size: 0.78rem;
}

.demand-table input {
  min-width: 64px;
}

.stock-list {
  overflow-x: auto;
}

.stock-table {
  min-width: 960px;
}

.stock-table input {
  width: 100%;
  min-width: 90px;
}

.stock-table td:nth-child(6) {
  background: #f4faf7;
}

.rota-sheet {
  min-width: 1320px;
  table-layout: fixed;
  font-size: 0.78rem;
  background: #fff;
}

.rota-sheet caption {
  caption-side: top;
  padding: 4px 0 6px;
  color: #6c5a4c;
  font-size: 1.28rem;
  font-weight: 800;
  letter-spacing: 0;
}

.rota-sheet th,
.rota-sheet td {
  height: 22px;
  padding: 1px 3px;
  border-color: #9aa3aa;
  text-align: center;
  line-height: 1.1;
}

.rota-sheet .date-cell {
  width: 74px;
  background: #d7d83f;
  color: #303514;
  font-weight: 800;
}

.rota-sheet .day-name-cell {
  width: 132px;
  background: #3e3f38;
  color: #fff;
  font-size: 0.86rem;
  text-align: center;
}

.rota-sheet .day-name-cell span {
  display: block;
  margin-bottom: 4px;
}

.inline-order {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 600;
}

.inline-order input {
  width: auto;
  min-height: auto;
}

.rota-sheet .brand-cell {
  background: #b56f2d;
  color: #2f271f;
  font-size: 1rem;
  font-weight: 800;
}

.rota-sheet .metric-head,
.rota-sheet .time-row th:last-child,
.rota-sheet .time-row th:nth-last-child(2),
.rota-sheet .time-row th:nth-last-child(3),
.rota-sheet .time-row th:nth-last-child(4) {
  background: #6d6247;
  color: #fff;
  width: 72px;
}

.rota-sheet .name-head,
.rota-sheet .person-cell,
.rota-sheet .demand-row th,
.rota-sheet .coverage-row th {
  width: 132px;
  background: #eef1f3;
  color: #333;
  text-align: left;
  font-weight: 800;
}

.rota-sheet .person-cell {
  font-size: 0.84rem;
}

.rota-sheet .time-row th {
  background: #f3f4f4;
  color: #333;
  font-weight: 700;
}

.rota-sheet .person-rota-row td {
  background: #fbfbfb;
}

.shift-paint-cell {
  cursor: crosshair;
  user-select: none;
}

.rota-sheet .person-rota-row .shift-on {
  background: #3f403b;
  color: #111;
}

.rota-sheet .person-rota-row .drag-preview {
  background: #126e82;
  color: #fff;
}

.rota-sheet .note-row td,
.rota-sheet .note-row th {
  background: #fbfcfd;
  text-align: left;
  vertical-align: top;
}

.note-block {
  display: grid;
  gap: 6px;
  padding: 5px 3px;
}

.note-list {
  display: grid;
  gap: 5px;
}

.note-empty {
  color: var(--muted);
  font-size: 0.78rem;
}

.note-item,
.note-composer {
  display: grid;
  grid-template-columns: 110px minmax(220px, 1fr) auto auto;
  align-items: center;
  gap: 6px;
}

.note-item select,
.note-item input,
.note-composer select,
.note-composer input {
  min-height: 30px;
  font-size: 0.76rem;
}

.note-item small {
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.note-item button,
.note-composer button {
  min-height: 30px;
  padding: 5px 8px;
  font-size: 0.76rem;
}

.person-cell > span:first-child {
  display: block;
  margin-bottom: 2px;
}

.person-cell select {
  height: 24px;
  min-height: 24px;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 0.82rem;
  font-weight: 700;
}

.mini-remove {
  float: right;
  min-height: 18px;
  padding: 1px 5px;
  border-color: var(--bad);
  background: #fff;
  color: var(--bad);
  font-size: 0.66rem;
}

.mini-controls {
  display: grid;
  grid-template-columns: 1fr 1fr 44px;
  gap: 2px;
  clear: both;
}

.mini-controls input {
  min-height: 18px;
  height: 18px;
  min-width: 0;
  padding: 1px 2px;
  border-radius: 0;
  font-size: 0.66rem;
}

.day-add-row td {
  background: #f7fafb;
  text-align: left;
}

.day-add-row button {
  min-height: 24px;
  padding: 3px 8px;
  background: #fff;
  color: var(--accent-dark);
  font-size: 0.72rem;
}

.demand-row td {
  background: #fff7fb;
  color: #9a3761;
  font-size: 0.74rem;
  font-weight: 700;
}

.coverage-row td {
  background: #f7fbff;
  color: #344255;
  font-size: 0.74rem;
}

.coverage-row .under {
  background: var(--soft-bad);
  color: var(--bad);
  font-weight: 800;
}

.coverage-row .over {
  background: var(--soft-warn);
  color: var(--warn);
  font-weight: 800;
}

.coverage-row .right {
  background: var(--soft-ok);
  color: var(--ok);
  font-weight: 800;
}

.is-locked {
  opacity: 0.6;
  pointer-events: none;
}

.week-total-row th,
.week-total-row td {
  background: #d7d83f;
  color: #2f3314;
  font-weight: 800;
}

.fairness-panel {
  display: grid;
  gap: 10px;
  margin: 0 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}

.compact-heading h3 {
  margin: 0;
  font-size: 1rem;
}

.fairness-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.fairness-summary {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 210px;
  color: var(--muted);
  font-weight: 700;
}

.fairness-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  min-height: 30px;
  border-radius: 999px;
  padding: 4px 10px;
  color: #fff;
  font-weight: 900;
}

.fairness-score.ok {
  background: var(--ok);
}

.fairness-score.warning {
  background: var(--warn);
}

.fairness-score.bad {
  background: var(--bad);
}

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

.fairness-finding {
  display: grid;
  gap: 5px;
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  padding: 9px 10px;
  background: #eef7fa;
}

.fairness-finding strong {
  font-size: 0.88rem;
}

.fairness-finding span,
.fairness-finding small {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.fairness-finding.ok {
  border-left-color: var(--ok);
  background: var(--soft-ok);
}

.fairness-finding.warning {
  border-left-color: var(--warn);
  background: var(--soft-warn);
}

.fairness-finding.bad {
  border-left-color: var(--bad);
  background: var(--soft-bad);
}

.warnings {
  display: grid;
  gap: 8px;
}

.warning {
  display: grid;
  gap: 8px;
  border-left: 4px solid var(--warn);
  background: var(--soft-warn);
  padding: 10px;
  border-radius: 6px;
}

.warning.bad {
  border-left-color: var(--bad);
  background: var(--soft-bad);
}

.warning.info {
  border-left-color: var(--accent);
  background: #eef7fa;
}

.warning.ok {
  border-left-color: var(--ok);
  background: var(--soft-ok);
}

.check-title {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.severity-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 2px 8px;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
}

.severity-pill.critical {
  background: var(--bad);
}

.severity-pill.warning {
  background: var(--warn);
}

.severity-pill.info {
  background: var(--accent);
}

.publish-summary {
  margin-bottom: 12px;
}

.publish-summary-card {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: 8px;
  padding: 10px 12px;
  background: #f7fafb;
}

.publish-summary-card.bad {
  border-left-color: var(--bad);
  background: var(--soft-bad);
}

.publish-summary-card.ok {
  border-left-color: var(--ok);
  background: var(--soft-ok);
}

.publish-summary-card strong {
  font-size: 0.98rem;
}

.publish-summary-card span,
.publish-summary-card small {
  color: var(--muted);
}

.publish-summary-card ul {
  margin: 4px 0 0 18px;
  padding: 0;
}

.app-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(17, 57, 70, 0.34);
  pointer-events: auto;
}

.app-modal {
  display: grid;
  gap: 12px;
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(17, 57, 70, 0.24);
  pointer-events: auto;
}

.app-modal h2 {
  margin: 0;
  font-size: 1.08rem;
}

.app-modal p {
  margin: 0;
  color: var(--muted);
}

.app-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.app-modal-actions .secondary {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.fix-row {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.84rem;
}

.fix-row button {
  min-height: 30px;
  padding: 4px 10px;
}

.ai-notes {
  display: grid;
  gap: 8px;
}

.historical-notes {
  display: grid;
  gap: 8px;
}

.historical-note {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fbfcfd;
}

.historical-note strong {
  color: var(--accent-dark);
}

.historical-note span,
.historical-note small {
  color: var(--muted);
}

.review-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.review-grid label:first-child {
  grid-column: 1 / -1;
}

.ai-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #f7fafb;
}

.ai-note.muted {
  color: var(--muted);
}

.weekly-hours-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.demand-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.demand-summary div {
  display: grid;
  gap: 2px;
  min-width: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  background: #f7fafb;
}

.demand-summary span {
  color: var(--muted);
  font-size: 0.74rem;
}

.demand-summary strong {
  font-size: 0.96rem;
}

.weekly-hours-summary div {
  display: grid;
  gap: 2px;
  min-width: 140px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #f7fafb;
}

.weekly-hours-summary span {
  color: var(--muted);
  font-size: 0.78rem;
}

.weekly-hours-summary strong {
  font-size: 1.05rem;
}

@media (max-width: 980px) {
  .topbar,
  .home-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .control-grid,
  .control-grid.compact,
  .rule-grid,
  .opening-hours-grid,
  .staff-detail-grid,
  .order-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 620px) {
  .control-grid,
  .control-grid.compact,
  .rule-grid,
  .opening-hours-grid,
  .staff-detail-grid,
  .order-grid {
    grid-template-columns: 1fr;
  }

  .status-card {
    min-width: 0;
  }

  .staff-detail summary {
    display: grid;
  }

  .staff-rota-tools,
  .staff-rota-tools select,
  .staff-actions,
  .staff-actions button,
  .action-row button,
  .action-row label,
  .file-button {
    width: 100%;
  }

  .saved-actions,
  .event-item,
  .template-item {
    display: grid;
    grid-template-columns: 1fr;
  }

  .template-actions,
  .template-actions button,
  .saved-actions button,
  .event-item button,
  .template-line {
    width: 100%;
  }

  .template-line {
    grid-template-columns: 1fr;
  }

  .rota-grid {
    margin-left: -16px;
    margin-right: -16px;
    padding: 0 10px 8px;
  }

  .rota-sheet {
    min-width: 980px;
    font-size: 0.66rem;
  }

  .rota-sheet th,
  .rota-sheet td {
    padding: 2px;
  }

  .mini-controls {
    grid-template-columns: 54px 54px 38px;
  }
}

@media print {
  html,
  body {
    width: 210mm;
    height: 297mm;
    margin: 0;
    background: #fff;
  }

  body:not(.print-mode) > * {
    display: none !important;
  }

  body.print-mode > *:not(#printSheet) {
    display: none !important;
  }

  #printSheet {
    display: block !important;
    width: var(--print-page-width, 202mm);
    height: var(--print-page-height, 289mm);
    overflow: hidden;
    color: #111;
    font-family: Arial, Helvetica, sans-serif;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
    break-after: avoid;
    page-break-after: avoid;
  }

  .print-sheet-content {
    width: var(--print-content-width, 202mm);
    transform: scale(var(--print-fit-scale, 1));
    transform-origin: top left;
  }

  .print-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    height: 12mm;
    margin-bottom: 1.5mm;
    border-bottom: 0.28mm solid #444;
  }

  .print-header h1 {
    margin: 0;
    font-size: 12pt;
    line-height: 1;
  }

  .print-header p,
  .print-header span {
    display: block;
    margin: 1mm 0 0;
    font-size: 7pt;
  }

  .print-rota-table {
    width: 100%;
    height: var(--print-table-height, 274mm);
    border-collapse: collapse;
    table-layout: fixed;
    font-size: var(--print-font-size, 5.2pt);
    line-height: 1.05;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .print-rota-table th,
  .print-rota-table td {
    border: 0.12mm solid #7a7f86;
    padding: 0.16mm 0.28mm;
    text-align: center;
    vertical-align: middle;
    height: var(--print-row-height, 2.35mm);
    overflow: hidden;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .print-rota-table tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .print-rota-table th {
    background: #eef1f4;
    font-weight: 800;
    font-size: calc(var(--print-font-size, 5.2pt) + 0.35pt);
  }

  .print-date {
    width: 17mm;
    background: #d6d83a !important;
    font-size: calc(var(--print-font-size, 5.2pt) + 1pt) !important;
    font-weight: 900 !important;
  }

  .print-day {
    width: 21mm;
    background: #30332f !important;
    color: #fff;
    font-weight: 900 !important;
  }

  .print-brand {
    background: #c68643 !important;
    color: #111;
    font-size: calc(var(--print-font-size, 5.2pt) + 1pt);
    font-weight: 900 !important;
  }

  .print-name-cell {
    text-align: left !important;
    padding-left: 0.7mm !important;
    font-weight: 900 !important;
  }

  .print-time-row th {
    font-weight: 900 !important;
  }

  .print-total-cell {
    background: #fff !important;
    color: #111 !important;
    font-weight: 500;
    font-size: calc(var(--print-font-size, 5.2pt) - 0.45pt);
  }

  .print-shift {
    background: #383a36 !important;
    color: #111;
  }

  .print-demand td {
    background: #fff8fb;
    color: #6d324d;
    font-size: calc(var(--print-font-size, 5.2pt) - 0.55pt);
  }

  .print-demand th,
  .print-cover th,
  .print-cover td {
    font-size: calc(var(--print-font-size, 5.2pt) - 0.6pt);
  }

  .print-cover td.right {
    background: #eef8f1;
    color: #1f7a3f;
  }

  .print-cover td.over {
    background: #fff4df;
    color: #8b4d00;
  }

  .print-cover td.under {
    background: #ffefed;
    color: #9f2017;
  }

  body.native-print-mode #printSheet {
    width: 289mm;
    height: 202mm;
  }

  body.native-print-mode .print-header {
    height: 9mm;
    margin-bottom: 1.5mm;
  }

  body.native-print-mode .print-header h1 {
    font-size: 11pt;
  }

  body.native-print-mode .print-header p,
  body.native-print-mode .print-header span {
    font-size: 6.4pt;
  }

  body.native-print-mode .print-date {
    width: 19mm;
  }

  body.native-print-mode .print-day {
    width: 25mm;
  }
}

#printSheet {
  display: none;
}
