:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #172033;
  --muted: #667085;
  --line: #e4e8ef;
  --line-strong: #d6dce6;
  --primary: #3156d3;
  --primary-dark: #2443ad;
  --primary-soft: #edf1ff;
  --success: #16794b;
  --success-soft: #eaf8f1;
  --danger: #b42318;
  --danger-soft: #fff0ef;
  --warning: #a15c00;
  --warning-soft: #fff5df;
  --purple: #6d3fc0;
  --orange: #b14d13;
  --shadow: 0 8px 30px rgba(28, 39, 61, .055);
  --radius: 14px;
  --sidebar: 242px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); }
body { min-height: 100vh; line-height: 1.55; }
button, input, textarea, select { font: inherit; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: not-allowed; }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace; }
.break-all { word-break: break-all; }
.nowrap { white-space: nowrap; }
.mobile-only { display: none; }

.boot-screen { display: grid; place-items: center; min-height: 100vh; }
.boot-card { display: flex; align-items: center; gap: 14px; padding: 20px 24px; background: white; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.boot-card span { color: var(--muted); }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; flex: 0 0 auto; border-radius: 11px; color: white; background: linear-gradient(145deg, #365edc, #243b93); font-weight: 800; letter-spacing: -.5px; box-shadow: 0 7px 16px rgba(49,86,211,.22); }
.brand { display: flex; align-items: center; gap: 11px; }
.brand > div:last-child { min-width: 0; display: flex; flex-direction: column; }
.brand strong { font-size: 15px; line-height: 1.3; }
.brand span { color: #8590a5; font-size: 11px; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 50; display: flex; flex-direction: column; width: var(--sidebar); background: #111827; color: #d8dfed; border-right: 1px solid #1f2937; }
.sidebar .brand { height: 76px; padding: 0 20px; border-bottom: 1px solid rgba(255,255,255,.07); }
.sidebar .brand strong { color: white; }
.side-nav { flex: 1; padding: 16px 12px 24px; overflow-y: auto; }
.nav-section + .nav-section { margin-top: 18px; }
.nav-section-title { padding: 0 10px 7px; color: #7f8ba1; font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; }
.nav-item { display: flex; align-items: center; gap: 11px; min-height: 39px; padding: 8px 10px; border-radius: 9px; color: #aeb9cc; font-size: 14px; transition: background .16s, color .16s; }
.nav-item:hover { color: white; background: rgba(255,255,255,.055); }
.nav-item.active { color: white; background: #243867; }
.nav-icon { display: grid; place-items: center; width: 22px; height: 22px; color: #aebcf7; font-size: 13px; font-weight: 750; }
.sidebar-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 15px 19px; border-top: 1px solid rgba(255,255,255,.07); color: #8190aa; font-size: 11px; }
.sidebar-foot a:hover { color: white; }
.sidebar-backdrop { display: none; }
.workspace { min-width: 0; width: calc(100% - var(--sidebar)); margin-left: var(--sidebar); }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; min-height: 76px; padding: 13px 30px; background: rgba(255,255,255,.92); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.page-heading { flex: 1; min-width: 0; }
.page-heading h1 { margin: 0; font-size: 21px; letter-spacing: -.02em; }
.page-heading p { margin: 2px 0 0; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.admin-chip { padding: 6px 10px; color: #344054; background: var(--panel-soft); border: 1px solid var(--line); border-radius: 999px; font-size: 12px; }
.content { max-width: 1500px; margin: 0 auto; padding: 28px 30px 58px; }

.panel { margin-bottom: 20px; padding: 22px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.compact-panel { padding: 16px 18px; }
.panel h2 { margin: 0; font-size: 17px; letter-spacing: -.015em; }
.panel h3 { margin: 0 0 10px; font-size: 14px; }
.panel p { color: var(--muted); }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.panel-head p { margin: 3px 0 0; font-size: 12px; }
.panel-actions, .form-actions { display: flex; align-items: center; gap: 10px; margin-top: 18px; }
.button-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 39px; padding: 8px 15px; border: 1px solid transparent; border-radius: 9px; font-weight: 650; font-size: 13px; transition: transform .1s, background .15s, border-color .15s; }
.button:active { transform: translateY(1px); }
.button-primary { color: white; background: var(--primary); border-color: var(--primary); }
.button-primary:hover { background: var(--primary-dark); }
.button-secondary { color: #2847ad; background: var(--primary-soft); border-color: #d8e0ff; }
.button-ghost { color: #344054; background: white; border-color: var(--line-strong); }
.button-ghost:hover { background: var(--panel-soft); }
.button-warning { color: #844900; background: var(--warning-soft); border-color: #f4d899; }
.button-danger { color: white; background: var(--danger); border-color: var(--danger); }
.button-small { min-height: 32px; padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.button-block { width: 100%; }
.icon-button { display: inline-grid; place-items: center; min-width: 34px; height: 34px; padding: 0 8px; color: #475467; background: white; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; }

.metric-grid { display: grid; gap: 15px; margin-bottom: 20px; }
.metric-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric-card { position: relative; min-height: 124px; padding: 20px; overflow: hidden; background: white; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.metric-card::after { content: ''; position: absolute; right: -18px; bottom: -25px; width: 85px; height: 85px; border-radius: 50%; background: #f1f4f8; }
.metric-card span { display: block; position: relative; z-index: 1; color: var(--muted); font-size: 12px; }
.metric-card strong { display: block; position: relative; z-index: 1; margin-top: 8px; font-size: 29px; letter-spacing: -.04em; }
.metric-card small { position: relative; z-index: 1; color: #8792a5; }
.metric-blue::after { background: #e8eeff; }.metric-green::after { background: #e4f6ec; }.metric-purple::after { background: #f0eafb; }.metric-orange::after { background: #fff0e7; }

.two-column { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.two-column.wide-left { grid-template-columns: minmax(0, 1.6fr) minmax(280px, .65fr); }
.two-column.wide-right { grid-template-columns: minmax(310px, .7fr) minmax(0, 1.35fr); }
.counter-list { display: grid; gap: 0; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.counter-list + .counter-list { margin-top: 14px; }
.counter-row { display: grid; grid-template-columns: minmax(140px, 1.4fr) repeat(3, minmax(80px, .7fr)); align-items: center; gap: 12px; padding: 12px 14px; background: white; font-size: 12px; }
.counter-row + .counter-row { border-top: 1px solid var(--line); }
.counter-row span { color: var(--muted); text-align: right; }
.counter-list.compact .counter-row { padding: 9px 12px; }
.token-summary { display: grid; gap: 12px; }
.token-summary > div { padding: 15px; background: var(--panel-soft); border: 1px solid var(--line); border-radius: 10px; }
.token-summary span { display: block; color: var(--muted); font-size: 12px; }
.token-summary strong { display: block; margin-top: 5px; font-size: 20px; }
.system-strip { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.system-strip > div { padding: 14px; background: var(--panel-soft); border: 1px solid var(--line); border-radius: 10px; }
.system-strip span, .detail-grid span, .detail-list span { display: block; color: var(--muted); font-size: 11px; }
.system-strip strong, .detail-grid strong { display: block; margin-top: 4px; font-size: 14px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; }
.form-grid.inner { margin-top: 15px; }
.form-stack { display: grid; gap: 16px; }
.full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; min-width: 0; gap: 6px; }
.field > span, .fieldset legend { color: #344054; font-size: 12px; font-weight: 650; }
.field small, .check-card small, form > small { color: var(--muted); font-size: 11px; }
input, textarea, select { width: 100%; color: var(--text); background: white; border: 1px solid var(--line-strong); border-radius: 9px; outline: none; transition: border-color .15s, box-shadow .15s; }
input, select { height: 41px; padding: 8px 11px; }
textarea { min-height: 86px; padding: 10px 11px; resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus { border-color: #7891e8; box-shadow: 0 0 0 3px rgba(49,86,211,.1); }
.fieldset { margin: 0; padding: 12px 14px 14px; border: 1px solid var(--line); border-radius: 10px; }
.fieldset legend { padding: 0 6px; }
.fieldset .check { display: inline-flex; margin-right: 18px; }
.check { display: flex; align-items: center; gap: 8px; color: #475467; font-size: 13px; }
.check input, .check-card input { width: 16px; height: 16px; padding: 0; accent-color: var(--primary); }
.check-card { display: flex; align-items: flex-start; gap: 10px; padding: 13px 14px; background: var(--panel-soft); border: 1px solid var(--line); border-radius: 10px; }
.check-card > span { display: flex; flex-direction: column; }
.switch-group { padding: 8px 0; }
.switch-group .check { margin-top: 4px; }
.inline-form, .toolbar { display: flex; align-items: flex-end; gap: 12px; }
.grow { flex: 1; }
.advanced { padding: 12px 14px; background: var(--panel-soft); border: 1px solid var(--line); border-radius: 10px; }
.advanced summary { cursor: pointer; color: #344054; font-size: 13px; font-weight: 650; }

.badge { display: inline-flex; align-items: center; min-height: 25px; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge-neutral { color: #475467; background: #f2f4f7; }.badge-success { color: var(--success); background: var(--success-soft); }.badge-danger { color: var(--danger); background: var(--danger-soft); }.badge-warning { color: var(--warning); background: var(--warning-soft); }
.alert { margin: 14px 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; font-size: 12px; }
.alert strong { display: block; margin-bottom: 2px; }
.alert code { display: inline-block; margin-top: 6px; }
.alert-danger { color: #8d1b13; background: var(--danger-soft); border-color: #f3c7c3; }.alert-info { color: #304466; background: #f0f5ff; border-color: #d7e3ff; }
.loading-panel { display: flex; align-items: center; justify-content: center; gap: 11px; min-height: 180px; color: var(--muted); }
.spinner { width: 22px; height: 22px; border: 2px solid #dce3ef; border-top-color: var(--primary); border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { padding: 42px 18px; color: var(--muted); background: var(--panel-soft); border: 1px dashed var(--line-strong); border-radius: 10px; text-align: center; font-size: 13px; }
.muted-box { padding: 13px 14px; color: var(--muted); background: var(--panel-soft); border: 1px solid var(--line); border-radius: 10px; font-size: 12px; }
.eyebrow { color: var(--primary); font-size: 10px; font-weight: 800; letter-spacing: .13em; }

.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { padding: 10px 12px; color: #667085; background: #f8fafc; border-bottom: 1px solid var(--line); text-align: left; font-size: 11px; font-weight: 700; white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfcfe; }
td code { padding: 2px 5px; color: #31415e; background: #f2f4f7; border-radius: 5px; }

.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.detail-grid > div { padding: 13px 14px; background: var(--panel-soft); border: 1px solid var(--line); border-radius: 10px; }
.detail-list { display: grid; gap: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.detail-list > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; }
.detail-list > div + div { border-top: 1px solid var(--line); }
.detail-list span { display: inline; }
.danger-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 18px; padding-top: 17px; border-top: 1px solid var(--line); }
.note-panel p { margin: 12px 0; font-size: 12px; }
.note-panel code { padding: 2px 5px; background: #f1f3f7; border-radius: 5px; }

.generated-panel { margin-top: 20px; }
.key-output-list { display: grid; gap: 8px; max-height: 500px; overflow: auto; }
.key-output-list > div { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 11px; background: var(--panel-soft); border: 1px solid var(--line); border-radius: 8px; }
.key-output-list code { min-width: 0; word-break: break-all; }

.model-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-bottom: 20px; }
.model-card { position: relative; display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 17px; margin: 0; }
.model-card.model-active { border-color: #9eafea; box-shadow: 0 8px 30px rgba(49,86,211,.09); }
.model-slot { display: grid; place-items: center; width: 52px; height: 52px; color: white; background: #283d74; border-radius: 13px; font-size: 22px; font-weight: 800; }
.model-card-body h2 { margin: 8px 0 5px; }
.model-card-body p { margin: 0; min-height: 38px; font-size: 11px; }
.model-card dl { display: flex; gap: 24px; margin: 13px 0 0; }
.model-card dl div { min-width: 0; }.model-card dt { color: var(--muted); font-size: 10px; }.model-card dd { margin: 2px 0 0; font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.model-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; padding-top: 15px; border-top: 1px solid var(--line); }
.model-editor textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.empty-editor { text-align: center; padding: 48px; }

.test-result pre, .code-block pre, #cleanup-result pre { margin: 0; padding: 15px; max-height: 520px; overflow: auto; color: #d7e2f6; background: #111827; border-radius: 10px; font-size: 11px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 20px; }
.stats-card .counter-row { grid-template-columns: minmax(120px, 1fr); }
.stats-card .counter-row span { text-align: left; }
.code-block { margin-bottom: 20px; overflow: hidden; background: #111827; border: 1px solid #243048; border-radius: var(--radius); box-shadow: var(--shadow); }
.code-block > div { display: flex; align-items: center; justify-content: space-between; padding: 10px 13px; color: #e9eef8; border-bottom: 1px solid #27344e; }
.code-block pre { border-radius: 0; max-height: none; }
.steps { display: grid; gap: 8px; padding-left: 20px; color: #475467; font-size: 13px; }
.flow { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 10px; padding: 17px; background: var(--panel-soft); border: 1px solid var(--line); border-radius: 10px; }
.flow span { padding: 8px 12px; background: white; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; }.flow b { color: #8290a8; }

.auth-page { min-height: 100vh; }
.auth-layout { display: grid; grid-template-columns: minmax(370px, .9fr) minmax(470px, 1.1fr); min-height: 100vh; }
.auth-intro { display: flex; flex-direction: column; padding: 42px 8vw 48px; color: white; background: radial-gradient(circle at 25% 15%, #334f94, transparent 34%), linear-gradient(145deg, #121b31, #1c2f5f); }
.brand-dark .brand-mark { background: white; color: #233b7f; }.brand-dark strong { color: white; }.brand-dark span { color: #b8c5df; }
.auth-copy { margin: auto 0; max-width: 550px; }.auth-copy h1 { margin: 0 0 18px; font-size: clamp(38px, 5vw, 70px); letter-spacing: -.055em; }.auth-copy p { color: #cad4e8; font-size: 15px; line-height: 1.8; }
.auth-public-link { color: #c8d4ef; font-size: 13px; }
.auth-panel { display: grid; place-items: center; padding: 35px; background: #f6f8fb; }
.auth-card { display: grid; gap: 18px; width: min(430px, 100%); padding: 34px; background: white; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 20px 60px rgba(23,32,51,.09); }
.auth-card h2 { margin: 5px 0 0; font-size: 27px; }.auth-card p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }.auth-card > small { color: var(--muted); text-align: center; }

.public-page { min-height: 100vh; background: #f5f7fb; }
.public-header { display: flex; align-items: center; justify-content: space-between; height: 74px; padding: 0 max(24px, calc((100vw - 1180px)/2)); background: white; border-bottom: 1px solid var(--line); }
.public-main { max-width: 1180px; min-height: calc(100vh - 140px); margin: 0 auto; padding: 58px 24px; }
.query-hero { max-width: 780px; margin: 0 auto 34px; text-align: center; }.query-hero h1 { margin: 6px 0 8px; font-size: 38px; letter-spacing: -.045em; }.query-hero p { margin: 0 0 24px; color: var(--muted); }.query-hero small { display: block; margin-top: 9px; color: #8993a5; }
.query-form { display: flex; gap: 10px; }.query-form input { height: 48px; padding: 10px 14px; box-shadow: var(--shadow); }.query-form .button { min-height: 48px; padding-inline: 25px; }
.public-footer { padding: 20px; color: var(--muted); text-align: center; font-size: 11px; }
.result-panel h2 { max-width: 800px; font-size: 17px; }

#toast-root { position: fixed; z-index: 1000; right: 22px; bottom: 22px; display: grid; gap: 9px; pointer-events: none; }
.toast { min-width: 260px; max-width: 440px; padding: 12px 15px; color: #344054; background: white; border: 1px solid var(--line); border-left: 4px solid var(--primary); border-radius: 9px; box-shadow: 0 12px 35px rgba(20,30,50,.16); opacity: 0; transform: translateY(10px); transition: opacity .2s, transform .2s; font-size: 13px; }
.toast-show { opacity: 1; transform: none; }.toast-success { border-left-color: var(--success); }.toast-error { border-left-color: var(--danger); }

@media (max-width: 1120px) {
  .metric-grid.four { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: 1fr; }
  .system-strip { grid-template-columns: repeat(3, 1fr); }
  .detail-grid { grid-template-columns: repeat(2, 1fr); }
  .model-grid { grid-template-columns: 1fr; }
  .two-column.wide-right { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .mobile-only { display: inline-grid; }
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: 20px 0 45px rgba(0,0,0,.16); }
  .sidebar.sidebar-open { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 40; display: block; visibility: hidden; opacity: 0; background: rgba(13,20,35,.42); border: 0; transition: opacity .2s, visibility .2s; }
  .sidebar-backdrop.show { visibility: visible; opacity: 1; }
  .workspace { width: 100%; margin-left: 0; }
  .topbar { padding: 12px 16px; }.content { padding: 20px 16px 44px; }
  .two-column, .two-column.wide-left { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }.full { grid-column: auto; }
  .auth-layout { grid-template-columns: 1fr; }.auth-intro { display: none; }.auth-panel { min-height: 100vh; padding: 20px; }
  .system-strip { grid-template-columns: repeat(2, 1fr); }
  .counter-row { grid-template-columns: 1fr 1fr; }.counter-row strong { grid-column: 1/-1; }.counter-row span { text-align: left; }
  .inline-form, .toolbar { align-items: stretch; flex-direction: column; }.inline-form .button, .toolbar .button { width: 100%; }
}

@media (max-width: 540px) {
  .metric-grid.four { grid-template-columns: 1fr; }
  .topbar-actions .admin-chip { display: none; }
  .page-heading h1 { font-size: 18px; }.page-heading p { display: none; }
  .panel { padding: 17px; }.panel-head { flex-direction: column; }
  .detail-grid, .system-strip { grid-template-columns: 1fr; }
  .query-form { flex-direction: column; }.query-form .button { width: 100%; }
  .query-hero h1 { font-size: 30px; }
  .public-header { padding: 0 15px; }.public-main { padding: 38px 14px; }
  .model-card { grid-template-columns: 44px minmax(0,1fr); }.model-slot { width: 44px; height: 44px; }
  #toast-root { right: 12px; bottom: 12px; left: 12px; }.toast { min-width: 0; width: 100%; }
}

.example-preview { min-width: 190px; max-width: 330px; white-space: normal; line-height: 1.55; color: var(--text-soft); }


.table-sub { margin-top: 3px; color: var(--muted); font-size: 10px; }
.compact-form { align-content: start; }
