/* 学员地图 v3 - 主样式（v2 方案：A/B/C/D 分层） */
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue', sans-serif;
  background: #f4f5f7; color: #1f2937; font-size: 14px;
}
a { color: #4f46e5; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ==================== 分层语义颜色（v2） ====================
   A 核心家长 = 红    #ef4444
   B 在读     = 蓝/紫 #3b82f6
   C 未在读高端 = 黄  #eab308
   D 未接触/估算 = 灰 #9ca3af
*/

/* ==================== Layout: 侧栏 + 内容 ==================== */
.app {
  display: grid; grid-template-columns: 220px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: linear-gradient(180deg, #1f2937 0%, #111827 100%);
  color: #cbd5e1; padding: 16px 12px; position: relative;
}
.sidebar h2 {
  margin: 0 0 18px; padding: 0 6px;
  font-size: 18px; color: #fff; font-weight: 700;
  letter-spacing: 1px;
}
.sidebar h2 small {
  font-size: 11px; color: #94a3b8; font-weight: 400;
  display: block; margin-top: 2px;
}
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: block; padding: 9px 12px; border-radius: 6px;
  color: #cbd5e1; font-size: 13px; transition: all .15s;
}
.nav a:hover { background: rgba(255,255,255,0.06); color: #fff; text-decoration: none; }
.nav a.active { background: #4f46e5; color: #fff; font-weight: 500; }
.user-card {
  position: absolute; bottom: 12px; left: 12px; right: 12px;
  background: rgba(255,255,255,0.05); border-radius: 8px;
  padding: 10px 12px; font-size: 12px;
}
.user-card .name { color: #fff; font-weight: 500; }
.user-card .role { color: #94a3b8; font-size: 11px; margin-top: 2px; }
.user-card .logout { float: right; color: #ef4444; cursor: pointer; }
.user-card .logout:hover { text-decoration: underline; }

.main { padding: 0; min-width: 0; }
.topbar {
  background: #fff; border-bottom: 1px solid #e5e7eb;
  padding: 12px 24px; display: flex; align-items: center;
  gap: 14px; min-height: 52px;
}
.crumbs { font-size: 13px; color: #6b7280; }
.crumbs a { color: #4f46e5; }
.crumbs span.sep { margin: 0 6px; color: #d1d5db; }
.crumbs b { color: #111827; }

.content { padding: 22px 24px 60px; max-width: 1500px; margin: 0 auto; }

/* ==================== KPI Cards ==================== */
.kpi-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px; margin-bottom: 18px;
}
.kpi {
  background: #fff; border-radius: 10px; padding: 14px 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  border-top: 3px solid #4f46e5;
}
.kpi-num {
  font-size: 26px; font-weight: 700; color: #4f46e5;
  line-height: 1.1;
}
.kpi-label {
  font-size: 12px; color: #6b7280; margin-top: 4px;
}
.kpi-sub {
  font-size: 11px; color: #9ca3af; margin-top: 4px;
}
.kpi-target {
  font-size: 11px; color: #16a34a; margin-top: 4px; font-weight: 500;
}
/* 分层 KPI */
.kpi.k-core      { border-top-color: #ef4444; } .kpi.k-core .kpi-num      { color: #dc2626; }
.kpi.k-enrolled  { border-top-color: #3b82f6; } .kpi.k-enrolled .kpi-num  { color: #2563eb; }
.kpi.k-contacted { border-top-color: #eab308; } .kpi.k-contacted .kpi-num { color: #ca8a04; }
.kpi.k-untouched { border-top-color: #9ca3af; } .kpi.k-untouched .kpi-num { color: #6b7280; }
/* 渗透率高亮 */
.kpi.k-penet { border-top-color: #7c3aed; }
.kpi.k-penet .kpi-num { color: #7c3aed; }
/* 学校规模 */
.kpi.k-scale { border-top-color: #0891b2; }
.kpi.k-scale .kpi-num { color: #0891b2; }

/* ==================== Penetration bar ==================== */
.penet-bar {
  display: flex; height: 22px; border-radius: 11px; overflow: hidden;
  background: #f3f4f6; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.04);
  font-size: 11px; color: #fff; font-weight: 600;
}
.penet-bar > div {
  display: flex; align-items: center; justify-content: center;
  white-space: nowrap; overflow: hidden;
}
.penet-core      { background: #ef4444; }   /* A 红 */
.penet-enrolled  { background: #3b82f6; }   /* B 蓝 */
.penet-contacted { background: #eab308; }   /* C 黄 */
.penet-untouched { background: #9ca3af; }   /* D 灰 */

/* ==================== Branch Cards ==================== */
.branch-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px; margin-bottom: 18px;
}
.branch-card {
  background: #fff; border-radius: 10px; padding: 12px 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  cursor: pointer; transition: all .12s;
  border: 2px solid transparent;
}
.branch-card:hover {
  transform: translateY(-2px); box-shadow: 0 4px 12px rgba(99,102,241,0.18);
  border-color: #c7d2fe;
}
.branch-card .tier {
  display: inline-block; padding: 2px 10px; border-radius: 4px;
  font-size: 11px; color: #fff; font-weight: 600;
}
.branch-card h3 { margin: 8px 0 4px; font-size: 16px; color: #111827; }
.branch-card .meta { font-size: 12px; color: #6b7280; }
.tier-HQ    { background: #7c3aed; }
.tier-T1    { background: #4f46e5; }
.tier-T2    { background: #0891b2; }
.tier-T3    { background: #0d9488; }
.tier-T4    { background: #ca8a04; }
.tier-T5    { background: #ea580c; }
.tier-T6    { background: #6b7280; }
.tier-OTHER { background: #9ca3af; }

/* ==================== School / Class Cards ==================== */
.card {
  background: #fff; border-radius: 10px; padding: 16px 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04); margin-bottom: 14px;
}
.card h3 { margin: 0 0 10px; font-size: 16px; color: #111827; }
.card .sub { color: #6b7280; font-size: 12px; margin-bottom: 10px; }

.school-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.school-card {
  background: #fff; border-radius: 10px; padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  cursor: pointer; transition: all .15s;
  border-left: 3px solid #4f46e5;
}
.school-card:hover {
  transform: translateY(-2px); box-shadow: 0 4px 12px rgba(99,102,241,0.18);
}
.school-card h4 { margin: 0 0 6px; font-size: 15px; color: #111827; }
.school-card .district { font-size: 11px; color: #6b7280; margin-bottom: 8px; }
.school-card .stats {
  display: flex; gap: 10px; font-size: 11px; color: #6b7280;
  margin-top: 8px; flex-wrap: wrap;
}
.school-card .stats b { color: #1f2937; }

/* ==================== Grade Pills ==================== */
.grade-tabs {
  display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap;
}
.grade-tab {
  padding: 6px 14px; border-radius: 16px; background: #fff;
  border: 1px solid #d1d5db; color: #4b5563; cursor: pointer;
  font-size: 13px; transition: all .12s;
}
.grade-tab:hover { background: #eef2ff; border-color: #c7d2fe; }
.grade-tab.active { background: #4f46e5; color: #fff; border-color: #4f46e5; }
.grade-tab .num { color: #6b7280; font-size: 11px; margin-left: 4px; }
.grade-tab.active .num { color: #c7d2fe; }

/* ==================== Class Grid ==================== */
.class-row {
  display: grid; grid-template-columns: 110px 100px 1fr;
  gap: 12px; padding: 10px 12px; align-items: center;
  background: #fafbfc; border-radius: 6px; margin-bottom: 6px;
  border-left: 3px solid #c7d2fe; cursor: pointer;
  transition: all .1s;
}
.class-row:hover { background: #eef2ff; border-left-color: #4f46e5; }
.grade-block { margin-bottom: 10px; }
.class-row.grade-row { background: #f5f3ff; border-left-color: #7c3aed; }
.class-row.grade-row:hover { background: #ede9fe; }
.class-row.grade-row .label { font-size: 16px; color: #4c1d95; }
.class-row.grade-row .label small { color: #7c3aed; font-weight: 400; }
.class-row .label { font-weight: 600; color: #111827; }
.class-row .label small { display: block; color: #9ca3af; font-size: 11px; margin-top: 2px; font-weight: 400; }
.class-row .penet { font-size: 12px; color: #4b5563; }
.class-row .stat-row { display: flex; gap: 8px; font-size: 11px; color: #6b7280; flex-wrap: wrap; }
.class-row .stat-row b { color: #1f2937; }

/* ==================== Student Cells (色块) ==================== */
.student-grid {
  display: grid; grid-template-columns: repeat(auto-fill, 28px);
  gap: 4px; padding: 8px 0;
}
.s-cell {
  width: 28px; height: 28px; border-radius: 4px;
  cursor: pointer; transition: transform .1s;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #fff; font-weight: 700;
  position: relative;
}
.s-cell:hover { transform: scale(1.25); z-index: 5; box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
.s-core      { background: #ef4444; }   /* A */
.s-enrolled  { background: #3b82f6; }   /* B */
.s-contacted { background: #eab308; }   /* C */
.s-untouched { background: #9ca3af; }   /* D */
/* 单科 vs 多科：外框 */
.s-single { border: 1px solid rgba(0,0,0,0.18); }
.s-multi  { border: 3px solid #1e293b; }
/* 我打过的星标 */
.s-cell.tagged-by-me::after {
  content: '★'; position: absolute; top: -2px; right: -2px;
  font-size: 10px; color: #fbbf24; text-shadow: 0 0 2px rgba(0,0,0,0.6);
}

/* D 类警告条（合规） */
.untouched-notice {
  background: #fef3c7; border-left: 3px solid #d97706;
  padding: 10px 14px; border-radius: 6px;
  font-size: 12px; color: #78350f; line-height: 1.6;
}
.untouched-notice b { color: #b45309; }
.untouched-stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 12px; margin-top: 12px;
}
.untouched-stat {
  background: #f9fafb; border-radius: 6px; padding: 10px 14px;
}
.untouched-stat .v { font-size: 22px; font-weight: 700; color: #4b5563; }
.untouched-stat .l { font-size: 11px; color: #6b7280; margin-top: 2px; }

/* ==================== Tooltip ==================== */
.tooltip {
  position: fixed; background: #1f2937; color: #fff;
  padding: 8px 12px; border-radius: 6px; font-size: 12px;
  pointer-events: none; z-index: 1000; max-width: 280px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25); display: none;
  line-height: 1.5;
}
.tooltip b { color: #fbbf24; }
.tooltip .tag { display: inline-block; padding: 1px 6px; border-radius: 3px; font-size: 10px; margin-right: 4px; }

/* ==================== Modal ==================== */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.modal {
  background: #fff; border-radius: 12px; padding: 22px 26px;
  width: 520px; max-width: 92%; max-height: 85vh; overflow: auto;
  box-shadow: 0 12px 32px rgba(0,0,0,0.25);
}
.modal h3 { margin: 0 0 14px; }
.modal .row { display: grid; grid-template-columns: 100px 1fr; gap: 8px; padding: 6px 0; font-size: 13px; border-bottom: 1px solid #f3f4f6; }
.modal .row .k { color: #6b7280; }
.modal .row .v { color: #1f2937; }
.modal .section-title {
  margin: 14px 0 6px; padding: 6px 10px; background: #f3f4f6;
  border-radius: 4px; font-size: 12px; color: #4b5563;
  font-weight: 600;
}
.modal .actions { margin-top: 18px; display: flex; gap: 10px; justify-content: flex-end; }
.btn {
  padding: 7px 16px; border-radius: 6px; border: 1px solid #d1d5db;
  background: #fff; cursor: pointer; font-size: 13px;
  transition: all .12s;
}
.btn:hover { background: #f3f4f6; }
.btn-primary { background: #4f46e5; color: #fff; border-color: #4f46e5; }
.btn-primary:hover { background: #4338ca; }
.btn-success { background: #16a34a; color: #fff; border-color: #16a34a; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: #dc2626; color: #fff; border-color: #dc2626; }
.btn-danger:hover { background: #b91c1c; }
/* 分层快捷按钮 */
.btn-A { background: #ef4444; color: #fff; border-color: #ef4444; }
.btn-A:hover { background: #dc2626; }
.btn-B { background: #3b82f6; color: #fff; border-color: #3b82f6; }
.btn-B:hover { background: #2563eb; }
.btn-C { background: #eab308; color: #fff; border-color: #eab308; }
.btn-C:hover { background: #ca8a04; }
.btn-D { background: #9ca3af; color: #fff; border-color: #9ca3af; }
.btn-D:hover { background: #6b7280; }

/* ==================== Login ==================== */
.login-bg {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
}
.login-box {
  background: #fff; border-radius: 12px; padding: 36px 40px 28px;
  width: 380px; max-width: 92%;
  box-shadow: 0 16px 48px rgba(0,0,0,0.2);
}
.login-box h2 {
  margin: 0 0 6px; font-size: 22px; color: #111827; text-align: center;
}
.login-box .sub { color: #6b7280; font-size: 12px; text-align: center; margin-bottom: 22px; }
.login-box label { display: block; margin-bottom: 14px; font-size: 13px; color: #4b5563; }
.login-box input {
  width: 100%; padding: 9px 12px; margin-top: 4px;
  border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px;
  outline: none;
}
.login-box input:focus { border-color: #4f46e5; box-shadow: 0 0 0 3px rgba(79,70,229,0.15); }
.login-box .btn-primary { width: 100%; padding: 10px; font-size: 14px; }
.login-tip {
  margin-top: 16px; padding: 10px; background: #f3f4f6; border-radius: 6px;
  font-size: 11px; color: #6b7280; line-height: 1.6;
}
.login-tip code { background: #e5e7eb; padding: 1px 5px; border-radius: 3px; color: #4338ca; }
.login-error {
  background: #fee2e2; color: #b91c1c; padding: 8px 12px;
  border-radius: 6px; font-size: 13px; margin-bottom: 12px;
}

/* ==================== Legend ==================== */
.legend {
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
  font-size: 12px; color: #4b5563; padding: 8px 0;
}
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.swatch.s-multi-demo { width: 16px; height: 16px; border: 3px solid #1e293b; }

.empty {
  text-align: center; padding: 60px 20px;
  color: #9ca3af; font-size: 13px;
}

/* ==================== FAB: 浮动操作按钮 ==================== */
.fab-bar {
  display: flex; gap: 8px; align-items: center;
  margin-left: auto;
}
.fab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px;
  border: none; cursor: pointer; font-size: 13px; font-weight: 500;
  transition: all .15s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.fab-primary {
  background: #4f46e5; color: #fff;
}
.fab-primary:hover {
  background: #4338ca; transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(79,70,229,0.25);
}

/* ==================== Forms in Modal ==================== */
.form-field {
  display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px;
}
.form-field label {
  font-size: 12px; color: #6b7280; font-weight: 500;
}
.form-field input, .form-field select {
  width: 100%; padding: 8px 12px;
  border: 1px solid #d1d5db; border-radius: 8px;
  font-size: 14px; color: #1f2937;
  background: #fff; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.form-field input:focus, .form-field select:focus {
  border-color: #4f46e5; box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}
.form-field input::placeholder { color: #9ca3af; }
.form-grid-2 {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.form-hint {
  padding: 10px 14px; background: #f0f9ff; border-radius: 8px;
  font-size: 12px; color: #0369a1; line-height: 1.6;
  margin: 12px 0;
}

/* 班级调整区块 */
.class-change-section {
  background: #fafbfc; border-radius: 8px; padding: 14px 16px; margin-top: 12px;
}
.class-change-section select,
.class-change-section input {
  padding: 6px 10px; border: 1px solid #d1d5db; border-radius: 6px;
  font-size: 13px; outline: none;
}
.class-change-section select:focus,
.class-change-section input:focus {
  border-color: #4f46e5; box-shadow: 0 0 0 2px rgba(79,70,229,0.1);
}

/* ==================== Audit table ==================== */
table.audit {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
table.audit th, table.audit td {
  padding: 8px 10px; text-align: left; border-bottom: 1px solid #f3f4f6;
}
table.audit th { background: #fafbfc; color: #6b7280; font-weight: 500; font-size: 12px; }
.role-pill {
  display: inline-block; padding: 1px 8px; border-radius: 10px;
  font-size: 11px; color: #fff; font-weight: 500;
}
.role-admin      { background: #dc2626; }
.role-consultant { background: #4f46e5; }
.role-teacher    { background: #16a34a; }

/* ==================== Tier Pill (A/B/C/D 大徽章) ==================== */
.abcd-pill {
  display: inline-block; min-width: 22px; padding: 2px 6px;
  border-radius: 4px; color: #fff; font-weight: 700;
  font-size: 11px; text-align: center; letter-spacing: 0.5px;
}
.abcd-A { background: #ef4444; }
.abcd-B { background: #3b82f6; }
.abcd-C { background: #eab308; }
.abcd-D { background: #9ca3af; }

/* ==================== SPA route loading & transitions ==================== */
.route-loading { padding:40px; text-align:center; color:#9ca3af; }
#content { transition: opacity 0.15s ease; }
#content.fade-in { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
