:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --card-2: #fbfcff;
  --text: #1b2436;
  --muted: #6b7891;
  --line: #e4e9f2;
  --brand: #2f6bff;
  --brand-weak: #eaf1ff;
  --red: #e5484d;
  --red-weak: #fdecec;
  --orange: #f5820b;
  --orange-weak: #fff2e2;
  --yellow: #c99a00;
  --yellow-weak: #fff8dd;
  --green: #16a34a;
  --green-weak: #e8f7ee;
  --gray-weak: #eef1f6;
  --shadow: 0 1px 2px rgba(20, 32, 60, .06), 0 8px 24px rgba(20, 32, 60, .06);
  --radius: 14px;
}
html[data-theme="dark"] {
  --bg: #0f1420;
  --card: #171e2d;
  --card-2: #1b2333;
  --text: #e8edf7;
  --muted: #93a0b8;
  --line: #26304a;
  --brand: #5b8cff;
  --brand-weak: #1d2a4a;
  --red: #ff6b6f;
  --red-weak: #3a1d20;
  --orange: #ffa348;
  --orange-weak: #3a2716;
  --yellow: #f0c000;
  --yellow-weak: #383011;
  --green: #35d07f;
  --green-weak: #14301f;
  --gray-weak: #232c40;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 "Microsoft YaHei UI", "Microsoft YaHei", -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 700; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 20px;
  padding: 12px 22px;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.logo { font-size: 28px; }
.brand h1 { font-size: 18px; letter-spacing: .5px; }
.sub { margin: 0; font-size: 12px; color: var(--muted); }
.topnav { display: flex; gap: 6px; flex: 1; }
.topnav a {
  padding: 8px 14px; border-radius: 10px; color: var(--muted); font-weight: 600; font-size: 14px;
  transition: .15s;
}
.topnav a:hover { background: var(--gray-weak); color: var(--text); }
.topnav a.active { background: var(--brand-weak); color: var(--brand); }
.topActions { display: flex; gap: 8px; }

.btn {
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  padding: 8px 14px; border-radius: 10px; cursor: pointer; font-size: 13.5px; font-weight: 600;
  transition: .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, var(--line)); }
.btn.danger:hover { background: var(--red-weak); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

main { padding: 20px 22px 60px; max-width: 1500px; margin: 0 auto; }

/* ---------- 卡片 ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); cursor: pointer; transition: .18s; position: relative; overflow: hidden;
}
.card:hover { transform: translateY(-2px); border-color: var(--brand); }
.card .label { font-size: 13px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.card .num { font-size: 32px; font-weight: 800; line-height: 1.2; margin-top: 6px; letter-spacing: -.5px; }
.card .unit { font-size: 13px; font-weight: 600; color: var(--muted); margin-left: 4px; }
.card .foot { font-size: 12px; color: var(--muted); margin-top: 4px; }
.card.red { background: linear-gradient(180deg, var(--red-weak), var(--card)); }
.card.red .num { color: var(--red); }
.card.orange { background: linear-gradient(180deg, var(--orange-weak), var(--card)); }
.card.orange .num { color: var(--orange); }
.card.yellow { background: linear-gradient(180deg, var(--yellow-weak), var(--card)); }
.card.yellow .num { color: var(--yellow); }
.card.blue .num { color: var(--brand); }

/* ---------- 面板 ---------- */
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 18px; overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 13px 18px; border-bottom: 1px solid var(--line); background: var(--card-2);
}
.panel-head h3 { font-size: 15px; }
.panel-head .spacer { flex: 1; }
.panel-body { padding: 16px 18px; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
input[type=text], input[type=search], input[type=date], input[type=number], select, textarea {
  background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px; font-size: 13.5px; font-family: inherit; outline: none; transition: .15s;
}
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-weak); }
input::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.search { min-width: 240px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  padding: 6px 13px; border-radius: 999px; cursor: pointer; font-size: 13px; font-weight: 600; transition: .15s;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- 表格 ---------- */
.table-wrap { overflow: auto; max-height: 70vh; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  position: sticky; top: 0; z-index: 2; background: var(--card-2); text-align: left;
  padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--muted); font-weight: 700;
  white-space: nowrap; font-size: 12.5px;
}
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: color-mix(in srgb, var(--brand-weak) 45%, transparent); }
tbody tr.selected { background: var(--brand-weak); }
td.qq { font-family: Consolas, "Courier New", monospace; font-weight: 700; }
td.name { font-weight: 600; }
td.actions { white-space: nowrap; text-align: right; }
.mini {
  border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer;
  border-radius: 8px; padding: 4px 9px; font-size: 12.5px; margin-left: 4px; transition: .15s;
}
.mini:hover { border-color: var(--brand); color: var(--brand); }
.mini.del:hover { border-color: var(--red); color: var(--red); background: var(--red-weak); }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap;
}
.badge.red { background: var(--red-weak); color: var(--red); }
.badge.orange { background: var(--orange-weak); color: var(--orange); }
.badge.yellow { background: var(--yellow-weak); color: var(--yellow); }
.badge.green { background: var(--green-weak); color: var(--green); }
.badge.gray { background: var(--gray-weak); color: var(--muted); }
.days { font-weight: 800; font-size: 14px; }
.days.red { color: var(--red); }
.days.orange { color: var(--orange); }
.days.yellow { color: var(--yellow); }
.days.green { color: var(--green); }
.days.gray { color: var(--muted); }
.muted { color: var(--muted); }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty .big { font-size: 42px; display: block; margin-bottom: 10px; }

/* ---------- 拖拽导入区 ---------- */
.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 26px 20px; text-align: center;
  cursor: pointer; transition: .18s; background: var(--card-2);
}
.dropzone:hover { border-color: var(--brand); background: var(--brand-weak); }
.dropzone .big { font-size: 34px; display: block; margin-bottom: 8px; }
.dropzone strong { font-size: 15px; }
.dropzone p { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); }
.dropzone.drag { border-color: var(--brand); background: var(--brand-weak); transform: scale(1.01); }

.watchbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; border-radius: 12px; background: var(--card-2); border: 1px solid var(--line); font-size: 13px;
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-weak); }
.dot.off { background: var(--muted); box-shadow: 0 0 0 4px var(--gray-weak); }
.path { font-family: Consolas, monospace; font-size: 12px; color: var(--muted); word-break: break-all; }

.eventlist { max-height: 240px; overflow: auto; font-size: 13px; }
.eventlist li { list-style: none; padding: 7px 0; border-bottom: 1px dashed var(--line); display: flex; gap: 10px; }
.eventlist li:last-child { border: 0; }
.eventlist .t { color: var(--muted); font-size: 12px; font-family: Consolas, monospace; white-space: nowrap; }
ul { margin: 0; padding: 0; }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: rgba(12, 18, 32, .5); backdrop-filter: blur(3px); padding: 20px;
}
.modal[hidden] { display: none; }
.modal-box {
  background: var(--card); border-radius: 16px; width: 100%; max-width: 560px; max-height: 90vh;
  display: flex; flex-direction: column; box-shadow: 0 24px 70px rgba(0,0,0,.35); border: 1px solid var(--line);
  animation: pop .16s ease-out;
}
.modal-box.wide { max-width: 1000px; }
@keyframes pop { from { transform: translateY(10px) scale(.99); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { flex: 1; font-size: 16px; }
.modal-body { padding: 18px 20px; overflow: auto; }
.modal-foot { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); }
.modal-foot .hint { flex: 1; font-size: 12.5px; color: var(--muted); }
.x { border: 0; background: transparent; font-size: 17px; cursor: pointer; color: var(--muted); }
.x:hover { color: var(--red); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.quick { margin-top: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hint { font-size: 12.5px; color: var(--muted); }
.err { color: var(--red); font-size: 13px; margin: 10px 0 0; }

.mapgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 14px; }
.mapitem { border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; background: var(--card-2); }
.mapitem .k { font-size: 12.5px; color: var(--muted); font-weight: 700; display: flex; justify-content: space-between; }
.mapitem select { width: 100%; margin-top: 7px; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 999px; }
.tag.high { background: var(--green-weak); color: var(--green); }
.tag.guess { background: var(--yellow-weak); color: var(--yellow); }
.issues { background: var(--yellow-weak); border: 1px solid color-mix(in srgb, var(--yellow) 30%, transparent); border-radius: 12px; padding: 10px 14px; font-size: 13px; margin-bottom: 14px; }
.issues ul { padding-left: 18px; list-style: disc; }
.issues li { margin: 3px 0; }

/* ---------- 提示条 ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--brand);
  border-radius: 12px; padding: 12px 16px; box-shadow: var(--shadow); font-size: 13.5px; max-width: 380px;
  animation: slide .18s ease-out;
}
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
.toast.warn { border-left-color: var(--orange); }
@keyframes slide { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

.selbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 18px; background: var(--brand-weak); border-bottom: 1px solid var(--line); font-size: 13px;
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; }
  .brand { min-width: auto; }
  .topnav { order: 3; width: 100%; overflow: auto; }
  .row2 { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
}
