:root {
  --bg: #0b1020;
  --bg-elev: #11172a;
  --panel: #161d34;
  --line: #232b48;
  --text: #e8ecf8;
  --muted: #99a3c4;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --code-bg: #0a0e1c;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif; }
a { color: #a5b4fc; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Layout -------------------------------------------------------------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--bg-elev); border-right: 1px solid var(--line); padding: 24px 16px; }
.sidebar h1 { font-size: 18px; margin: 0 8px 24px; display: flex; align-items: center; gap: 8px; }
.sidebar .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--success); display: inline-block; }
.sidebar nav a { display: block; padding: 10px 12px; border-radius: 6px; color: var(--muted); font-size: 14px; margin-bottom: 4px; }
.sidebar nav a:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.sidebar .footer { position: absolute; bottom: 16px; font-size: 12px; color: var(--muted); }
.sidebar .footer .user { padding: 0 8px; margin-bottom: 8px; }
.main { padding: 24px 32px; overflow-y: auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.topbar h2 { margin: 0; font-size: 22px; }
.topbar .actions { display: flex; gap: 8px; }

/* ---- Cards / panels ----------------------------------------------------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 20px; margin-bottom: 16px; }
.card h3 { margin: 0 0 12px; font-size: 16px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.stat .value { font-size: 28px; font-weight: 600; margin-top: 6px; }

/* ---- Buttons ----------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 6px; border: 1px solid transparent; cursor: pointer; font-size: 14px; font-weight: 500; transition: background 0.15s; background: var(--panel); color: var(--text); border-color: var(--line); }
.btn:hover { background: var(--bg-elev); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ---- Forms ------------------------------------------------------------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font-size: 14px; font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--primary); }
.field textarea { font-family: ui-monospace, "SF Mono", monospace; font-size: 12px; min-height: 120px; resize: vertical; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

/* ---- Table ------------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
td.mono { font-family: ui-monospace, "SF Mono", monospace; font-size: 12px; color: var(--muted); }
td .row-actions { display: flex; gap: 4px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 500; }
.badge-success { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

/* ---- Modal ------------------------------------------------------------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 24px; width: 90%; max-width: 560px; max-height: 80vh; overflow-y: auto; }
.modal h3 { margin: 0 0 16px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---- Code / responses -------------------------------------------------- */
pre, code { font-family: ui-monospace, "SF Mono", monospace; font-size: 12px; }
pre { background: var(--code-bg); padding: 12px; border-radius: 6px; overflow-x: auto; border: 1px solid var(--line); margin: 0; white-space: pre-wrap; word-break: break-all; }
.kv { display: flex; gap: 8px; font-size: 13px; margin-bottom: 6px; }
.kv .k { color: var(--muted); min-width: 100px; }
.kv .v { font-family: ui-monospace, monospace; }

/* ---- Auth pages -------------------------------------------------------- */
.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 32px; width: 100%; max-width: 400px; }
.auth-card h1 { margin: 0 0 4px; font-size: 24px; display: flex; align-items: center; gap: 8px; }
.auth-card .subtitle { color: var(--muted); font-size: 13px; margin-bottom: 24px; }

/* ---- Toast ------------------------------------------------------------- */
.toast-container { position: fixed; top: 16px; right: 16px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 16px; border-radius: 6px; background: var(--panel); border: 1px solid var(--line); font-size: 13px; min-width: 220px; box-shadow: 0 8px 24px rgba(0,0,0,0.4); animation: slidein 0.2s ease-out; }
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--primary); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---- API tester -------------------------------------------------------- */
.tester { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.tester .col h4 { margin: 0 0 12px; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; }
.method-url { display: flex; gap: 8px; margin-bottom: 12px; }
.method-url select { width: 110px; }
.method-url input { flex: 1; }
.endpoint-list { display: flex; flex-direction: column; gap: 4px; max-height: 320px; overflow-y: auto; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 6px; padding: 8px; }
.endpoint-list .ep { padding: 6px 8px; border-radius: 4px; cursor: pointer; font-size: 12px; font-family: ui-monospace, monospace; display: flex; gap: 8px; align-items: center; }
.endpoint-list .ep:hover { background: var(--bg-elev); }
.endpoint-list .ep .m { display: inline-block; width: 50px; font-weight: 600; font-size: 10px; padding: 2px 6px; border-radius: 3px; text-align: center; }
.m-GET { background: rgba(99, 102, 241, 0.2); color: #a5b4fc; }
.m-POST { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; }
.m-DELETE { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
.response-meta { display: flex; gap: 16px; margin-bottom: 8px; font-size: 12px; color: var(--muted); }
.response-meta .status { font-weight: 600; }
.response-meta .status.ok { color: var(--success); }
.response-meta .status.err { color: var(--danger); }

/* ---- Integration guide ------------------------------------------------ */
.guide { max-width: 980px; margin: 0 auto; padding: 32px 24px; }
.guide h1 { margin-top: 0; }
.guide h2 { margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--line); }
.guide h3 { margin-top: 24px; }
.guide .tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 12px 0; }
.guide .tabs button { background: transparent; color: var(--muted); border: none; padding: 8px 16px; cursor: pointer; font-size: 13px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.guide .tabs button.active { color: var(--text); border-bottom-color: var(--primary); }
.guide pre { background: var(--code-bg); padding: 16px; border-radius: 6px; overflow-x: auto; white-space: pre; word-break: normal; }
.guide .callout { background: rgba(99, 102, 241, 0.1); border-left: 3px solid var(--primary); padding: 12px 16px; border-radius: 4px; margin: 16px 0; font-size: 14px; }
.guide .callout.warn { background: rgba(245, 158, 11, 0.1); border-left-color: var(--warning); }
.guide table { margin: 12px 0; }

/* ---- Small ----- */
.muted { color: var(--muted); }
.small { font-size: 12px; }
.spacer { height: 16px; }
.right { text-align: right; }
.row-flex { display: flex; gap: 8px; align-items: center; }
