:root {
  --bg: #f4f7fc;
  --surface: #ffffff;
  --line: #d9e3f2;
  --line-strong: #c5d4ea;
  --text: #12243d;
  --muted: #5b6f8c;
  --primary: #1b6ef3;
  --primary-hover: #1557c7;
  --primary-soft: #e8f1fe;
  --ok: #0f9f6e;
  --ok-soft: #e7f8f1;
  --warn: #c47d0b;
  --warn-soft: #fff6e5;
  --bad: #d12c4a;
  --bad-soft: #fdecef;
  --shadow: 0 10px 30px rgba(18, 52, 102, 0.08);
  --radius: 14px;
  --font: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { color-scheme: light only; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text) !important;
  background: var(--bg) !important;
  font-size: 14px;
  line-height: 1.5;
}
::selection { background: #cfe0ff; color: var(--text); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--bad); min-height: 1.2em; font-size: 13px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 10px; }

/* Login */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 420px at 12% -10%, #d6e6ff 0%, transparent 60%),
    radial-gradient(700px 380px at 100% 0%, #eaf1ff 0%, transparent 55%),
    var(--bg);
}
.login-card {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
}
.brand-logo {
  display: block;
  width: 72px;
  height: 72px;
  object-fit: contain;
  border-radius: 16px;
  background: #0a0a0a;
  margin-bottom: 16px;
  box-shadow: 0 8px 18px rgba(18, 52, 102, 0.16);
}
.brand-logo-sm {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 10px;
  background: #0a0a0a;
  flex: 0 0 auto;
}
.brand-mark {
  display: none;
}
.brand-dot { display: none; }
.sidebar-brand strong {
  display: block;
  font-size: 13px;
  line-height: 1.35;
  max-width: 150px;
}
.login-card h1 { margin: 0; font-size: 24px; letter-spacing: -0.02em; }
.login-sub { margin: 4px 0 22px; color: var(--muted); }
.login-card label,
.panel.narrow label {
  display: block;
  margin: 12px 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}
input, select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:hover, select:hover { border-color: #9db6d8; }
input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27, 110, 243, 0.15);
  outline: none;
}

.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
  padding: 9px 14px;
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}
.btn:hover { background: #f7faff; border-color: #9db6d8; }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); border-color: #f0b7c2; background: var(--bad-soft); }
.btn.block { width: 100%; margin-top: 16px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* Shell */
.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 8px 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}
.sidebar-brand strong { display: block; font-size: 15px; }
.sidebar-brand small { color: var(--muted); font-size: 12px; }
.brand-dot {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(145deg, #3b86ff, #1b6ef3);
  flex: 0 0 auto;
}
.side-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 11px 12px;
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.nav-item:hover { background: var(--primary-soft); color: var(--primary); }
.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  box-shadow: inset 3px 0 0 var(--primary);
}
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.admin-chip {
  padding: 8px 10px;
  margin-bottom: 8px;
  border-radius: 10px;
  background: var(--bg);
  color: var(--muted);
  font-size: 13px;
}

.main { padding: 22px 28px 40px; min-width: 0; }
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}
.page-head h2 { margin: 0; font-size: 22px; letter-spacing: -0.02em; }
.page-head .muted { margin: 4px 0 0; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 1px 0 rgba(18, 52, 102, 0.02);
}
.kpi .label { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.kpi .value { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.kpi .foot { margin-top: 6px; font-size: 12px; color: var(--muted); }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 1px 0 rgba(18, 52, 102, 0.02);
}
.panel.narrow { max-width: 460px; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.panel-head h3 { margin: 0; font-size: 16px; }
.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters input, .filters select { width: auto; min-width: 160px; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.table-wrap { overflow: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
th, td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  vertical-align: middle;
}
th { color: var(--muted); font-weight: 600; background: #fafcff; position: sticky; top: 0; }
tr:hover td { background: #f8fbff; }
code, .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  background: var(--bg);
  padding: 3px 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.muted { background: #eef2f7; color: var(--muted); }
.ops { display: flex; gap: 6px; flex-wrap: wrap; }
.ops .btn { padding: 6px 10px; font-size: 12px; }

.pager {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}
.empty {
  margin: 18px 0 6px;
  color: var(--muted);
  text-align: center;
  padding: 24px;
}
.result {
  margin-top: 12px;
  padding: 12px;
  background: #0f2744;
  color: #e8f0ff;
  border-radius: 10px;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  max-height: 180px;
  overflow: auto;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 39, 68, 0.42);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
}
.modal-card {
  width: min(440px, 100%);
  background: #fff;
  border-radius: 16px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 18px;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.modal-head h3 { margin: 0; font-size: 17px; }
.icon-btn {
  border: 0;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
.modal label {
  display: block;
  margin: 10px 0 6px;
  color: var(--muted);
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #12243d;
  color: #fff;
  padding: 12px 16px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 60;
  max-width: min(360px, calc(100vw - 32px));
}

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .side-nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { display: flex; gap: 8px; align-items: center; }
  .sidebar-foot .btn { margin-top: 0; width: auto; }
  .main { padding: 16px; }
}
