:root {
  --bg: #f7f8fb;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #667085;
  --line: #d9dee7;
  --line-strong: #b9c1cf;
  --brand: #005f73;
  --brand-strong: #0a4d5d;
  --mint: #2a9d8f;
  --amber: #b76e00;
  --danger: #bd2d3a;
  --soft: #eef6f6;
  --shadow: 0 16px 40px rgba(23, 32, 42, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  min-width: 320px;
}

a {
  color: var(--brand);
  font-weight: 800;
}

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

button,
.button-link {
  border: 0;
  background: var(--brand);
  color: white;
  border-radius: 6px;
  padding: 0.55rem 0.8rem;
  cursor: pointer;
  font-weight: 700;
}

button:hover,
.button-link:hover {
  background: var(--brand-strong);
}

button.secondary,
.button-link.secondary {
  background: #e7edf1;
  color: var(--ink);
}

button.secondary:hover,
.button-link.secondary:hover {
  background: #d8e1e8;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  white-space: nowrap;
}

button.danger {
  background: var(--danger);
}

button.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

button.active {
  background: var(--ink);
  color: white;
}

input,
select,
textarea {
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--ink);
  background: white;
  padding: 0.48rem 0.6rem;
  min-width: 0;
}

textarea {
  min-height: 2.4rem;
  resize: vertical;
}

label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.app-shell {
  min-height: 100vh;
}

.loading-panel,
.login-panel,
.panel,
.message {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.loading-panel {
  width: min(560px, calc(100vw - 32px));
  margin: 12vh auto;
  padding: 2rem;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.2rem;
  background:
    linear-gradient(180deg, rgba(238, 246, 246, 0.88), rgba(247, 248, 251, 0.95)),
    var(--bg);
}

.login-panel {
  width: min(430px, 100%);
  padding: 1.55rem;
  gap: 1rem;
}

.login-panel h1,
.page-title h1 {
  margin: 0;
  letter-spacing: 0;
}

.login-panel h1 {
  font-size: 1.55rem;
  line-height: 1.15;
}

.login-panel p,
.empty {
  color: var(--muted);
}

.login-head {
  display: grid;
  gap: 0.45rem;
}

.login-head .brand-mark {
  width: 42px;
  height: 42px;
  font-size: 0.92rem;
}

.login-head p,
.login-help {
  margin: 0;
}

.login-fields {
  display: grid;
  gap: 0.75rem;
}

.login-fields label {
  display: grid;
  gap: 0.3rem;
}

.login-help {
  border-top: 1px solid var(--line);
  padding-top: 0.85rem;
  font-size: 0.86rem;
  line-height: 1.4;
}

.stack {
  display: grid;
  gap: 0.8rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.topbar-inner {
  width: min(1500px, calc(100vw - 28px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  padding: 0.75rem 0;
  align-items: center;
}

.brand {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  min-width: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--brand), var(--mint));
  color: white;
  display: grid;
  place-items: center;
  font-weight: 900;
}

.brand strong {
  display: block;
}

.brand span {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
}

.userbox {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.nav {
  width: min(1500px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 0 0 0.75rem;
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
}

.nav button {
  white-space: nowrap;
}

.main {
  width: min(1500px, calc(100vw - 28px));
  margin: 1.1rem auto 3rem;
}

.page-title {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.page-title p {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.panel {
  padding: 1rem;
  margin-bottom: 1rem;
}

.message {
  padding: 0.7rem 0.9rem;
  margin-bottom: 0.9rem;
  border-left: 4px solid var(--mint);
}

.message.error {
  border-left-color: var(--danger);
}

.toolbar,
.form-grid,
.row-actions,
.status-strip,
.day-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: end;
}

.form-grid label {
  display: grid;
  gap: 0.25rem;
}

.form-grid .wide {
  flex: 1 1 260px;
}

.timezone-note {
  display: grid;
  gap: 0.25rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 0.48rem 0.65rem;
  min-width: 210px;
}

.timezone-note strong {
  color: var(--muted);
  font-size: 0.82rem;
}

.status-strip {
  align-items: stretch;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.8rem;
  min-width: 145px;
  background: #fbfcfd;
}

.stat strong {
  display: block;
  font-size: 1.35rem;
}

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

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

table {
  width: 100%;
  border-collapse: collapse;
}

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

th:last-child,
td:last-child {
  border-right: 0;
}

thead th {
  position: sticky;
  top: 0;
  background: #edf4f4;
  z-index: 1;
}

.time-col {
  width: 112px;
  min-width: 112px;
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
}

.slot-cell {
  min-width: 205px;
  background: #fff;
}

.slot-cell.has-work {
  background: #fbfdfd;
}

.schedule-board {
  --slot-row-height: 34px;
  display: grid;
  grid-template-columns: 124px repeat(var(--day-count), minmax(260px, 1fr));
  grid-template-rows: 76px repeat(var(--row-count), var(--slot-row-height));
  min-width: calc(124px + var(--day-count) * 260px);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
  background: white;
}

.schedule-corner,
.schedule-day-head,
.schedule-time {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #edf4f4;
  padding: 0.5rem;
  font-weight: 800;
}

.schedule-corner {
  position: sticky;
  left: 0;
  top: 0;
  z-index: 4;
}

.schedule-day-head {
  grid-row: 1;
  position: sticky;
  top: 0;
  z-index: 3;
}

.schedule-time {
  grid-column: 1;
  position: sticky;
  left: 0;
  z-index: 2;
  color: var(--muted);
  font-size: 0.82rem;
  background: #f7fafb;
  white-space: nowrap;
}

.schedule-day-track {
  grid-row: 2 / span var(--row-count);
  display: grid;
  grid-template-rows: repeat(var(--row-count), var(--slot-row-height));
  grid-template-columns: repeat(var(--lane-count), minmax(0, 1fr));
  column-gap: 2px;
  row-gap: 0;
  padding: 0;
  border-right: 1px solid var(--line);
  background: repeating-linear-gradient(
    to bottom,
    #ffffff 0,
    #ffffff calc(var(--slot-row-height) - 1px),
    var(--line) calc(var(--slot-row-height) - 1px),
    var(--line) var(--slot-row-height)
  );
}

.slot-title {
  font-weight: 800;
  margin-bottom: 0.25rem;
}

.slot-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0.25rem 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.14rem 0.45rem;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  background: white;
  font-size: 0.78rem;
  font-weight: 800;
}

.pill.local {
  color: #12633f;
  background: #e8f6ef;
  border-color: #afdac5;
}

.pill.coverage-count {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.74);
  border-color: var(--line-strong);
  min-width: 2.6rem;
  justify-content: center;
}

.coverage-complete .pill.coverage-count {
  color: #0f6b44;
  background: #e5f7ec;
  border-color: #9fd2b7;
}

.coverage-partial .pill.coverage-count {
  color: var(--amber);
  background: #fff5df;
  border-color: #f2d19a;
}

.coverage-open .pill.coverage-count {
  color: #b33d18;
  background: #ffeade;
  border-color: #e6a07d;
}

.avatar,
.avatar-small {
  border-radius: 50%;
  object-fit: cover;
  background: var(--avatar-bg, #d9e5e7);
  color: var(--avatar-fg, var(--brand));
  display: inline-grid;
  place-items: center;
  font-weight: 900;
  flex: 0 0 auto;
}

.avatar {
  width: 72px;
  height: 72px;
}

.avatar-small {
  width: 24px;
  height: 24px;
  font-size: 0.75rem;
}

.slot-editor {
  display: grid;
  gap: 0.6rem;
}

.schedule-task {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  position: relative;
  overflow: visible;
  box-shadow: 0 3px 10px rgba(23, 32, 42, 0.08);
  cursor: pointer;
  align-self: stretch;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  font-size: 0.78rem;
  line-height: 1.18;
}

.schedule-task.coverage-complete {
  border-color: #7abd9c;
  background: #eefaf3;
  box-shadow: inset 4px 0 0 #1f9d63, 0 3px 10px rgba(23, 32, 42, 0.08);
}

.schedule-task.coverage-open {
  border-color: #d99b74;
  background: #fff4eb;
  box-shadow: inset 4px 0 0 #d3642f, 0 3px 10px rgba(23, 32, 42, 0.08);
}

.schedule-task.coverage-partial {
  border-color: #e5bc72;
  background: #fff8e8;
  box-shadow: inset 4px 0 0 var(--amber), 0 3px 10px rgba(23, 32, 42, 0.08);
}

.schedule-task.coverage-none {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.schedule-task:hover,
.schedule-task:focus-within {
  z-index: 5;
}

.schedule-task:focus {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

.schedule-task.has-assignees {
  padding-right: 0;
}

.schedule-task:last-child {
  margin-bottom: 0;
}

.schedule-task-body {
  height: 100%;
  min-height: 0;
  overflow: hidden;
  padding: 0.34rem;
}

.schedule-task.has-assignees .schedule-task-body {
  padding-right: 3.7rem;
}

.schedule-task .slot-title {
  font-size: 0.82rem;
  line-height: 1.15;
  margin-bottom: 0.16rem;
}

.schedule-task .muted {
  font-size: 0.72rem;
}

.schedule-task .slot-meta {
  gap: 0.18rem;
  margin: 0.18rem 0;
}

.schedule-task .pill {
  padding: 0.08rem 0.32rem;
  font-size: 0.68rem;
}

.schedule-task .avatar-small {
  width: 18px;
  height: 18px;
  font-size: 0.58rem;
}

.schedule-assignees {
  position: absolute;
  top: 0.24rem;
  right: 0.24rem;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.assignment-avatar {
  position: relative;
  display: inline-grid;
  place-items: center;
  outline: none;
}

.assignment-avatar + .assignment-avatar {
  margin-left: -0.35rem;
}

.assignment-avatar:hover,
.assignment-avatar:focus {
  z-index: 8;
}

.assignment-avatar .avatar-small {
  border: 2px solid white;
  box-shadow: 0 1px 5px rgba(23, 32, 42, 0.22);
}

.assignment-tooltip {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  z-index: 10;
  display: none;
  width: max-content;
  max-width: 230px;
  gap: 0.1rem;
  padding: 0.42rem 0.5rem;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #17202a;
  color: white;
  box-shadow: 0 8px 22px rgba(23, 32, 42, 0.22);
  font-size: 0.72rem;
  line-height: 1.2;
  pointer-events: none;
}

.assignment-tooltip span,
.assignment-tooltip strong {
  display: block;
}

.assignment-tooltip span {
  color: #d8e2e7;
}

.assignment-avatar:hover .assignment-tooltip,
.assignment-avatar:focus .assignment-tooltip {
  display: grid;
}

.admin-task-form {
  display: grid;
  gap: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.7rem;
  background: #fbfcfd;
}

.task-fields {
  display: grid;
  grid-template-columns: 92px 92px minmax(180px, 1.05fr) minmax(230px, 1.3fr) 170px;
  gap: 0.55rem;
  align-items: end;
}

.task-fields label {
  display: grid;
  gap: 0.25rem;
}

.task-title-field,
.task-note-field {
  min-width: 0;
}

.task-fields .local-toggle {
  min-height: 2.35rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--ink);
  background: white;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.48rem 0.6rem;
}

.task-fields .local-toggle input {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  accent-color: #1f9d63;
}

.task-fields .local-toggle span {
  display: grid;
  gap: 0.08rem;
  line-height: 1.15;
}

.task-fields .local-toggle small {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.manual-assignments {
  display: grid;
  gap: 0.4rem;
  border-top: 1px solid var(--line);
  padding-top: 0.6rem;
}

.manual-assignments > strong,
.section-title-row > strong {
  font-size: 0.82rem;
  color: var(--muted);
}

.section-title-row {
  display: flex;
  justify-content: space-between;
  gap: 0.65rem;
  align-items: center;
}

.section-title-row button {
  padding: 0.4rem 0.6rem;
  font-size: 0.82rem;
}

.task-slot-list {
  display: grid;
  gap: 0.4rem;
}

.task-slot-row {
  display: grid;
  grid-template-columns: 32px minmax(190px, 0.9fr) minmax(260px, 1.35fr) auto;
  gap: 0.45rem;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 0.45rem;
}

.task-slot-row label {
  display: grid;
  gap: 0.25rem;
}

.slot-index {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--soft);
  color: var(--brand);
  font-weight: 900;
  align-self: center;
}

.slot-role-field {
  min-width: 0;
}

.slot-row-actions {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  justify-content: flex-end;
}

.slot-row-actions .assignment-remove {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  background: #f2e7e9;
  color: var(--danger);
  display: inline-grid;
  place-items: center;
  font-size: 1.05rem;
  line-height: 1;
  font-weight: 900;
}

.slot-row-actions .assignment-remove:hover {
  background: var(--danger);
  color: white;
}

.assignment-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  min-height: 2rem;
  align-items: center;
}

.assignment-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: white;
  padding: 0.18rem 0.25rem 0.18rem 0.3rem;
  font-size: 0.82rem;
  font-weight: 800;
}

.assignment-chip input {
  width: min(220px, 28vw);
  padding: 0.3rem 0.45rem;
  font-size: 0.78rem;
  font-weight: 600;
}

.assignment-chip button {
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  background: #f2e7e9;
  color: var(--danger);
  display: inline-grid;
  place-items: center;
  font-size: 1rem;
  line-height: 1;
  font-weight: 900;
}

.assignment-chip button:hover {
  background: var(--danger);
  color: white;
}

.assignment-add {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) auto;
  gap: 0.35rem;
}

.assignment-add select {
  min-height: auto;
}

.admin-task-form .row-actions {
  justify-content: flex-end;
  gap: 0.45rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(23, 32, 42, 0.42);
}

.task-modal {
  width: min(620px, 100%);
  max-height: min(760px, calc(100vh - 2rem));
  overflow: auto;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 22px 70px rgba(23, 32, 42, 0.28);
  padding: 1rem;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.75rem;
}

.modal-head h2,
.modal-head p,
.modal-note p {
  margin: 0;
}

.modal-head p {
  color: var(--muted);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
  margin: 0.85rem 0;
}

.detail-grid div,
.modal-note {
  display: grid;
  gap: 0.2rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 0.55rem;
}

.detail-grid span,
.modal-note p {
  color: var(--muted);
}

.detail-grid .muted {
  font-size: 0.78rem;
}

.modal-assignments {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.85rem;
}

.modal-assignment-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 0.55rem;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem;
}

.modal-assignment-row .avatar-small {
  width: 28px;
  height: 28px;
}

.modal-assignment-row div {
  display: grid;
  gap: 0.12rem;
  min-width: 0;
}

.volunteer-grid {
  display: grid;
  gap: 0.65rem;
}

.volunteer-row {
  display: grid;
  grid-template-columns: 62px minmax(150px, 1.2fr) minmax(210px, 1.6fr) 0.65fr 0.55fr auto;
  gap: 0.45rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem;
  background: white;
}

.task-list {
  display: grid;
  gap: 0.6rem;
}

.task-item {
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: 8px;
  background: white;
  padding: 0.75rem;
}

.conflict-grid th,
.conflict-grid td {
  text-align: center;
  min-width: 120px;
}

.conflict-grid .time-col {
  text-align: left;
}

.conflict-grid input {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: #1f9d63;
}

.conflict-grid .availability-cell {
  transition: background 120ms ease, box-shadow 120ms ease;
}

.conflict-grid .availability-available {
  background: #e9f8ef;
  box-shadow: inset 0 0 0 1px #b9dfc9;
}

.conflict-grid .availability-unavailable {
  background: #fdebed;
  box-shadow: inset 0 0 0 1px #efb7bd;
}

.conflict-grid .availability-unavailable input {
  accent-color: var(--danger);
}

.profile-layout {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

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

.danger-text {
  color: var(--danger);
}

@media (max-width: 900px) {
  .topbar-inner {
    grid-template-columns: 1fr;
  }

  .userbox {
    justify-content: space-between;
  }

  .page-title {
    display: block;
  }

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

  .task-fields {
    grid-template-columns: 1fr;
  }

  .task-slot-row {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .slot-role-field,
  .slot-row-actions {
    grid-column: 1 / -1;
  }

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

  .modal-head {
    display: grid;
  }

  .assignment-chip input {
    width: 100%;
  }

  .profile-layout {
    grid-template-columns: 1fr;
  }
}
