:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #eef2f6;
  --line: #cfd6df;
  --line-strong: #aab5c2;
  --text: #18202a;
  --muted: #617084;
  --brand: #146c94;
  --brand-2: #0f4f6d;
  --ok: #1d7f45;
  --warn: #b35c00;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

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

button {
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--text);
  min-height: 34px;
  border-radius: 6px;
  padding: 0 12px;
  cursor: pointer;
}

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

button.danger {
  border-color: var(--danger);
  color: var(--danger);
}

button:disabled {
  opacity: .5;
  cursor: not-allowed;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
}

textarea {
  resize: vertical;
  min-height: 72px;
}

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

.login-box {
  width: min(380px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 18px 50px rgba(25, 35, 50, .12);
}

.login-box h1 {
  margin: 0 0 16px;
  font-size: 24px;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

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

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px;
  background: #202a35;
  color: #fff;
}

.topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.topbar .meta {
  color: #c8d2df;
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar {
  display: grid;
  grid-template-columns: 220px minmax(390px, 1fr) minmax(320px, auto) auto;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(95px, 1fr));
  gap: 8px;
}

.metric {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
}

.metric .label {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric .value {
  display: block;
  font-size: 20px;
  font-weight: 700;
}

.metric.status-pending {
  background: #ffe8e5;
  border-color: #efb1aa;
}

.metric.status-progress {
  background: #fff3d6;
  border-color: #e7c46f;
}

.metric.status-complete {
  background: #dff5e7;
  border-color: #9dd7b2;
}

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

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 318px minmax(0, 1fr);
}

.side-panel {
  min-height: 0;
  overflow: auto;
  padding: 12px;
  border-right: 1px solid var(--line);
  background: #e9eef4;
}

.main-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.calendar-card,
.group-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.group-card {
  margin-top: 12px;
}

.calendar-card header,
.group-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.calendar-card h2,
.group-card h2 {
  margin: 0;
  font-size: 16px;
}

.calendar-card header div,
.group-card header div {
  display: flex;
  align-items: center;
  gap: 6px;
}

.calendar-card header button {
  width: 32px;
  padding: 0;
}

.legend {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

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

.calendar-weekdays {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
}

.calendar-day {
  min-width: 0;
  min-height: 42px;
  padding: 4px 0;
  border-radius: 6px;
  text-align: center;
  font-weight: 700;
}

.calendar-day.muted,
.calendar-day.day-empty {
  background: #f6f7f9;
  border-color: #e0e5eb;
  color: #9aa5b1;
}

.calendar-day.status-pending,
.group-item.status-pending,
.dot.status-pending {
  background: #ffe8e5;
  border-color: #efb1aa;
  color: #891f16;
}

.calendar-day.status-progress,
.group-item.status-progress,
.dot.status-progress {
  background: #fff3d6;
  border-color: #e7c46f;
  color: #6f4200;
}

.calendar-day.status-complete,
.group-item.status-complete,
.dot.status-complete {
  background: #dff5e7;
  border-color: #9dd7b2;
  color: #145a32;
}

.calendar-day.selected {
  outline: 3px solid rgba(20, 108, 148, .32);
  outline-offset: 1px;
}

.group-list {
  display: grid;
  gap: 6px;
  max-height: 360px;
  overflow: auto;
}

.group-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  cursor: pointer;
}

.group-item input {
  width: auto;
}

.group-item strong,
.group-item small {
  display: block;
}

.group-item small,
.group-note,
.muted-text {
  color: var(--muted);
}

.group-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.group-note {
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.35;
}

.table-wrap {
  min-width: 0;
  overflow: auto;
  padding: 12px 16px 22px;
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line-strong);
}

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

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #dfe6ee;
  color: #26313f;
  font-size: 12px;
  text-transform: uppercase;
}

td.size-cell {
  text-align: center;
  width: 72px;
  padding: 0;
}

.cell-button {
  width: 100%;
  height: 38px;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
}

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

.cell-partial {
  background: #fff3d6;
  color: #6f4200;
  font-weight: 700;
}

.cell-complete {
  background: #dff5e7;
  color: #145a32;
  font-weight: 700;
}

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

.status-line {
  padding: 10px 16px;
  background: #fff7e6;
  border-bottom: 1px solid #f0d18a;
  color: #6f4200;
}

.error {
  margin-top: 10px;
  color: var(--danger);
  font-size: 14px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(14, 22, 32, .55);
  z-index: 20;
  padding: 18px;
}

.modal {
  width: min(620px, 100%);
  max-height: min(760px, 94vh);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: 0 22px 70px rgba(0, 0, 0, .25);
}

.modal header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.modal header h2 {
  margin: 0;
  font-size: 18px;
}

.modal-body {
  padding: 16px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
}

.stepper {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

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

.audit-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: var(--panel-2);
}

.audit-item strong {
  display: block;
  margin-bottom: 4px;
}

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

.audit-detail {
  margin-top: 8px;
  line-height: 1.35;
}

.audit-reason {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  line-height: 1.35;
}

.audit-reason strong {
  display: inline;
  margin: 0;
  color: var(--text);
}

.sizes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 8px;
}

@media (max-width: 860px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .side-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .summary,
  .filters {
    grid-template-columns: 1fr;
  }

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