:root {
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  color: #18212b;
  background: #f3f6f8;
  font-synthesis: none;
  --ink: #18212b;
  --muted: #687583;
  --line: #dce2e7;
  --soft: #f6f8f9;
  --surface: #fff;
  --primary: #1677b8;
  --primary-dark: #105f94;
  --green: #247a4d;
  --red: #b64343;
  --amber: #9b6b14;
  --sidebar: #15222c;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
.kicker { color: #71808e; font-size: 11px; font-weight: 800; letter-spacing: 1.6px; }

.login-page { min-height: 100vh; background: #edf3f7; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 28px; }
.login-panel { width: min(100%, 460px); padding: 42px; background: #fff; border: 1px solid #dce4e9; border-radius: 8px; box-shadow: 0 24px 60px rgba(34, 57, 74, .12); }
.brand-mark { display: grid; place-items: center; width: 46px; height: 46px; margin-bottom: 24px; color: #fff; background: #1577b8; border-radius: 7px; font-size: 16px; font-weight: 850; }
.brand-mark.small { width: 36px; height: 36px; margin: 0; font-size: 13px; }
.login-panel h1 { margin-top: 9px; font-size: 29px; line-height: 1.25; }
.login-subtitle { margin: 9px 0 28px; color: var(--muted); font-size: 14px; }
.login-panel label, .field span { display: block; margin-bottom: 8px; color: #4f5e6b; font-size: 13px; font-weight: 650; }
.password-field { position: relative; }
.password-field input { padding-right: 48px; }
input, select, textarea {
  width: 100%; min-height: 42px; padding: 10px 12px; color: var(--ink); background: #fff;
  border: 1px solid #cfd7dd; border-radius: 5px; outline: none;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #5295c4; box-shadow: 0 0 0 3px rgba(34, 131, 190, .13); }
.password-field .icon-button { position: absolute; top: 4px; right: 4px; }
.primary-button, .secondary-button, .text-button {
  min-height: 38px; padding: 8px 14px; border-radius: 5px; border: 1px solid transparent; font-weight: 700;
}
.primary-button { color: #fff; background: var(--primary); border-color: var(--primary); }
.primary-button:hover { background: var(--primary-dark); }
.secondary-button { color: #41505d; background: #fff; border-color: #ccd5dc; }
.text-button { min-height: auto; padding: 4px; color: var(--primary); background: transparent; }
.full { width: 100%; }
.login-panel .primary-button { margin-top: 18px; min-height: 46px; }
.icon-button {
  display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; color: #53616e;
  background: transparent; border: 1px solid transparent; border-radius: 5px; font-size: 18px;
}
.icon-button:hover { background: #eef3f6; border-color: #d7e0e6; }
.icon-button.inverse { color: #c8d3da; }
.icon-button.inverse:hover { background: #263742; border-color: #354853; }
.mobile-only { display: none; }
.form-message { min-height: 21px; margin-top: 12px; color: var(--red); font-size: 13px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 230px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 20px 14px; color: #dce5ea; background: var(--sidebar); }
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 24px; border-bottom: 1px solid #2a3a45; }
.sidebar-brand strong { display: block; color: #fff; font-size: 15px; }
.sidebar-brand span:not(.brand-mark) { display: block; margin-top: 3px; color: #82939e; font-size: 10px; text-transform: uppercase; }
.sidebar nav { display: grid; gap: 3px; padding-top: 18px; }
.nav-item { display: flex; align-items: center; gap: 11px; width: 100%; min-height: 40px; padding: 8px 11px; color: #aebdc6; text-align: left; background: transparent; border: 0; border-radius: 5px; font-size: 13px; }
.nav-item > span { width: 18px; text-align: center; font-size: 16px; }
.nav-item:hover { color: #fff; background: #202f39; }
.nav-item.active { color: #fff; background: #1677b8; }
.sidebar-footer { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 7px 0; border-top: 1px solid #2a3a45; color: #98a9b3; font-size: 12px; overflow: hidden; }
.sidebar-footer > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.workspace { min-width: 0; padding: 0 28px 44px; }
.workspace-header { height: 92px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--line); }
.workspace-header h1 { margin-top: 5px; font-size: 24px; line-height: 1.25; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.status-badge, .badge { display: inline-flex; align-items: center; width: max-content; padding: 4px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.status-badge.online, .badge.success { color: var(--green); background: #e9f6ef; }
.status-badge.offline, .badge.danger { color: var(--red); background: #fbecec; }
.badge.warning { color: var(--amber); background: #fff4da; }
.badge.neutral { color: #5d6974; background: #edf1f4; }
.view { display: none; padding-top: 24px; }
.view.active { display: block; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric {
  min-height: 112px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 7px;
}
.metric-label { color: var(--muted); font-size: 12px; font-weight: 650; }
.metric-value { display: block; margin-top: 13px; font-size: 28px; line-height: 1; }
.metric-note { display: block; margin-top: 9px; color: #84919b; font-size: 11px; }
.content-grid { display: grid; gap: 14px; margin-top: 14px; }
.content-grid.split { grid-template-columns: minmax(0, 1.6fr) minmax(280px, .8fr); }
.content-grid.parser-grid { grid-template-columns: minmax(360px, .75fr) minmax(0, 1.25fr); margin-top: 0; }
.section-block { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; }
.section-heading { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 17px; border-bottom: 1px solid #e7ebee; }
.section-heading h2 { font-size: 15px; }
.section-heading p { margin-top: 4px; color: var(--muted); font-size: 11px; }
.section-heading-actions { display: flex; align-items: center; gap: 8px; }
.section-heading-actions select { width: 220px; }
.table-block { overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { padding: 10px 13px; color: #73808a; text-align: left; background: #f7f9fa; border-bottom: 1px solid var(--line); font-weight: 700; white-space: nowrap; }
td { padding: 12px 13px; border-bottom: 1px solid #edf0f2; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcfd; }
.cell-title { display: block; max-width: 240px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-subtitle { display: block; margin-top: 3px; color: #87939c; font-size: 10px; }
.table-actions { display: flex; justify-content: flex-end; gap: 4px; white-space: nowrap; }
.client-actions-cell { min-width: 214px; }
.row-action-button { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 32px; padding: 5px 9px; font-size: 11px; }
.clients-access-table { min-width: 1120px; }
.client-keys-cell { width: 410px; min-width: 340px; padding-top: 7px; padding-bottom: 7px; }
.client-key-list { display: grid; gap: 6px; }
.client-key-entry { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; min-height: 42px; padding: 5px 7px; background: #f7f9fa; border: 1px solid #e4e9ec; border-radius: 5px; }
.client-key-identity { min-width: 0; }
.client-key-identity code { display: block; color: #465764; overflow-wrap: anywhere; }
.client-key-secret { display: block; width: 100%; padding: 0; text-align: left; background: transparent; border: 0; cursor: copy; }
.client-key-secret:hover code { color: var(--primary); text-decoration: underline; }
.client-key-controls { display: flex; align-items: center; gap: 4px; }
.client-key-controls .icon-button { width: 28px; height: 28px; }
.client-key-empty { color: var(--muted); font-size: 11px; }
.client-key-create { width: max-content; padding-inline: 0; font-size: 11px; }
.client-key-actions { display: flex; align-items: center; gap: 12px; }
.client-key-actions .text-button { padding-inline: 0; font-size: 11px; }
.client-key-actions .text-button:disabled { color: #98a3aa; cursor: not-allowed; }
.empty-row { padding: 34px; color: var(--muted); text-align: center; }
.health-list { display: grid; padding: 8px 16px 14px; }
.health-row { display: flex; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid #edf0f2; font-size: 12px; }
.health-row:last-child { border-bottom: 0; }
.health-row span:first-child { color: var(--muted); }

.toolbar { min-height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.toolbar > select { width: 220px; }
.search-field { position: relative; width: min(360px, 100%); }
.search-field > span { position: absolute; top: 10px; left: 12px; color: #7d8993; }
.search-field input { padding-left: 34px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 18px; }
.field { display: block; }
.field.full, .form-grid > .full { grid-column: 1 / -1; }
.checkbox-row { display: flex; align-items: center; gap: 9px; color: #53616d; font-size: 13px; }
.checkbox-row input { width: 17px; min-height: 17px; }
.result-block { min-height: 420px; }
.empty-state { display: grid; min-height: 340px; place-items: center; padding: 24px; color: #8a969f; font-size: 13px; text-align: center; }
.result-content { padding: 18px; }
.result-summary { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 16px; }
.result-summary strong { font-size: 18px; }
.quality-list { display: grid; gap: 8px; }
.quality-row { display: grid; grid-template-columns: 74px 100px minmax(0, 1fr) 58px; align-items: start; gap: 10px; padding: 10px; background: #f7f9fa; border: 1px solid #e4e9ec; border-radius: 5px; }
.quality-row > strong, .quality-row > span { padding-top: 8px; }
.quality-url { min-width: 0; padding-top: 7px; color: #245f86; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 10px; line-height: 1.5; overflow-wrap: anywhere; word-break: break-all; }
.copy-link-button { min-height: 32px; padding: 6px 10px; font-size: 11px; }
.search-result-list, .episode-list { display: grid; gap: 8px; }
.search-result-row, .episode-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px; background: #f7f9fa; border: 1px solid #e4e9ec; border-radius: 5px; }
.search-result-main { min-width: 0; }
.search-result-main > strong { display: block; font-size: 14px; }
.search-result-main .cell-subtitle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.episode-row { grid-template-columns: 100px minmax(0, 1fr) auto; }
.episode-row code { color: #526675; overflow-wrap: anywhere; font-size: 11px; }

.settings-list { display: grid; gap: 10px; }
.setting-row { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(240px, .65fr); align-items: center; gap: 20px; padding: 16px 18px; background: #fff; border: 1px solid var(--line); border-radius: 7px; }
.setting-row h3 { font-size: 14px; }
.setting-row p { margin-top: 5px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.setting-control { display: flex; align-items: center; justify-content: flex-end; gap: 9px; }
.setting-control input, .setting-control select { width: 170px; }
.toggle { position: relative; width: 42px; height: 24px; flex: 0 0 auto; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle span { display: block; width: 42px; height: 24px; background: #c7d0d6; border-radius: 12px; transition: .2s; }
.toggle span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: .2s; }
.toggle input:checked + span { background: var(--primary); }
.toggle input:checked + span::after { transform: translateX(18px); }

dialog { width: min(92vw, 500px); padding: 0; border: 1px solid #d7dfe4; border-radius: 8px; box-shadow: 0 24px 70px rgba(22, 38, 50, .24); }
dialog::backdrop { background: rgba(19, 31, 40, .45); }
.modal-form { display: grid; gap: 15px; padding: 20px; }
.modal-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid #e6eaed; }
.modal-heading h2 { font-size: 17px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 5px; }
.warning-strip { padding: 10px 12px; color: #7d5918; background: #fff5dc; border: 1px solid #f0daa4; border-radius: 5px; font-size: 12px; }
.secret-box { display: flex; align-items: center; gap: 8px; padding: 12px; background: #111b22; border-radius: 5px; }
.secret-box code { min-width: 0; flex: 1; color: #dcebf3; overflow-wrap: anywhere; font-size: 12px; }
.secret-box .icon-button { color: #dcebf3; }
.credential-dialog { width: min(94vw, 720px); }
.credential-dialog .modal-form { max-height: min(88vh, 820px); overflow-y: auto; }
.modal-subtitle { margin-top: 4px; color: var(--muted); font-size: 11px; }
.credential-label, .credential-heading { color: #53616d; font-size: 12px; font-weight: 700; }
.credential-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.credential-code { min-height: 160px; max-height: 260px; margin: 0; padding: 13px; overflow: auto; color: #dcebf3; background: #111b22; border-radius: 5px; font-size: 11px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.credential-code.compact { min-height: 72px; max-height: 120px; }
.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 50; display: grid; gap: 8px; }
.toast { width: min(360px, calc(100vw - 40px)); padding: 12px 14px; color: #fff; background: #22313b; border-radius: 5px; box-shadow: 0 10px 30px rgba(19,31,40,.25); font-size: 12px; }
.toast.error { background: #983c3c; }
.request-modal-form { max-height: min(760px, 88vh); }
.request-detail { min-height: 180px; overflow: auto; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.detail-item { padding: 10px; background: #f6f8f9; border: 1px solid #e3e8eb; border-radius: 5px; }
.detail-item span { display: block; color: var(--muted); font-size: 10px; }
.detail-item strong { display: block; margin-top: 4px; overflow-wrap: anywhere; font-size: 12px; }
.stage-list { display: grid; gap: 7px; margin-top: 14px; }
.stage-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; padding: 9px 10px; border-bottom: 1px solid #e8ecef; font-size: 11px; }

.client-shell { min-height: 100vh; display: grid; grid-template-columns: 230px minmax(0, 1fr); }
.client-sidebar { min-height: 100vh; }
.client-workspace { min-width: 0; }
.client-view { padding-top: 24px; }
.client-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.client-metric-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 22px; }
.client-log-block { margin-top: 14px; overflow: hidden; }
.client-log-heading { align-items: flex-start; }
.client-log-filters { display: flex; gap: 8px; }
.client-log-filters select { width: 148px; }
.client-requests-table { min-width: 860px; }
.client-pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 17px; color: var(--muted); font-size: 12px; }
.client-pagination > div { display: flex; gap: 8px; }
.client-pagination button { min-height: 32px; padding: 5px 10px; font-size: 11px; }
.client-pagination button:disabled { cursor: not-allowed; opacity: .45; }

@media (max-width: 1050px) {
  .metric-grid, .client-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content-grid.split, .content-grid.parser-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: sticky; z-index: 10; width: 100%; height: auto; padding: 10px; }
  .sidebar-brand { padding: 0 4px 10px; }
  .sidebar nav { display: flex; overflow-x: auto; padding-top: 10px; }
  .nav-item { width: max-content; flex: 0 0 auto; }
  .sidebar-footer { display: none; }
  .mobile-only { display: inline-grid; }
  .workspace { padding: 0 14px 32px; }
  .workspace-header { height: 78px; }
  .workspace-header h1 { font-size: 20px; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric { min-height: 100px; padding: 14px; }
  .metric-value { font-size: 24px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar > select, .search-field { width: 100%; }
  .section-heading-actions { width: 100%; align-items: stretch; flex-direction: column; }
  .section-heading-actions select { width: 100%; }
  .form-grid, .form-row { grid-template-columns: 1fr; }
  .field.full, .form-grid > .full { grid-column: auto; }
  .setting-row { grid-template-columns: 1fr; gap: 12px; }
  .setting-control { justify-content: flex-start; }
  .setting-control input, .setting-control select { width: 100%; }
  .detail-grid { grid-template-columns: 1fr; }
  .client-shell { display: block; }
  .client-sidebar { min-height: auto; }
  .client-log-heading { align-items: stretch; flex-direction: column; }
  .client-log-filters { width: 100%; }
  .client-log-filters select { flex: 1; width: auto; }
  .login-shell { padding: 14px; }
  .login-panel { padding: 28px 22px; }
}
@media (max-width: 430px) {
  .metric-grid, .client-metrics { grid-template-columns: 1fr; }
  .quality-row { grid-template-columns: 62px minmax(0, 1fr) 58px; }
  .quality-url { grid-column: 1 / -1; grid-row: 2; padding-top: 0; }
  .copy-link-button { grid-column: 3; grid-row: 1; }
}
