:root {
  color-scheme: dark;
  --bg: #080b10;
  --panel: #0d131b;
  --panel-2: #121a25;
  --panel-3: #182231;
  --line: #263244;
  --line-soft: #1b2634;
  --text: #e7edf5;
  --muted: #91a0b4;
  --accent: #58d6c2;
  --accent-2: #21ad98;
  --blue: #6ea8fe;
  --warning: #f2c56b;
  --danger: #ff7b85;
  --success: #68d391;
  --shadow: 0 18px 60px rgba(0, 0, 0, .38);
  --radius: 12px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 20% 15%, rgba(44, 170, 153, .15), transparent 34%),
    radial-gradient(circle at 85% 80%, rgba(67, 107, 183, .12), transparent 32%),
    var(--bg);
}

.auth-card { width: min(520px, 100%); padding: 34px; background: rgba(13, 19, 27, .96); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.brand-mark { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 11px; color: #06110f; background: var(--accent); font-weight: 800; letter-spacing: -.04em; }
.auth-card h1 { margin: 18px 0 7px; font-size: 26px; letter-spacing: -.03em; }
.auth-card .lead { color: var(--muted); line-height: 1.65; margin: 0 0 24px; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--line-soft); background: #090e15; padding: 20px 14px; display: flex; flex-direction: column; gap: 18px; }
.sidebar-brand { display: flex; gap: 11px; align-items: center; padding: 0 8px; }
.sidebar-brand strong { display: block; font-size: 14px; }
.sidebar-brand small { display: block; color: var(--muted); margin-top: 3px; }
.nav { display: grid; gap: 5px; }
.nav button { width: 100%; text-align: left; border: 1px solid transparent; background: transparent; color: var(--muted); border-radius: 9px; padding: 10px 12px; transition: .15s ease; }
.nav button:hover { color: var(--text); background: var(--panel-2); }
.nav button.active { color: var(--text); background: #15222b; border-color: #24443f; }
.sidebar-footer { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 12px; }
.sidebar-footer button { margin-top: 12px; }

.workspace { min-width: 0; }
.topbar { min-height: 66px; position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 13px 26px; background: rgba(8, 11, 16, .88); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line-soft); }
.topbar h1 { font-size: 18px; margin: 0; }
.topbar p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.content { padding: 24px 26px 48px; max-width: 1600px; margin: 0 auto; }

.grid { display: grid; gap: 16px; }
.cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 18px; }
.card h2, .panel h2 { margin: 0; font-size: 15px; }
.metric { font-size: 28px; font-weight: 720; margin-top: 12px; letter-spacing: -.035em; }
.metric small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 5px; }
.eyebrow { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.panel { margin-top: 16px; background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden; }
.panel-head { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--line-soft); }
.panel-body { padding: 18px; }
.panel-note { color: var(--muted); line-height: 1.6; }
.toolbar { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }

.btn { border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: 8px; padding: 8px 12px; min-height: 36px; transition: .15s ease; }
.btn:hover { border-color: #40536e; background: var(--panel-3); }
.btn.primary { color: #06110f; background: var(--accent); border-color: var(--accent); font-weight: 700; }
.btn.primary:hover { background: #75e1d0; }
.btn.danger { color: #ffd6d9; border-color: #63323b; background: #25151a; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 30px; padding: 5px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label, .field > span { color: #cbd5e1; font-size: 12px; font-weight: 650; }
.field small { color: var(--muted); line-height: 1.5; }
input, select, textarea { width: 100%; color: var(--text); background: #090f16; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(88, 214, 194, .1); }
textarea { min-height: 108px; resize: vertical; }
select[multiple] { min-height: 130px; }
.check { display: flex; align-items: flex-start; gap: 9px; line-height: 1.45; color: var(--muted); }
.check input { width: 16px; height: 16px; margin-top: 2px; accent-color: var(--accent); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 840px; }
th { color: var(--muted); text-align: left; font-size: 11px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; background: #0b1118; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:hover { background: rgba(255, 255, 255, .018); }
tbody tr:last-child td { border-bottom: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.truncate { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; border: 1px solid var(--line); padding: 3px 8px; font-size: 11px; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.badge.online::before, .badge.enabled::before, .badge.success::before { background: var(--success); box-shadow: 0 0 9px rgba(104, 211, 145, .6); }
.badge.error::before, .badge.failed::before { background: var(--danger); }
.badge.disabled::before, .badge.dry::before { background: var(--warning); }
.badge.shared::before { background: var(--blue); }
.empty { padding: 42px 18px; text-align: center; color: var(--muted); }
.notice { padding: 12px 14px; border: 1px solid #324052; background: #101824; border-radius: 9px; color: #bac7d8; line-height: 1.6; }
.notice.warning { border-color: #5d4b2b; background: #1e190f; color: #e8d4a8; }
.notice.danger { border-color: #5d3038; background: #211317; color: #f2c1c6; }
.codebox { background: #070b10; border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow: auto; white-space: pre-wrap; word-break: break-word; color: #c8d4e3; }

dialog { width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 50px); overflow: auto; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 0; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0, 0, 0, .72); backdrop-filter: blur(3px); }
.modal-head { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; padding: 16px 19px; border-bottom: 1px solid var(--line); background: var(--panel); }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 19px; }
.modal-close { border: 0; background: transparent; color: var(--muted); font-size: 24px; line-height: 1; }

#toast { position: fixed; right: 20px; bottom: 20px; z-index: 50; max-width: min(420px, calc(100vw - 40px)); padding: 12px 15px; color: var(--text); background: #17212d; border: 1px solid #3b4b60; border-radius: 9px; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); pointer-events: none; transition: .2s ease; }
#toast.show { opacity: 1; transform: translateY(0); }
#toast.error { border-color: #6b3841; background: #2a161b; }

.mobile-menu { display: none; }
@media (max-width: 1100px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .shell { grid-template-columns: 208px minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .shell { display: block; }
  .sidebar { position: fixed; z-index: 20; width: 245px; transform: translateX(-100%); transition: .2s ease; box-shadow: var(--shadow); }
  .shell.menu-open .sidebar { transform: translateX(0); }
  .mobile-menu { display: inline-flex; }
  .topbar { padding: 12px 14px; }
  .content { padding: 16px 14px 40px; }
  .cards, .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .auth-card { padding: 24px; }
}
