:root {
    --bg: #f4f6fa;
    --card: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --border: #e5e7eb;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: #eff6ff;
    --danger: #dc2626;
    --ok: #16a34a;
    --code-bg: #f3f4f6;
    --callback: #7c3aed;
    --webhook: #0891b2;
    --side-bg: #0f172a;
    --side-text: #cbd5e1;
    --side-w: 236px;
    --radius: 12px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.55 "Segoe UI", system-ui, -apple-system, Arial, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 14px; }
h3 { margin: 0 0 4px; font-size: 16px; }
h4 { margin: 18px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
p { margin: 4px 0 0; }
code, pre { font-family: Consolas, "Cascadia Mono", monospace; font-size: 13px; }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Sidebar layout ---------- */
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--side-w); background: var(--side-bg); color: var(--side-text);
    display: flex; flex-direction: column; padding: 18px 14px; z-index: 50; transition: transform .2s; }
.sidebar .brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 600; font-size: 16px; padding: 4px 8px 22px; }
.sidebar .brand:hover { text-decoration: none; }
.logo { display: inline-grid; place-items: center; width: 30px; height: 30px; background: var(--primary); color: #fff; border-radius: 8px; font-size: 16px; }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; color: var(--side-text); font-weight: 500; }
.side-nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.side-nav a.active { background: var(--primary); color: #fff; }
.side-footer { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.help-btn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px dashed #334155;
    background: transparent; color: #e2e8f0; font: inherit; font-weight: 500; cursor: pointer; }
.help-btn:hover { border-color: var(--primary); background: rgba(37, 99, 235, .15); }
.user-box { display: flex; align-items: center; gap: 10px; padding: 10px 8px 0; border-top: 1px solid #1e293b; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #334155; color: #fff; display: grid; place-items: center; font-weight: 600; flex: none; }
.user-info { min-width: 0; display: flex; flex-direction: column; font-size: 12px; }
.user-info strong { color: #fff; font-size: 13px; }
.user-info span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #94a3b8; }
.logout { width: 100%; background: none; border: 0; color: #94a3b8; font: inherit; text-align: left; padding: 4px 8px; cursor: pointer; }
.logout:hover { color: #fff; }

.mobile-bar { display: none; }
.content { margin-left: var(--side-w); padding: 28px 32px 56px; max-width: calc(1320px + var(--side-w)); }

/* ---------- Guest (login/register) ---------- */
.guest-content { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px 16px; }
.guest-content > .alert { max-width: 940px; width: 100%; margin: 0 auto 14px; }
.auth-wrap { display: grid; grid-template-columns: 1.1fr 1fr; max-width: 940px; width: 100%; margin: 0 auto;
    background: var(--card); border-radius: 16px; overflow: hidden; box-shadow: 0 10px 40px rgba(15, 23, 42, .08); }
.auth-hero { background: linear-gradient(150deg, #0f172a, #1e3a8a); color: #e2e8f0; padding: 44px 40px; }
.brand-lg { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 600; color: #fff; }
.auth-hero h2 { color: #fff; font-size: 24px; line-height: 1.3; margin: 36px 0 26px; }
.hero-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.hero-list li { display: flex; gap: 12px; align-items: flex-start; }
.hero-list span { flex: none; width: 26px; height: 26px; border-radius: 50%; background: rgba(255, 255, 255, .12); display: grid; place-items: center; font-size: 13px; font-weight: 600; }
.auth-card { border: 0; margin: 0; padding: 44px 40px; border-radius: 0; }
.auth-card h1 { margin-bottom: 2px; }
.auth-card form { margin-top: 22px; }
.forgot-link { text-align: right; margin: -6px 0 16px; font-size: 13px; }

/* ---------- Generic ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
.head-actions { display: flex; gap: 8px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; margin-bottom: 18px; }
.card.narrow { max-width: 480px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.inline { display: inline; margin: 0; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty-ico { font-size: 28px; width: 56px; height: 56px; margin: 0 auto 10px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; }
.empty-state { text-align: center; padding: 40px 20px; border: 2px dashed var(--border); border-radius: var(--radius); }

label { display: block; margin-bottom: 14px; font-weight: 500; }
label.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; }
label.check input { margin-top: 3px; }
input[type=text], input[type=email], input[type=password], input[type=number], textarea, select {
    display: block; width: 100%; margin-top: 5px; padding: 9px 11px; font: inherit; color: inherit;
    border: 1px solid #d1d5db; border-radius: 8px; background: #fff; }
textarea { font-family: Consolas, monospace; font-size: 13px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 3px solid rgba(37, 99, 235, .2); border-color: var(--primary); }
input:disabled { background: var(--code-bg); color: var(--muted); }
fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px 2px; margin: 0 0 16px; }
legend { font-weight: 600; padding: 0 6px; }
.cols { display: grid; grid-template-columns: 160px 1fr; gap: 12px; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border: 1px solid #d1d5db; border-radius: 8px; background: #fff;
    color: var(--text); font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: #f9fafb; text-decoration: none; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { color: var(--danger); border-color: #fca5a5; }
.btn-danger:hover { background: #fef2f2; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; padding: 10px; }

.alert { padding: 11px 14px; border-radius: 10px; margin-bottom: 16px; border: 1px solid; }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

/* ---------- Dashboard ---------- */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.step { display: flex; gap: 12px; align-items: flex-start; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.step p { color: var(--muted); font-size: 13px; }
.step-num { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700;
    background: var(--code-bg); color: var(--muted); }
.step.current { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.step.current .step-num { background: var(--primary); color: #fff; }
.step.done .step-num { background: var(--ok); color: #fff; }
.row-form { display: flex; gap: 10px; }
.row-form input { margin: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.project-card { display: block; color: inherit; transition: border-color .15s, box-shadow .15s, transform .15s; margin: 0; }
.project-card:hover { text-decoration: none; border-color: var(--primary); box-shadow: 0 6px 18px rgba(37, 99, 235, .1); transform: translateY(-1px); }
.project-card-head { display: flex; justify-content: space-between; gap: 8px; }
.stats { display: flex; justify-content: space-between; gap: 8px; margin-top: 14px; font-size: 13px; color: var(--muted); }
.card-cta { display: inline-block; margin-top: 14px; color: var(--primary); font-weight: 500; font-size: 13px; }
.badge { display: inline-block; font-size: 12px; background: var(--primary-soft); color: var(--primary); border-radius: 10px; padding: 1px 8px; height: fit-content; }

/* ---------- Project ---------- */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; color: var(--muted); font-size: 12px; }
.stat span { display: block; font-size: 22px; font-weight: 600; color: var(--text); }
.endpoint { margin-bottom: 18px; }
.endpoint-label { margin-bottom: 6px; font-weight: 500; }
.copy-field { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.copy-field code { flex: 1; min-width: 260px; background: var(--code-bg); padding: 9px 11px; border-radius: 8px; word-break: break-all; }
.secret:not(.revealed) { color: transparent; text-shadow: 0 0 7px rgba(0, 0, 0, .5); user-select: none; }
pre.code { background: var(--code-bg); padding: 12px; border-radius: 8px; overflow: auto; white-space: pre-wrap; word-break: break-all; margin: 12px 0; }
.help { margin-top: 8px; }
.help summary { cursor: pointer; color: var(--primary); }
.help ul { color: var(--muted); padding-left: 20px; }
.danger-zone { border-color: #fecaca; }
.danger-zone form { margin-right: 8px; }

.tag { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .05em; padding: 2px 7px; border-radius: 4px; color: #fff; }
.tag-callback { background: var(--callback); }
.tag-webhook { background: var(--webhook); }
.method { font-family: Consolas, monospace; font-weight: 600; font-size: 12px; }

/* ---------- Monitor ---------- */
.filters { display: flex; gap: 8px; align-items: center; }
.filters select { width: auto; margin: 0; }
.live { font-size: 12px; font-weight: 500; color: var(--ok); vertical-align: middle; margin-left: 6px; }
.live.paused { color: var(--muted); }
.live.offline { color: var(--danger); }
.monitor { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.monitor-list { padding: 0; overflow: auto; max-height: calc(100vh - 170px); margin: 0; }
.monitor-list table { width: 100%; border-collapse: collapse; font-size: 13px; }
.monitor-list th { position: sticky; top: 0; background: #f9fafb; text-align: left; font-weight: 600; color: var(--muted);
    padding: 9px 10px; border-bottom: 1px solid var(--border); }
.monitor-list td { padding: 8px 10px; border-bottom: 1px solid var(--border); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.monitor-list tbody tr[data-id] { cursor: pointer; }
.monitor-list tbody tr[data-id]:hover { background: #f9fafb; }
.monitor-list tr.selected { background: var(--primary-soft) !important; }
.monitor-list tr.fresh td:first-child { box-shadow: inset 3px 0 0 var(--ok); font-weight: 700; }
.monitor-list .placeholder td { text-align: center; color: var(--muted); padding: 28px; }
.monitor-detail { position: sticky; top: 16px; max-height: calc(100vh - 170px); overflow: auto; margin: 0; }
.detail-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.kv { width: 100%; border-collapse: collapse; font-size: 13px; }
.kv td { padding: 5px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.kv td:first-child { color: var(--muted); white-space: nowrap; width: 1%; }
.kv td:last-child { font-family: Consolas, monospace; word-break: break-all; }
pre.body { max-height: 420px; }

/* ---------- Tour ---------- */
.tour-spot, .tour-pop { display: none; }
.tour-active .tour-spot { display: block; position: fixed; z-index: 1000; border-radius: 12px; pointer-events: auto;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .55), 0 0 0 9999px rgba(15, 23, 42, .62); transition: all .25s ease; }
.tour-active .tour-pop { display: block; position: fixed; z-index: 1001; width: min(360px, calc(100vw - 24px)); background: #fff;
    border-radius: 14px; padding: 18px; box-shadow: 0 18px 50px rgba(0, 0, 0, .25); transition: top .25s ease, left .25s ease; }
.tour-progress { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.tour-bar { flex: 1; height: 4px; background: var(--code-bg); border-radius: 4px; overflow: hidden; }
.tour-bar i { display: block; height: 100%; background: var(--primary); transition: width .25s; }
.tour-title { font-size: 16px; margin: 0 0 6px; }
.tour-text { color: #374151; margin: 0 0 16px; }
.tour-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
    .monitor { grid-template-columns: 1fr; }
    .monitor-detail { position: static; }
}
@media (max-width: 860px) {
    .sidebar { transform: translateX(-100%); }
    .menu-open .sidebar { transform: none; box-shadow: 0 0 0 9999px rgba(15, 23, 42, .5); }
    .mobile-bar { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 40;
        background: var(--side-bg); color: #fff; padding: 10px 16px; }
    .menu-toggle, .help-btn-sm { background: none; border: 1px solid #334155; color: #fff; border-radius: 8px; width: 36px; height: 36px; font-size: 16px; cursor: pointer; }
    .brand-sm { font-weight: 600; }
    .content { margin-left: 0; padding: 20px 16px 48px; }
    .steps, .stats-row { grid-template-columns: 1fr 1fr; }
    .steps .step:last-child { grid-column: 1 / -1; }
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-hero { padding: 28px 24px; }
    .auth-hero h2 { margin: 20px 0 18px; font-size: 20px; }
    .auth-card { padding: 28px 24px; }
    .row-form { flex-direction: column; }
    .cols { grid-template-columns: 1fr; }
    .filters { flex-wrap: wrap; }
}
@media (max-width: 520px) {
    .steps, .stats-row { grid-template-columns: 1fr; }
    .copy-field code { min-width: 0; width: 100%; }
}
