:root {
  --ink: #1b1e26;
  --slate: #5b6573;
  --muted: #9aa1ad;
  --line: #e4e8f0;
  --line-blue: #d4dcf5;
  --blue: #2b4acb;
  --blue-dark: #1d3ba8;
  --canvas: #f6f8fc;
  --card: #fcfdff;
  --sidebar: 240px;
  --header: 56px;
  font-family: ui-sans-serif, system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body, #app { width: 100%; height: 100%; margin: 0; }
body { overflow: hidden; background: var(--canvas); }
button { font: inherit; letter-spacing: 0; }
button:focus-visible { outline: 2px solid #7aa2ff; outline-offset: 2px; }
[hidden] { display: none !important; }

.app-shell { display: flex; min-width: 1060px; height: 100vh; overflow: hidden; }
.sidebar {
  width: var(--sidebar);
  flex: 0 0 var(--sidebar);
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-right: 1px solid var(--line);
  z-index: 70;
}
.brand-button {
  height: 68px;
  padding: 20px 16px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--ink);
  transition: opacity 150ms ease;
}
.brand-button:hover { opacity: .8; }
.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
}
.brand-mark svg { width: 17px; height: 17px; }
.brand-name { font-size: 15px; line-height: 1; font-weight: 650; letter-spacing: 0; }

.main-nav { padding: 8px 12px 0; display: grid; gap: 6px; }
.nav-item {
  width: 100%; height: 36px; padding: 0 12px;
  display: flex; align-items: center; gap: 8px;
  border: 0; border-radius: 12px; background: transparent;
  color: var(--slate); font-size: 13px; font-weight: 500; text-align: left;
  cursor: pointer; transition: color 150ms, background 150ms;
}
.nav-item svg { width: 16px; height: 16px; }
.nav-item:hover { background: #f0f2f5; }
.nav-item.is-active { background: var(--ink); color: #fff; }
.history {
  min-height: 0; flex: 1; margin-top: 12px; padding: 12px 12px 0;
  border-top: 1px solid #eceef2;
}
.history-heading { padding: 0 4px; display: flex; align-items: center; justify-content: space-between; }
.history-heading > span { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 11px; font-weight: 500; }
.history-heading svg { width: 11px; height: 11px; }
.history-heading button { padding: 0; border: 0; color: #6e7785; background: transparent; font-size: 11px; cursor: pointer; }
.history-heading button:hover { color: var(--blue); }
.history p { margin: 12px 8px; color: #b3b9c4; font-size: 11px; }
.account-wrap { position: relative; padding: 0 12px 16px; }
.account-button {
  width: 100%; padding: 8px 10px; display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: 16px; background: #fff; cursor: pointer;
  transition: background 150ms, border-color 150ms;
}
.account-button:hover { background: #f6f7f9; border-color: #cdd4e0; }
.account-button img { width: 32px; height: 32px; flex: 0 0 auto; border-radius: 50%; object-fit: cover; background: #f0f2f5; }
.account-copy { min-width: 0; display: block; text-align: left; line-height: 1.2; }
.account-copy strong { display: block; overflow: hidden; color: var(--ink); font-size: 13px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.account-copy small { display: block; width: 148px; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.account-chevron { margin-left: auto; color: #cdd4e0; transition: transform 150ms; }
.account-chevron svg { width: 14px; height: 14px; }
.account-button[aria-expanded="true"] .account-chevron { transform: rotate(-90deg); }
.account-menu { position: absolute; right: 12px; bottom: 70px; left: 12px; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: 0 12px 28px rgba(15,23,42,.12); }
.account-menu button { width: 100%; padding: 7px 9px; border: 0; border-radius: 7px; background: transparent; color: var(--slate); font-size: 12px; text-align: left; cursor: pointer; }
.account-menu button:hover { background: #f0f2f5; }

.main-area { min-width: 0; height: 100vh; flex: 1; display: flex; flex-direction: column; background: var(--canvas); }
.top-header {
  position: relative; z-index: 60; height: var(--header); flex: 0 0 var(--header);
  padding: 0 24px; display: flex; align-items: center; gap: 16px;
  border-bottom: 1px solid var(--line); background: rgba(255,255,255,.8); backdrop-filter: blur(10px);
}
.header-icon { color: #b3b9c4; }
.header-icon svg { display: block; width: 16px; height: 16px; }
.header-copy { min-width: 0; }
.header-copy strong { display: block; color: var(--ink); font-size: 14px; line-height: 1; font-weight: 650; }
.header-copy span { display: block; margin-top: 6px; overflow: hidden; color: var(--muted); font-size: 11px; line-height: 1; text-overflow: ellipsis; white-space: nowrap; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.tour-button {
  height: 28px; padding: 0 10px; display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--line-blue); border-radius: 12px; background: transparent;
  color: #465064; font-size: 11px; font-weight: 500; cursor: pointer; transition: 150ms;
}
.tour-button svg { width: 13px; height: 13px; }
.tour-button:hover { color: var(--blue); background: #f6f8ff; }
.scope-chip { padding: 6px 10px; display: inline-flex; align-items: center; gap: 6px; border-radius: 12px; background: #f0f2f5; color: var(--slate); font-size: 11px; }
.scope-chip i, .update-copy i { width: 6px; height: 6px; border-radius: 50%; background: var(--blue); }

.dashboard-toolbar { height: 100px; flex: 0 0 100px; background: linear-gradient(180deg, #f9faff 0%, #f5f7fc 100%); border-bottom: 1px solid #e8ebf2; }
.tabs-row { height: 60px; padding: 0 16px; display: flex; align-items: center; gap: 16px; }
.dashboard-tabs { min-width: 0; display: flex; align-items: center; gap: 6px; }
.dashboard-tab {
  height: 32px; padding: 0 28px; border: 0; border-radius: 12px; background: transparent;
  color: #596273; font-size: 12px; font-weight: 500; white-space: nowrap; cursor: pointer;
}
.dashboard-tab.is-active { color: var(--blue); background: #e9edfc; font-weight: 650; }
.tab-icon-button, .new-dashboard {
  width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 10px; background: transparent; color: #697386; cursor: pointer;
}
.tab-icon-button { width: 20px; opacity: 0; transition: opacity 150ms; }
.dashboard-tabs:hover .tab-icon-button { opacity: 1; }
.tab-icon-button:hover, .new-dashboard:hover { background: #e9edf5; }
.tab-icon-button svg { width: 12px; height: 12px; }
.new-dashboard svg { width: 14px; height: 14px; }
.toolbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.secondary-button, .ai-button, .primary-button {
  height: 32px; padding: 0 12px; display: inline-flex; align-items: center; gap: 6px;
  border-radius: 12px; font-size: 12px; font-weight: 500; white-space: nowrap; cursor: pointer; transition: 150ms;
}
.secondary-button { border: 1px solid var(--line-blue); background: transparent; color: #465064; }
.secondary-button:hover { background: #f6f8ff; }
.ai-button { padding-inline: 14px; border: 1px solid var(--line-blue); background: #ecf0fd; color: var(--blue); }
.ai-button:hover { background: #dfe6fb; }
.primary-button { padding-inline: 14px; border: 0; background: var(--blue); color: #fff; font-weight: 650; box-shadow: 0 1px 2px rgba(15,23,42,.12); }
.primary-button:hover { background: var(--blue-dark); }
.secondary-button svg, .ai-button svg, .primary-button svg { width: 13px; height: 13px; }
.filters-row { height: 40px; padding: 0 16px 8px; display: flex; align-items: center; gap: 8px; }
.filter-button {
  max-width: 200px; height: 32px; padding: 0 8px 0 12px; display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line-blue); border-radius: 12px; background: #fff; color: #465064; font-size: 12px; cursor: pointer;
}
.filter-button span { color: #60708a; }
.filter-button:hover { background: #f6f8ff; }
.filter-button svg { width: 14px; height: 14px; color: #7b8494; }
.date-filter { padding-left: 10px; }
.update-copy { margin: 0 0 0 auto; display: flex; align-items: center; gap: 7px; color: #a1a9b7; font-size: 11px; white-space: nowrap; }

.dashboard-scroller { min-height: 0; flex: 1; padding: 16px; overflow-x: hidden; overflow-y: auto; scrollbar-gutter: stable; }
.dashboard-grid-clone {
  width: 100%; min-width: 920px; display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-template-rows: 160px 144px 144px 208px 160px 224px 216px 240px 224px 256px;
  gap: 16px 12px;
  padding-bottom: 8px;
}
.dashboard-card {
  min-width: 0; height: 100%; display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid #dbe3ef; border-radius: 12px; background: var(--card);
  box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 22px rgba(15,23,42,.045);
  transition: border-color 180ms cubic-bezier(.2,0,0,1), box-shadow 180ms cubic-bezier(.2,0,0,1), transform 180ms cubic-bezier(.2,0,0,1);
}
.dashboard-card.metric-card { background: linear-gradient(135deg, #fff 0%, #fbfdff 52%, #f2f7ff 100%); border-color: #d6e2f2; box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 10px 28px rgba(37,99,235,.07); }
.dashboard-card:hover { border-color: #cbd7e6; box-shadow: 0 4px 10px rgba(15,23,42,.055), 0 14px 30px rgba(15,23,42,.07); }
.metric-card:hover { border-color: #bfd0e7; box-shadow: 0 4px 10px rgba(15,23,42,.06), 0 14px 34px rgba(37,99,235,.10); }
.card-head { position: relative; flex: 0 0 auto; min-height: 48px; padding: 8px 14px 0; display: flex; align-items: flex-start; cursor: default; }
.card-title-wrap { min-width: 0; padding-right: 58px; flex: 1; }
.card-title { display: flex; align-items: center; gap: 4px; color: #526174; font-size: 11px; line-height: 16px; font-weight: 650; }
.card-title > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.info-button { width: 14px; height: 14px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 50%; background: transparent; color: #9aa6b7; cursor: help; }
.info-button:hover { color: #475569; background: #eef3f9; }
.info-button svg { width: 10px; height: 10px; }
.card-subtitle { margin-top: 1px; overflow: hidden; color: #9aa6b2; font-size: 10px; line-height: 15px; text-overflow: ellipsis; white-space: nowrap; }
.card-tools { position: absolute; top: 6px; right: 12px; display: flex; gap: 2px; opacity: 0; transition: opacity 150ms; }
.dashboard-card:hover .card-tools { opacity: 1; }
.card-tool { width: 24px; height: 24px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 10px; background: transparent; color: #2563eb; cursor: pointer; }
.card-tool:hover { background: #eef4ff; }
.card-tool.remove { color: #64748b; }
.card-tool.remove:hover { color: #ef476f; background: #fff1f4; }
.card-tool svg { width: 12px; height: 12px; }
.metric-body { position: relative; min-height: 0; padding: 0 14px 10px; flex: 1; display: flex; flex-direction: column; }
.metric-button { position: relative; min-height: 0; height: 100%; padding: 8px 0; display: flex; flex-direction: column; justify-content: center; border: 0; border-radius: 10px; background: transparent; text-align: left; cursor: pointer; }
.metric-value { color: #111827; font-size: 28px; line-height: 1; font-weight: 650; letter-spacing: 0; }
.metric-meta { margin-top: 4px; display: flex; flex-wrap: wrap; align-items: center; gap: 0 4px; color: #7b8494; font-size: 10px; line-height: 16px; }
.metric-meta .sep { color: #c3cad5; }
.delta-chip { width: fit-content; margin-top: 6px; padding: 2px 8px; display: inline-flex; align-items: center; gap: 4px; border: 1px solid #d1fae5; border-radius: 999px; background: #ecfdf5; color: #047857; font-size: 11px; line-height: 16px; font-weight: 650; }
.delta-chip svg { width: 12px; height: 12px; }
.detail-label { position: absolute; right: 0; bottom: 0; color: #2563eb; font-size: 10px; opacity: 0; transition: opacity 150ms; }
.metric-button:hover .detail-label, .metric-button:focus-visible .detail-label { opacity: 1; }

.chart-card .card-head, .table-card .card-head { min-height: 46px; }
.chart-wrap { min-height: 0; padding: 2px 14px 12px; flex: 1; }
.chart-wrap svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart-grid { stroke: #e7edf5; stroke-width: 1; stroke-dasharray: 3 3; }
.chart-axis { stroke: #d7e0ec; stroke-width: 1; }
.chart-line { fill: none; stroke: #3066ef; stroke-width: 2; }
.chart-dot { fill: #fff; stroke: #3066ef; stroke-width: 2; }
.chart-text { fill: #9aa6b7; font-size: 9px; }

.table-card { background: #fcfdff; }
.table-head { padding: 8px 12px 5px; display: flex; align-items: flex-end; gap: 12px; }
.table-head-copy { min-width: 0; }
.table-head-copy .card-title-wrap { padding: 0; }
.table-meta { margin-top: 2px; color: #9aa6b2; font-size: 10px; line-height: 15px; white-space: nowrap; }
.table-tools { margin-left: auto; display: flex; gap: 10px; }
.table-tools button { padding: 0; display: inline-flex; align-items: center; gap: 3px; border: 0; background: transparent; color: #64748b; font-size: 10px; cursor: pointer; }
.table-tools button:hover { color: var(--blue); }
.table-tools svg { width: 12px; height: 12px; }
.table-viewport { min-height: 0; flex: 1; overflow: auto; border-top: 1px solid #edf1f6; }
.data-table { width: 100%; min-width: max-content; border-collapse: separate; border-spacing: 0; color: #475569; font-size: 11px; }
.data-table thead { position: sticky; top: 0; z-index: 2; background: #f8fafc; }
.data-table th { height: 28px; padding: 6px 8px; border-bottom: 1px solid #e2e8f0; color: #64748b; font-weight: 650; text-align: left; white-space: nowrap; }
.data-table td { height: 34px; padding: 6px 8px; border-bottom: 1px solid #edf1f6; color: #556174; white-space: nowrap; }
.data-table th:first-child, .data-table td:first-child { position: sticky; left: 0; z-index: 1; background: inherit; box-shadow: 2px 0 4px -2px rgba(15,23,42,.12); }
.data-table thead th:first-child { z-index: 3; background: #f8fafc; }
.field-tag { margin-left: 4px; padding: 0 4px; display: inline-flex; border-radius: 4px; background: #eef2f7; color: #64748b; font-size: 9px; line-height: 16px; font-weight: 500; }
.field-tag.live { background: #ecfdf5; color: #047857; }
.status-bad { color: #dc4455; }
.empty-cell { height: 80px !important; color: #94a3b8 !important; font-size: 12px; text-align: center; }
.table-footer { height: 34px; padding: 0 12px; display: flex; align-items: center; border-top: 1px solid #edf1f6; color: #8a96a8; font-size: 10px; }
.pager { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.pager button { width: 24px; height: 22px; border: 1px solid #e2e8f0; border-radius: 6px; background: #fff; color: #8a96a8; }
.pager button:disabled { opacity: .45; }
.teacher-placeholder { min-height: 0; flex: 1; display: grid; place-items: center; color: #a0a9b7; font-size: 12px; border-top: 1px solid #edf1f6; }

.toast { position: fixed; left: 50%; bottom: 28px; z-index: 100; padding: 9px 14px; border: 1px solid #dce3ef; border-radius: 10px; background: rgba(27,30,38,.94); color: #fff; box-shadow: 0 10px 30px rgba(15,23,42,.2); font-size: 12px; opacity: 0; transform: translate(-50%, 12px); pointer-events: none; transition: opacity 180ms, transform 180ms; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1180px) {
  :root { --sidebar: 208px; }
  .account-copy small { width: 116px; }
  .dashboard-tab { padding-inline: 18px; }
  .update-copy { max-width: 430px; overflow: hidden; text-overflow: ellipsis; }
}

@media (max-width: 900px) {
  .app-shell { min-width: 0; }
  .sidebar { width: 64px; flex-basis: 64px; }
  .brand-button { padding-inline: 16px; }
  .brand-name, .nav-item span:last-child, .history, .account-copy, .account-chevron { display: none; }
  .main-nav { padding-inline: 10px; }
  .nav-item { justify-content: center; padding: 0; }
  .account-button { justify-content: center; padding-inline: 8px; }
  .header-copy span, .scope-chip, .secondary-button { display: none; }
  .dashboard-toolbar { overflow-x: auto; }
  .tabs-row, .filters-row { min-width: 760px; }
  .dashboard-scroller { overflow: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
