:root {
  color-scheme: light;
  --ink: #0a1835;
  --muted: #69758c;
  --line: #dde3ed;
  --surface: #ffffff;
  --canvas: #f5f7fb;
  --blue: #1263e8;
  --blue-dark: #0846ad;
  --cyan: #0b93a3;
  --green: #14865f;
  --red: #c53b48;
  --shadow: 0 8px 28px rgba(24, 43, 78, 0.08);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); color: var(--ink); }
button, input, textarea, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.portal-shell { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 28px 18px 22px; display: flex; flex-direction: column; background: #081a3b; color: #fff; }
.brand { display: flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.brand-mark { position: relative; width: 38px; height: 38px; flex: 0 0 auto; border-radius: 50%; border: 1px solid #4f83dc; background: radial-gradient(circle, #06132d 0 20%, #1d4f9e 21% 35%, #08275f 36% 52%, #3975d4 53% 66%, #0d2f70 67% 100%); box-shadow: inset 0 0 8px rgba(255,255,255,.24); }
.brand-mark i { position: absolute; inset: 7px; border: 1px solid rgba(255,255,255,.38); border-radius: 50%; }
.brand b { display: block; font-size: 22px; font-weight: 500; line-height: 1; }
.brand b span { color: #3d86ff; }
.brand small { display: block; margin-top: 4px; font-size: 10px; color: #91a5ca; text-transform: uppercase; }
.sidebar nav { display: grid; gap: 7px; margin-top: 42px; }
.sidebar nav button { height: 44px; display: flex; align-items: center; gap: 12px; padding: 0 14px; border: 0; border-radius: 6px; color: #9eb0d0; background: transparent; text-align: left; }
.sidebar nav button span { width: 24px; color: #7294cc; font-weight: 700; }
.sidebar nav button:hover, .sidebar nav button.active { color: #fff; background: #142d5b; }
.sidebar nav button.active span { color: #5c9cff; }
.sidebar-bottom { margin-top: auto; }
.service-state { display: flex; align-items: center; gap: 10px; padding: 12px; border-top: 1px solid #1d3560; border-bottom: 1px solid #1d3560; }
.service-state i { width: 9px; height: 9px; border-radius: 50%; background: #e7a323; box-shadow: 0 0 0 4px rgba(231,163,35,.12); }
.service-state i.online { background: #35ba83; box-shadow: 0 0 0 4px rgba(53,186,131,.12); }
.service-state b, .service-state small { display: block; }
.service-state b { font-size: 12px; }
.service-state small { margin-top: 2px; color: #7f95bb; font-size: 10px; }
.sign-out { width: 100%; margin-top: 13px; padding: 10px; border: 0; color: #90a5c8; background: transparent; text-align: left; }
.sign-out:hover { color: #fff; }

.portal-main { min-width: 0; }
.topbar { height: 78px; display: flex; align-items: center; gap: 18px; padding: 0 34px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.92); }
.topbar > div:first-of-type { flex: 1; }
.topbar p { margin: 0 0 3px; color: var(--blue); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.topbar h1 { margin: 0; font-size: 20px; }
.tenant-chip { display: flex; align-items: center; gap: 10px; }
.tenant-chip > span { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: #e8f0ff; color: var(--blue); font-weight: 800; }
.tenant-chip b, .tenant-chip small { display: block; }
.tenant-chip b { max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.tenant-chip small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.mobile-menu { display: none; border: 0; background: transparent; color: var(--ink); font-size: 20px; }

.portal-page { display: none; max-width: 1320px; margin: 0 auto; padding: 34px; }
.portal-page.active { display: block; }
.welcome-row { display: flex; align-items: center; justify-content: space-between; gap: 22px; margin-bottom: 24px; }
.welcome-row h2 { margin: 0; font-size: 25px; }
.welcome-row p { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.primary-button { min-height: 40px; padding: 0 18px; border: 1px solid var(--blue); border-radius: 6px; background: var(--blue); color: #fff; font-weight: 750; }
.primary-button:hover { background: var(--blue-dark); }
.primary-button:disabled { opacity: .6; cursor: wait; }
.text-button { border: 0; color: var(--blue); background: transparent; font-weight: 700; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metric-grid article, .panel { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: 0 2px 8px rgba(24,43,78,.025); }
.metric-grid article { min-height: 132px; padding: 20px; }
.metric-grid span, .metric-grid small { display: block; color: var(--muted); font-size: 12px; }
.metric-grid strong { display: block; margin: 14px 0 9px; font-size: 29px; line-height: 1; }
.content-grid { display: grid; grid-template-columns: 1.08fr .92fr; gap: 14px; margin-top: 14px; }
.panel { padding: 22px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.panel-head h3, .output-head h3 { margin: 0; font-size: 15px; }
.panel-head p, .output-head p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.panel-head > span { color: var(--blue); font-size: 13px; font-weight: 800; }
.quota-track { height: 8px; margin: 25px 0 20px; border-radius: 8px; overflow: hidden; background: #edf1f6; }
.quota-track i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--cyan)); transition: width .4s ease; }
.quota-breakdown { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.quota-breakdown div { padding-right: 10px; border-right: 1px solid var(--line); }
.quota-breakdown div:last-child { border: 0; }
.quota-breakdown span, .quota-breakdown b { display: block; }
.quota-breakdown span { color: var(--muted); font-size: 10px; }
.quota-breakdown b { margin-top: 5px; font-size: 12px; }
.compatibility { padding: 5px 8px; border-radius: 4px; background: #e9f8f2; color: var(--green) !important; font-size: 10px !important; }
.copy-field { display: flex; align-items: center; margin-top: 24px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #f8fafc; }
.copy-field code { flex: 1; min-width: 0; padding: 13px; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.copy-field button { align-self: stretch; padding: 0 14px; border: 0; border-left: 1px solid var(--line); color: var(--blue); background: #fff; }
.endpoint-meta { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.endpoint-meta span, .session-badge, .version-badge { padding: 5px 8px; border-radius: 4px; background: #f0f3f8; color: #52617a; font-size: 10px; font-weight: 700; }
.request-panel { margin-top: 14px; }
.table-wrap { margin: 17px -22px -22px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 13px 22px; border-top: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); background: #fafbfd; font-size: 10px; text-transform: uppercase; }
td code { color: #40506a; font-size: 11px; }
.status-pill { padding: 4px 7px; border-radius: 4px; background: #eaf8f1; color: var(--green); font-size: 10px; font-weight: 800; }
.status-pill.error { background: #ffedef; color: var(--red); }
.empty-row td { padding: 40px; color: var(--muted); text-align: center; }

.security-note { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; padding: 14px 16px; border: 1px solid #cfe0f8; border-radius: 6px; background: #f3f8ff; }
.security-note > span { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: var(--blue); color: #fff; font-weight: 900; }
.security-note p { margin: 1px 0; color: #455571; font-size: 12px; line-height: 1.55; }
.key-panel { padding: 0; overflow: hidden; }
.key-row { min-height: 76px; display: grid; grid-template-columns: minmax(200px,1fr) minmax(150px,.6fr) minmax(150px,.6fr) auto; align-items: center; gap: 16px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.key-row:last-child { border: 0; }
.key-row b, .key-row small { display: block; }
.key-row small { margin-top: 5px; color: var(--muted); font-size: 10px; }
.key-prefix { font-family: Consolas, monospace; color: #344561; font-size: 12px; }
.key-state { color: var(--green); font-size: 11px; font-weight: 800; }
.key-state.revoked { color: var(--red); }
.danger-button { min-width: 68px; height: 32px; border: 1px solid #e8c8cd; border-radius: 5px; color: var(--red); background: #fff; }
.danger-button:disabled { color: #9aa4b5; border-color: var(--line); cursor: default; }

.playground-grid { display: grid; grid-template-columns: minmax(340px, .78fr) minmax(400px, 1.22fr); gap: 14px; }
.playground-form { display: grid; gap: 17px; }
.playground-form label, .create-dialog label { display: grid; gap: 7px; color: #43516a; font-size: 11px; font-weight: 750; }
select, textarea, input { width: 100%; border: 1px solid #ced6e2; border-radius: 5px; outline: none; background: #fff; color: var(--ink); }
select, input { height: 40px; padding: 0 11px; }
textarea { padding: 11px; resize: vertical; line-height: 1.5; }
select:focus, textarea:focus, input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(18,99,232,.1); }
.parameter-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.run-button { width: 100%; }
.run-button span { margin-right: 7px; }
.playground-output { min-height: 520px; display: flex; flex-direction: column; background: #091a37; border-color: #091a37; color: #eaf1ff; }
.output-head { display: flex; justify-content: space-between; }
.output-head p { color: #8298bf; }
.playground-output .text-button { color: #79a9ff; }
.playground-output pre { flex: 1; margin: 24px 0 0; white-space: pre-wrap; word-break: break-word; font-family: Consolas, "SFMono-Regular", monospace; font-size: 13px; line-height: 1.75; color: #d9e6fb; }

.steps-panel { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; padding: 0; }
.step { display: flex; gap: 13px; padding: 22px; border-right: 1px solid var(--line); }
.step:last-child { border: 0; }
.step > span { width: 25px; height: 25px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 50%; background: #e9f1ff; color: var(--blue); font-size: 11px; font-weight: 800; }
.step h3 { margin: 2px 0 7px; font-size: 13px; }
.step p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
code { font-family: Consolas, "SFMono-Regular", monospace; }
.code-panel { margin-top: 14px; padding: 0; overflow: hidden; background: #091a37; border-color: #091a37; }
.code-tabs { height: 50px; display: flex; align-items: center; gap: 4px; padding: 0 14px; border-bottom: 1px solid #233757; }
.code-tabs button { height: 32px; padding: 0 11px; border: 0; border-radius: 4px; background: transparent; color: #8499bb; font-size: 11px; }
.code-tabs button.active { background: #18345f; color: #fff; }
.code-tabs .copy-code { margin-left: auto; color: #72a8ff; }
.code-panel pre { min-height: 250px; margin: 0; padding: 24px; overflow: auto; color: #dce8fa; font-size: 12px; line-height: 1.7; }
.docs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.docs-grid h3 { margin: 0 0 17px; font-size: 15px; }
.docs-grid dl { margin: 0; }
.docs-grid dl div { display: flex; gap: 15px; padding: 10px 0; border-top: 1px solid var(--line); }
.docs-grid dt { width: 38px; color: var(--blue); font-size: 10px; font-weight: 850; }
.docs-grid dd { margin: 0; font-family: Consolas, monospace; font-size: 11px; }
.docs-grid ul { margin: 0; padding-left: 18px; color: #455571; font-size: 12px; line-height: 2.1; }

.login-screen { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, 46%) 1fr; background: #fff; }
.login-panel { width: min(460px, calc(100% - 48px)); margin: auto; padding: 40px 0; }
.login-brand { color: var(--ink); margin-bottom: 70px; }
.login-brand small { color: var(--muted); }
.login-copy .product-label { color: var(--blue); font-size: 11px; font-weight: 850; text-transform: uppercase; }
.login-copy h1 { max-width: 430px; margin: 13px 0 14px; font-size: 34px; line-height: 1.15; }
.login-copy p { max-width: 420px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
#loginForm { margin-top: 38px; }
#loginForm > label { display: block; margin-bottom: 8px; font-size: 12px; font-weight: 750; }
.secret-input { display: flex; border: 1px solid #cbd4e0; border-radius: 6px; overflow: hidden; }
.secret-input:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(18,99,232,.1); }
.secret-input input { height: 46px; border: 0; border-radius: 0; box-shadow: none; }
.secret-input button { padding: 0 14px; border: 0; background: #f6f8fb; color: var(--blue); font-size: 11px; font-weight: 750; }
.form-error { min-height: 18px; margin: 8px 0; color: var(--red); font-size: 11px; }
.login-button { width: 100%; height: 46px; }
.trust-row { display: flex; gap: 20px; margin-top: 25px; color: #7b8799; font-size: 10px; }
.trust-row span::before { content: "✓"; margin-right: 5px; color: var(--green); font-weight: 900; }
.login-aside { display: grid; place-items: center; overflow: hidden; background: #071a3c; }
.aside-visual { position: relative; width: min(650px, 80%); aspect-ratio: 1; }
.aside-visual::before, .aside-visual::after { content: ""; position: absolute; inset: 12%; border: 1px solid rgba(99,151,241,.2); border-radius: 50%; }
.aside-visual::after { inset: 26%; }
.router-node { position: absolute; inset: 34%; display: grid; place-items: center; align-content: center; gap: 10px; border: 1px solid #2b5593; border-radius: 50%; background: #0b244e; color: #fff; box-shadow: 0 30px 80px rgba(0,0,0,.25); }
.brand-mark.large { width: 68px; height: 68px; }
.router-node b { font-size: 15px; }
.router-node small { max-width: 140px; color: #8fa9d1; font-size: 10px; text-align: center; }
.model-node { position: absolute; min-width: 86px; padding: 11px 13px; border: 1px solid #31578b; border-radius: 6px; background: #102b58; color: #cbdcf8; text-align: center; font-size: 12px; font-weight: 750; }
.model-node.n1 { left: 3%; top: 28%; }.model-node.n2 { right: 2%; top: 25%; }.model-node.n3 { left: 7%; bottom: 24%; }.model-node.n4 { right: 6%; bottom: 21%; }

dialog { width: min(500px, calc(100% - 32px)); padding: 24px; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 30px 80px rgba(8,24,53,.25); }
dialog::backdrop { background: rgba(5,18,43,.55); }
.dialog-head { display: flex; justify-content: space-between; gap: 15px; }
.dialog-head h2 { margin: 0; font-size: 19px; }
.dialog-head p { margin: 6px 0 0; color: var(--muted); font-size: 11px; }
.dialog-head > button { width: 32px; height: 32px; border: 0; background: transparent; color: var(--muted); font-size: 22px; }
.generated-key { display: flex; margin-top: 22px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #f6f8fb; }
.generated-key code { flex: 1; min-width: 0; padding: 13px; overflow: auto; white-space: nowrap; font-size: 11px; }
.generated-key button { border: 0; border-left: 1px solid var(--line); background: #fff; color: var(--blue); }
.dialog-warning { margin: 13px 0 0; color: #9a5a13; font-size: 11px; }
.create-dialog form { display: grid; gap: 18px; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 100; max-width: calc(100% - 32px); padding: 11px 16px; border-radius: 6px; background: #0b1d3d; color: #fff; opacity: 0; transform: translate(-50%, 12px); pointer-events: none; transition: .18s ease; font-size: 12px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 980px) {
  .portal-shell { grid-template-columns: 78px minmax(0, 1fr); }
  .sidebar { padding: 24px 12px; }
  .sidebar .brand > span:last-child, .sidebar nav button:not(.active) { font-size: 0; }
  .sidebar nav button { justify-content: center; padding: 0; font-size: 0; }
  .sidebar nav button span { width: auto; font-size: 15px; }
  .sidebar-bottom .service-state span, .sign-out { display: none; }
  .service-state { justify-content: center; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid, .playground-grid { grid-template-columns: 1fr; }
  .login-screen { grid-template-columns: 1fr; }
  .login-aside { display: none; }
}

@media (max-width: 680px) {
  .portal-shell { display: block; }
  .sidebar { position: fixed; left: -250px; z-index: 40; width: 232px; transition: left .2s ease; }
  .sidebar.open { left: 0; box-shadow: 20px 0 50px rgba(6,22,58,.25); }
  .sidebar .brand > span:last-child, .sidebar nav button:not(.active), .sidebar-bottom .service-state span, .sign-out { display: initial; font-size: initial; }
  .sidebar nav button { justify-content: flex-start; padding: 0 14px; font-size: 13px; }
  .sidebar nav button span { width: 24px; }
  .service-state { justify-content: flex-start; }
  .mobile-menu { display: block; }
  .topbar { height: 68px; padding: 0 16px; }
  .tenant-chip div { display: none; }
  .portal-page { padding: 22px 16px; }
  .welcome-row { align-items: flex-start; }
  .welcome-row h2 { font-size: 21px; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .metric-grid article { min-height: 116px; padding: 16px; }
  .metric-grid strong { font-size: 22px; }
  .quota-breakdown { grid-template-columns: 1fr; }
  .quota-breakdown div { padding: 0 0 10px; border-right: 0; border-bottom: 1px solid var(--line); }
  .key-row { grid-template-columns: 1fr auto; }
  .key-prefix, .key-row > div:nth-child(3) { grid-column: 1; }
  .key-row .danger-button { grid-column: 2; grid-row: 1; }
  .steps-panel, .docs-grid { grid-template-columns: 1fr; }
  .step { border-right: 0; border-bottom: 1px solid var(--line); }
  .parameter-row { grid-template-columns: 1fr; }
  .playground-grid { display: block; }
  .playground-output { min-height: 420px; margin-top: 12px; }
  .login-copy h1 { font-size: 28px; }
  .login-brand { margin-bottom: 54px; }
  .trust-row { gap: 10px; flex-wrap: wrap; }
}

/* phone layout (2026-10-29): larger type, no wrapped buttons, safe areas */
.alt-login { margin: 18px 0 0; color: var(--muted); font-size: 13px; }
.alt-login a { color: var(--blue); font-weight: 700; text-decoration: none; }
@media (max-width: 680px) {
  body { font-size: 15px; }
  .topbar { height: auto; min-height: 60px; padding: calc(8px + env(safe-area-inset-top)) 16px 8px; position: sticky; top: 0; z-index: 20; backdrop-filter: blur(10px); }
  .topbar p { font-size: 11px; }
  .topbar h1 { font-size: 19px; }
  .mobile-menu { width: 40px; height: 40px; }
  .welcome-row { flex-wrap: wrap; }
  .welcome-row .primary-button, .primary-button { white-space: nowrap; }
  .welcome-row p { font-size: 13.5px; }
  .metric-grid span, .metric-grid small { font-size: 12.5px; }
  .panel-head h3, .output-head h3 { font-size: 16px; }
  .panel-head p, .output-head p { font-size: 12.5px; }
  .quota-breakdown span { font-size: 12px; }
  .quota-breakdown b { font-size: 14px; }
  .copy-field code { font-size: 13px; }
  .endpoint-meta span, .session-badge, .version-badge, .compatibility { font-size: 11.5px !important; }
  th { font-size: 11.5px; }
  td { font-size: 13px; }
  .key-row small, .key-state { font-size: 12px; }
  .step p, .docs-grid ul { font-size: 13px; }
  .docs-grid dd { font-size: 12px; overflow-wrap: anywhere; }
  .playground-form label, .create-dialog label { font-size: 13px; }
  select, input { height: 44px; font-size: 16px; }
  textarea { font-size: 16px; }
  .secret-input button { font-size: 13px; white-space: nowrap; }
  .form-error, .dialog-head p, .dialog-warning { font-size: 12.5px; }
  .trust-row { font-size: 12px; }
  .login-screen { min-height: 100dvh; }
  .login-panel { padding: calc(24px + env(safe-area-inset-top)) 0 calc(24px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(16px + env(safe-area-inset-bottom)); font-size: 13.5px; }
}
