:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #eef3f1;
  color: #142024;
  --ink: #142024;
  --muted: #5f6e75;
  --line: #d5dfdc;
  --panel: #fbfdfb;
  --panel-strong: #ffffff;
  --teal: #0f766e;
  --blue: #2457a6;
  --red: #b42318;
  --amber: #9a6700;
  --yellow: #fff4bf;
  --soft-blue: #eef5ff;
  --soft-teal: #e8f8f5;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
}

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

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  border-color: #9eb5ae;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

[hidden] {
  display: none !important;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(100%, 460px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 28px;
  box-shadow: 0 24px 60px rgba(20, 32, 36, 0.12);
}

.login-panel h1 {
  font-size: 2.4rem;
}

.login-copy {
  margin: 14px 0 20px;
  color: var(--muted);
  line-height: 1.55;
}

.login-form {
  display: grid;
  gap: 12px;
}

.login-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-weight: 800;
}

.recovery-form {
  margin-top: 20px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.recovery-form h2 {
  color: var(--ink);
}

.recovery-message {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.35;
}

.app-shell {
  width: min(1840px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 8px 0 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 3.35rem);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
  letter-spacing: 0;
}

.topbar-actions,
.panel-actions {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.session-pill {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  border: 1px solid #b8ded6;
  border-radius: 999px;
  background: var(--soft-teal);
  color: #115e59;
  padding: 0 14px;
  font-size: 0.9rem;
  font-weight: 900;
}

.compact-field,
.resident-form label,
.profile-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

input,
select {
  min-height: 40px;
}

textarea {
  min-height: 82px;
  padding-top: 10px;
  resize: vertical;
}

fieldset {
  display: flex;
  min-width: 0;
  gap: 10px;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0;
  padding: 11px 12px 12px;
}

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

fieldset label,
.availability-row label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 700;
}

fieldset input,
.availability-row input {
  width: 16px;
  min-height: 16px;
}

.ghost-button {
  min-width: 72px;
  padding: 0 14px;
}

.primary-button {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.danger-button {
  border-color: #f0b5af;
  color: var(--red);
  padding: 0 14px;
}

.text-button {
  min-height: 32px;
  border: 0;
  background: transparent;
  color: var(--blue);
  padding: 0;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metrics article,
.sidebar,
.rota-panel,
.profile-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metrics article {
  display: grid;
  gap: 4px;
  padding: 16px;
}

.metrics span,
.metrics small {
  color: var(--muted);
  font-weight: 700;
}

.metrics strong {
  font-size: 1.8rem;
  line-height: 1;
}

.rota-tabs,
.month-tabs,
.app-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.rota-tabs,
.app-tabs {
  margin-bottom: 16px;
}

.rota-tabs-wrap {
  display: flex;
  align-items: start;
  gap: 8px;
  margin-bottom: 16px;
}

.rota-tabs-wrap .rota-tabs {
  margin-bottom: 0;
}

.add-rota-button {
  width: 38px;
  min-width: 38px;
  min-height: 38px;
  border-color: #76b7ae;
  background: var(--soft-teal);
  color: #115e59;
  font-size: 1.2rem;
  line-height: 1;
}

.tab-button,
.month-tab,
.app-tab {
  min-height: 38px;
  padding: 0 14px;
}

.tab-button.active,
.month-tab.active,
.app-tab.active {
  border-color: #76b7ae;
  background: var(--soft-teal);
  color: #115e59;
}

.tab-button span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 24px;
  margin-left: 8px;
  border-radius: 999px;
  background: #e8edf0;
  color: var(--muted);
  font-size: 0.78rem;
}

.rota-name-form {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
}

.rota-name-form input {
  width: min(220px, 36vw);
  min-height: 30px;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  font-weight: 800;
}

.rota-name-form input:focus {
  outline: 2px solid #76b7ae;
  outline-offset: 3px;
}

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

.sidebar {
  padding: 16px;
}

.main-column {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  gap: 16px;
  align-items: start;
}

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

.section-heading {
  margin-bottom: 14px;
}

.resident-form {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.form-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.form-divider::before,
.form-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.inline-message {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.35;
}

.admin-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  padding: 10px;
  font-size: 0.86rem;
  font-weight: 700;
}

body[data-role="admin"] .trainee-note {
  display: none;
}

body[data-role="trainee"] .admin-only {
  display: none !important;
}

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

.resident-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  padding: 6px;
}

.resident-row.active {
  border-color: #76b7ae;
  background: var(--soft-teal);
}

.resident-select {
  display: grid;
  min-width: 0;
  min-height: 44px;
  justify-items: start;
  gap: 2px;
  border: 0;
  background: transparent;
  padding: 4px;
  text-align: left;
}

.resident-select strong,
.resident-select span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resident-select span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.remove-button {
  width: 36px;
  min-height: 36px;
  color: var(--red);
}

.actions-heading {
  margin-top: 22px;
}

.action-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

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

.rota-panel,
.profile-panel {
  min-width: 0;
  overflow: hidden;
}

.table-header,
.profile-header {
  border-bottom: 1px solid var(--line);
  padding: 16px;
}

.table-header p {
  margin: 6px 0 0;
  color: var(--muted);
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(164px, 1fr));
  overflow-x: auto;
}

.month-head {
  min-height: 42px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #f5f8f7;
  color: var(--muted);
  padding: 12px;
  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
}

.month-day {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 228px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
  padding: 10px;
}

.month-day.blank {
  background: #f7faf9;
}

.month-day.today {
  background: var(--soft-blue);
}

.month-day.bank-holiday {
  background: var(--yellow);
}

.day-number {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.day-number strong {
  font-size: 1.1rem;
}

.day-number span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.holiday-label {
  border: 1px solid #dfc45d;
  border-radius: 8px;
  background: #fff9d8;
  color: #6b4f00;
  padding: 5px 7px;
  font-size: 0.76rem;
  font-weight: 900;
}

.month-shift {
  display: grid;
  gap: 5px;
  border: 1px solid #e3eae8;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  padding: 8px;
}

.month-shift > span,
.shift-item span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 900;
}

.month-shift b {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.month-shift select {
  min-width: 128px;
  min-height: 34px;
  padding: 0 8px;
  font-size: 0.86rem;
}

.month-shift small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.privacy-status {
  color: var(--muted);
  font-size: 0.86rem;
}

.shift-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--teal);
}

.shift-dot.evening {
  background: var(--amber);
}

.shift-dot.night {
  background: var(--blue);
}

.shift-dot.daytime {
  background: var(--teal);
}

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

.profile-form > fieldset,
.wide-field,
.profile-form > .primary-button {
  grid-column: 1 / -1;
}

.notes-save-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.notes-save-row label {
  min-width: 0;
}

.notes-save-row .primary-button {
  min-width: 170px;
}

.inline-fieldset {
  display: grid;
  gap: 8px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.inline-fieldset label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.availability-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.availability-grid {
  display: grid;
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.availability-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
}

.availability-row:last-child {
  border-bottom: 0;
}

.availability-row.bank {
  background: #fff7ce;
}

.availability-row strong {
  display: grid;
  gap: 2px;
  font-size: 0.86rem;
}

.availability-row strong span {
  color: #6b4f00;
  font-size: 0.75rem;
}

.availability-row .weekday-label {
  color: var(--muted);
  font-size: 0.78rem;
}

.trainee-schedule {
  border-top: 1px solid var(--line);
  padding: 16px;
}

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

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

.shift-item strong {
  color: var(--muted);
  font-size: 0.82rem;
  text-align: right;
}

.empty-state {
  border: 1px dashed #c6d5d1;
  border-radius: 8px;
  padding: 16px;
  color: var(--muted);
  font-weight: 700;
}

.uncovered-panel {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
}

.uncovered-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.uncovered-row {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.uncovered-row span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  font-weight: 900;
}

.uncovered-row b,
.uncovered-row em {
  color: var(--muted);
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 800;
}

.holiday-chip {
  width: fit-content;
  border-radius: 999px;
  background: #fff4bf;
  color: #6b4f00;
  padding: 4px 8px;
  font-size: 0.72rem;
  font-weight: 900;
}

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

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

.rules-header,
.rules-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
}

.rules-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.rules-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.rules-grid article {
  background: #fff;
}

.rules-grid h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.rules-grid ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.45;
}

.preview-panel {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(260px, 1fr) minmax(180px, 1fr);
  align-items: end;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  margin-bottom: 16px;
  padding: 16px;
}

.previewing .admin-only {
  display: none !important;
}

.user-create-panel,
.user-list-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
}

.user-form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.user-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.retention-warning {
  margin: 0;
  color: var(--red);
  font-size: 0.86rem;
  font-weight: 900;
  line-height: 1.4;
}

.user-management-heading {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.activity-note {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.user-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 130px 120px 140px;
  gap: 10px;
  margin-bottom: 12px;
}

.user-toolbar label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.user-table {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.user-empty {
  margin: 12px;
}

.user-row {
  display: grid;
  grid-template-columns: 1.1fr 0.55fr 1.1fr 0.65fr 0.9fr 1.2fr;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 12px;
}

.activity-row {
  grid-template-columns: 1.1fr 0.55fr 1.1fr 0.65fr 0.9fr;
}

.user-row strong {
  display: grid;
  gap: 3px;
}

.user-row strong small {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.user-row:last-child {
  border-bottom: 0;
}

.user-head {
  background: #f5f8f7;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
}

.user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.user-actions button {
  min-height: 32px;
  padding: 0 8px;
  font-size: 0.76rem;
}

.user-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.pager-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pager-buttons button {
  min-height: 34px;
  padding: 0 10px;
}

.status-pill {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 0.78rem;
  font-weight: 900;
}

.status-pill.online {
  background: var(--soft-teal);
  color: #115e59;
}

.status-pill.offline {
  background: #eef1f2;
  color: var(--muted);
}

@media (max-width: 1360px) {
  .main-column {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .topbar-actions,
  .panel-actions {
    justify-content: flex-start;
  }

  .metrics,
  .workspace,
  .user-admin-panel,
  .rules-grid,
  .uncovered-list,
  .preview-panel {
    grid-template-columns: 1fr;
  }

  .sidebar {
    order: 2;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: 16px;
  }

  .topbar-actions,
  .table-header,
  .profile-header,
  .user-pagination {
    align-items: stretch;
    flex-direction: column;
  }

  .ghost-button {
    width: 100%;
  }

  .profile-form,
  .availability-row,
  .user-row,
  .user-toolbar,
  .notes-save-row {
    grid-template-columns: 1fr;
  }

  .metrics strong {
    font-size: 1.45rem;
  }
}
