:root {
  color-scheme: light;
  --bg: #f4f6f4;
  --surface: #ffffff;
  --surface-2: #eef3f0;
  --ink: #17211d;
  --muted: #69746f;
  --line: #dce4df;
  --line-strong: #b8c5bf;
  --green: #26745f;
  --green-dark: #185744;
  --blue: #2b64b1;
  --cyan: #178195;
  --amber: #a96814;
  --red: #b33b37;
  --purple: #7654a6;
  --radius: 8px;
  --shadow: 0 12px 36px rgba(29, 45, 38, 0.1);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100vh;
  padding: 22px 18px;
  background: #10241d;
  color: #f5fbf8;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: var(--radius);
  background: #dfeee7;
  color: #0d3528;
  font-size: 23px;
  font-weight: 800;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel-heading h3,
.panel-heading p,
.insight-panel h3 {
  margin: 0;
}

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

.brand p,
.eyebrow,
.panel-heading p,
.event-meta,
.empty,
.kpi-card span {
  color: var(--muted);
}

.sidebar .brand p {
  color: rgba(245, 251, 248, 0.72);
  font-size: 12px;
}

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

.nav-tab {
  min-height: 38px;
  padding: 0 12px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.08);
  color: #edf7f3;
  text-align: left;
}

.nav-tab.active,
.nav-tab:hover {
  background: #dfeee7;
  color: #0d3528;
}

.mini-map {
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  background: #f7faf8;
}

.mini-map img {
  display: block;
  width: 100%;
  height: auto;
}

.filter-stack {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: inherit;
  font-size: 13px;
  font-weight: 650;
}

[hidden] {
  display: none !important;
}

.sidebar label {
  color: rgba(245, 251, 248, 0.84);
}

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

textarea {
  resize: vertical;
}

.workspace {
  display: grid;
  grid-template-rows: auto auto 1fr;
  min-width: 0;
  padding: 22px;
  gap: 18px;
}

.topbar,
.panel-heading,
.dialog-head,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar h2 {
  font-size: 28px;
}

.eyebrow {
  margin-bottom: 3px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

.sync-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.sync-status[data-mode="online"] {
  border-color: #b9d9cb;
  background: #eef9f3;
  color: var(--green-dark);
}

.sync-status[data-mode="offline"] {
  border-color: #edd39f;
  background: #fff8e8;
  color: #805112;
}

.sync-status[data-mode="error"] {
  border-color: #efc6c2;
  background: #fff0ef;
  color: var(--red);
}

.primary-btn,
.ghost-btn,
.icon-btn {
  min-height: 38px;
  border-radius: var(--radius);
  transition:
    background 0.15s ease,
    transform 0.15s ease,
    border-color 0.15s ease;
}

.primary-btn {
  padding: 0 15px;
  background: var(--green);
  color: #fff;
  font-weight: 750;
}

.primary-btn:hover,
.icon-btn:hover,
.ghost-btn:hover {
  transform: translateY(-1px);
}

.ghost-btn {
  padding: 0 13px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.danger-btn {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid #efc6c2;
  border-radius: var(--radius);
  background: #fff4f2;
  color: var(--red);
  font-weight: 750;
}

.danger-btn:hover {
  background: #ffe9e6;
}

.icon-btn {
  display: grid;
  width: 38px;
  place-items: center;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 23px;
  line-height: 1;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
}

.kpi-card,
.primary-panel,
.insight-panel,
dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.kpi-card {
  display: grid;
  gap: 4px;
  min-height: 82px;
  padding: 14px;
}

.kpi-card strong {
  font-size: 28px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  min-height: 0;
}

.primary-panel,
.insight-panel {
  min-width: 0;
  padding: 16px;
}

.primary-panel {
  overflow: hidden;
}

.insight-panel {
  display: grid;
  align-content: start;
  gap: 20px;
}

.panel-heading {
  margin-bottom: 14px;
}

.panel-heading h3,
.insight-panel h3 {
  font-size: 17px;
}

.legend {
  display: none;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.legend-item,
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 12px;
  font-weight: 650;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.schedule-grid {
  display: grid;
  grid-template-columns: 104px repeat(9, minmax(138px, 1fr));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.teacher-grid {
  display: grid;
  grid-template-columns: 126px repeat(7, minmax(128px, 1fr));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.grid-cell,
.grid-head,
.grid-row-head {
  min-height: 112px;
  padding: 8px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.grid-head {
  position: sticky;
  top: 0;
  z-index: 2;
  min-height: 54px;
  background: #e7eee9;
  font-size: 13px;
  font-weight: 800;
}

.grid-row-head {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #f7faf8;
  font-weight: 800;
}

.date-head {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.event-card {
  display: grid;
  gap: 5px;
  margin-bottom: 7px;
  padding: 8px;
  border-left: 4px solid var(--green);
  border-radius: 6px;
  background: #f8fbfa;
  box-shadow: inset 0 0 0 1px rgba(23, 33, 29, 0.07);
  cursor: pointer;
  transition:
    box-shadow 0.15s ease,
    transform 0.15s ease,
    background 0.15s ease;
}

.event-card:hover,
.event-card:focus-visible {
  background: #ffffff;
  box-shadow:
    inset 0 0 0 1px rgba(23, 33, 29, 0.1),
    0 8px 20px rgba(23, 33, 29, 0.12);
  outline: none;
  transform: translateY(-1px);
}

.event-card h4 {
  margin: 0;
  font-size: 13px;
  line-height: 1.25;
}

.event-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  font-size: 11px;
}

.event-card[data-status="已安排"] {
  border-color: var(--blue);
  background: #f2f7ff;
}

.event-card[data-status="待确认"] {
  border-color: var(--amber);
  background: #fff8e8;
}

.event-card[data-status="已完成"] {
  border-color: var(--green);
  background: #f1faf5;
}

.event-card[data-status="因故取消"] {
  border-color: var(--red);
  background: #fff0ef;
  opacity: 0.6;
  text-decoration: line-through;
}

.empty {
  padding: 16px;
  text-align: center;
}

.empty-slot {
  display: grid;
  width: 100%;
  min-height: 82px;
  place-items: center;
  border: 1px dashed transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  font-weight: 750;
  cursor: pointer;
}

.empty-slot:hover,
.empty-slot:focus-visible {
  border-color: var(--green);
  background: #f4faf7;
  color: var(--green-dark);
  outline: none;
}

.empty-slot:hover::after,
.empty-slot:focus-visible::after {
  content: "新增活动";
  display: block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 750;
}

.teacher-load {
  display: grid;
  gap: 10px;
}

.load-row {
  display: grid;
  grid-template-columns: 76px 1fr 28px;
  align-items: center;
  gap: 9px;
  font-size: 13px;
}

.bar {
  overflow: hidden;
  height: 9px;
  border-radius: 999px;
  background: var(--surface-2);
}

.bar span {
  display: block;
  height: 100%;
  background: var(--green);
}

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

.alert {
  padding: 9px 10px;
  border-left: 4px solid var(--amber);
  border-radius: 6px;
  background: #fff8e8;
  font-size: 13px;
}

.alert.high {
  border-color: var(--red);
  background: #fff0ef;
}

.activity-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

.activity-table th {
  position: sticky;
  top: 0;
  background: #e7eee9;
  font-size: 12px;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 280px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.analytics-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.analytics-summary article {
  display: grid;
  gap: 4px;
  min-height: 78px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fbfa;
}

.analytics-summary span,
.stat-row span {
  color: var(--muted);
  font-size: 12px;
}

.analytics-summary strong {
  font-size: 25px;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.analytics-panel {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.analytics-panel h4 {
  margin: 0 0 12px;
  font-size: 15px;
}

.stat-row {
  display: grid;
  grid-template-columns: minmax(120px, 1.2fr) minmax(110px, 2fr) 52px;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 7px 0;
  border-top: 1px solid var(--line);
}

.stat-row:first-of-type {
  border-top: 0;
}

.stat-row div:first-child {
  display: grid;
  gap: 2px;
}

.stat-bar {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
}

.stat-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.stat-row b {
  text-align: right;
}

.people-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fbfa;
  color: var(--muted);
  font-size: 13px;
}

dialog {
  width: min(760px, calc(100vw - 32px));
  padding: 0;
  border: 0;
}

dialog::backdrop {
  background: rgba(12, 24, 20, 0.46);
}

.event-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.dialog-head {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.dialog-head h3 {
  margin: 0;
}

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

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 0;
  padding: 10px 12px 12px;
}

legend {
  padding: 0 6px;
  font-size: 13px;
  font-weight: 750;
}

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

.teacher-checks label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 500;
}

.teacher-checks input {
  width: auto;
  min-height: auto;
}

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

  .sidebar {
    min-height: auto;
  }

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

@media (max-width: 760px) {
  .workspace {
    padding: 14px;
  }

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

  .kpi-row,
  .form-grid,
  .teacher-checks,
  .analytics-summary,
  .analytics-grid {
    grid-template-columns: 1fr;
  }

  .stat-row {
    grid-template-columns: 1fr;
  }

  .schedule-grid {
    grid-template-columns: 92px repeat(9, minmax(122px, 1fr));
  }

  .teacher-grid {
    grid-template-columns: 92px repeat(7, minmax(122px, 1fr));
  }
}
