:root {
  color-scheme: light;
  --bg: #e8edf4;
  --surface: #e8edf4;
  --text: #27364a;
  --muted: #708199;
  --accent: #688ee8;
  --accent-dark: #436dd1;
  --green: #3fae95;
  --red: #d97582;
  --shadow: 9px 9px 20px #c8d1de, -9px -9px 20px #fff;
  --shadow-small: 5px 5px 11px #cbd4e0, -5px -5px 11px #fff;
  --inset: inset 5px 5px 11px #cbd4e0, inset -5px -5px 11px #fff;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { min-height: 100vh; margin: 0; color: var(--text); background: var(--bg); font-size: 14px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden], .section { display: none !important; }
.section.active { display: block !important; }
.ambient { position: fixed; z-index: 0; border-radius: 50%; pointer-events: none; filter: blur(5px); }
.ambient-a { width: 320px; height: 320px; top: -155px; left: -100px; background: rgba(142, 175, 244, .22); }
.ambient-b { width: 420px; height: 420px; top: 100px; right: -250px; background: rgba(125, 221, 212, .12); }
.shell { position: relative; z-index: 1; width: min(1330px, calc(100% - 42px)); margin: auto; padding: 28px 0 46px; }
.raised { border: 1px solid rgba(255,255,255,.65); background: var(--surface); box-shadow: var(--shadow); }
.inset { background: var(--surface); box-shadow: var(--inset); }
.eyebrow { margin: 0; color: var(--accent-dark); font-size: 10px; font-weight: 750; letter-spacing: .17em; }
.muted { color: var(--muted); }
.brand-icon { display: grid; width: 49px; height: 49px; place-items: center; border-radius: 16px; background: linear-gradient(145deg, #8aabf6, #5f86e8); color: white; font-size: 25px; font-weight: 850; box-shadow: 5px 5px 11px #c1ccdf, -5px -5px 11px #fff; }
.brand-icon.small { width: 37px; height: 37px; border-radius: 12px; font-size: 19px; }
.login-view { display: grid; place-items: center; min-height: calc(100vh - 60px); }
.login-card { width: min(440px, 100%); border-radius: 29px; padding: 39px; }
.login-card .eyebrow { margin: 24px 0 7px; }
.login-card h1 { margin: 0 0 6px; font-size: 33px; letter-spacing: -.05em; }
.login-card .muted { margin: 0 0 32px; }
.login-card form { display: grid; gap: 17px; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; }
input, select, textarea { border: 0; border-radius: 13px; background: var(--surface); box-shadow: var(--inset); padding: 12px 14px; }
input:focus, select:focus, textarea:focus { background: #eef2f8; }
button { border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-small); padding: 9px 13px; transition: transform .16s, box-shadow .16s; }
button:hover { transform: translateY(-1px); }
button:active, button.active { box-shadow: var(--inset); transform: translateY(0); }
button:disabled { opacity: .55; cursor: wait; }
.primary { color: #fff; background: linear-gradient(145deg, #7ea1f0, #567edb); box-shadow: 6px 6px 15px #bcc8db, -5px -5px 14px #fff; font-weight: 720; }
.login-card .primary { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; padding: 13px 17px; }
.form-message { min-height: 18px; margin: 0; color: var(--red); font-size: 12px; }
.topbar { display: flex; align-items: center; gap: 22px; min-height: 74px; border-radius: 22px; padding: 10px 14px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 170px; }
.brand strong { display: block; font-size: 17px; letter-spacing: -.02em; }
.brand small { display: block; color: var(--muted); font-size: 10px; }
.tabs { display: flex; align-items: center; gap: 4px; margin: auto; border-radius: 15px; padding: 5px; box-shadow: var(--inset); white-space: nowrap; }
.tabs button { min-width: 61px; padding: 9px 14px; background: transparent; box-shadow: none; color: var(--muted); font-size: 12px; }
.tabs button.active { color: var(--accent-dark); background: var(--surface); box-shadow: var(--shadow-small); font-weight: 750; }
.top-actions { display: flex; align-items: center; gap: 7px; }
.top-actions button { padding: 9px 11px; font-size: 12px; }
.service-pill, .small-pill, .private-tag { display: inline-flex; align-items: center; gap: 7px; border-radius: 99px; padding: 8px 12px; color: var(--muted); box-shadow: var(--inset); font-size: 11px; white-space: nowrap; }
.service-pill i { width: 7px; height: 7px; border-radius: 50%; background: #dfaf67; }
.service-pill.ok i { background: var(--green); box-shadow: 0 0 7px var(--green); }
.service-pill.error i { background: var(--red); }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 36px 8px 27px; }
.page-heading h1 { margin: 5px 0 6px; font-size: clamp(29px, 3.4vw, 40px); letter-spacing: -.055em; }
.page-heading .muted { margin: 0; font-size: 12px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 17px; }
.stat, .panel { border-radius: 23px; }
.stat { display: grid; gap: 8px; min-height: 145px; padding: 23px; }
.stat span, .stat small { color: var(--muted); font-size: 12px; }
.stat strong { font-size: 30px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.two-col { display: grid; grid-template-columns: 1.05fr 1fr; gap: 19px; margin-top: 19px; }
.panel { min-width: 0; padding: 25px; }
.panel-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; margin-bottom: 20px; }
.panel-head h2 { margin: 5px 0 0; font-size: 20px; letter-spacing: -.03em; }
.panel-note { color: var(--muted); font-size: 11px; }
.model-list, .failures, .key-models { display: grid; gap: 12px; }
.model-item, .failure-item, .breakdown-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-radius: 14px; padding: 13px 15px; box-shadow: var(--inset); }
.model-item strong, .breakdown-row strong { font-size: 13px; }
.model-item span, .failure-item span, .breakdown-row span { color: var(--muted); font-size: 11px; }
.failure-item { align-items: start; }
.failure-item strong { color: var(--red); font-size: 12px; }
.failure-item div { display: grid; gap: 4px; }
.empty { margin: 0; padding: 34px 10px; text-align: center; color: var(--muted); font-size: 12px; }
.period-picker { display: flex; align-items: center; gap: 9px; }
.period-picker select, .chat-controls select { min-width: 145px; padding: 9px 13px; color: var(--text); }
.usage-chart { display: flex; align-items: end; gap: 7px; min-height: 232px; overflow-x: auto; padding: 25px 7px 0; }
.bar-col { display: grid; flex: 1 0 26px; min-width: 26px; justify-items: center; gap: 8px; align-content: end; height: 210px; color: var(--muted); font-size: 10px; }
.bar { width: min(100%, 27px); min-height: 3px; border-radius: 9px 9px 3px 3px; background: linear-gradient(180deg, #8aabf7, #5f86e8); box-shadow: 4px 4px 9px #c9d4e4, -3px -3px 9px #fff; }
.key-models { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.key-card { border-radius: 23px; padding: 23px; }
.key-card-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.key-card h2 { margin: 0; font-size: 18px; }
.key-card small { display: block; margin-top: 4px; color: var(--muted); }
.key-card-actions, .key-row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.key-card-actions button, .key-row-actions button { padding: 6px 9px; font-size: 11px; }
.key-list { display: grid; gap: 9px; margin: 20px 0 14px; }
.key-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; border-radius: 13px; padding: 10px 12px; box-shadow: var(--inset); }
.key-row code { color: var(--text); font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.key-row .slot { color: var(--accent-dark); font-size: 11px; font-weight: 750; }
.danger { color: var(--red); }
.key-add { display: flex; gap: 9px; }
.key-add input { min-width: 0; flex: 1; padding: 10px 12px; }
.key-add button { white-space: nowrap; font-size: 11px; }
.chat-controls { display: flex; gap: 10px; }
.chat-panel { border-radius: 24px; padding: 25px; }
.chat-messages { display: flex; flex-direction: column; gap: 15px; min-height: 330px; max-height: 52vh; overflow-y: auto; border-radius: 18px; padding: 21px; box-shadow: var(--inset); }
.chat-message { max-width: min(78%, 760px); border-radius: 17px; padding: 12px 15px; box-shadow: var(--shadow-small); background: var(--surface); }
.chat-message.user { align-self: flex-end; background: #dce7fc; }
.chat-message.assistant { align-self: flex-start; }
.chat-message small { color: var(--accent-dark); font-weight: 750; }
.chat-message p { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.7; }
.chat-panel form { display: grid; gap: 13px; margin-top: 16px; }
.chat-panel textarea { width: 100%; min-height: 100px; resize: vertical; line-height: 1.6; }
.chat-bottom { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.chat-bottom span { color: var(--muted); font-size: 11px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
footer { margin: 40px 0 0; text-align: center; color: #8a99ad; font-size: 11px; }
.edit-dialog { width: min(460px, calc(100% - 28px)); border: 1px solid #fff; border-radius: 23px; padding: 25px; color: var(--text); }
.edit-dialog::backdrop { background: rgba(37,53,76,.36); backdrop-filter: blur(3px); }
.edit-dialog .panel-head { align-items: center; }
.edit-dialog .panel-head h2 { margin: 0; }
.edit-dialog .panel-head button { padding: 5px 10px; font-size: 18px; }
.edit-fields { display: grid; gap: 16px; }
.edit-fields input { width: 100%; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
@media (max-width: 1000px) {
  .topbar { flex-wrap: wrap; }
  .tabs { order: 3; width: 100%; justify-content: center; }
  .top-actions { margin-left: auto; }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .shell { width: calc(100% - 24px); padding-top: 12px; }
  .topbar { padding: 12px; }
  .tabs { overflow-x: auto; justify-content: start; }
  .stat-grid, .key-models { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { min-height: 125px; padding: 16px; }
  .stat strong { font-size: 24px; }
  .page-heading { align-items: start; flex-direction: column; margin: 28px 4px 20px; }
  .panel, .chat-panel, .key-card { padding: 18px; }
  .key-row { align-items: start; flex-direction: column; }
  .chat-message { max-width: 92%; }
}
@media (max-width: 480px) {
  .login-card { padding: 28px 22px; }
  .tabs button { min-width: 58px; padding: 9px 11px; }
  .model-item, .breakdown-row { align-items: start; flex-direction: column; }
  .key-models { grid-template-columns: 1fr; }
  .chat-controls { width: 100%; }
  .chat-controls select { flex: 1; min-width: 0; }
}
