:root {
    --bg: #0f172a;
    --bg-soft: #1e293b;
    --panel: #ffffff;
    --panel-soft: #f8fafc;
    --border: #e2e8f0;
    --border-dark: #334155;
    --text: #0f172a;
    --text-soft: #64748b;
    --text-invert: #e2e8f0;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --green: #16a34a;
    --amber: #d97706;
    --red: #dc2626;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 8px 24px rgba(15, 23, 42, .06);
    --mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
    font-family: 'Cairo', system-ui, sans-serif;
    background: var(--panel-soft);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

.app {
    display: grid;
    grid-template-columns: 320px 1fr;
    height: 100vh;
    overflow: hidden;
    min-width: 0;
}

/* ── Sidebar ─────────────────────────── */
.sidebar {
    background: var(--bg);
    color: var(--text-invert);
    display: flex;
    flex-direction: column;
    border-inline-start: 1px solid var(--border-dark);
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    contain: layout paint;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px;
    border-bottom: 1px solid var(--border-dark);
}

.brand__logo {
    width: 42px; height: 42px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--primary), #38bdf8);
    border-radius: var(--radius-sm);
    font-weight: 800; font-size: 22px; color: #fff;
}

.brand__text h1 { font-size: 17px; font-weight: 800; }
.brand__text span { font-size: 12px; color: #94a3b8; }

.search-box { padding: 14px 16px; }
.search-box input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-soft);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-sm);
    color: var(--text-invert);
    font-family: inherit;
    font-size: 13px;
}
.search-box input:focus { outline: none; border-color: var(--primary); }

.nav {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    padding: 4px 10px 16px;
}
.nav__loading { padding: 20px; color: #64748b; font-size: 13px; text-align: center; }

.system { margin-bottom: 6px; min-width: 0; overflow: hidden; }
.system__head {
    display: flex; align-items: center; gap: 8px;
    width: 100%;
    padding: 11px 12px;
    background: transparent; border: none;
    color: var(--text-invert);
    font-family: inherit; font-size: 14px; font-weight: 700;
    cursor: pointer; border-radius: var(--radius-sm);
    text-align: start;
    min-width: 0;
}
.system__head:hover { background: var(--bg-soft); }
.system__dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.system__name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.system__count { font-size: 11px; color: #64748b; font-weight: 600; }
.system__chevron { transition: transform .2s; font-size: 11px; color: #64748b; }
.system--open .system__chevron { transform: rotate(90deg); }

.badge-soon {
    font-size: 10px; font-weight: 700;
    padding: 2px 7px; border-radius: 20px;
    background: rgba(217, 119, 6, .18); color: #fbbf24;
}

.system__body {
    display: none;
    padding: 2px 0 6px;
    max-width: 100%;
    overflow: hidden;
}
.system--open .system__body { display: block; }
.system--disabled .system__head { cursor: default; opacity: .65; }
.system--disabled .system__head:hover { background: transparent; }

.group__title {
    padding: 8px 14px 4px;
    font-size: 11px; font-weight: 700;
    color: #64748b; letter-spacing: .3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.endpoint-link {
    display: flex; align-items: center; gap: 8px;
    width: 100%;
    padding: 7px 12px 7px 14px;
    background: transparent; border: none;
    color: #cbd5e1; cursor: pointer;
    font-family: inherit; font-size: 13px;
    border-radius: var(--radius-sm);
    text-align: start;
    min-width: 0;
    overflow: hidden;
}
.endpoint-link span:last-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.endpoint-link:hover { background: var(--bg-soft); color: #fff; }
.endpoint-link--active { background: var(--primary); color: #fff; }
.endpoint-link--active:hover { background: var(--primary); }

.m-tag {
    font-family: var(--mono); font-size: 10px; font-weight: 700;
    padding: 2px 6px; border-radius: 4px; flex-shrink: 0;
    background: #14532d; color: #4ade80;
}
.m-tag--post   { background: #1e3a8a; color: #93c5fd; }
.m-tag--put    { background: #78350f; color: #fbbf24; }
.m-tag--patch  { background: #78350f; color: #fbbf24; }
.m-tag--delete { background: #7f1d1d; color: #fca5a5; }
.method--post   { background: #1e3a8a !important; color: #93c5fd !important; }
.method--put    { background: #78350f !important; color: #fbbf24 !important; }
.method--patch  { background: #78350f !important; color: #fbbf24 !important; }
.method--delete { background: #7f1d1d !important; color: #fca5a5 !important; }

.sidebar__footer { padding: 14px 16px; border-top: 1px solid var(--border-dark); }
.base-url { display: flex; flex-direction: column; gap: 6px; }
.base-url span { font-size: 11px; color: #94a3b8; }
.base-url input {
    padding: 8px 12px; font-size: 12px; font-family: var(--mono);
    background: var(--bg-soft); border: 1px solid var(--border-dark);
    border-radius: var(--radius-sm); color: var(--text-invert);
}
.base-url input:focus { outline: none; border-color: var(--primary); }

/* ── Main ─────────────────────────── */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px; height: 60px;
    background: var(--panel); border-bottom: 1px solid var(--border);
}
.tabs { display: flex; gap: 4px; }
.tab {
    padding: 8px 18px; border: none; background: transparent;
    font-family: inherit; font-size: 14px; font-weight: 600;
    color: var(--text-soft); cursor: pointer;
    border-radius: var(--radius-sm);
}
.tab:hover { background: var(--panel-soft); }
.tab--active { background: #eff6ff; color: var(--primary); }
.topbar__meta { font-size: 12px; color: var(--text-soft); }

.view {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 28px;
    display: none;
}
.view--active { display: block; }

/* ── Empty state ─────────────── */
.empty-state {
    height: 100%; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    text-align: center; color: var(--text-soft);
}
.empty-state__icon { font-size: 54px; margin-bottom: 12px; }
.empty-state h2 { font-size: 20px; color: var(--text); margin-bottom: 6px; }
.empty-state p { max-width: 420px; font-size: 14px; }

/* ── Endpoint panel ─────────────── */
.endpoint { max-width: 920px; margin: 0 auto; }
.endpoint__head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }

.method {
    font-family: var(--mono); font-weight: 700; font-size: 13px;
    padding: 5px 12px; border-radius: 6px;
    background: #dcfce7; color: #15803d;
}
.endpoint__path {
    font-family: var(--mono); font-size: 15px; font-weight: 600;
    color: var(--text); direction: ltr; word-break: break-all;
}
.endpoint__desc { color: var(--text-soft); font-size: 14px; margin-bottom: 22px; }

.params__group { margin-bottom: 20px; }
.params__group h3 { font-size: 13px; color: var(--text-soft); margin-bottom: 10px; font-weight: 700; }
.params__list { display: grid; gap: 12px; }

.param {
    display: grid; grid-template-columns: 200px 1fr; gap: 14px;
    align-items: start;
    background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 12px 14px;
}
.param__label { display: flex; flex-direction: column; gap: 3px; padding-top: 7px; }
.param__name { font-family: var(--mono); font-size: 13px; font-weight: 600; direction: ltr; text-align: start; }
.param__req { color: var(--red); }
.param__hint { font-size: 11px; color: var(--text-soft); }
.param__control { display: flex; flex-direction: column; gap: 4px; }
.param input, .param select {
    width: 100%; padding: 9px 12px;
    border: 1px solid var(--border); border-radius: 6px;
    font-family: inherit; font-size: 13px; background: var(--panel-soft);
}
.param input:focus, .param select:focus { outline: none; border-color: var(--primary); background: #fff; }
.param input[type="text"], .param input[type="number"] { font-family: var(--mono); direction: ltr; text-align: start; }
.param__type { font-size: 10px; color: var(--text-soft); font-family: var(--mono); }

/* ── Request bar ─────────────── */
.request-bar {
    display: flex; align-items: center; gap: 12px;
    background: var(--bg); border-radius: var(--radius);
    padding: 12px 16px; margin-top: 6px;
}
.request-url {
    flex: 1; font-family: var(--mono); font-size: 12px;
    color: #7dd3fc; direction: ltr; word-break: break-all;
}
.request-bar__actions { display: flex; gap: 8px; flex-shrink: 0; }

.btn {
    font-family: inherit; font-weight: 700; font-size: 13px;
    padding: 9px 18px; border-radius: var(--radius-sm);
    border: none; cursor: pointer; transition: .15s;
}
.btn--sm { padding: 5px 12px; font-size: 12px; }
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-dark); }
.btn--primary:disabled { opacity: .6; cursor: wait; }
.btn--ghost { background: rgba(255,255,255,.08); color: #e2e8f0; }
.btn--ghost:hover { background: rgba(255,255,255,.16); }
.response .btn--ghost { background: var(--panel-soft); color: var(--text-soft); border: 1px solid var(--border); }
.response .btn--ghost:hover { background: var(--border); }

/* ── Response ─────────────── */
.response { margin-top: 22px; }
.response__head {
    display: flex; align-items: center; gap: 14px;
    padding: 10px 14px; background: var(--panel);
    border: 1px solid var(--border); border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
}
.status-pill {
    font-family: var(--mono); font-weight: 700; font-size: 13px;
    padding: 4px 12px; border-radius: 20px;
}
.status-pill--ok { background: #dcfce7; color: #15803d; }
.status-pill--err { background: #fee2e2; color: #b91c1c; }
.response__time, .response__size { font-size: 12px; color: var(--text-soft); }
.response__head .btn { margin-inline-start: auto; }

.response__body {
    margin: 0; padding: 18px;
    background: var(--bg); color: #e2e8f0;
    border-radius: 0 0 var(--radius) var(--radius);
    overflow-x: auto; max-height: 460px;
    font-family: var(--mono); font-size: 12.5px; line-height: 1.7;
    direction: ltr; text-align: start;
}
.tok-key { color: #7dd3fc; }
.tok-str { color: #86efac; }
.tok-num { color: #fca5a5; }
.tok-bool { color: #c4b5fd; }
.tok-null { color: #94a3b8; }

/* ── Output field help ─────────────── */
.output-help {
    margin-top: 16px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.output-help__head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--panel-soft);
}
.output-help__head h3 { font-size: 14px; }
.output-help__head span { font-size: 12px; color: var(--text-soft); }
.output-help__body {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 10px;
    padding: 14px;
}
.field-help {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    background: #fff;
}
.field-help code {
    display: inline-block;
    font-family: var(--mono);
    direction: ltr;
    font-size: 12px;
    color: var(--primary);
    margin-bottom: 4px;
}
.field-help p { font-size: 12.5px; color: var(--text-soft); }
.field-help__meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.field-help__meta .chip { font-size: 9px; }

/* ── Docs ─────────────── */
.docs { max-width: 960px; margin: 0 auto; }
.docs__intro { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; margin-bottom: 24px; }
.docs__intro h2 { font-size: 22px; margin-bottom: 8px; }
.docs__intro p { color: var(--text-soft); font-size: 14px; }
.docs__stats { display: flex; gap: 14px; margin-top: 16px; flex-wrap: wrap; }
.stat { background: var(--panel-soft); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 18px; min-width: 110px; }
.stat__num { font-size: 24px; font-weight: 800; color: var(--primary); }
.stat__label { font-size: 12px; color: var(--text-soft); }

.docs-system { margin-bottom: 30px; }
.docs-system__head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.docs-system__head h3 { font-size: 18px; }
.docs-system__desc { color: var(--text-soft); font-size: 13px; margin-bottom: 14px; }

.docs-ep {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px;
}
.docs-ep__head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.docs-ep__path { font-family: var(--mono); font-size: 13px; direction: ltr; word-break: break-all; }
.docs-ep__name { font-size: 13px; color: var(--text-soft); margin-inline-start: auto; }
.docs-ep__desc { font-size: 13px; color: var(--text-soft); margin-bottom: 10px; }

.docs-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.docs-table th, .docs-table td { text-align: start; padding: 7px 10px; border-bottom: 1px solid var(--border); }
.docs-table th { color: var(--text-soft); font-weight: 700; font-size: 11px; }
.docs-table td:first-child { font-family: var(--mono); direction: ltr; }
.chip { display: inline-block; font-size: 10px; padding: 1px 7px; border-radius: 20px; background: var(--panel-soft); border: 1px solid var(--border); color: var(--text-soft); }
.chip--req { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }

/* ── Toast ─────────────── */
.toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    background: var(--bg); color: #fff; padding: 11px 22px;
    border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
    box-shadow: var(--shadow); z-index: 100;
    animation: toastIn .2s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ── Scrollbar ─────────────── */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 20px; }
.nav::-webkit-scrollbar-thumb, .response__body::-webkit-scrollbar-thumb { background: #475569; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 860px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { position: fixed; z-index: 50; width: 300px; height: 100vh; transform: translateX(100%); transition: transform .25s; }
    .param { grid-template-columns: 1fr; }
}
