:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --line: #d6dee8;
  --text: #172033;
  --muted: #627084;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --soft: #e6f5f2;
  --danger: #b42318;
  --warn: #9a5b00;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

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

button {
  cursor: pointer;
}

h1,
h2,
p {
  margin: 0;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #edf4f3 0%, #f8fafc 52%, #eef2f7 100%);
}

.login-panel {
  width: min(520px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .12);
}

.eyebrow {
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}

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

.login-copy {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.7;
}

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

.login-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

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

input[readonly],
textarea[readonly] {
  background: #f3f6fa;
  color: #475569;
}

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

.primary {
  background: var(--brand);
  border: 1px solid var(--brand);
  color: #fff;
  border-radius: 6px;
  padding: 9px 14px;
}

.demo-users {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.demo-users p {
  width: 100%;
  color: var(--muted);
  font-size: 13px;
}

.demo-users button,
.panel-head button,
.form button,
.row-actions button,
.top-actions button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  padding: 8px 12px;
}

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

.topbar {
  min-height: 72px;
  padding: 12px 24px;
  background: #071622;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.topbar h1 {
  font-size: 22px;
  line-height: 1.2;
}

.topbar p {
  color: #b9c8d8;
  font-size: 13px;
  margin-top: 4px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.link {
  color: #fff;
  border: 1px solid rgba(255,255,255,.35);
  padding: 8px 12px;
  border-radius: 6px;
  text-decoration: none;
}

.notification-box {
  max-width: 360px;
  color: #fee6a3;
  border: 1px solid rgba(254, 230, 163, .4);
  background: rgba(154, 91, 0, .18);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
}

.shell {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
}

.tabs {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  height: calc(100vh - 104px);
}

.tab {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 14px;
}

.tab.active {
  background: var(--soft);
  color: var(--brand-dark);
  font-weight: 700;
}

.panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

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

#viewHint {
  color: var(--muted);
  margin-top: 4px;
}

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

.filter-panel {
  padding: 12px 0 0;
}

.view-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 0 0 12px;
}

.followup-targets,
.deadline-board {
  display: grid;
  gap: 12px;
  padding-bottom: 12px;
}

.followup-targets h3,
.deadline-board h3 {
  margin: 0;
  font-size: 17px;
}

.followup-targets p,
.deadline-board p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 10px;
}

.stat-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 12px;
  display: grid;
  gap: 6px;
}

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

.stat-card strong {
  font-size: 18px;
  line-height: 1.2;
}

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

.cell-stack {
  display: grid;
  gap: 4px;
  white-space: normal;
}

.cell-stack span {
  line-height: 1.35;
}

.table-scroll {
  overflow-x: auto;
}

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

.deadline-day {
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 8px;
  display: grid;
  align-content: start;
  gap: 4px;
}

.deadline-day.has-deadline {
  border-color: rgba(15, 118, 110, .45);
  background: #f0fdfa;
}

.deadline-day strong {
  font-size: 13px;
}

.deadline-day span,
.deadline-day em {
  font-size: 12px;
  color: var(--muted);
  font-style: normal;
  line-height: 1.35;
}

.filter-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) repeat(4, minmax(130px, 1fr)) auto;
  gap: 8px;
  align-items: end;
}

.student-filter-grid {
  grid-template-columns: minmax(240px, 1.5fr) minmax(150px, 1fr) minmax(150px, 1fr) auto;
}

.filter-grid label,
.filter-groups > div {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
}

.filter-grid button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  padding: 9px 12px;
}

.filter-groups {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  padding-top: 10px;
}

.filter-groups > div {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

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

.check-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 5px 8px;
  color: var(--text);
  font-size: 12px;
}

.check-pill input {
  width: auto;
}

.form {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  padding: 16px 0;
}

.form[hidden] {
  display: none;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.field.wide {
  grid-column: span 2;
}

.actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  align-items: center;
}

.permission-note {
  color: var(--muted);
  font-size: 13px;
}

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

.config-panel {
  padding: 16px 0 0;
}

.config-toolbar {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.config-toolbar label {
  display: grid;
  gap: 6px;
  min-width: 220px;
  color: var(--muted);
  font-size: 13px;
}

.config-toolbar button,
.config-table button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  padding: 8px 12px;
}

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

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

.config-table {
  min-width: 1180px;
}

.config-table th:nth-child(1),
.config-table th:nth-child(2),
.config-table th:nth-child(3),
.config-table td:nth-child(1),
.config-table td:nth-child(2),
.config-table td:nth-child(3) {
  width: 58px;
  text-align: center;
}

.config-table th:nth-child(4),
.config-table td:nth-child(4) {
  width: 86px;
}

.config-table th:nth-child(5),
.config-table td:nth-child(5) {
  width: 170px;
}

.config-table code {
  color: #334155;
  font-size: 12px;
}

.config-table textarea {
  min-height: 52px;
}

.config-table textarea:disabled {
  background: #f3f6fa;
  color: #94a3b8;
}

.schedule-panel {
  padding: 0 0 16px;
}

.schedule-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 0 10px;
  border-top: 1px solid var(--line);
}

.schedule-head h3 {
  margin: 0;
  font-size: 18px;
}

.schedule-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.schedule-tools {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.schedule-tools label {
  display: grid;
  gap: 5px;
  min-width: 150px;
  color: var(--muted);
  font-size: 13px;
}

.schedule-tools button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  padding: 8px 12px;
}

.schedule-conflict {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 10px;
  font-size: 13px;
}

.schedule-conflict.ok {
  color: var(--brand-dark);
  background: var(--soft);
  border-color: #b7e0d8;
}

.schedule-conflict.danger {
  color: var(--danger);
  background: #fff1f0;
  border-color: #f3b7b1;
}

tr.row-alert td {
  background: #fff1f0;
  color: var(--danger);
  font-weight: 600;
}

.cell-overdue {
  color: var(--danger);
  font-weight: 600;
}

.lead-insights-panel {
  padding: 16px 0 0;
  display: grid;
  gap: 20px;
}

.insight-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.insight-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 12px;
  display: grid;
  gap: 6px;
}

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

.insight-card strong {
  font-size: 22px;
  line-height: 1.2;
}

.insight-chart-block h4 {
  margin: 0 0 10px;
  font-size: 15px;
}

.insight-chart-body {
  display: flex;
  align-items: center;
  gap: 28px;
  flex-wrap: wrap;
}

.insight-pie {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  flex-shrink: 0;
}

.insight-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
  font-size: 13px;
}

.insight-legend .legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}

.insight-note {
  color: var(--muted);
  font-size: 12px;
  margin: 0;
}

.schedule-grid {
  display: grid;
  grid-template-columns: 1fr;
  max-height: 520px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.schedule-slot {
  min-height: 44px;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: stretch;
  border: 0;
  border-bottom: 1px solid #edf1f5;
  background: #fff;
  color: var(--text);
  padding: 0;
  text-align: left;
  user-select: none;
  touch-action: none;
}

.schedule-slot:hover {
  background: #f8fbfd;
}

.schedule-slot.occupied {
  background: #eef8f6;
}

.schedule-slot.conflict {
  background: #fff7ed;
}

.schedule-slot.selecting,
.schedule-slot.selected {
  background: #dbeafe;
  box-shadow: inset 4px 0 0 #2563eb;
}

.schedule-slot.selecting .slot-time,
.schedule-slot.selected .slot-time {
  color: #1d4ed8;
  font-weight: 700;
}

.slot-time {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
  border-right: 1px solid #edf1f5;
}

.slot-content {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px 8px;
}

.lesson-chip {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  max-width: 100%;
  border: 1px solid #b7e0d8;
  border-radius: 6px;
  background: #fff;
  color: #134e4a;
  padding: 5px 7px;
  font-size: 12px;
  white-space: normal;
  font-family: inherit;
  text-align: left;
}

.lesson-chip strong {
  color: var(--brand-dark);
}

.schedule-lesson-card {
  cursor: pointer;
}

.schedule-lesson-card:hover,
.schedule-lesson-card:focus-visible {
  border-color: var(--brand-dark);
  box-shadow: 0 0 0 2px rgba(19, 78, 74, 0.12);
  outline: none;
}

.schedule-mode-toggle {
  display: flex;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px;
}

.schedule-mode-toggle button {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 5px;
  padding: 6px 10px;
  font-size: 13px;
}

.schedule-mode-toggle button.active {
  background: var(--brand-dark);
  color: #fff;
}

.schedule-week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.schedule-week-day {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.schedule-week-day.is-today {
  border-color: var(--brand-dark);
  box-shadow: 0 0 0 1px var(--brand-dark);
}

.schedule-week-day-head {
  background: #f8fafc;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 1px solid var(--line);
}

.schedule-week-day-body {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.lesson-chip-week {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  border: 1px solid #b7e0d8;
}

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

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

th {
  background: #eef3f8;
  color: #334155;
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 1;
}

tr:hover td {
  background: #fbfdff;
}

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

.cell-link,
.status-link {
  border: 0;
  border-radius: 4px;
  padding: 4px 7px;
  color: #fff;
  background: #f59e0b;
}

.status-link {
  background: var(--brand);
}

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

.row-actions button.warn {
  color: var(--warn);
}

.summary-row td {
  background: #f8fafc;
  border-top: 2px solid var(--line);
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  background: #111827;
  color: #fff;
  padding: 10px 14px;
  border-radius: 6px;
  box-shadow: 0 12px 32px rgba(0,0,0,.2);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, .42);
}

.modal-card {
  width: min(980px, 100%);
  max-height: min(820px, calc(100vh - 48px));
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: 0 24px 70px rgba(15, 23, 42, .25);
}

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

.modal-foot {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.modal-head h3 {
  margin: 0;
  font-size: 18px;
}

.modal-head button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  padding: 7px 10px;
}

.modal-body {
  padding: 16px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 10px;
}

.detail-grid div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: #f8fafc;
}

.detail-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 3px;
}

.detail-grid strong {
  font-size: 13px;
  font-weight: 600;
}

.modal-body h4 {
  margin: 18px 0 8px;
}

.service-actions,
.section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.manage-edit-grid {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.manage-edit-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #f8fafc;
}

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

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

.service-actions button,
.section-head button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  padding: 7px 10px;
}

.section-head {
  justify-content: space-between;
  margin-top: 18px;
}

.section-head h4 {
  margin: 0;
}

.mini-table {
  width: 100%;
  min-width: 0;
}

.empty-note {
  color: var(--muted);
  font-size: 13px;
}

.modal-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 12px;
}

.modal-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.modal-form .wide {
  grid-column: 1 / -1;
}

.lesson-modal-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.lesson-form-panel {
  display: grid;
  gap: 12px;
}

.lesson-form-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.lesson-form-actions {
  display: flex;
  justify-content: flex-start;
  padding-top: 4px;
}

.lesson-calendar-panel {
  min-width: 0;
}

.lesson-calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.lesson-calendar-grid {
  display: grid;
  grid-template-columns: 64px repeat(7, minmax(88px, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
  max-height: 720px;
  background: #fff;
}

.lesson-calendar-corner,
.lesson-calendar-dayhead,
.lesson-calendar-time,
.lesson-calendar-slot {
  border-right: 1px solid #edf1f5;
  border-bottom: 1px solid #edf1f5;
}

.lesson-calendar-corner,
.lesson-calendar-dayhead {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8fafc;
}

.lesson-calendar-dayhead {
  padding: 10px 6px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: #334155;
}

.lesson-calendar-time {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  font-size: 12px;
  color: var(--muted);
  background: #fff;
}

.lesson-calendar-slot {
  min-height: 28px;
  background: #fff;
  border-left: 0;
  border-top: 0;
  padding: 2px;
  text-align: left;
  user-select: none;
  touch-action: none;
}

.lesson-calendar-slot:hover {
  background: #f8fbfd;
}

.lesson-calendar-slot.occupied {
  background: #fef7e8;
}

.lesson-calendar-slot.conflict {
  background: #fff1f0;
}

.lesson-calendar-slot.selecting,
.lesson-calendar-slot.selected {
  background: #dbeafe;
  box-shadow: inset 4px 0 0 #2563eb;
}

.lesson-calendar-chip {
  display: grid;
  gap: 2px;
  width: 100%;
  padding: 3px 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, .95);
  color: #0f172a;
  font-size: 11px;
  line-height: 1.2;
}

.lesson-calendar-chip strong {
  color: #0f766e;
  font-weight: 700;
}

.watermark {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  align-content: space-around;
  gap: 36px;
  padding: 36px;
  opacity: .075;
  transform: rotate(-18deg);
  color: #0f172a;
  font-size: 13px;
  font-weight: 700;
}

.watermark span {
  white-space: nowrap;
}

@media (max-width: 920px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

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

  .tabs {
    height: auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .field.wide {
    grid-column: auto;
  }

  .watermark {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    font-size: 12px;
  }
}
