:root {
  --bg: #f7f7f8; --panel: #ffffff; --panel-2: #fafafa; --border: #e5e5e8;
  --text: #17171a; --text-2: #5c5c66; --text-3: #8a8a94;
  --accent: #6d5cff; --accent-soft: #efedff; --accent-text: #5543e6;
  --green: #0e9f6e; --green-soft: #e3f6ef; --red: #e02424; --red-soft: #fdecec;
  --amber: #b7791f; --amber-soft: #fdf3e3;
  --shadow: 0 1px 2px rgba(16,16,20,.04), 0 4px 16px rgba(16,16,20,.05);
  --radius: 12px;
}
[data-theme="dark"] {
  --bg: #0e0e11; --panel: #16161b; --panel-2: #1c1c22; --border: #26262e;
  --text: #f2f2f4; --text-2: #a2a2ad; --text-3: #6d6d78;
  --accent: #8b7bff; --accent-soft: #241f4d; --accent-text: #a99dff;
  --green: #34d399; --green-soft: #0c2b21; --red: #f87171; --red-soft: #331515;
  --amber: #f0b45a; --amber-soft: #2e2210;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
}
* { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-feature-settings: "cv11", "calt";
  background: var(--bg); color: var(--text); font-size: 14.5px; line-height: 1.55;
  transition: background .2s, color .2s;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }
input, select { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
code, pre, .mono { font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { border-right: 1px solid var(--border); background: var(--panel); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.brand .logo { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), #a15cff); display: grid; place-items: center; color: #fff; font-size: 15px; font-weight: 800; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text-2); font-weight: 500; border: none; background: none; width: 100%; text-align: left; }
.nav-item svg { width: 17px; height: 17px; flex: none; }
.nav-item:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent-text); }
.sidebar .spacer { flex: 1; }
.main { min-width: 0;  padding: 28px 32px 64px; max-width: 1180px; width: 100%; margin: 0 auto; }
.topbar { display: none; }

.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 21px; font-weight: 700; letter-spacing: -.02em; }
.page-head .sub { color: var(--text-2); font-size: 13.5px; margin-top: 2px; }

/* ---------- components ---------- */
.grid > * { min-width: 0; }
.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card h3 { font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; text-transform: none; }
.stat { font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-sub { color: var(--text-3); font-size: 12.5px; margin-top: 2px; }

.btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border); background: var(--panel); color: var(--text); border-radius: 8px; padding: 8px 14px; font-weight: 500; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.danger { color: var(--red); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; padding: 8px 12px; border-bottom: 1px solid var(--border); }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr.clickable:hover { background: var(--panel-2); cursor: pointer; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.ok { background: var(--green-soft); color: var(--green); }
.pill.err { background: var(--red-soft); color: var(--red); }
.pill.warn { background: var(--amber-soft); color: var(--amber); }
.pill.dim { background: var(--panel-2); color: var(--text-2); border: 1px solid var(--border); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-2); }

.banner { border-radius: 10px; padding: 12px 14px; font-size: 13.5px; margin-bottom: 16px; }
.banner.err { background: var(--red-soft); color: var(--red); }
.banner.ok { background: var(--green-soft); color: var(--green); }
.banner.warn { background: var(--amber-soft); color: var(--amber); }

.codeblock { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px; overflow-x: auto; position: relative; }
.codeblock pre { white-space: pre; }
.codeblock .copy { position: absolute; top: 8px; right: 8px; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(10,10,14,.5); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 22px; width: 100%; max-width: 460px; box-shadow: var(--shadow); }
.modal h2 { font-size: 17px; margin-bottom: 12px; }

.drawer-backdrop { position: fixed; inset: 0; background: rgba(10,10,14,.4); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 94vw); background: var(--panel); border-left: 1px solid var(--border); z-index: 41; padding: 22px; overflow-y: auto; }
.drawer h2 { font-size: 16px; margin-bottom: 14px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 14px; font-size: 13.5px; }
.kv dt { color: var(--text-3); } .kv dd { word-break: break-word; }

.empty { text-align: center; padding: 48px 16px; color: var(--text-2); }
.empty .icon { font-size: 28px; margin-bottom: 8px; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; vertical-align: -4px; }
@keyframes spin { to { transform: rotate(360deg); } }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab { border: none; background: none; padding: 8px 12px; color: var(--text-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--accent-text); border-bottom-color: var(--accent); }

/* ---------- auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 70% -10%, var(--accent-soft), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .brand { justify-content: center; padding-bottom: 20px; }

/* ---------- docs ---------- */
.doc-section { margin-bottom: 34px; }
.doc-section h2 { font-size: 17px; margin-bottom: 10px; }
.doc-section h4 { font-size: 14px; margin: 16px 0 6px; }
.doc-section p, .doc-section li { color: var(--text-2); }
.doc-section ul { padding-left: 20px; }
.method { font-weight: 700; font-size: 12px; padding: 2px 7px; border-radius: 6px; margin-right: 8px; }
.method.get { background: var(--green-soft); color: var(--green); }
.method.post { background: var(--accent-soft); color: var(--accent-text); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-3 { grid-template-columns: 1fr; }
  .grid.cols-2 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; flex-direction: row; overflow-x: auto; padding: 8px; border-right: none; border-top: 1px solid var(--border); z-index: 30; gap: 2px; }
  .sidebar .brand, .sidebar .spacer, .sidebar .nav-item .label { display: none; }
  .nav-item { width: auto; padding: 8px 11px; }
  .main { padding: 18px 16px 96px; }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--panel); position: sticky; top: 0; z-index: 20; }
  th:nth-child(n+5), td:nth-child(n+5) { display: none; }
}
canvas { max-width: 100% !important; }
.chart-wrap { min-width: 0; overflow: hidden; }

/* ---------- design pass: polish + distinctiveness ---------- */
:root { --radius: 14px; }
body { letter-spacing: -.003em; }
h1, h2, h3, .brand, .stat { letter-spacing: -.025em; }
.page-head h1 { font-size: 22px; font-weight: 760; }
.brand .logo { box-shadow: 0 2px 10px rgba(109,92,255,.45); }

.card { border-radius: var(--radius); transition: border-color .15s; }
.card h3 { letter-spacing: 0; font-weight: 620; }

.btn { border-radius: 9px; font-weight: 560; transition: background .15s, border-color .15s, transform .1s, box-shadow .15s; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, var(--accent), #9d5cff); border: none; color: #fff; box-shadow: 0 2px 10px rgba(109,92,255,.35), inset 0 1px 0 rgba(255,255,255,.18); }
.btn.primary:hover { filter: brightness(1.07); background: linear-gradient(135deg, var(--accent), #9d5cff); }

.nav-item { border-radius: 9px; font-weight: 520; transition: background .12s, color .12s; }
.nav-item.active { font-weight: 640; box-shadow: inset 2px 0 0 var(--accent); }

tbody tr { transition: background .1s; }
.table-card tbody tr:hover { background: var(--panel-2); }

input, select { border-radius: 9px; }
.field label { font-weight: 580; }

.pill { font-weight: 620; letter-spacing: .01em; }

.empty.small { padding: 30px 16px; font-size: 13px; }

/* ---------- auth: split brand panel ---------- */
.auth-wrap { padding: 0; display: block; background: var(--bg); }
.auth-split { display: grid; grid-template-columns: 1.05fr 1fr; min-height: 100vh; }
.auth-hero {
  position: relative; overflow: hidden; color: #eceaff; padding: 56px 60px;
  display: flex; flex-direction: column; justify-content: space-between;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(157,92,255,.5), transparent 60%),
    radial-gradient(700px 500px at -10% 100%, rgba(84,60,230,.45), transparent 55%),
    linear-gradient(160deg, #191436 0%, #0d0b1d 70%);
}
.auth-hero::after {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,.13) 1px, transparent 1px);
  background-size: 26px 26px;
  mask-image: radial-gradient(700px 420px at 70% 20%, black, transparent 75%);
  pointer-events: none;
}
.auth-hero .brand { color: #fff; padding: 0; }
.auth-hero h1 { font-size: 34px; line-height: 1.18; font-weight: 780; letter-spacing: -.03em; color: #fff; max-width: 480px; margin: 0 0 18px; }
.auth-hero p { color: #b6b0dd; font-size: 15px; max-width: 440px; margin-bottom: 26px; }
.auth-hero ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.auth-hero li { color: #cfcaef; font-size: 13.5px; font-weight: 500; display: flex; gap: 10px; align-items: center; }
.auth-hero li::before { content: ""; width: 6px; height: 6px; border-radius: 2px; background: linear-gradient(135deg, #8b7bff, #c15cff); flex: none; }
.auth-hero .hero-foot { color: #7c76a5; font-size: 12.5px; }
.auth-side { display: grid; place-items: center; padding: 40px 24px; }
.auth-side .auth-card { max-width: 380px; }
@media (max-width: 900px) {
  .auth-split { grid-template-columns: 1fr; }
  .auth-hero { padding: 28px 24px 30px; }
  .auth-hero h1 { font-size: 24px; }
  .auth-hero p, .auth-hero ul { display: none; }
}
.chart-box{position:relative;height:230px}
@media (max-width: 720px) {
  .pg-grid { grid-template-columns: 1fr !important; }
}
@media (max-width: 720px) {
  th, td { padding: 8px 8px; }
  table { font-size: 12.5px; }
  th { font-size: 11px; letter-spacing: .02em; }
}
