:root {
  --navy: #0a1f44;
  --navy-2: #102a5c;
  --blue: #1f5fd6;
  --teal: #16c79a;
  --teal-d: #0fa784;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #fafbfe;
  --border: #e3e8f2;
  --border-2: #eef1f8;
  --text: #15233f;
  --text-muted: #5d6b86;
  --text-faint: #93a0ba;
  --danger: #d8443c;
  --warn: #e08a1e;
  --ok: #16a37a;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(16,30,70,.06), 0 2px 8px rgba(16,30,70,.04);
  --shadow-md: 0 8px 30px rgba(16,30,70,.10);
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.spacer { flex: 1; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  height: 62px; padding: 0 24px;
  background: linear-gradient(100deg, var(--navy) 0%, var(--navy-2) 60%, #173a78 100%);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255,255,255,.06), var(--shadow-md);
}
.topbar-brand { display: flex; align-items: center; gap: 13px; }
.brand-icon { width: 36px; height: 36px; filter: drop-shadow(0 2px 6px rgba(0,0,0,.3)); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 800; font-size: 1.06rem; letter-spacing: .2px; }
.brand-sub { font-size: .72rem; color: #9fb4dd; font-weight: 500; letter-spacing: .4px; text-transform: uppercase; }

.topbar-status { display: flex; align-items: center; gap: 16px; }

.env-toggle { display: inline-flex; background: rgba(255,255,255,.10); border-radius: 999px; padding: 3px; gap: 2px; }
.env-btn {
  border: 0; background: transparent; color: #cdd9f0; cursor: pointer;
  font-family: inherit; font-size: .78rem; font-weight: 600;
  padding: 6px 16px; border-radius: 999px; transition: all .22s ease; letter-spacing: .3px;
}
.env-btn:hover { color: #fff; }
.env-btn.active { background: var(--teal); color: #06251c; box-shadow: 0 2px 10px rgba(22,199,154,.4); }
.env-btn.env-prod.active { background: #ffffff; color: var(--navy); }

.auth-pill {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.08); padding: 6px 13px; border-radius: 999px;
  font-size: .76rem; font-weight: 500;
}
.status-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }
.status-pending { background: var(--warn); box-shadow: 0 0 0 0 rgba(224,138,30,.6); animation: pulse 1.6s infinite; }
.status-ok { background: var(--teal); box-shadow: 0 0 8px rgba(22,199,154,.7); }
.status-err { background: var(--danger); }
@keyframes pulse { 0%{box-shadow:0 0 0 0 rgba(224,138,30,.5)} 70%{box-shadow:0 0 0 7px rgba(224,138,30,0)} 100%{box-shadow:0 0 0 0 rgba(224,138,30,0)} }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 290px 1fr; min-height: calc(100vh - 62px); }

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 62px; height: calc(100vh - 62px); overflow-y: auto;
}
.sidebar-head { padding: 20px 20px 12px; border-bottom: 1px solid var(--border-2); }
.sidebar-title { display: block; font-weight: 700; font-size: .82rem; color: var(--navy); letter-spacing: .3px; }
.sidebar-gw { display: block; margin-top: 4px; font-family: var(--mono); font-size: .68rem; color: var(--text-faint); word-break: break-all; }

.nav { padding: 10px 12px; flex: 1; }
.nav-group { margin-bottom: 6px; }
.nav-group-title {
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .6px;
  color: var(--text-faint); padding: 12px 10px 5px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer;
  color: var(--text-muted); font-size: .82rem; font-weight: 500;
  transition: background .16s ease, color .16s ease; position: relative;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: rgba(31,95,214,.08); color: var(--navy); font-weight: 600; }
.nav-item.active::before {
  content: ''; position: absolute; left: -12px; top: 7px; bottom: 7px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--teal);
}
.m-badge {
  font-family: var(--mono); font-size: .58rem; font-weight: 600; letter-spacing: .3px;
  padding: 2px 5px; border-radius: 4px; flex: none; min-width: 34px; text-align: center;
}
.m-get { background: #e6f2ec; color: #0c8a63; }
.m-post { background: #e8eefc; color: #2257c4; }

.sidebar-foot { padding: 14px 20px 18px; border-top: 1px solid var(--border-2); display: flex; flex-direction: column; gap: 6px; }
.dot-legend { font-size: .68rem; color: var(--text-muted); display: flex; align-items: center; gap: 7px; }
.foot-note { font-size: .66rem; color: var(--text-faint); }

/* ---------- Content ---------- */
.content { padding: 28px 34px 60px; max-width: 1180px; width: 100%; }

.welcome { display: flex; align-items: flex-start; }
.welcome-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 34px 38px; box-shadow: var(--shadow-sm); max-width: 720px;
  animation: rise .5s cubic-bezier(.2,.7,.3,1);
}
.welcome-card h1 { font-size: 1.7rem; font-weight: 800; color: var(--navy); margin-bottom: 12px; letter-spacing: -.4px; }
.welcome-card p { color: var(--text-muted); font-size: .95rem; max-width: 620px; }
.welcome-meta { display: flex; gap: 14px; margin-top: 26px; flex-wrap: wrap; }
.welcome-meta > div {
  background: var(--surface-2); border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  padding: 12px 16px; min-width: 150px;
}
.meta-k { display: block; font-size: .66rem; text-transform: uppercase; letter-spacing: .5px; color: var(--text-faint); font-weight: 600; }
.meta-v { display: block; margin-top: 3px; font-weight: 600; color: var(--navy); font-size: .86rem; font-family: var(--mono); word-break: break-all; }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Endpoint view ---------- */
.endpoint-view { animation: rise .35s cubic-bezier(.2,.7,.3,1); }
.ev-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 14px; }
.ev-head-left { display: flex; gap: 14px; align-items: flex-start; }
.method-badge {
  font-family: var(--mono); font-weight: 600; font-size: .72rem; letter-spacing: .4px;
  padding: 6px 10px; border-radius: 7px; margin-top: 3px; flex: none;
}
.method-badge.GET { background: #e6f2ec; color: #0c8a63; }
.method-badge.POST { background: #e8eefc; color: #2257c4; }
.ev-header h1 { font-size: 1.42rem; font-weight: 700; color: var(--navy); letter-spacing: -.3px; }
.ev-desc { color: var(--text-muted); font-size: .9rem; margin-top: 3px; max-width: 640px; }
.ev-head-actions { display: flex; gap: 10px; flex: none; }

.ev-path {
  background: var(--navy); color: #d6e2fb; border-radius: var(--radius-sm);
  padding: 11px 16px; font-family: var(--mono); font-size: .8rem; margin-bottom: 18px;
  overflow-x: auto; white-space: nowrap;
}
.ev-path code { color: inherit; }
.ev-path .pp { color: var(--teal); }

/* ---------- Buttons ---------- */
.btn-primary, .btn-secondary {
  font-family: inherit; font-weight: 600; font-size: .84rem; cursor: pointer;
  border-radius: var(--radius-sm); padding: 9px 18px; border: 1px solid transparent;
  transition: transform .12s ease, box-shadow .18s ease, background .18s ease;
}
.btn-primary { background: var(--blue); color: #fff; box-shadow: 0 2px 12px rgba(31,95,214,.3); }
.btn-primary:hover { background: #1a55c4; transform: translateY(-1px); box-shadow: 0 5px 18px rgba(31,95,214,.36); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: #c7d1e6; background: var(--surface-2); }
.btn-secondary.small { padding: 5px 12px; font-size: .76rem; }

/* ---------- Form ---------- */
.ev-form {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px 24px; box-shadow: var(--shadow-sm); margin-bottom: 22px;
}
.form-section-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .5px; color: var(--text-faint); font-weight: 700; margin-bottom: 12px; }
.form-section-title.mt { margin-top: 22px; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 18px; }
.field-group { display: flex; flex-direction: column; gap: 5px; }
.field-group label { font-size: .76rem; font-weight: 600; color: var(--text-muted); }
.field-group label .req { color: var(--danger); margin-left: 3px; }
.field-group input, .field-group select, .body-editor {
  font-family: inherit; font-size: .85rem; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 12px; transition: border-color .16s ease, box-shadow .16s ease; width: 100%;
}
.field-group input:focus, .field-group select:focus, .body-editor:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(31,95,214,.12); background: #fff;
}
.body-editor { font-family: var(--mono); font-size: .8rem; line-height: 1.5; min-height: 170px; resize: vertical; white-space: pre; }
.form-empty { color: var(--text-faint); font-size: .85rem; font-style: italic; }

/* ---------- cURL ---------- */
.curl-panel {
  background: #07142f; border-radius: var(--radius); margin-bottom: 18px; overflow: hidden;
  border: 1px solid #15294f; animation: rise .25s ease;
}
.curl-header { display: flex; align-items: center; gap: 10px; padding: 9px 14px; background: #0b1c3d; border-bottom: 1px solid #15294f; }
.curl-label { font-size: .7rem; font-weight: 700; letter-spacing: .6px; color: #7fa0d8; text-transform: uppercase; flex: 1; }
.curl-copy, .curl-close {
  background: rgba(255,255,255,.06); border: 0; color: #c6d6f5; cursor: pointer; font-family: inherit;
  font-size: .72rem; font-weight: 600; padding: 4px 11px; border-radius: 6px; transition: background .15s ease;
}
.curl-copy:hover, .curl-close:hover { background: rgba(255,255,255,.14); }
.curl-pre { padding: 14px 16px; font-family: var(--mono); font-size: .77rem; line-height: 1.7; color: #cfe0ff; overflow-x: auto; white-space: pre; }
.curl-pre .c-flag { color: #7fd6bd; }
.curl-pre .c-url { color: #ffd479; }
.curl-pre .c-hdr { color: #9db8ec; }

/* ---------- Result ---------- */
.ev-result {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 20px 22px; min-height: 120px;
}
.result-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.result-status { font-family: var(--mono); font-weight: 600; font-size: .8rem; padding: 4px 11px; border-radius: 6px; }
.result-status.ok { background: #e6f6ef; color: var(--ok); }
.result-status.err { background: #fcebea; color: var(--danger); }
.result-meta { font-size: .78rem; color: var(--text-muted); }
.result-count { font-size: .82rem; color: var(--text-muted); margin-bottom: 10px; font-weight: 500; }
.placeholder { color: var(--text-faint); font-size: .86rem; font-style: italic; padding: 16px 0; }

.error-banner { background: #fcebea; border: 1px solid #f3c9c6; color: #a8322b; padding: 13px 16px; border-radius: var(--radius-sm); font-size: .84rem; white-space: pre-wrap; word-break: break-word; }

.loading-state { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 36px 0; color: var(--text-muted); }
.spinner { width: 30px; height: 30px; border: 3px solid var(--border); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border-2); border-radius: var(--radius-sm); }
.data-table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.data-table th {
  text-align: left; padding: 10px 13px; background: var(--surface-2); color: var(--text-muted);
  font-weight: 600; font-size: .7rem; text-transform: uppercase; letter-spacing: .4px;
  border-bottom: 1px solid var(--border); position: sticky; top: 0; white-space: nowrap;
}
.data-table td { padding: 10px 13px; border-bottom: 1px solid var(--border-2); color: var(--text); vertical-align: top; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background .12s ease; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table td.mono, .data-table td.num { font-family: var(--mono); font-size: .76rem; }
.data-table td.num { text-align: right; }
.cell-obj { color: var(--text-faint); font-style: italic; font-size: .74rem; }

.json-pre {
  font-family: var(--mono); font-size: .76rem; line-height: 1.6; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  padding: 16px; overflow-x: auto; max-height: 560px; white-space: pre; margin-top: 4px;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .content { padding: 22px 18px 50px; }
  .ev-header { flex-direction: column; }
}
