:root {
  color-scheme: light dark;
  --bg: #f4f7fb;
  --bg-soft: #e8eef7;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --line: #d9e2ef;
  --text: #172033;
  --muted: #65748b;
  --accent: #2563eb;
  --accent-2: #0f9f8f;
  --danger: #dc2626;
  --warn: #b7791f;
  --ok: #0f9f5f;
  --shadow: rgba(15,23,42,.08);
  --sidebar: rgba(255,255,255,.88);
  --nav-hover: rgba(37,99,235,.11);
  --input-bg: #ffffff;
  --soft-fill: rgba(15,23,42,.04);
  --soft-line: rgba(15,23,42,.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --bg-soft: #15223a;
    --panel: #111b2e;
    --panel-2: #162238;
    --line: #24324d;
    --text: #e7eefc;
    --muted: #8fa2c2;
    --accent: #2f81f7;
    --accent-2: #14b8a6;
    --danger: #e35d6a;
    --warn: #f0b429;
    --ok: #12b76a;
    --shadow: rgba(0,0,0,.18);
    --sidebar: rgba(11,18,32,.82);
    --nav-hover: rgba(47,129,247,.16);
    --input-bg: #0f182a;
    --soft-fill: rgba(255,255,255,.04);
    --soft-line: rgba(255,255,255,.08);
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"PingFang SC","Microsoft YaHei",sans-serif;
  background: radial-gradient(circle at top left, var(--bg-soft), var(--bg) 55%);
  color: var(--text);
}
a { color: inherit; text-decoration: none; }
.shell { min-height: 100vh; display: flex; }
.sidebar {
  width: 260px;
  background: var(--sidebar);
  border-right: 1px solid var(--soft-line);
  padding: 22px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { font-size: 20px; font-weight: 700; margin-bottom: 18px; }
.nav a {
  display: block;
  padding: 11px 12px;
  border-radius: 10px;
  color: var(--muted);
  margin-bottom: 6px;
}
.nav a.active, .nav a:hover {
  background: var(--nav-hover);
  color: var(--text);
}
.content { flex: 1; padding: 24px; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 22px;
}
.title { font-size: 26px; font-weight: 700; }
.subtitle { color: var(--muted); margin-top: 4px; font-size: 13px; }
.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0,1fr));
  gap: 16px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 16px 48px var(--shadow);
}
.kpi { grid-column: span 3; }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font-size: 28px; font-weight: 700; margin-top: 8px; }
.kpi .hint { color: var(--muted); font-size: 12px; margin-top: 6px; }
.table-wrap { overflow: auto; }
.table-scroll {
  max-height: min(620px, calc(100vh - 330px));
  overflow: auto;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
}
.table-scroll .table-wrap { overflow: visible; }
.table-scroll th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel);
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--soft-line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; letter-spacing: 0; }
td { font-size: 14px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 9px; border-radius: 999px; font-size: 12px;
  background: var(--soft-fill); color: var(--text);
}
.badge.ok { background: rgba(18,183,106,.16); color: #7de5b4; }
.badge.warn { background: rgba(240,180,41,.16); color: #ffd36c; }
.badge.danger { background: rgba(227,93,106,.16); color: #ff9aa4; }
.btn, button {
  border: 0; border-radius: 8px; padding: 10px 14px;
  background: var(--accent); color: white; cursor: pointer; font-weight: 600;
}
.btn.secondary { background: var(--soft-fill); color: var(--text); }
.btn.danger { background: var(--danger); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.field label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--soft-line); border-radius: 8px;
  background: var(--input-bg); color: var(--text); padding: 10px 12px; outline: none;
}
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: var(--soft-fill);
  color: var(--text);
}
.check-item input { width: auto; }
.check-item span { word-break: break-all; }
.security-field label { color: var(--text); font-weight: 700; }
.security-help { color: var(--muted); font-size: 12px; line-height: 1.5; margin: -2px 0 8px; min-height: 36px; }
.security-unit { font-size: 12px; margin-top: 6px; }
.field textarea { min-height: 180px; resize: vertical; font-family: Consolas,monospace; }
.stack { display: grid; gap: 14px; }
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.login-card { width: min(480px, 100%); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-bar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(140px, 180px) minmax(160px, 220px) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}
.filter-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.page-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  background: var(--soft-fill);
}
.page-link.active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}
.page-link.disabled {
  opacity: .45;
  cursor: not-allowed;
}
.page-info { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
.section-title { font-size: 18px; font-weight: 700; margin-bottom: 12px; }
.pill-row { display: flex; gap: 8px; flex-wrap: wrap; }
.code { font-family: Consolas,monospace; word-break: break-all; }
.toast-wrap {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 9999;
  pointer-events: none;
}
.toast {
  min-width: 260px;
  max-width: 420px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--text);
  background: color-mix(in srgb, var(--panel) 92%, var(--ok));
  box-shadow: 0 18px 48px var(--shadow);
  animation: toast-in .18s ease-out;
}
.toast.success { border-color: rgba(18,183,106,.45); }
.toast.error, .toast.danger { border-color: rgba(227,93,106,.5); background: color-mix(in srgb, var(--panel) 90%, var(--danger)); }
.toast.warn { border-color: rgba(240,180,41,.5); background: color-mix(in srgb, var(--panel) 90%, var(--warn)); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.detail-list {
  display: grid;
  gap: 12px;
}
.detail-list > div {
  padding: 10px 12px;
  background: var(--soft-fill);
  border: 1px solid var(--soft-line);
  border-radius: 8px;
}
.detail-list .muted {
  display: block;
  font-size: 12px;
  margin-bottom: 4px;
}
@media (max-width: 1100px) {
  .kpi { grid-column: span 6; }
  .sidebar { width: 220px; }
}
@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar { position: relative; width: 100%; height: auto; }
  .content { padding: 16px; }
  .kpi { grid-column: span 12; }
  .form-grid { grid-template-columns: 1fr; }
  .filter-bar { grid-template-columns: 1fr; }
}
