:root {
  --bg: #0f1419;
  --card: #172029;
  --line: #2a3a4c;
  --text: #e8eef5;
  --muted: #93a4b8;
  --accent: #2f6fed;
  --ok: #1f9d55;
  --warn: #c98512;
  --bad: #d64545;
  --radius: 12px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: radial-gradient(1200px 600px at 10% -10%, #1b2a40 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
}
body.access-locked > :not(#accessGate) { visibility: hidden; }
.access-gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 12, 18, 0.92);
  backdrop-filter: blur(6px);
  padding: 24px;
}
.access-gate[hidden] { display: none !important; }
.access-card {
  width: min(380px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px 20px 18px;
  box-shadow: 0 16px 48px rgba(0,0,0,.35);
}
.access-card h2 { margin: 0 0 8px; font-size: 20px; }
.access-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 14px 0 16px;
  font-size: 13px;
  color: var(--muted);
}
.access-card input {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0f1720;
  color: var(--text);
  font-size: 15px;
}
.access-err {
  margin: 10px 0 0;
  color: #f0a0a0;
  font-size: 13px;
}
.top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 20px 24px 8px;
}
.top h1 { margin: 0 0 6px; font-size: 22px; font-weight: 650; }
.sub { margin: 0; color: var(--muted); font-size: 13px; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.account-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #223145;
}
.account-btn.is-ok {
  background: color-mix(in srgb, var(--ok) 35%, #223145);
  border-color: transparent;
}
.account-btn.is-bad {
  background: color-mix(in srgb, var(--bad) 40%, #223145);
  border-color: transparent;
}
.account-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #93a4b8;
  display: inline-block;
}
.account-btn.is-ok .account-dot { background: #8de0b0; }
.account-btn.is-bad .account-dot { background: #f0a0a0; }

.login-float {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #15202c;
  color: var(--text);
  padding: 0;
  width: min(420px, 92vw);
  box-shadow: 0 20px 50px rgba(0,0,0,.45);
}
.login-float::backdrop { background: rgba(0,0,0,.55); }
.login-float-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.login-float-head h3 { margin: 0; font-size: 16px; }
.login-float .status-line,
.login-float .session-panel,
.login-float #loginForm,
.login-float #loginLog {
  margin-left: 16px;
  margin-right: 16px;
}
.login-float .status-line { margin-top: 14px; }
.login-float #loginForm { margin-top: 8px; margin-bottom: 12px; }
.login-float #loginLog { margin-bottom: 16px; max-height: 120px; }

.tabs {
  display: flex;
  gap: 6px;
  padding: 4px 24px 0;
  border-bottom: 1px solid var(--line);
}
.tab {
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  color: var(--muted);
  padding: 10px 16px;
  border-radius: 10px 10px 0 0;
  cursor: pointer;
  font-size: 14px;
}
.tab:hover { color: var(--text); background: #1a2431; }
.tab.active {
  color: var(--text);
  background: var(--card);
  border-color: var(--line);
  font-weight: 600;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 16px 24px 32px;
}
.grid.single { grid-template-columns: minmax(280px, 560px); }

/* 检索栏：统一栅格，字段等宽对齐 */
.filter-panel {
  margin: 0 0 12px;
  padding: 14px 14px 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #121a24;
}
.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px 14px;
  margin-bottom: 8px;
}
.filter-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.filter-grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.inline-search {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.inline-search input { flex: 1; min-width: 0; }
.unmapped-box {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #121a24;
}
.unmapped-box h3 {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 600;
}
.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  border: 1px solid var(--line);
  background: #1a2736;
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: #cfe0ff; }
.chip small { color: var(--muted); margin-left: 4px; }
.map-pick-list { max-height: 320px; }
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}
.field-label {
  line-height: 1.2;
  white-space: nowrap;
}
.field-span-2 { grid-column: span 2; }
.field input,
.field select {
  width: 100%;
  min-width: 0;
  background: #0d131a;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 14px;
}
.field input[type="date"] { color-scheme: dark; }
.field select,
#uploadHistorySelect {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #93a4b8 50%),
    linear-gradient(135deg, #93a4b8 50%, transparent 50%);
  background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 28px;
}
.history-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}
.history-select {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  min-width: 0;
}
#uploadHistorySelect {
  width: 100%;
  background: #0d131a;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 28px 9px 11px;
  font-size: 14px;
}
.btn.danger {
  background: color-mix(in srgb, var(--bad) 55%, #223145);
  border-color: transparent;
  white-space: nowrap;
  height: 38px;
}
@media (max-width: 640px) {
  .history-bar { grid-template-columns: 1fr; }
  .btn.danger { width: 100%; }
}

.pager { margin-top: 12px; }
.session-panel { margin-top: 8px; }
.session-meta {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #101821;
  border: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.6;
  color: #b7c6d8;
}
#loginForm[hidden], #sessionPanel[hidden] { display: none !important; }
.detail {
  max-height: 60vh;
  overflow: auto;
  background: #0c1117;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  font-size: 12px;
  white-space: pre-wrap;
}
.card {
  background: color-mix(in srgb, var(--card) 92%, #000);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px 18px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.card.wide { grid-column: 1 / -1; }
.card h2 { margin: 0 0 8px; font-size: 16px; }
.card-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.hint { margin: 0 0 12px; color: var(--muted); font-size: 12px; line-height: 1.5; }

.form { display: flex; flex-direction: column; gap: 10px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.form input[type="text"],
.form input[type="password"],
.form input:not([type]),
.pick-list input,
dialog input {
  background: #0d131a;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 14px;
}
.captcha-box { display: flex; gap: 10px; align-items: center; }
.captcha-box img {
  height: 38px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: #fff;
}
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chk { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; }

.btn {
  border: 1px solid var(--line);
  background: #223145;
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
}
.btn:hover { filter: brightness(1.08); }
.btn.primary { background: var(--accent); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.status-line {
  margin-bottom: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #101821;
  border: 1px solid var(--line);
  font-size: 13px;
}
.status-line.ok { border-color: color-mix(in srgb, var(--ok) 50%, var(--line)); color: #8de0b0; }
.status-line.bad { border-color: color-mix(in srgb, var(--bad) 50%, var(--line)); color: #f0a0a0; }

.meta { margin-top: 10px; color: var(--muted); font-size: 13px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { background: #121a24; color: var(--muted); font-weight: 600; position: sticky; top: 0; }
tr:hover td { background: #1a2431; }
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: #243246;
}
.tag.warn { background: color-mix(in srgb, var(--warn) 30%, #243246); }
.tag.ok { background: color-mix(in srgb, var(--ok) 30%, #243246); }
.tag.bad { background: color-mix(in srgb, var(--bad) 30%, #243246); }

.col-expand { width: 36px; text-align: center; }
.expand-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 6px;
}
.expand-btn:hover { background: #243246; color: var(--text); }
.group-row { cursor: pointer; }
.group-row.is-open > td { background: #1a2736; }
.group-detail-row > td {
  padding: 0;
  background: #0c1117;
  border-bottom: 1px solid var(--line);
  white-space: normal;
}
.detail-panel { padding: 12px 14px 14px; }
.detail-title {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}
.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  background: #121a24;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.detail-table th,
.detail-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.detail-table th {
  background: #182230;
  color: var(--muted);
  position: static;
}
.detail-table tr:hover td { background: #1a2431; }

.log {
  margin: 12px 0 0;
  max-height: 180px;
  overflow: auto;
  background: #0c1117;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font-size: 12px;
  color: #b7c6d8;
  white-space: pre-wrap;
}

dialog {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #15202c;
  color: var(--text);
  padding: 16px;
  width: min(520px, 92vw);
}
dialog::backdrop { background: rgba(0,0,0,.55); }
.pick-list { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 12px; max-height: 240px; overflow: auto; }
.pick-list label {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 8px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
}
.pick-list label:hover { background: #1a2736; }

@media (max-width: 1100px) {
  .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-grid-2 { grid-template-columns: 1fr; }
  .field-span-2 { grid-column: span 2; }
}
@media (max-width: 960px) {
  .grid { grid-template-columns: 1fr; padding: 12px; }
  .top { padding: 16px 12px 4px; flex-direction: column; }
  .tabs { padding-left: 12px; padding-right: 12px; overflow-x: auto; }
}
@media (max-width: 640px) {
  .filter-grid,
  .filter-grid-2,
  .filter-grid-3 { grid-template-columns: 1fr; }
  .field-span-2 { grid-column: span 1; }
  .card-head { align-items: flex-start; }
}
