:root {
  color-scheme: light;
  font-family: "Segoe UI", "Microsoft YaHei UI", sans-serif;
  background: #f3f6fb;
  color: #13213a;
  --panel: #fff;
  --muted: #63708a;
  --line: #dce3ee;
  --primary: #2463eb;
  --primary-hover: #174bc2;
  --danger: #cf2d48;
  --success: #087f5b;
  --shadow: 0 12px 36px rgb(29 54 93 / 9%);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  background: #111827;
  color: #ecf2ff;
  --panel: #172033;
  --muted: #a9b5ca;
  --line: #344058;
  --primary: #4f83ff;
  --primary-hover: #75a0ff;
  --danger: #ff6b81;
  --success: #5dd7b1;
  --shadow: 0 12px 36px rgb(0 0 0 / 25%);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: inherit; color: inherit; }
button, input, select, textarea { font: inherit; }
.topbar { height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 0 28px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 800; letter-spacing: .12em; color: var(--primary); }
.subtitle, .panel p, .capabilities { color: var(--muted); font-size: 13px; }
.toolbar, .section-title, .dialog-actions, .instance-actions { display: flex; align-items: center; gap: 10px; }
main { width: min(1440px, calc(100% - 32px)); margin: 24px auto 60px; }
.dashboard { display: grid; gap: 20px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 22px; box-shadow: var(--shadow); }
.login-panel { max-width: 460px; margin: 80px auto; }
h1 { margin: 0 0 6px; font-size: 22px; }
h2 { margin-top: 0; }
form { display: grid; gap: 14px; }
.login-panel form { margin-top: 22px; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); background: transparent; color: inherit; border-radius: 10px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgb(36 99 235 / 14%); }
textarea { min-height: 76px; resize: vertical; }
button { border: 0; border-radius: 10px; padding: 10px 15px; background: var(--primary); color: white; cursor: pointer; font-weight: 650; }
button:hover { background: var(--primary-hover); }
button:disabled { opacity: .55; cursor: wait; }
button.secondary { background: transparent; color: inherit; border: 1px solid var(--line); }
button.danger { background: var(--danger); }
.hidden { display: none !important; }
.section-title { justify-content: space-between; margin-bottom: 18px; }
.grid-form { grid-template-columns: repeat(3, minmax(180px, 1fr)); align-items: end; padding: 16px; border: 1px solid var(--line); border-radius: 14px; }
.wide { grid-column: span 2; }
.capabilities { margin: 14px 2px; }
.card-list { display: grid; gap: 10px; margin-top: 16px; }
.item-card { border: 1px solid var(--line); border-radius: 14px; padding: 15px; display: grid; gap: 11px; }
.item-head { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; }
.item-title { font-weight: 750; }
.meta { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 13px; color: var(--muted); }
.badge { border-radius: 999px; padding: 4px 9px; font-size: 12px; background: rgb(36 99 235 / 12%); color: var(--primary); }
.badge.error { background: rgb(207 45 72 / 12%); color: var(--danger); }
.notice { border-radius: 12px; padding: 12px 15px; background: rgb(8 127 91 / 12%); color: var(--success); }
.notice.error { background: rgb(207 45 72 / 12%); color: var(--danger); }
.audit-list { display: grid; gap: 8px; font-size: 13px; }
.audit-row { display: grid; grid-template-columns: 170px 120px 1fr 90px; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
dialog { max-width: 560px; width: calc(100% - 32px); color: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgb(0 0 0 / 45%); }
#secret-value { min-height: 110px; }
.dialog-actions { justify-content: flex-end; }

@media (max-width: 850px) {
  .grid-form { grid-template-columns: 1fr; }
  .wide { grid-column: span 1; }
  .topbar { padding: 0 14px; }
  main { width: min(100% - 18px, 1440px); }
  .audit-row { grid-template-columns: 1fr; gap: 3px; }
  .item-head { display: grid; }
  .instance-actions { flex-wrap: wrap; }
}
