:root {
  --ink: #17332e; --muted: #657a75; --green: #147d6e; --green2: #2d9b84;
  --line: #d9e7e2; --bg: #f3f8f6; --warm: #e6a84a; --bad: #bd554d; --blue: #5476be;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: radial-gradient(ellipse at 50% -8%, rgba(166, 220, 204, .48), transparent 43%), linear-gradient(180deg, #f7fbfa 0%, #edf6f3 100%); color: var(--ink); font: 16px/1.55 system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; }
button, a, input, select, textarea { font: inherit; }
.topbar { position: sticky; z-index: 30; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 11px max(18px, calc((100% - 1180px) / 2)); border-bottom: 1px solid rgba(213, 230, 224, .9); background: rgba(249, 253, 252, .92); backdrop-filter: blur(15px); }
.brand { display: flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.brand > span { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 13px; background: linear-gradient(145deg, #176f61, #52b49e); color: #fff; font-weight: 850; }
.brand strong, .brand small { display: block; }
.brand small { color: var(--muted); font-size: 11px; }
.top-actions, .dashboard-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.back, .template-link, .secondary { min-height: 42px; padding: 9px 14px; border: 1px solid var(--line); border-radius: 11px; background: #fff; color: #3d5a54; text-decoration: none; font-weight: 750; cursor: pointer; }
.template-link { color: var(--green); }
.teacher-rail { position: fixed; z-index: 25; left: 16px; top: 50%; width: 138px; padding: 12px; border: 1px solid var(--line); border-radius: 20px; background: rgba(255, 255, 255, .94); box-shadow: 0 16px 42px rgba(32, 67, 59, .12); transform: translateY(-50%); }
.teacher-rail > div { padding: 2px 4px 10px; border-bottom: 1px solid #e7efec; }
.teacher-rail strong, .teacher-rail small { display: block; }
.teacher-rail small { color: #8a9a96; font-size: 8px; letter-spacing: .1em; }
.teacher-rail a { display: flex; align-items: center; gap: 8px; margin-top: 9px; padding: 8px; border-radius: 12px; background: #e8f5f1; color: var(--green); text-decoration: none; font-size: 12px; font-weight: 800; }
.teacher-rail b { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 10px; background: var(--green); color: #fff; }
.teacher-rail p { margin: 10px 0 0; padding-top: 8px; border-top: 1px dashed var(--line); color: #97a5a1; font-size: 9px; text-align: center; }
main { width: min(1120px, calc(100% - 36px)); min-height: calc(100vh - 135px); margin: auto; padding: 48px 0 90px; }
.intro { position: relative; max-width: 780px; margin: clamp(34px, 7vh, 82px) auto 0; text-align: center; }
.intro::before { position: absolute; z-index: -1; top: -110px; left: 50%; width: 520px; height: 250px; border-radius: 50%; background: rgba(113, 194, 171, .14); content: ""; filter: blur(70px); transform: translateX(-50%); }
.intro-badge { display: grid; width: 58px; height: 58px; margin: 0 auto 18px; place-items: center; border: 1px solid rgba(255, 255, 255, .82); border-radius: 19px; background: linear-gradient(145deg, #176f61 0%, #43a58f 100%); box-shadow: 0 14px 34px rgba(23, 111, 97, .22), inset 0 1px rgba(255, 255, 255, .28); color: #fff; font-size: 23px; font-weight: 900; }
.eyebrow { margin: 0 0 8px; color: var(--green); font-size: 11px; font-weight: 850; letter-spacing: .14em; }
.intro h1 { margin: 0; font-size: clamp(42px, 5vw, 62px); line-height: 1.08; letter-spacing: -.055em; }
.intro > .intro-summary { max-width: 620px; margin: 14px auto 0; color: #607873; font-size: clamp(14px, 1.6vw, 17px); letter-spacing: .01em; }
.upload-row { display: flex; justify-content: center; gap: 12px; margin-top: 24px; }
.upload-button { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 54px; padding: 12px 26px; border-radius: 16px; background: linear-gradient(145deg, #173d35, #1d584c); color: #fff; cursor: pointer; font-weight: 850; box-shadow: 0 14px 30px rgba(23, 61, 53, .2); transition: transform .16s ease, box-shadow .16s ease, background .16s ease; }
.upload-button:hover { background: linear-gradient(145deg, #1b493f, #24705f); box-shadow: 0 16px 34px rgba(23, 61, 53, .25); transform: translateY(-2px); }
.upload-button small { opacity: .65; font-size: 10px; }
.intro .secondary { min-height: 54px; padding-inline: 22px; border-color: #c9ddd7; border-radius: 16px; background: rgba(255, 255, 255, .84); transition: border-color .16s ease, background .16s ease, transform .16s ease; }
.intro .secondary:hover { border-color: #86b9ab; background: #fff; transform: translateY(-2px); }
.status { min-height: 0; margin: 16px auto 0 !important; font-size: 13px !important; }
.status:empty { display: none; }
.status.error { color: var(--bad) !important; }
.hidden { display: none !important; }
.dashboard-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.dashboard-head h2 { margin: 0; font-size: 34px; }
.dashboard-head p { margin: 5px 0 0; color: var(--muted); }
.metrics { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 15px; }
.metric, .chart-card, .validation { border: 1px solid var(--line); border-radius: 20px; background: #fff; box-shadow: 0 8px 28px rgba(33, 69, 61, .055); }
.metric { padding: 17px; }
.metric small, .metric strong { display: block; }
.metric small { color: var(--muted); font-size: 12px; }
.metric strong { margin-top: 3px; font-size: 27px; font-variant-numeric: tabular-nums; }
.chart-card { margin-top: 15px; padding: 22px; }
.chart-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 15px; }
.chart-heading > div { display: flex; align-items: center; gap: 10px; }
.chart-heading span { color: var(--green); font-size: 11px; font-weight: 850; }
.chart-heading h3 { margin: 0; font-size: 19px; }
.chart-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.chart { min-height: 260px; overflow-x: auto; }
.chart svg { display: block; min-width: 680px; width: 100%; height: auto; }
.axis-label { fill: var(--muted); font-size: 12px; }
.value-label { fill: var(--ink); font-size: 12px; font-weight: 700; }
.grid-line { stroke: #e5eeeb; stroke-width: 1; }
.average-line { stroke: var(--warm); stroke-width: 2; stroke-dasharray: 7 5; }
.bar-main { fill: var(--green2); }
.bar-top10 { fill: var(--green); }
.bar-quarter { fill: #9bcfc1; }
.heatmap-wrap { overflow-x: auto; }
.heatmap { display: grid; min-width: 720px; gap: 5px; align-items: stretch; }
.heat-cell { display: grid; min-height: 48px; place-items: center; padding: 5px; border-radius: 8px; text-align: center; font-size: 12px; }
.heat-head, .heat-row-label { background: #f0f5f3; font-weight: 800; }
.heat-cell strong { display: block; font-size: 14px; }
.distribution-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.dist-panel { min-width: 0; padding-top: 10px; border-top: 1px solid #edf2f0; }
.dist-panel h4 { margin: 0 0 10px; font-size: 15px; }
.dist-row { display: grid; grid-template-columns: 72px 1fr 34px; align-items: center; gap: 8px; min-height: 25px; }
.dist-label { color: var(--muted); font-size: 10px; text-align: right; }
.dist-track { display: grid; grid-template-columns: 1fr 1fr; height: 14px; }
.dist-left, .dist-right { background: var(--blue); }
.dist-left { justify-self: end; border-radius: 7px 0 0 7px; }
.dist-right { justify-self: start; border-radius: 0 7px 7px 0; }
.dist-count { font-size: 11px; font-weight: 750; }
.legend { display: flex; justify-content: center; gap: 22px; margin-top: 8px; color: var(--muted); font-size: 12px; }
.legend i { display: inline-block; width: 12px; height: 12px; margin-right: 5px; border-radius: 3px; vertical-align: -1px; }
.legend .top10 { background: var(--green); }
.legend .quarter { background: #9bcfc1; }
.validation { margin-top: 15px; padding: 18px 22px; }
.validation h3 { margin: 0 0 7px; font-size: 16px; }
.validation ul { margin: 0; padding-left: 20px; color: var(--bad); font-size: 13px; }
footer { padding: 22px; text-align: center; color: #81938e; font-size: 11px; }
.report-button, .download-word { min-height: 42px; padding: 10px 16px; border: 0; border-radius: 11px; background: linear-gradient(145deg, var(--green), var(--green2)); color: #fff; font-weight: 850; cursor: pointer; box-shadow: 0 9px 22px rgba(20, 125, 110, .2); }
.report-button:disabled, .download-word:disabled { cursor: not-allowed; opacity: .5; box-shadow: none; }
.report-builder { margin-top: 24px; padding: 26px; border: 1px solid var(--line); border-radius: 24px; background: #fdfefe; box-shadow: 0 13px 38px rgba(23, 51, 46, .08); scroll-margin-top: 78px; }
.report-builder-head, .preview-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.report-builder-head h2, .preview-title h3 { margin: 0; font-size: 28px; }
.report-builder-head p:not(.eyebrow) { max-width: 720px; margin: 5px 0 0; color: var(--muted); }
.local-badge { flex: none; padding: 7px 11px; border-radius: 999px; background: #e7f5f1; color: var(--green); font-size: 12px; font-weight: 850; }
.report-meta-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin-top: 22px; padding: 20px; border: 1px solid #e4eeeb; border-radius: 18px; background: #f5faf8; }
.report-meta-form label, .narrative-editor, .narrative-grid label { display: grid; gap: 6px; color: #49645e; font-size: 12px; font-weight: 800; }
.report-meta-form .wide { grid-column: span 2; }
.report-meta-form input, .report-meta-form select, .narrative-editor textarea, .narrative-grid textarea { width: 100%; border: 1px solid #cfe0db; border-radius: 10px; background: #fff; color: var(--ink); outline: none; }
.report-meta-form input, .report-meta-form select { min-height: 44px; padding: 8px 11px; }
.report-meta-form input:focus, .report-meta-form select:focus, .narrative-editor textarea:focus, .narrative-grid textarea:focus { border-color: var(--green2); box-shadow: 0 0 0 3px rgba(45, 155, 132, .12); }
.report-meta-form .report-button { align-self: end; }
.report-status { min-height: 24px; margin: 13px 2px 0; color: var(--green); font-size: 13px; font-weight: 750; }
.report-status.error { color: var(--bad); }
.report-preview { margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--line); scroll-margin-top: 78px; }
.preview-title small { color: var(--green); font-size: 11px; font-weight: 850; letter-spacing: .12em; }
.preview-note { margin: 12px 0 18px; padding: 12px 14px; border-radius: 12px; background: #eef7f4; color: var(--muted); font-size: 13px; }
.preview-section { margin-top: 15px; padding: 20px; border: 1px solid #ddeae6; border-radius: 17px; background: #fff; }
.preview-section h4 { margin: 0 0 14px; color: var(--green); font-size: 18px; }
.preview-chart { margin: 12px 0; padding: 10px; border: 1px solid #e4eeeb; border-radius: 13px; overflow-x: auto; background: #fff; }
.preview-chart svg { display: block; min-width: 650px; width: 100%; height: auto; }
.preview-chart.compact svg { max-height: 330px; }
.preview-table-wrap { overflow-x: auto; }
.preview-table-wrap table { width: 100%; min-width: 720px; border-collapse: separate; border-spacing: 0; font-size: 12px; }
.preview-table-wrap th, .preview-table-wrap td { padding: 9px; border-right: 1px solid #dce8e4; border-bottom: 1px solid #dce8e4; text-align: center; }
.preview-table-wrap thead th { background: var(--green); color: #fff; }
.preview-table-wrap tr > *:first-child { border-left: 1px solid #dce8e4; }
.preview-table-wrap thead tr:first-child > * { border-top: 1px solid var(--green); }
.preview-table-wrap .total > * { background: #eef7f4; font-weight: 850; }
.narrative-editor { margin-top: 12px; }
.narrative-editor textarea, .narrative-grid textarea { min-height: 92px; padding: 11px 12px; resize: vertical; line-height: 1.65; }
.narrative-grid { display: grid; gap: 10px; margin-top: 12px; }
.download-word { min-width: 155px; }
.download-chart { flex: none; padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px; background: #f7faf9; color: var(--green); font-size: 11px; font-weight: 800; cursor: pointer; }
.download-chart:disabled { opacity: .55; }
.chart-card.exporting { box-shadow: none; }

@media (max-width: 1340px) { .teacher-rail { display: none; } }
@media (max-width: 900px) { .report-meta-form { grid-template-columns: repeat(2, minmax(0, 1fr)); } .report-meta-form .wide { grid-column: span 2; } }
@media (max-width: 800px) {
  main { width: calc(100% - 24px); padding-top: 34px; } .topbar { padding-inline: 12px; } .template-link { display: none; }
  .intro { margin-top: 4vh; } .intro h1 { font-size: 42px; } .metrics { grid-template-columns: repeat(2, 1fr); }
  .distribution-grid { grid-template-columns: 1fr; } .chart-card { padding: 17px; } .chart-heading { align-items: flex-start; flex-direction: column; }
  .dashboard-head { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 640px) {
  .dashboard-actions { justify-content: flex-start; } .report-builder { padding: 17px; } .report-builder-head, .preview-title { flex-direction: column; }
  .report-meta-form { grid-template-columns: 1fr; padding: 14px; } .report-meta-form .wide { grid-column: auto; } .report-meta-form .report-button, .download-word { width: 100%; }
}
@media (max-width: 480px) { .brand small { display: none; } .back { font-size: 12px; } .upload-row { flex-direction: column; } .upload-row > * { width: 100%; } .metrics { grid-template-columns: 1fr 1fr; } .metric strong { font-size: 23px; } }
