:root {
  --bg: #0f1218;
  --panel: #171c26;
  --panel-2: #1d2330;
  --border: #2a3346;
  --text: #e5e9f0;
  --muted: #8a94a6;
  --accent: #4f8cff;
  --accent-2: #2f6ae0;
  --green: #3fb950;
  --red: #f85149;
  --yellow: #d29922;
  --radius: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 -apple-system, "Segoe UI", Roboto, Inter, sans-serif; }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }

.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; width: 340px; }
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card p { color: var(--muted); margin: 0 0 20px; }

.layout { display: flex; min-height: 100vh; }
.sidebar { width: 210px; background: var(--panel); border-right: 1px solid var(--border); padding: 16px 10px; flex-shrink: 0; }
.sidebar .brand { font-weight: 700; font-size: 15px; padding: 8px 12px 18px; }
.sidebar .brand span { color: var(--accent); }
.nav-item { display: block; padding: 9px 12px; border-radius: 6px; color: var(--muted); margin-bottom: 2px; }
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active { background: var(--accent-2); color: #fff; }
.main { flex: 1; padding: 24px 28px; max-width: 1200px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.topbar h1 { font-size: 20px; margin: 0; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.card .value { font-size: 26px; font-weight: 700; margin-top: 6px; }
.card .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 22px; }
.panel h2 { margin: 0 0 14px; font-size: 15px; }
.panel .panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.panel .panel-head h2 { margin: 0; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--border); }
td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }

.btn { background: var(--accent-2); color: #fff; border: 0; border-radius: 6px; padding: 8px 14px; }
.btn:hover { background: var(--accent); }
.btn.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: var(--border); }
.btn.danger { background: transparent; color: var(--red); border: 1px solid var(--red); }
.btn.danger:hover { background: var(--red); color: #fff; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }

.field { margin-bottom: 14px; }
.field label { display: block; color: var(--muted); margin-bottom: 5px; font-size: 13px; }
.field input[type=text], .field input[type=password], .field select, .field textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 10px; color: var(--text);
}
.field textarea { resize: vertical; min-height: 64px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.checkbox-row label { color: var(--text); margin: 0; }
.model-checks { max-height: 180px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; background: var(--bg); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge.green { background: rgba(63,185,80,.15); color: var(--green); }
.badge.red { background: rgba(248,81,73,.15); color: var(--red); }
.badge.yellow { background: rgba(210,153,34,.15); color: var(--yellow); }
.badge.gray { background: var(--panel-2); color: var(--muted); }
.badge.blue { background: rgba(79,140,255,.15); color: var(--accent); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.dot.green { background: var(--green); }
.dot.red { background: var(--red); }
.dot.gray { background: var(--muted); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; width: 520px; max-width: 92vw; max-height: 85vh; overflow-y: auto; }
.modal h3 { margin: 0 0 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.key-reveal { background: var(--bg); border: 1px solid var(--yellow); border-radius: 6px; padding: 14px; margin: 14px 0; font-family: ui-monospace, monospace; word-break: break-all; }
.warn { color: var(--yellow); font-size: 13px; }

.toast { position: fixed; bottom: 22px; right: 22px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px 18px; z-index: 200; max-width: 380px; }
.toast.error { border-color: var(--red); color: var(--red); }
.toast.ok { border-color: var(--green); color: var(--green); }

.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filters select { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px; color: var(--text); }

.mono { font-family: ui-monospace, SFMono-Regular, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.body-view { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 12px; max-height: 300px; overflow: auto; white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, monospace; font-size: 12px; }
.chart-wrap { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 10px; }
.row-flex { display: flex; gap: 10px; align-items: center; }
.grow { flex: 1; }
.empty { color: var(--muted); text-align: center; padding: 26px 0; }
