:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #1b2420;
  --muted: #62706a;
  --line: #dce3dd;
  --brand: #116149;
  --brand-2: #0a7a66;
  --warn: #a65416;
  --danger: #a82d35;
  --soft: #e8f3ed;
  --radius: 8px;
  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);
}

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

button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  min-height: 38px;
  padding: 8px 12px;
}

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

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

button.secondary {
  background: var(--soft);
  border-color: #bfdbcd;
  color: var(--brand);
}

button.danger {
  background: #fff2f2;
  border-color: #efc6c9;
  color: var(--danger);
}

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

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

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(17, 97, 73, 0.12), transparent 32%),
    linear-gradient(315deg, rgba(166, 84, 22, 0.1), transparent 30%),
    var(--bg);
}

.login-card {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 20px 70px rgba(23, 34, 29, 0.12);
}

.login-card h1,
.page-title h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0;
}

.login-card p,
.page-title p,
.muted {
  color: var(--muted);
}

.field {
  display: grid;
  gap: 6px;
  margin: 14px 0;
}

.field label {
  color: #34443d;
  font-weight: 650;
  font-size: 13px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px 1fr;
}

.sidebar {
  background: #18231f;
  color: #fff;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: grid;
  gap: 3px;
  padding: 10px 8px;
}

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

.brand span {
  color: #b4c9bf;
  font-size: 13px;
}

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

.nav button {
  width: 100%;
  text-align: left;
  background: transparent;
  border-color: transparent;
  color: #dbe7e0;
}

.nav button.active,
.nav button:hover {
  background: #26362f;
  border-color: #354941;
  color: #fff;
}

.user-box {
  margin-top: auto;
  border-top: 1px solid #31443c;
  padding-top: 14px;
  display: grid;
  gap: 8px;
  color: #dbe7e0;
}

.content {
  padding: 28px;
  display: grid;
  gap: 18px;
  align-content: start;
}

.topbar,
.filters,
.toolbar {
  display: flex;
  gap: 10px;
  align-items: end;
  flex-wrap: wrap;
}

.topbar {
  justify-content: space-between;
  align-items: center;
}

.page-title {
  display: grid;
  gap: 4px;
}

.grid {
  display: grid;
  gap: 14px;
}

.school-list,
.date-list,
.month-school-list,
.month-date-list {
  display: grid;
  gap: 12px;
}

.grid.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

.metric,
.panel,
.school-card,
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.metric {
  padding: 16px;
}

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

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

.panel {
  padding: 16px;
}

.school-card {
  padding: 14px;
  display: grid;
  gap: 12px;
}

.school-card.collapsed {
  gap: 0;
}

.school-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.school-toggle {
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  cursor: pointer;
}

.school-head h3,
.school-toggle h3,
.panel h2 {
  margin: 0;
  font-size: 17px;
}

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

.chevron {
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  background: #fff;
}

.date-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 12px;
  background: #fbfcfa;
}

.date-card.collapsed {
  padding: 10px 12px;
}

.date-toggle {
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  cursor: pointer;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.warn {
  background: #fff1df;
  color: var(--warn);
}

.badge.done {
  background: #e5f6e9;
  color: #17642b;
}

.badge.progress {
  background: #e8f3f7;
  color: #14627a;
}

.card-selector,
.qty-grid,
.assign-grid {
  display: grid;
  gap: 8px;
}

.card-selector {
  grid-template-columns: repeat(auto-fill, minmax(116px, 1fr));
}

.check-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
  min-height: 40px;
}

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

.qty-grid {
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
}

.month-school {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: grid;
  gap: 12px;
}

.month-school.collapsed {
  gap: 0;
}

.school-total-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

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

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

.school-total-item strong {
  font-size: 16px;
}

.month-date-card {
  border-top: 1px solid var(--line);
}

.month-date-row {
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  display: grid;
  grid-template-columns: 120px 150px 1fr 120px 32px;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  text-align: left;
  cursor: pointer;
}

.month-date-row > span:nth-last-child(2) {
  text-align: right;
  font-weight: 700;
}

.month-date-row .chevron {
  justify-self: end;
}

.month-date-detail {
  display: grid;
  gap: 8px;
  padding: 0 0 12px 120px;
}

.card-lines {
  display: grid;
  gap: 6px;
}

.card-line {
  display: grid;
  grid-template-columns: 1fr 80px 120px;
  gap: 10px;
  align-items: center;
  max-width: 560px;
}

.card-line strong,
.card-line span:last-child {
  text-align: right;
}

.empty {
  border: 1px dashed #c8d4ce;
  border-radius: var(--radius);
  padding: 24px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.6);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

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

th {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0;
  background: #fbfcfa;
}

.status-line {
  min-height: 22px;
  color: var(--brand);
  font-weight: 650;
}

.error {
  color: var(--danger);
  font-weight: 650;
}

.inline-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.progress-cell {
  display: grid;
  gap: 4px;
  min-width: 150px;
}

.progress-cell strong {
  font-size: 15px;
}

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

.progress-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1ed;
}

.progress-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand-2);
}

.admin-school-button {
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.admin-school-button span:first-child {
  font-weight: 650;
}

.admin-detail-row td {
  padding: 0;
  background: #fbfcfa;
}

.admin-school-detail {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-top: 1px solid var(--line);
}

.admin-detail-summary {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-detail-summary span {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
}

.admin-date-list {
  display: grid;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.admin-date-card + .admin-date-card {
  border-top: 1px solid var(--line);
}

.admin-date-card .month-date-row {
  padding: 10px 12px;
}

.admin-date-detail {
  display: grid;
  gap: 10px;
  padding: 0 12px 12px 132px;
}

.admin-entry-detail {
  display: grid;
  gap: 8px;
}

.admin-entry-detail + .admin-entry-detail {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.admin-entry-head {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  max-width: 560px;
}

@media (max-width: 880px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
  }

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

  .grid.cols-4,
  .grid.cols-3 {
    grid-template-columns: 1fr;
  }

  .content {
    padding: 18px;
  }
}

@media (max-width: 640px) {
  .login-card {
    padding: 22px;
  }

  .login-card h1,
  .page-title h1 {
    font-size: 23px;
  }

  .sidebar {
    gap: 10px;
    padding: 12px;
  }

  .brand {
    padding: 4px;
  }

  .user-box {
    margin-top: 0;
  }

  .topbar,
  .filters,
  .toolbar {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .field {
    margin: 8px 0;
  }

  .school-card {
    padding: 12px;
  }

  .school-head {
    display: grid;
  }

  .school-toggle {
    display: grid;
  }

  .school-status {
    justify-content: start;
  }

  .date-toggle,
  .date-summary {
    align-items: start;
  }

  .date-toggle {
    display: grid;
  }

  .date-summary {
    justify-content: start;
  }

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

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

  .month-date-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .month-date-row > span:nth-last-child(2) {
    text-align: left;
  }

  .month-date-row .chevron {
    justify-self: start;
  }

  .month-date-detail {
    padding-left: 0;
  }

  .admin-date-detail {
    padding-left: 12px;
  }

  .admin-entry-head,
  .admin-school-button {
    display: grid;
    justify-items: start;
  }

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

  .card-line strong,
  .card-line span:last-child {
    text-align: left;
  }

  .check-pill {
    min-height: 44px;
    padding: 9px;
  }

  .table-wrap {
    border: 0;
    background: transparent;
    overflow: visible;
  }

  .responsive-table,
  .responsive-table thead,
  .responsive-table tbody,
  .responsive-table tr,
  .responsive-table th,
  .responsive-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .responsive-table thead {
    display: none;
  }

  .responsive-table tr {
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    overflow: hidden;
  }

  .responsive-table td {
    display: grid;
    grid-template-columns: 112px 1fr;
    gap: 10px;
    border-bottom: 1px solid var(--line);
  }

  .responsive-table td:last-child {
    border-bottom: 0;
  }

  .responsive-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
  }
}
