:root {
  --primary: #3d5af1;
  --primary-dark: #2e45cc;
  --nav: #1b2440;
  --bg: #f4f5f9;
  --panel: #fff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --danger: #dc2626;
  --success: #15803d;
  --warn: #b45309;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.muted { color: var(--muted); }
.error { color: var(--danger); }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: linear-gradient(135deg, #eef1ff, #f7f8fc); }
.login-card { flex: 0 1 420px; min-width: 0; width: 100%; max-width: 420px; background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 28px; box-shadow: 0 18px 60px #1b244018; }
.login-card h1 { margin: 0 0 4px; font-size: 24px; }
.login-card p { margin: 0 0 20px; }
.login-card label { margin-bottom: 14px; }
.login-card .btn { width: 100%; margin-top: 4px; }
.topbar { min-height: 64px; display: flex; align-items: center; gap: 14px; padding: 0 24px; background: var(--nav); color: #fff; position: sticky; top: 0; z-index: 5; }
.topbar .muted { color: #c7ccef; margin-left: auto; }
.shell { display: grid; grid-template-columns: 210px minmax(0, 1fr); min-height: calc(100vh - 64px); }
.tabs { background: #fff; border-right: 1px solid var(--line); padding: 16px 10px; display: flex; flex-direction: column; gap: 6px; }
.tabs button { border: 0; border-radius: 10px; background: transparent; text-align: left; padding: 11px 14px; color: var(--muted); }
.tabs button:hover { background: #f0f3ff; color: var(--primary); }
.tabs button.active { background: var(--primary); color: #fff; }
.content { padding: 24px; min-width: 0; }
.content.single { max-width: 1120px; margin: 0 auto; width: 100%; }
.tab { display: none; }
.tab.active { display: block; }
h2 { font-size: 20px; margin: 0 0 16px; }
.stats, .cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.stat, .card, .panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.stat b { display: block; font-size: 28px; margin-top: 4px; color: var(--primary); }
.panel { margin-bottom: 18px; }
.card h3 { margin: 0 0 8px; font-size: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; align-items: end; }
.form-grid label, .login-card label { display: grid; gap: 6px; font-weight: 600; }
.form-grid .wide { grid-column: 1 / -1; }
input, select, textarea { width: 100%; border: 1px solid #d7dbe7; border-radius: 9px; padding: 10px 11px; background: #fff; color: var(--text); }
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
.btn { border: 1px solid transparent; border-radius: 9px; padding: 9px 14px; background: #eef0f6; color: var(--text); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: transparent; color: inherit; border-color: #ffffff44; }
.btn.danger { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.btn.small { padding: 5px 9px; font-size: 12px; }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.table-wrap { overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); background: #fafbff; font-size: 12px; }
tr:last-child td { border-bottom: 0; }
.notice { margin: 0 0 16px; padding: 12px 14px; border-radius: 10px; background: #eef4ff; color: #1e3a8a; border: 1px solid #bfdbfe; white-space: pre-wrap; word-break: break-all; }
.notice.warn { background: #fffbeb; color: var(--warn); border-color: #fde68a; }
.notice.error { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #eef0f6; font-size: 12px; }
.tag.active { color: var(--success); background: #ecfdf3; }
.tag.bad { color: var(--danger); background: #fef2f2; }
.code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; word-break: break-all; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 20; max-width: min(420px, calc(100vw - 40px)); background: #111827; color: #fff; padding: 12px 15px; border-radius: 10px; box-shadow: 0 10px 30px #0003; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.mini-form { display: grid; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.mini-form label { display: grid; gap: 4px; font-weight: 600; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .tabs { position: sticky; top: 64px; z-index: 4; flex-direction: row; overflow: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; }
  .tabs button { white-space: nowrap; }
  .content { padding: 16px; }
}
@media (max-width: 640px) {
  .topbar { padding: 0 14px; }
  .topbar .muted { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .table-wrap { border-radius: 10px; }
  .stat, .card, .panel { padding: 14px; }
}
