:root {
  --bg: #F5F7FA;
  --panel: #FFFFFF;
  --ink: #0A2540;
  --muted: #64748B;
  --line: #E2E8F0;
  --primary: #0B5FFF;
  --ok: #16A34A;
  --warn: #D97706;
  --danger: #DC2626;
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* ---------- login ---------- */
.auth-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.auth-card { background: var(--panel); border-radius: var(--radius); padding: 32px; width: 100%; max-width: 380px; box-shadow: 0 1px 3px rgba(10,37,64,.1); }
.auth-card h1 { font-size: 20px; margin-bottom: 4px; }
.auth-card .sub { color: var(--muted); font-size: 14px; margin-bottom: 24px; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100dvh; }

aside.nav {
  width: 232px; background: var(--ink); color: #fff; padding: 20px 12px;
  display: flex; flex-direction: column; flex-shrink: 0;
}
aside.nav .logo { font-size: 17px; font-weight: 600; padding: 0 10px 20px; }
aside.nav a {
  display: block; padding: 10px 12px; color: #C7D6E5; text-decoration: none;
  border-radius: 8px; font-size: 14px; margin-bottom: 2px;
}
aside.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
aside.nav a.active { background: var(--primary); color: #fff; }
aside.nav .spacer { flex: 1; }
aside.nav .who { padding: 12px 10px; border-top: 1px solid rgba(255,255,255,.12); font-size: 13px; color: #9BB0C4; }

main { flex: 1; padding: 24px 28px 60px; min-width: 0; }
main header.page { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
main header.page h1 { font-size: 22px; }
main header.page .grow { flex: 1; }

/* ---------- panels ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.panel h2 { font-size: 15px; margin-bottom: 14px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat .n { font-size: 26px; font-weight: 600; line-height: 1.2; }
.stat .l { font-size: 13px; color: var(--muted); margin-top: 2px; }
.stat.alert .n { color: var(--danger); }
.stat.good .n { color: var(--ok); }

/* ---------- tables ---------- */
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  text-align: left; padding: 10px 12px; border-bottom: 2px solid var(--line);
  color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
}
table.data td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: #FAFBFC; }
.empty { color: var(--muted); padding: 28px 12px; text-align: center; font-size: 14px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.badge.neutral { background: #EEF2F6; color: var(--muted); }
.badge.ok { background: #DCFCE7; color: #15803D; }
.badge.warn { background: #FEF3C7; color: #B45309; }
.badge.danger { background: #FEE2E2; color: #B91C1C; }
.badge.info { background: #DBEAFE; color: #1D4ED8; }

/* ---------- forms ---------- */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; background: #fff; color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.btn { padding: 10px 18px; border: 0; border-radius: 8px; font: inherit; font-weight: 500; cursor: pointer; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:disabled { background: #93B4FF; cursor: not-allowed; }
.btn.ghost { background: #fff; border: 1px solid var(--line); color: var(--ink); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn.block { width: 100%; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(10,37,64,.45); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal[hidden] { display: none; }
.modal-card { background: #fff; border-radius: var(--radius); padding: 24px; width: 100%; max-width: 520px; max-height: 88dvh; overflow-y: auto; }
.modal-card h3 { margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* Credentials shown once — visually loud on purpose. */
.secret-box { background: #FFFBEB; border: 1px solid #FDE68A; border-radius: 8px; padding: 14px; margin: 14px 0; font-family: ui-monospace, monospace; font-size: 13px; word-break: break-all; }
.secret-box strong { display: block; font-family: inherit; color: #92400E; margin-bottom: 6px; font-size: 12px; text-transform: uppercase; }

/* ---------- toasts ---------- */
#toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 8px; font-size: 14px; max-width: 380px; box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.toast.error { background: var(--danger); }
.toast.success { background: var(--ok); }

.err { color: var(--danger); font-size: 14px; margin-top: 10px; }
.muted { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

@media (max-width: 760px) {
  .shell { flex-direction: column; }
  aside.nav { width: 100%; flex-direction: row; overflow-x: auto; padding: 10px; }
  aside.nav .logo, aside.nav .who, aside.nav .spacer { display: none; }
  main { padding: 16px; }
  .row { grid-template-columns: 1fr; }
}
