:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #f0f4f7;
  --line: #dce2e8;
  --text: #17202a;
  --muted: #6f7a86;
  --accent: #166534;
  --accent-soft: #e8f5ed;
  --accent-strong: #0f5132;
  --info: #2563eb;
  --info-soft: #eaf1ff;
  --danger: #b42318;
  --chat-bg: #f0eee8;
  --shadow: 0 12px 30px rgba(20, 31, 43, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

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

.login-panel {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-panel h1,
.brand h1,
.conversation-header h2,
.panel-title h3 {
  margin: 0;
  letter-spacing: 0;
}

.login-panel h1 {
  font-size: 28px;
}

.muted {
  margin: 8px 0 0;
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

label {
  display: grid;
  gap: 7px;
  color: #314151;
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 11px;
  outline: none;
}

input:focus,
select:focus {
  border-color: #388e5b;
  box-shadow: 0 0 0 3px rgba(22, 101, 52, 0.12);
}

.login-form button,
.secondary-button,
.ghost-button,
.icon-button {
  min-height: 38px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-weight: 700;
}

.login-form button {
  background: var(--accent);
  color: #fff;
}

.secondary-button {
  background: #17202a;
  color: #fff;
  padding: 0 14px;
}

.ghost-button {
  background: transparent;
  border-color: var(--line);
  color: #314151;
  padding: 0 14px;
}

.icon-button {
  width: 38px;
  background: var(--surface-soft);
  color: #314151;
  border-color: var(--line);
}

.error {
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 320px minmax(420px, 1fr) 360px;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.app-shell.dashboard-mode {
  grid-template-columns: minmax(0, 1fr);
}

.sidebar,
.conversation,
.inspector {
  min-height: 0;
}

.sidebar {
  display: grid;
  grid-template-rows: auto 1fr;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.brand,
.conversation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.brand h1 {
  font-size: 22px;
}

.view-switcher {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.app-tabs {
  grid-column: 1 / -1;
  background: var(--surface);
}

.view-tab {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #314151;
  font-weight: 800;
}

.view-tab.active {
  border-color: #9dd2af;
  background: var(--accent-soft);
  color: var(--accent);
}

.sidebar-tools {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
}

.search-box {
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.group-list {
  overflow: auto;
  padding: 8px;
}

.group-item {
  width: 100%;
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  text-align: left;
}

.group-item:hover {
  background: var(--surface-soft);
}

.group-item.active {
  border-color: #9dd2af;
  background: var(--accent-soft);
}

.group-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.group-name,
.sender-name {
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-time,
.message-time,
.event-time {
  color: var(--muted);
  font-size: 12px;
}

.last-message {
  display: -webkit-box;
  overflow: hidden;
  color: #45515d;
  font-size: 13px;
  line-height: 1.35;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

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

.conversation-header,
.dashboard-header {
  background: var(--surface);
}

.conversation-header h2,
.dashboard-header h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

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

.filters {
  display: grid;
  grid-template-columns: minmax(160px, 1.3fr) minmax(140px, 1fr) 140px 140px auto auto;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}

.chat-tools {
  display: grid;
  gap: 10px;
  padding: 12px;
}

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

.member-list {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
  padding: 12px;
}

.member-item {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
}

.member-name {
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-number {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-list {
  overflow: auto;
  padding: 18px 22px;
  background: var(--chat-bg);
}

.empty-state {
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.message {
  width: fit-content;
  max-width: min(860px, calc(100% - 28px));
  margin: 12px 0 0 0;
  padding: 9px 12px 7px;
  border: 0;
  border-radius: 4px 8px 8px 8px;
  background: var(--surface);
  box-shadow: 0 1px 1px rgba(22, 31, 42, 0.18);
}

.message.is-continuation {
  margin-top: 3px;
  border-top-left-radius: 8px;
}

.message-meta {
  margin-bottom: 4px;
  padding-right: 12px;
}

.message-content {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.sender-name {
  display: block;
  max-width: 100%;
  color: #0563c1;
  font-size: 14px;
  line-height: 1.25;
}

.sender-name.tone-1 {
  color: #c84a24;
}

.sender-name.tone-2 {
  color: #0f7b55;
}

.sender-name.tone-3 {
  color: #7c3aed;
}

.sender-name.tone-4 {
  color: #b45309;
}

.sender-name.tone-5 {
  color: #be185d;
}

.message-body {
  flex: 1 1 auto;
  min-width: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: #111827;
  font-size: 15px;
  line-height: 1.45;
}

.message-time {
  flex: 0 0 auto;
  margin-bottom: 1px;
  color: #6f6f6f;
  font-size: 12px;
  line-height: 1.2;
}

.dashboard {
  grid-column: 2 / -1;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background: #f4f6f8;
}

.dashboard-mode .dashboard,
.dashboard-mode .teacher-view {
  grid-column: 1 / -1;
}

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

.dashboard-filters {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(280px, 0.9fr) minmax(220px, 1.2fr) auto auto;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}

.date-range-picker {
  position: relative;
  min-width: 0;
}

.date-range-trigger {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-weight: 750;
  text-align: left;
}

.date-range-trigger::after {
  content: "";
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-right: 2px solid #6f7a86;
  border-bottom: 2px solid #6f7a86;
  transform: rotate(45deg) translateY(-2px);
}

.date-range-trigger:hover,
.date-range-trigger:focus {
  border-color: #388e5b;
  box-shadow: 0 0 0 3px rgba(22, 101, 52, 0.12);
  outline: none;
}

#dashboard-date-range-label,
#teacher-date-range-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.date-range-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 15;
  width: min(640px, calc(100vw - 24px));
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.range-presets {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.range-presets button,
.range-nav-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  color: #314151;
  font-weight: 800;
}

.range-presets button:hover,
.range-presets button:focus,
.range-nav-button:hover,
.range-nav-button:focus {
  border-color: #9dd2af;
  background: var(--accent-soft);
  color: var(--accent);
}

.range-calendar-header {
  display: grid;
  grid-template-columns: 38px 1fr 38px;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

#range-calendar-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 850;
  text-align: center;
}

.range-calendar-months {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.range-month {
  min-width: 0;
}

.range-month strong {
  display: block;
  margin-bottom: 8px;
  color: #314151;
  font-size: 13px;
  text-align: center;
}

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

.range-weekdays {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.range-day {
  min-width: 0;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #314151;
  font-size: 12px;
  font-weight: 800;
}

.range-day.blank {
  pointer-events: none;
}

button.range-day:hover,
button.range-day:focus {
  border-color: #9dd2af;
  background: var(--accent-soft);
  outline: none;
}

.range-day.today {
  border-color: #adc7ff;
  color: var(--info);
}

.range-day.in-range {
  background: #eaf1ff;
  color: #1e3a8a;
}

.range-day.selected {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.dashboard-sections {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.dashboard-section-tab {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #314151;
  font-weight: 850;
}

.dashboard-section-tab.active {
  border-color: #9dd2af;
  background: var(--accent-soft);
  color: var(--accent);
}

.dashboard-section {
  min-height: 0;
}

.dashboard-summary {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.85fr);
  gap: 12px;
  padding: 12px 12px 0;
}

.daily-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  min-width: 0;
}

.dashboard-stat {
  min-height: 116px;
  display: grid;
  align-content: space-between;
  gap: 8px;
  border-color: #d9e4dc;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbf9 100%);
}

.dashboard-stat .stat-value {
  color: var(--accent-strong);
  font-size: 28px;
}

.stat-helper {
  display: -webkit-box;
  overflow: hidden;
  color: #536171;
  font-size: 12px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.dashboard-insights {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  min-width: 0;
}

.insight-item,
.insight-empty {
  min-height: 70px;
  display: grid;
  gap: 3px;
  align-content: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.insight-item strong {
  overflow: hidden;
  color: var(--text);
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.insight-item span:last-child,
.insight-empty {
  color: var(--muted);
  font-size: 12px;
}

.insight-kicker {
  color: var(--accent);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.dashboard-analytics {
  display: grid;
  grid-template-columns: minmax(360px, 1.15fr) minmax(320px, 0.85fr);
  gap: 12px;
  padding: 12px;
}

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

.analytics-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(20, 31, 43, 0.05);
}

.analytics-panel .panel-title {
  min-height: 72px;
}

.analytics-panel .panel-title h3 {
  margin: 0;
  font-size: 16px;
}

.chart-caption {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.daily-chart {
  min-height: 268px;
  overflow-x: auto;
  padding: 14px 14px 12px;
}

.daily-chart-bars {
  height: 214px;
  min-width: calc(var(--chart-count) * 48px);
  display: grid;
  grid-template-columns: repeat(var(--chart-count), minmax(32px, 1fr));
  align-items: end;
  gap: 8px;
}

.daily-bar {
  height: 100%;
  min-width: 0;
  display: grid;
  grid-template-rows: 24px 1fr 28px;
  gap: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: center;
}

.daily-bar-value,
.daily-bar-label {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.daily-bar-fill {
  align-self: end;
  width: 100%;
  height: var(--bar-height);
  min-height: 12px;
  border: 1px solid #81bd99;
  border-radius: 6px 6px 3px 3px;
  background: #e7ecf1;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.daily-bar:hover .daily-bar-fill,
.daily-bar:focus .daily-bar-fill {
  border-color: var(--accent-strong);
}

.stacked-bar {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
}

.stack-segment {
  display: block;
  width: 100%;
}

.stack-segment.yes,
.chart-legend i.yes {
  background: #d97706;
}

.stack-segment.no,
.chart-legend i.no {
  background: #15803d;
}

.stack-segment.unknown,
.chart-legend i.unknown {
  background: #94a3b8;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

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

.chart-legend i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.dashboard-breakdowns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
}

.breakdown-column {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 8px;
}

.breakdown-column h4 {
  margin: 0 0 2px;
  color: #314151;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.rank-row {
  width: 100%;
  min-height: 68px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: inherit;
  text-align: left;
}

button.rank-row:hover,
button.rank-row:focus {
  border-color: #9dd2af;
  background: var(--accent-soft);
}

.rank-index {
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--info-soft);
  color: var(--info);
  font-size: 12px;
  font-weight: 850;
}

.rank-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.rank-copy strong,
.rank-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-copy strong {
  color: var(--text);
  font-size: 13px;
}

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

.rank-meter {
  grid-column: 2;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1f4;
}

.rank-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--info));
}

.breakdown-empty {
  min-height: 140px;
}

.daily-table-shell {
  min-height: 320px;
  overflow: auto;
  margin: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
  background: var(--surface);
}

.daily-table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
  background: var(--surface);
  table-layout: fixed;
}

.daily-table th:nth-child(1),
.daily-table td:nth-child(1) {
  width: 280px;
}

.daily-table th:nth-child(2),
.daily-table td:nth-child(2) {
  width: 118px;
}

.daily-table th:nth-child(3),
.daily-table td:nth-child(3),
.daily-table th:nth-child(4),
.daily-table td:nth-child(4) {
  width: 260px;
}

.daily-table th:nth-child(5),
.daily-table td:nth-child(5),
.daily-table th:nth-child(6),
.daily-table td:nth-child(6) {
  width: 96px;
}

.daily-table th:nth-child(7),
.daily-table td:nth-child(7) {
  width: 132px;
}

.daily-table th,
.daily-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  color: #314151;
  font-size: 13px;
  line-height: 1.4;
  text-align: left;
  vertical-align: top;
}

.daily-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f0f4f7;
  color: var(--text);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.table-sort-button {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  text-align: left;
  text-transform: inherit;
}

.sort-icons {
  display: inline-grid;
  gap: 3px;
  flex: 0 0 auto;
}

.sort-triangle {
  width: 0;
  height: 0;
  border-right: 4px solid transparent;
  border-left: 4px solid transparent;
  opacity: 0.28;
}

.sort-triangle.up {
  border-bottom: 6px solid #66717d;
}

.sort-triangle.down {
  border-top: 6px solid #66717d;
}

.table-sort-button.asc .sort-triangle.up {
  border-bottom-color: var(--accent);
  opacity: 1;
}

.table-sort-button.desc .sort-triangle.down {
  border-top-color: var(--accent);
  opacity: 1;
}

.table-sort-button:hover,
.table-sort-button:focus {
  color: var(--accent);
}

.daily-table td {
  word-break: break-word;
}

.daily-table .date-cell {
  white-space: nowrap;
  word-break: normal;
}

.daily-table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 12px 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  background: var(--surface);
}

.rows-per-page {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #314151;
  font-size: 13px;
  font-weight: 800;
}

.rows-per-page select {
  width: auto;
  min-width: 86px;
}

.daily-page-info {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

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

.daily-page-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.daily-group-button {
  display: inline;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: #2c3f52;
  font: inherit;
  font-weight: 850;
  text-align: left;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 4px;
  word-break: break-word;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: #eef2f4;
  color: #314151;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.status-chip.success {
  border-color: #9dd2af;
  background: var(--accent-soft);
  color: var(--accent);
}

.status-chip.warning {
  border-color: #f7c46c;
  background: #fff4de;
  color: #92400e;
}

.status-chip.info {
  border-color: #adc7ff;
  background: var(--info-soft);
  color: var(--info);
}

.status-chip.muted {
  border-color: #d7dde3;
  background: #f3f5f7;
  color: #66717d;
}

.daily-group-button:hover,
.daily-group-button:focus {
  color: var(--accent);
  text-decoration-color: currentColor;
}

.table-empty {
  height: 160px;
  color: var(--muted) !important;
  text-align: center !important;
  vertical-align: middle !important;
}

.teacher-view {
  grid-column: 2 / -1;
  grid-row: 2;
  overflow: hidden;
  background: #f4f6f8;
}

.teacher-dashboard {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-columns: minmax(240px, 0.9fr) minmax(260px, 1fr) minmax(360px, 1.35fr);
  gap: 12px;
  padding: 12px;
}

.teacher-filters {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(280px, 0.9fr) auto auto;
  gap: 8px;
  padding: 0;
}

.teacher-column,
.teacher-chat-column {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(20, 31, 43, 0.05);
}

.teacher-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}

.teacher-column-header .eyebrow {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.teacher-column-header h3 {
  margin: 0;
  color: var(--text);
  font-size: 16px;
  letter-spacing: 0;
}

.teacher-list {
  min-height: 0;
  overflow: auto;
  padding: 10px;
}

.teacher-list.empty-state {
  min-height: 220px;
}

.teacher-list-item {
  width: 100%;
  min-height: 66px;
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: inherit;
  text-align: left;
}

.teacher-list-item:hover,
.teacher-list-item:focus,
.teacher-list-item.active {
  border-color: #9dd2af;
  background: var(--accent-soft);
}

.teacher-list-item.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.teacher-item-main,
.teacher-item-main strong,
.teacher-item-main span,
.teacher-item-meta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.teacher-item-main {
  display: grid;
  gap: 2px;
}

.teacher-item-main strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 850;
}

.teacher-item-main span,
.teacher-item-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.teacher-chat-messages {
  min-height: 0;
  overflow: auto;
  padding: 14px;
  background: var(--chat-bg);
}

.teacher-chat-messages.empty-state {
  min-height: 320px;
  background: #fbfcfd;
}

.teacher-chat-messages .message {
  max-width: min(100%, 760px);
}

.inspector {
  display: grid;
  align-content: start;
  gap: 12px;
  overflow: auto;
  padding: 12px;
  border-left: 1px solid var(--line);
  background: #eef2f4;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.panel-title h3 {
  font-size: 15px;
}

.global-search {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px;
}

.search-results,
.event-list {
  display: grid;
  gap: 8px;
  max-height: 300px;
  overflow: auto;
  padding: 0 12px 12px;
}

.search-result,
.event-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
}

.search-result {
  cursor: pointer;
}

.search-result:hover {
  border-color: #9dd2af;
}

.result-context,
.event-reason {
  color: var(--muted);
  font-size: 12px;
}

.result-body {
  margin-top: 6px;
  color: #314151;
  font-size: 13px;
  line-height: 1.4;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 12px;
}

.stat {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
}

.stat-value {
  display: block;
  font-size: 22px;
  font-weight: 850;
}

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

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: #314151;
  font-size: 12px;
  font-weight: 800;
}

.status-pill.stored {
  background: var(--accent-soft);
  color: var(--accent);
}

.status-pill.failed {
  background: #fee4e2;
  color: var(--danger);
}

.chat-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(23, 32, 42, 0.42);
}

.chat-modal-panel {
  width: min(760px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.chat-modal-header h2 {
  margin: 0;
  color: var(--text);
  font-size: 20px;
  letter-spacing: 0;
}

.chat-modal-messages {
  min-height: 320px;
  overflow: auto;
  padding: 16px;
  background: var(--chat-bg);
}

.chat-modal-messages .message {
  max-width: 100%;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 280px minmax(360px, 1fr);
  }

  .inspector {
    display: none;
  }

  .dashboard,
  .teacher-view {
    grid-column: 2;
  }

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

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

  .teacher-dashboard {
    grid-template-columns: minmax(220px, 0.8fr) minmax(240px, 0.9fr) minmax(320px, 1.2fr);
  }

  .teacher-filters {
    grid-template-columns: minmax(180px, 1fr) minmax(240px, 0.9fr) auto auto;
  }
}

@media (max-width: 760px) {
  .app-shell {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    overflow: auto;
  }

  .app-tabs {
    grid-column: 1;
  }

  .sidebar {
    max-height: 42vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .conversation {
    min-height: 58vh;
  }

  .message-list {
    padding: 14px 12px;
  }

  .message {
    max-width: 94%;
  }

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

  .dashboard,
  .teacher-view {
    grid-column: 1;
    grid-row: auto;
    min-height: 58vh;
  }

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

  .date-range-picker {
    position: static;
  }

  .date-range-popover {
    position: fixed;
    top: 112px;
    right: 12px;
    left: 12px;
    width: auto;
    max-height: calc(100vh - 136px);
    overflow: auto;
  }

  .range-presets,
  .range-calendar-months {
    grid-template-columns: 1fr 1fr;
  }

  .range-presets button {
    min-height: 38px;
  }

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

  .daily-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .dashboard-breakdowns {
    grid-template-columns: 1fr;
  }

  .teacher-dashboard {
    grid-template-columns: 1fr;
  }

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

  .teacher-column,
  .teacher-chat-column {
    min-height: 320px;
  }

  .teacher-chat-messages {
    min-height: 260px;
  }

  .dashboard-stat {
    min-height: 104px;
  }

  .daily-table-pagination {
    align-items: stretch;
    flex-direction: column;
  }

  .rows-per-page,
  .daily-page-info,
  .daily-page-actions {
    justify-content: center;
  }

  .daily-page-actions button {
    flex: 1;
  }

  .chat-modal {
    padding: 10px;
  }

  .chat-modal-panel {
    max-height: calc(100vh - 20px);
  }

  .chat-modal-messages {
    min-height: 260px;
  }
}
