.unified-student-filters {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
  margin: 0 0 14px;
}

.unified-history-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

#unifiedHistoryDlg {
  width: min(1080px, 94vw);
  max-width: 94vw;
  overflow: hidden;
}

#unifiedHistoryDlg .modal-body {
  display: block;
  max-height: calc(90vh - 140px);
  overflow: auto;
}

.unified-history-actions {
  display: flex;
  gap: 8px;
}

.unified-history-course-table {
  max-height: 48vh;
  margin-top: 14px;
}

.unified-history-course-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

.unified-history-course-table th:first-child,
.unified-history-course-table td:first-child {
  width: 58px;
  text-align: center;
}

.unified-history-course-table th:last-child,
.unified-history-course-table td:last-child {
  width: 150px;
}

.unified-history-course-table input[type="date"] {
  width: 138px;
}

.unified-history-status {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 8px;
  background: #f1f2f3;
  color: #656a70;
}

.unified-history-status.done {
  background: #e8f3ec;
  color: #1d7049;
}

.unified-history-status.partial {
  background: #fff3db;
  color: #8b5a00;
}

.unified-history-course-table td small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

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

.unified-finance-metrics > div,
.unified-week-metric {
  border: 1px solid var(--line);
  background: #fff;
  padding: 14px;
  border-radius: 8px;
}

.unified-finance-metrics span,
.unified-week-metric span {
  color: var(--muted);
  display: block;
  margin-bottom: 5px;
}

.unified-finance-metrics b,
.unified-week-metric b {
  color: var(--green);
  font-size: 24px;
}

.unified-week-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0 18px;
}

.unified-week-chart {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.unified-week-column {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  min-width: 0;
}

.unified-week-bars {
  height: 128px;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}

.unified-week-bar {
  width: 34px;
  min-height: 4px;
  position: relative;
}

.unified-week-bar.attendance { background: #279667; }
.unified-week-bar.revenue { background: #5b91dc; }
.unified-week-bar span {
  position: absolute;
  bottom: calc(100% + 5px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 12px;
}

.unified-week-label {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding-top: 7px;
}

.expense-receipts {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.trial-stage {
  display: inline-block;
  margin-top: 4px;
  color: #9f4b00;
  font-size: 12px;
}

@media (max-width: 900px) {
  .unified-history-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .unified-week-chart { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .unified-week-bars { gap: 5px; }
  .unified-week-bar { width: 26px; }
  .unified-week-bar span { font-size: 10px; }
}

@media (max-width: 640px) {
  .unified-history-controls { grid-template-columns: 1fr; }
  .unified-history-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .unified-history-course-table { overflow: auto; }
  .unified-finance-metrics, .unified-week-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .unified-finance-metrics > div, .unified-week-metric { padding: 9px 7px; }
  .unified-finance-metrics b, .unified-week-metric b { font-size: 17px; overflow-wrap: anywhere; }
  .unified-week-bars { height: 104px; gap: 3px; }
  .unified-week-bar { width: 18px; }
  .unified-week-bar span { font-size: 9px; }
  .unified-week-label { font-size: 10px; }

  #students .table-wrap,
  #finance .table-wrap { overflow: visible; border: 0; background: transparent; }
  #students table,
  #students tbody,
  #finance table,
  #finance tbody { display: block; width: 100%; }
  #students thead,
  #finance thead { display: none; }
  #students #studentBody tr,
  #finance #expenseBody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    margin-bottom: 10px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
  }
  #students #studentBody td,
  #finance #expenseBody td {
    display: block;
    min-width: 0;
    padding: 7px;
    border: 0;
    overflow-wrap: anywhere;
  }
  #students #studentBody td::before,
  #finance #expenseBody td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 3px;
    color: var(--muted);
    font-size: 11px;
  }
  #students #studentBody td:first-child,
  #students #studentBody td:nth-child(5),
  #students #studentBody td:nth-child(6),
  #students #studentBody td:last-child,
  #finance #expenseBody td:nth-child(6),
  #finance #expenseBody td:nth-child(7),
  #finance #expenseBody td:last-child { grid-column: 1 / -1; }
}
