:root {
  --cobalt: #3759ff;
  --cobalt-ink: #1e36c9;
  --cobalt-soft: #e8edff;
  --cobalt-mid: #c9d4ff;
  --ink: #13231d;
  --ink-2: #2a3d36;
  --muted: #5d6f68;
  --paper: #f3f0e8;
  --paper-2: #eae6db;
  --lime: #d8ff49;
  --white: #ffffff;
  --line: rgba(19, 35, 29, 0.12);
  --line-strong: rgba(19, 35, 29, 0.22);
  --ok: #0f7a4a;
  --ok-bg: #e6f6ee;
  --warn: #9a5b00;
  --warn-bg: #fff3d6;
  --bad: #b42318;
  --bad-bg: #fdecea;
  --pending: #3d4a8c;
  --pending-bg: #eef0fb;
  --zero: #4a5560;
  --zero-bg: #eef0f2;
  --shadow: 0 1px 2px rgba(19, 35, 29, 0.06), 0 8px 24px rgba(19, 35, 29, 0.05);
  --sidebar-w: 248px;
  --header-h: 58px;
  --sans: "IBM Plex Sans", "Noto Sans SC", "PingFang SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { color-scheme: light; }
body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--cobalt); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: "IBM Plex Mono", "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace; }

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--white);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--line);
}
.brand img { width: 132px; height: auto; display: block; }
.brand-text { display: none; }
.brand-sub {
  padding: 0 16px 14px;
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding-top: 8px;
}

.nav-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 16px 16px 6px;
  font-weight: 600;
}

.nav a, .nav button.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  width: calc(100% - 16px);
  margin: 1px 8px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ink-2);
  background: none;
  border: 0;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  font-weight: 500;
}
.nav a:hover, .nav button.nav-link:hover { background: var(--paper); text-decoration: none; }
.nav a.active, .nav button.nav-link.active {
  background: var(--cobalt-soft);
  color: var(--cobalt-ink);
  font-weight: 600;
}

.sys-list { padding-bottom: 24px; }
.sys-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: calc(100% - 16px);
  margin: 1px 8px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  border: 0;
  background: none;
  cursor: pointer;
  text-align: left;
}
.sys-item:hover { background: var(--paper); text-decoration: none; }
.sys-item.disabled { opacity: 0.45; cursor: default; }
.sys-item .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--cobalt);
  margin-top: 7px;
  flex-shrink: 0;
}
.sys-item.disabled .dot { background: #bbb; }
.sys-item .nm { display: block; font-weight: 600; font-size: 13px; line-height: 1.3; }
.sys-item .sub { display: block; font-size: 11px; color: var(--muted); line-height: 1.3; margin-top: 1px; }
.sys-item .ext { margin-left: auto; color: var(--muted); font-size: 12px; padding-top: 2px; }

.main { min-width: 0; }
.topbar {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 20;
  gap: 16px;
}
.crumb { color: var(--muted); font-size: 13px; }
.crumb b { color: var(--ink); font-weight: 600; }
.top-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

select.ctl, input.ctl, button.btn {
  height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--white);
  padding: 0 10px;
}
select.ctl:focus, input.ctl:focus, textarea:focus {
  outline: 2px solid var(--cobalt-mid);
  border-color: var(--cobalt);
}
.btn { cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { background: var(--paper); }
.btn-primary { background: var(--cobalt); color: #fff; border-color: var(--cobalt); }
.btn-primary:hover { background: var(--cobalt-ink); }
.btn-lime { background: var(--lime); color: var(--ink); border-color: #b9dc2e; }
.btn-lime:hover { filter: brightness(0.97); }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--bad-bg); color: var(--bad); border-color: #f3c0bb; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--paper-2);
  color: var(--ink-2);
  white-space: nowrap;
}
.badge.demo { background: var(--lime); color: var(--ink); }
.badge.user { background: var(--cobalt-soft); color: var(--cobalt-ink); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.pending { background: var(--pending-bg); color: var(--pending); }
.badge.zero { background: var(--zero-bg); color: var(--zero); }
.badge.muted { background: var(--paper); color: var(--muted); border: 1px solid var(--line); }

.content { padding: 22px 24px 80px; max-width: 1280px; }

.page-h {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.page-h h1 { font-size: 22px; line-height: 1.25; margin: 0 0 4px; letter-spacing: -0.02em; }
.page-h p { margin: 0; color: var(--muted); max-width: 720px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.card.clickable { cursor: pointer; }
.card.clickable:hover { border-color: var(--cobalt-mid); }
.card .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.card .v { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; margin-top: 4px; line-height: 1.1; }
.card .s { font-size: 12px; color: var(--muted); margin-top: 6px; }

.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}
.panel-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.panel-h h2, .panel-h h3 { margin: 0; font-size: 14px; font-weight: 650; }
.panel-b { padding: 16px; }
.panel-b.tight { padding: 0; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data th, table.data td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.data th {
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 650;
  background: #faf9f5;
  position: sticky;
  top: 0;
}
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: #fbfaf6; }
table.data tbody tr.clickable { cursor: pointer; }
table.data .muted { color: var(--muted); }
table.data .err { color: var(--bad); }
.table-wrap { overflow: auto; max-height: min(64vh, 720px); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

.ds-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.ds-card { padding: 14px 16px; }
.ds-card h3 { margin: 0 0 2px; font-size: 15px; }
.ds-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin: 10px 0 12px; font-size: 12px; color: var(--muted); }
.ds-meta b { color: var(--ink); font-weight: 600; display: block; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field.span-2 { grid-column: span 2; }
.field label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.field input, .field select, .field textarea {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
}
.field textarea { min-height: 88px; resize: vertical; }

.drop {
  border: 1.5px dashed var(--line-strong);
  border-radius: 12px;
  padding: 22px;
  text-align: center;
  background: #fcfbf8;
  color: var(--muted);
}
.drop.drag { border-color: var(--cobalt); background: var(--cobalt-soft); color: var(--cobalt-ink); }

.notice {
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 12px;
}
.notice.info { background: var(--cobalt-soft); color: var(--cobalt-ink); }
.notice.ok { background: var(--ok-bg); color: var(--ok); }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
.notice.bad { background: var(--bad-bg); color: var(--bad); }

pre.code {
  background: #111a17;
  color: #e7f0ea;
  border-radius: 10px;
  padding: 14px 16px;
  overflow: auto;
  font-size: 12px;
  line-height: 1.55;
  margin: 0;
}
.kb h2 { font-size: 18px; margin: 28px 0 8px; }
.kb h3 { font-size: 15px; margin: 20px 0 6px; }
.kb p { color: var(--ink-2); }
.kb ul, .kb ol { color: var(--ink-2); padding-left: 1.2em; }
.kb li { margin: 4px 0; }
.kb .lead { font-size: 15px; color: var(--ink-2); }

.split { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 16px; }

.lookup {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.lookup input { min-width: 220px; }

.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 13px; }
.kv .k { color: var(--muted); }

.toast-wrap {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 50;
}
.toast {
  background: var(--ink);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  min-width: 240px;
  max-width: 420px;
  font-size: 13px;
}

.module-entry {
  display: grid;
  grid-template-columns: 40px 1.1fr 1.4fr 72px 88px 28px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 1100px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .ds-grid, .grid-2, .split, .form-grid { grid-template-columns: 1fr; }
  .field.span-2 { grid-column: span 1; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand-sub { border-bottom: 0; }
  .content { padding: 16px; }
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 12px; }
}
