:root {
  --bg: #0a0e13;
  --panel: #111821;
  --panel-2: #0d141c;
  --border: #1f2a37;
  --text: #e6edf7;
  --muted: #8b9bb4;
  --cyan: #22d3ee;
  --green: #34d399;
  --red: #f87171;
  --yellow: #fbbf24;
  --purple: #a78bfa;
}

html[data-theme="light"] {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-2: #eef3f8;
  --border: #d8e0ea;
  --text: #16202c;
  --muted: #5d6b7d;
  --cyan: #087ea4;
  --green: #0f7a5a;
  --red: #b42318;
  --yellow: #8a5a00;
  --purple: #6d4aff;
}
html[data-theme="light"] body { background: var(--bg); }
html[data-theme="light"] .topbar { background: rgba(255,255,255,.94); backdrop-filter: blur(8px); }
html[data-theme="light"] nav a:hover,
html[data-theme="light"] nav a.active { background: #e8eef6; }
html[data-theme="light"] th,
html[data-theme="light"] td,
html[data-theme="light"] .audit-list li { border-bottom-color: #e6ecf3; }
html[data-theme="light"] input,
html[data-theme="light"] select,
html[data-theme="light"] textarea { background: #fff; border-color: #cbd6e3; color: var(--text); }
html[data-theme="light"] button,
html[data-theme="light"] .button { background: #fff; border-color: #cbd6e3; }
html[data-theme="light"] .panel { box-shadow: 0 2px 12px rgba(20, 40, 70, .06); }
html[data-theme="light"] .flash.ok { background: #e8f7f1; border-color: #b7e4d3; }
html[data-theme="light"] .flash.err { background: #fdecea; border-color: #f2c0ba; }
html[data-theme="light"] .flash.warn { background: #fff6e0; border-color: #eed59a; }
html[data-theme="light"] .pill.active { background: #e8f7f1; border-color: #b7e4d3; }
html[data-theme="light"] .pill.unknown,
html[data-theme="light"] .pill.failed { background: #fff6e0; border-color: #eed59a; }
.theme-toggle { white-space: nowrap; color: var(--muted); }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif; }
body { min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: Consolas, "SFMono-Regular", monospace; }

.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 12px 22px; background: var(--panel-2);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; flex-direction: column; gap: 2px; }
.brand strong { font-size: 17px; letter-spacing: .4px; }
.brand .muted { font-size: 11px; }
nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
nav a { color: var(--muted); padding: 8px 10px; border-radius: 7px; font-size: 13px; }
nav a:hover { background: #16202c; color: var(--text); text-decoration: none; }
nav a.active { background: #16202c; color: var(--cyan); }
.inline-form { display: flex; align-items: center; gap: 8px; font-size: 12px; }

main { width: min(1440px, calc(100% - 32px)); margin: 20px auto; flex: 1; }
.footer { display: flex; justify-content: space-between; padding: 10px 22px; border-top: 1px solid var(--border); color: var(--muted); font-size: 11px; }

h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 15px; margin: 0 0 10px; }
p { line-height: 1.6; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; gap: 12px; }

.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px; min-width: 0;
}
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.panel-head h2 { margin: 0; }
.grid { display: grid; gap: 14px; margin-bottom: 14px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.stat { display: flex; flex-direction: column; gap: 4px; }
.stat span { color: var(--muted); font-size: 12px; }
.stat strong { font-size: 30px; color: var(--cyan); }
.stat small { color: var(--muted); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid #18222e; vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
tr:last-child td { border-bottom: 0; }
.wide td { padding-top: 10px; padding-bottom: 10px; }
.hash { font-size: 10px; word-break: break-all; color: var(--muted); }

.stack { display: flex; flex-direction: column; gap: 9px; }
.stack.compact { gap: 4px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
input, select, textarea {
  width: 100%; background: #070b10; color: var(--text);
  border: 1px solid var(--border); border-radius: 7px; padding: 8px 9px;
  font: inherit; font-size: 13px;
}
input:focus, select:focus, textarea:focus { outline: 1px solid var(--cyan); border-color: var(--cyan); }
input:disabled { opacity: .6; }
textarea { resize: vertical; font-family: Consolas, monospace; }
.check { flex-direction: row; align-items: center; gap: 7px; }
.check input { width: auto; }

button, .button {
  display: inline-block; border: 1px solid var(--border); border-radius: 7px;
  background: #172230; color: var(--text); padding: 8px 12px;
  font: inherit; font-size: 13px; cursor: pointer;
}
button:hover, .button:hover { border-color: var(--cyan); color: var(--cyan); text-decoration: none; }
button.primary { background: #0e7490; border-color: #0e7490; color: white; }
button.primary:hover { background: #0891b2; color: white; }
button.danger { color: var(--red); }
button.small-button { padding: 4px 8px; font-size: 11px; }
.link-button { background: none; border: 0; color: var(--muted); padding: 4px; }
.link-button:hover { color: var(--cyan); }

.flash { padding: 10px 14px; border-radius: 9px; margin: 14px 0; font-size: 13px; border: 1px solid var(--border); }
.flash.ok { background: #0d2b24; border-color: #145c4a; color: var(--green); }
.flash.err { background: #32161a; border-color: #6b2733; color: var(--red); }
.flash.warn { background: #33280e; border-color: #6b5420; color: var(--yellow); }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; border: 1px solid var(--border); }
.pill.active { color: var(--green); border-color: #1c6b54; background: #0d2b24; }
.pill.inactive { color: var(--muted); }
.pill.unknown, .pill.failed { color: var(--yellow); border-color: #6b5420; background: #33280e; }

.status-list, .audit-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.status-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.audit-list li { line-height: 1.5; border-bottom: 1px solid #18222e; padding-bottom: 6px; }
.usage { margin-top: 14px; font-size: 11px; }

.login-wrap { min-height: 70vh; display: flex; align-items: center; justify-content: center; }
.login-panel { width: min(380px, 92vw); padding: 28px; }
.login-panel h1 { margin-bottom: 4px; }
.section-gap { margin-top: 24px; }
.footer { margin-top: auto; }

@media (max-width: 980px) {
  .grid.two, .grid.four { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; gap: 8px; }
  nav { order: 3; width: 100%; }
  .inline-form { margin-left: auto; }
}
