:root {
  --bg-elevated: #1a2332;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #0f172a;
  --text-inv: #e2e8f0;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #6366f1;
  --brand-2: #8b5cf6;
  --brand-glow: rgba(99, 102, 241, 0.35);
  --ok: #10b981;
  --warn: #f59e0b;
  --err: #ef4444;
  --radius: 14px;
  --shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.15);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, sans-serif;
  background: linear-gradient(160deg, #eef2ff 0%, #f8fafc 40%, #f1f5f9 100%);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}
.hidden { display: none !important; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.55rem 1rem; border-radius: 10px; border: none;
  font: inherit; font-weight: 600; font-size: 0.85rem;
  cursor: pointer; transition: transform 0.15s, box-shadow 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; box-shadow: 0 4px 14px var(--brand-glow); }
.btn-ghost { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--surface-soft); }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.78rem; }
.btn-danger { background: #fef2f2; color: var(--err); border: 1px solid #fecaca; }

label { display: block; font-size: 0.78rem; font-weight: 600; color: var(--muted); margin-bottom: 0.35rem; }
input { width: 100%; padding: 0.65rem 0.85rem; border: 1px solid var(--line); border-radius: 10px; font: inherit; }
input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); }

.status-pill {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.3rem 0.7rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600;
  background: #f1f5f9;
}
.status-pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #94a3b8; }
.status-pill.connected { background: #ecfdf5; color: #047857; }
.status-pill.connected::before { background: var(--ok); }
.status-pill.qr_required, .status-pill.connecting { background: #fffbeb; color: #b45309; }
.status-pill.qr_required::before, .status-pill.connecting::before { background: var(--warn); }
.status-pill.error, .status-pill.logged_out { background: #fef2f2; color: #b91c1c; }
.status-pill.error::before, .status-pill.logged_out::before { background: var(--err); }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin: 1rem 0; }
.detail-cell { background: var(--surface-soft); border: 1px solid var(--line); border-radius: 10px; padding: 0.55rem 0.65rem; }
.detail-cell.full { grid-column: 1 / -1; }
.detail-cell kbd { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; display: block; margin-bottom: 0.2rem; }
.detail-cell var { font-style: normal; font-size: 0.88rem; word-break: break-word; }

.panel { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; }
.panel-head { padding: 0.85rem 1.1rem; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.panel-head h2 { margin: 0; font-size: 0.95rem; font-weight: 600; }
.panel-body { padding: 1rem 1.15rem 1.25rem; }

.log-stream { max-height: 420px; overflow: auto; padding: 0.5rem; }
.log-line { display: grid; grid-template-columns: auto 1fr; gap: 0.65rem; padding: 0.55rem 0.65rem; border-radius: 10px; margin-bottom: 0.35rem; font-size: 0.8rem; }
.log-line.warn { border-left: 3px solid var(--warn); }
.log-line.error { border-left: 3px solid var(--err); }
.log-time { font-size: 0.7rem; color: var(--muted); white-space: nowrap; }
.log-empty { padding: 2rem; text-align: center; color: var(--muted); }

.test-result { font-size: 0.78rem; margin-top: 0.5rem; padding: 0.5rem 0.65rem; border-radius: 8px; background: var(--surface-soft); border: 1px solid var(--line); }
.test-result.fail { background: #fef2f2; border-color: #fecaca; }
.test-result.ok { background: #ecfdf5; border-color: #a7f3d0; }
.test-result.pending { background: #fffbeb; border-color: #fde68a; }

.evo-box { font-size: 0.78rem; background: #f5f3ff; border: 1px solid #ddd6fe; border-radius: 10px; padding: 0.65rem; word-break: break-all; }
.action-grid { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55); backdrop-filter: blur(4px);
  z-index: 200; display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal { width: 100%; max-width: 440px; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); max-height: 90vh; overflow: auto; }
.modal.wide { max-width: 480px; }
.modal-head { padding: 1.15rem 1.25rem; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; font-size: 1.05rem; }
.modal-body { padding: 1.25rem; }
.modal-close { border: none; background: var(--surface-soft); width: 32px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 1.1rem; color: var(--muted); }

#toasts { position: fixed; bottom: 1.25rem; right: 1.25rem; z-index: 300; display: flex; flex-direction: column; gap: 0.5rem; max-width: 360px; pointer-events: none; }
.toast { pointer-events: auto; padding: 0.85rem 1.1rem; border-radius: 12px; color: #fff; font-size: 0.88rem; box-shadow: var(--shadow-lg); background: var(--bg-elevated); }
.toast.ok { background: linear-gradient(135deg, #059669, #10b981); }
.toast.err { background: linear-gradient(135deg, #dc2626, #ef4444); }

.page { max-width: 920px; margin: 0 auto; padding: 1.25rem 1.25rem 2.5rem; }
.page-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-top h1 { margin: 0; font-size: 1.35rem; }
.mono { font-family: ui-monospace, monospace; color: var(--muted); font-size: 0.9rem; }
.section-title { margin: 1.25rem 0 0.65rem; font-size: 0.85rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
