:root {
  --ink: #0e1726;
  --ink-muted: #4b5565;
  --primary: #1b4dff;
  --accent: #00b39a;
  --surface: #ffffff;
  --bg: #f0f3f9;
  --border: #dde3ee;
  --danger: #b91c1c;
  --warn: #a16207;
  --ok: #15803d;
  --radius: 10px;
  --shadow: 0 10px 30px rgba(14, 23, 38, .08);
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: radial-gradient(1200px 600px at 10% -10%, #dfe8ff 0%, transparent 55%), radial-gradient(900px 500px at 100% 0%, #d9fff6 0%, transparent 45%), var(--bg); }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; }

.center-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.loading { color: var(--ink-muted); }

.auth-card {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.auth-brand { font-weight: 800; letter-spacing: -.02em; margin-bottom: 18px; color: var(--ink); }
.auth-form h1 { margin: 0 0 8px; font-size: 1.45rem; }
.qr { display: grid; place-items: center; margin: 12px 0; }
.qr svg { background: #fff; border-radius: 8px; }
.mfa-box .mono { word-break: break-all; font-family: ui-monospace, Consolas, monospace; }

.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--ink);
  color: #fff;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.05rem; }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-link {
  color: rgba(255,255,255,.78);
  padding: 10px 12px;
  border-radius: 8px;
}
.nav-link:hover, .nav-link[aria-current="page"] { background: rgba(255,255,255,.1); color: #fff; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,.12); padding-top: 14px; }
.main { padding: 28px; max-width: 1200px; }

.view-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.view-head h1 { margin: 0; font-size: 1.6rem; letter-spacing: -.02em; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: 0 1px 0 rgba(14,23,38,.02);
}
.panel h2 { margin: 0 0 12px; font-size: 1.05rem; }
.panel h3 { margin: 16px 0 8px; font-size: .95rem; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.stat-value { display: block; font-size: 1.45rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--ink-muted); font-size: .85rem; }
.stat.ok .stat-value { color: var(--ok); }
.stat.warn .stat-value { color: var(--warn); }
.stat.danger .stat-value { color: var(--danger); }

.btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
}
.btn:hover { border-color: #b8c2d6; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: inherit; }
.btn.small { padding: 6px 10px; font-size: .9rem; }
.btn.block { width: 100%; }
.btn:disabled, .btn.busy { opacity: .6; cursor: wait; }

.form { display: grid; gap: 12px; }
.field { display: grid; gap: 6px; }
.field-label { font-size: .9rem; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}
.hint, .muted, .empty { color: var(--ink-muted); }
.small { font-size: .85rem; }
.field-error { color: var(--danger); }
.mono { font-family: ui-monospace, Consolas, monospace; }
.code { background: #0e1726; color: #e8eefc; padding: 12px; border-radius: 8px; overflow: auto; font-size: 12px; }

.filters { display: flex; gap: 10px; margin-bottom: 14px; }
.filters input, .filters select { border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; background: #fff; min-width: 240px; }

.table-wrap { overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-muted); background: #f7f9fc; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover { background: #f5f8ff; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: .75rem;
  background: #e8edf7;
  color: var(--ink);
}
.badge.ok { background: #dcfce7; color: var(--ok); }
.badge.warn { background: #fef3c7; color: var(--warn); }
.badge.danger { background: #fee2e2; color: var(--danger); }
.badge.info { background: #dbeafe; color: #1d4ed8; }
.badge.muted { background: #e5e7eb; color: #4b5563; }

.details { display: grid; grid-template-columns: 160px 1fr; gap: 8px 12px; margin: 0; }
.details dt { color: var(--ink-muted); }
.details dd { margin: 0; }
.plain-list { margin: 0; padding-left: 18px; }
.row-between { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.notice { padding: 10px 12px; border-radius: 8px; background: #fff7ed; border: 1px solid #fed7aa; }
.list { display: grid; gap: 12px; }

.backdrop {
  position: fixed; inset: 0; background: rgba(14,23,38,.45);
  display: grid; place-items: center; padding: 20px; z-index: 40;
}
.modal {
  width: min(520px, 100%);
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow);
  max-height: 90vh;
  overflow: auto;
}
.modal-wide { width: min(860px, 100%); }
.modal-head, .modal-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; }
.modal-head { border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 1.1rem; }
.modal-body { padding: 16px; }
.modal-actions { border-top: 1px solid var(--border); justify-content: flex-end; }
.icon-btn { border: 0; background: transparent; font-size: 1.3rem; cursor: pointer; color: var(--ink-muted); }

.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 50; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); max-width: 360px; }
.toast-success { background: var(--ok); }
.toast-error { background: var(--danger); }
.toast-warn { background: var(--warn); }
.toast.hide { opacity: 0; transition: opacity .4s; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 5; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .grid-2 { grid-template-columns: 1fr; }
  .main { padding: 16px; }
}
