:root {
  --bg: #f2f5fb;
  --panel: #ffffff;
  --ink: #0f172a;
  --ink-2: #344054;
  --muted: #667085;
  --line: #e4e9f2;
  --line-2: #eef2f8;
  --brand: #1d4ed8;
  --brand-2: #3b82f6;
  --brand-soft: #eaf1ff;
  --amber: #d97706;
  --amber-soft: #fff4e5;
  --green: #059669;
  --green-soft: #e8f7f1;
  --blue: #2563eb;
  --blue-soft: #e9f0ff;
  --red: #dc2626;
  --red-soft: #fdecec;
  --gray: #64748b;
  --gray-soft: #f1f4f9;
  --purple: #7c3aed;
  --purple-soft: #f2ecff;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow: 0 8px 24px rgba(16, 24, 40, .08);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Source Han Sans SC", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.boot { display: flex; align-items: center; justify-content: center; height: 100vh; color: var(--muted); }

/* ---------------- login ---------------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #f7f9ff 0%, #eef2fa 100%);
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.login-wrap::before {
  content: "";
  position: absolute;
  width: 620px; height: 620px; border-radius: 50%;
  left: -180px; top: -260px;
  background: radial-gradient(circle, rgba(59, 130, 246, .16), rgba(59, 130, 246, 0) 70%);
}
.login-wrap::after {
  content: "";
  position: absolute;
  width: 560px; height: 560px; border-radius: 50%;
  right: -160px; bottom: -240px;
  background: radial-gradient(circle, rgba(124, 58, 237, .12), rgba(124, 58, 237, 0) 70%);
}
.login-card { position: relative; z-index: 1; }

.login-card {
  width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 34px 34px 22px;
  box-shadow: 0 24px 60px rgba(16, 24, 40, .12);
  text-align: center;
}

.login-logo {
  width: 52px; height: 52px; margin: 0 auto 16px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--brand), #4f7cf7);
  color: #fff; font-size: 24px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 22px rgba(37, 99, 235, .35);
}

.login-card h1 { font-size: 19px; margin: 0 0 6px; letter-spacing: .3px; }
.login-card > p { margin: 0 0 24px; font-size: 12.5px; }
.login-card form { text-align: left; }
.login-foot { margin-top: 22px; padding-top: 14px; border-top: 1px dashed var(--line); font-size: 11.5px; color: #98a2b3; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 7px; font-weight: 600; }
.field input, .field select, .field textarea { width: 100%; }

input, select, textarea {
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #d5dced;
  border-radius: 9px;
  padding: 9px 11px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(59, 130, 246, .13); }
input::placeholder { color: #a4adc0; }
textarea { resize: vertical; min-height: 74px; line-height: 1.6; }

.form-error { color: var(--red); font-size: 12.5px; min-height: 18px; margin-top: 10px; }

/* ---------------- buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  border-radius: 9px;
  padding: 8px 14px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
}
.btn:hover { border-color: #c3cee4; background: #fafcff; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(29, 78, 216, .25); }
.btn.primary:hover { background: #1a45c0; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--gray-soft); color: var(--ink); }
.btn.danger { color: var(--red); border-color: #f3caca; background: #fff7f7; }
.btn.small { padding: 5px 9px; font-size: 12px; border-radius: 7px; }
.btn.block { width: 100%; padding: 11px; font-size: 14px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.icon-btn {
  border: 1px solid transparent; background: transparent; color: var(--muted);
  font-size: 12.5px; padding: 6px 10px; border-radius: 8px; cursor: pointer; font-family: inherit;
}
.icon-btn:hover { background: var(--gray-soft); color: var(--ink); }

/* ---------------- topbar ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 18px;
  height: 64px; padding: 0 26px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 230px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px;
  background: linear-gradient(135deg, var(--brand), #4f7cf7);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 17px; box-shadow: 0 6px 14px rgba(37, 99, 235, .3);
}
.brand-title { font-size: 14.5px; font-weight: 700; letter-spacing: .2px; }
.brand-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }

.nav { display: flex; align-items: center; gap: 4px; flex: 1; overflow-x: auto; }
.nav::-webkit-scrollbar { height: 0; }
.nav-item {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid transparent; background: transparent;
  color: var(--ink-2); font-size: 13.5px; font-family: inherit;
  padding: 8px 14px; border-radius: 9px; cursor: pointer; white-space: nowrap;
}
.nav-item:hover { background: var(--gray-soft); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.nav-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent, var(--brand)); flex: none; }
.nav-item.active .nav-dot { box-shadow: 0 0 0 3px rgba(37, 99, 235, .14); }

.top-actions { display: flex; align-items: center; gap: 4px; }
.today { font-size: 12px; color: var(--muted); margin-right: 8px; white-space: nowrap; }

/* ---------------- layout ---------------- */
.view { max-width: 1560px; margin: 0 auto; padding: 24px 26px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-title { font-size: 21px; font-weight: 700; letter-spacing: .3px; display: flex; align-items: center; gap: 10px; }
.page-desc { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- stats ---------------- */
.stat-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.stat::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--tone, var(--line)); }
.stat .label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 6px; line-height: 1.1; letter-spacing: .5px; }
.stat .foot { font-size: 11px; color: #98a2b3; margin-top: 5px; }
.stat.pending { --tone: var(--amber); } .stat.confirmed { --tone: var(--green); }
.stat.modified { --tone: var(--blue); } .stat.stale { --tone: var(--red); }
.stat.new { --tone: var(--purple); } .stat.total { --tone: var(--brand); }
.stat.gone { --tone: var(--gray); }

/* ---------------- overview cards ---------------- */
.overview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; }
.ov-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 20px 22px; box-shadow: var(--shadow-sm); cursor: pointer;
  transition: transform .16s, box-shadow .16s, border-color .16s; position: relative; overflow: hidden;
}
.ov-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: #cdd9ef; }
.ov-card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--accent); }
.ov-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.ov-name { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.ov-meta { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.ov-arrow { color: #b6c0d4; font-size: 18px; }
.ov-nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 18px 0 14px; }
.ov-num .n { font-size: 22px; font-weight: 700; }
.ov-num .t { font-size: 11px; color: var(--muted); margin-top: 2px; }
.ov-foot { display: flex; align-items: center; justify-content: space-between; border-top: 1px dashed var(--line); padding-top: 12px; font-size: 12px; color: var(--muted); }

.spark { display: flex; align-items: flex-end; gap: 3px; height: 26px; }
.spark i { width: 7px; background: var(--accent); opacity: .25; border-radius: 2px 2px 0 0; display: block; }
.spark i:last-child { opacity: .95; }

/* ---------------- panel ---------------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.panel-head { padding: 14px 18px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.panel-title { font-weight: 700; font-size: 14px; }

/* ---------------- filters ---------------- */
.filterbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 12px 14px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 14px; box-shadow: var(--shadow-sm);
}
.filterbar .search { position: relative; }
.filterbar .search input { width: 250px; padding-left: 32px; }
.filterbar .search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: #98a2b3; }
.filterbar select { width: auto; min-width: 104px; padding-right: 26px; }
.filterbar .rule-input { width: 96px; }
.filterbar .spacer { flex: 1; }
.seg { display: inline-flex; background: var(--gray-soft); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: transparent; font-family: inherit; font-size: 12.5px; color: var(--muted);
  padding: 6px 12px; border-radius: 7px; cursor: pointer; white-space: nowrap;
}
.seg button.active { background: #fff; color: var(--ink); font-weight: 700; box-shadow: var(--shadow-sm); }
.filter-note {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #eef4ff; border: 1px solid #d7e3fb; color: var(--brand);
  padding: 8px 12px; border-radius: 10px; margin: -2px 0 12px; font-size: 12.5px;
}
.filter-note b { color: var(--ink); }

/* ---------------- table ---------------- */
.table-wrap { overflow: auto; max-height: calc(100vh - 392px); min-height: 280px; border-radius: 0 0 var(--radius) var(--radius); }
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.8px; }
table.grid th {
  position: sticky; top: 0; z-index: 2; text-align: left; font-weight: 600; color: var(--muted);
  background: #f7f9fd; border-bottom: 1px solid var(--line); padding: 10px 12px; white-space: nowrap; font-size: 12px;
}
table.grid td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
table.grid tbody tr { cursor: pointer; }
table.grid tbody tr:hover td { background: #f8fbff; }
table.grid tr.selected td { background: var(--brand-soft); }
.cell-school { font-weight: 600; color: var(--ink); max-width: 190px; }
.cell-desc { max-width: 430px; color: var(--ink-2); line-height: 1.55; }
.cell-value { max-width: 300px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.cell-mono { font-family: "Cascadia Mono", Consolas, monospace; font-size: 11.5px; color: var(--muted); }
.nowrap { white-space: nowrap; }
.empty-row td { text-align: center; color: var(--muted); padding: 40px 0 !important; cursor: default; }

/* ---------------- badges ---------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 700; white-space: nowrap; line-height: 1.5;
}
.badge i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: block; }
.badge.pending { color: var(--amber); background: var(--amber-soft); }
.badge.confirmed { color: var(--green); background: var(--green-soft); }
.badge.modified { color: var(--blue); background: var(--blue-soft); }
.badge.stale { color: var(--red); background: var(--red-soft); }
.badge.chase { color: #b42318; background: #fee4e2; }
.badge.review { color: var(--brand); background: var(--brand-soft); }
.chan { font-size: 12px; color: var(--muted); }
.chan.manual { color: var(--amber); font-weight: 700; }
.badge.gone { color: var(--gray); background: var(--gray-soft); }
.badge.new { color: var(--purple); background: var(--purple-soft); }
.badge.soft { color: var(--muted); background: var(--gray-soft); font-weight: 600; }
.badge.plain { color: var(--ink-2); background: #f6f8fc; font-weight: 600; }
.tag-new { font-size: 10.5px; color: var(--purple); background: var(--purple-soft); border-radius: 5px; padding: 1px 5px; margin-left: 4px; font-weight: 700; white-space: nowrap; display: inline-block; vertical-align: 1px; }

/* ---------------- pagination ---------------- */
.pager { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--line-2); font-size: 12.5px; color: var(--muted); flex-wrap: wrap; gap: 10px; }
.pager .pages { display: flex; gap: 5px; align-items: center; }
.pager button { min-width: 30px; height: 30px; border-radius: 7px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-family: inherit; font-size: 12.5px; color: var(--ink-2); }
.pager button:hover { border-color: #c3cee4; }
.pager button.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager button:disabled { opacity: .45; cursor: not-allowed; }

/* ---------------- drawer ---------------- */
.drawer-mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .34); z-index: 60; animation: fade .16s ease; }
.drawer {
  position: fixed; right: 0; top: 0; bottom: 0; width: 520px; max-width: 94vw; background: #fff;
  z-index: 61; box-shadow: -16px 0 40px rgba(15, 23, 42, .18); display: flex; flex-direction: column;
  animation: slidein .2s cubic-bezier(.2, .8, .3, 1);
}
@keyframes slidein { from { transform: translateX(30px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.drawer-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.drawer-body { padding: 18px 22px; overflow-y: auto; flex: 1; }
.drawer-foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; background: #fbfcfe; }
.detail-grid { display: grid; grid-template-columns: 92px 1fr; gap: 10px 14px; font-size: 13px; }
.detail-grid dt { color: var(--muted); font-size: 12px; padding-top: 1px; }
.detail-grid dd { margin: 0; color: var(--ink); line-height: 1.65; word-break: break-word; }
.detail-block { background: #f8faff; border: 1px solid var(--line-2); border-radius: 10px; padding: 12px 14px; margin-top: 16px; }
.detail-block h4 { margin: 0 0 8px; font-size: 12px; color: var(--muted); font-weight: 600; }
.detail-desc { font-size: 13px; line-height: 1.7; }
.status-picker { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.status-opt {
  border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 8px 14px;
  cursor: pointer; font-family: inherit; font-size: 12.5px; color: var(--ink-2); display: flex; align-items: center; gap: 6px;
}
.status-opt:hover { border-color: #b9c8e6; }
.status-opt.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.status-opt i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---------------- modal ---------------- */
.modal-mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .38); z-index: 70; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 18px; overflow-y: auto; animation: fade .14s ease; }
.modal { background: #fff; width: 600px; max-width: 100%; border-radius: 16px; box-shadow: 0 30px 70px rgba(15, 23, 42, .3); animation: pop .18s ease; }
@keyframes pop { from { transform: translateY(8px) scale(.99); opacity: .7; } to { transform: none; opacity: 1; } }
.modal-head { padding: 18px 22px 14px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--line-2); display: flex; justify-content: flex-end; gap: 8px; background: #fbfcfe; border-radius: 0 0 16px 16px; }
.x-btn { border: 0; background: transparent; font-size: 20px; line-height: 1; color: #98a2b3; cursor: pointer; padding: 4px 6px; border-radius: 7px; }
.x-btn:hover { background: var(--gray-soft); color: var(--ink); }

/* ---------------- dropzone ---------------- */
.drop {
  border: 2px dashed #cdd8ec; border-radius: 12px; padding: 26px; text-align: center; color: var(--muted);
  background: #fafcff; cursor: pointer; transition: all .15s;
}
.drop:hover, .drop.over { border-color: var(--brand-2); background: var(--brand-soft); color: var(--brand); }
.drop strong { color: var(--ink); }
.drop .hint { font-size: 11.5px; margin-top: 6px; color: #98a2b3; }
.file-chip { display: flex; align-items: center; gap: 8px; background: var(--gray-soft); border-radius: 8px; padding: 8px 11px; font-size: 12.5px; margin-top: 10px; }

/* ---------------- toast ---------------- */
.toast-root { position: fixed; right: 22px; bottom: 22px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #101828; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow); animation: pop .18s ease; max-width: 420px; }
.toast.ok { background: #05603a; }
.toast.err { background: #912018; }
.toast.info { background: #101828; }

/* ---------------- empty ---------------- */
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 10px; opacity: .5; }
.empty h3 { color: var(--ink); margin: 0 0 6px; font-size: 16px; }

/* ---------------- settings ---------------- */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.form-row { display: grid; grid-template-columns: 120px 1fr; align-items: center; gap: 10px; margin-bottom: 12px; }
.form-row > label { font-size: 12.5px; color: var(--ink-2); }
.source-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.source-item:last-child { border-bottom: 0; }
.color-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.kv { display: flex; justify-content: space-between; font-size: 12.5px; padding: 7px 0; border-bottom: 1px dashed var(--line-2); }
.kv:last-child { border-bottom: 0; }

/* ---------------- school table ---------------- */
.open-num { font-weight: 700; }
.open-num.zero { color: var(--green); }
.open-num.hot { color: var(--red); }

/* ---------------- misc ---------------- */
.hint-line { font-size: 12px; color: var(--muted); line-height: 1.6; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.check input { width: 15px; height: 15px; accent-color: var(--brand); }
.result-box { background: #f8faff; border: 1px solid var(--line-2); border-radius: 10px; padding: 14px 16px; margin-top: 14px; font-size: 13px; }
.result-box .big { font-size: 22px; font-weight: 700; }
.result-ok { color: var(--green); } .result-warn { color: var(--amber); } .result-err { color: var(--red); }

@media (max-width: 1280px) {
  .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .topbar { padding: 0 14px; gap: 10px; }
  .brand-text { display: none; }
  .brand { min-width: auto; }
  .view { padding: 16px 14px 50px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filterbar .search input { width: 180px; }
  .settings-grid { grid-template-columns: 1fr; }
}
