:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-strong: #f9fafb;
  --ink: #172026;
  --muted: #6d7882;
  --line: #d9e0e6;
  --line-strong: #c7d0d8;
  --brand: #167a61;
  --brand-dark: #0f5f4c;
  --brand-soft: #e6f4ef;
  --accent: #2662d9;
  --accent-soft: #e8eefc;
  --warning: #a16207;
  --warning-soft: #fff6db;
  --danger: #bd2b2b;
  --danger-soft: #fdeaea;
  --ok: #13845e;
  --ok-soft: #e5f6ee;
  --shadow: 0 14px 36px rgba(23, 32, 38, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

.hidden {
  display: none !important;
}

body[data-portal="client"] #proxyConfigPanel,
body[data-portal="client"] #quotaNavItem,
body[data-portal="client"] #quotaView,
body[data-portal="client"] .nav-item[data-view="docs"],
body[data-portal="client"] #docsView {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.app-shell {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  min-height: 100vh;
}

.login-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(22, 122, 97, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(38, 98, 217, 0.08), transparent 34%),
    var(--bg);
}

.login-panel {
  display: grid;
  gap: 22px;
  width: min(100%, 430px);
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.login-heading h1 {
  margin-top: 4px;
}

.login-actions {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.login-token-hint {
  display: grid;
  gap: 8px;
  padding: 12px;
  color: #5f4a11;
  background: var(--warning-soft);
  border: 1px solid #e8ca6b;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
}

.login-command-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: center;
  gap: 8px;
}

.login-command-row input {
  min-width: 0;
  height: 34px;
  padding: 8px 10px;
  overflow: hidden;
  color: #27343b;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(161, 98, 7, 0.22);
  border-radius: 6px;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: text;
}

.copy-command-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  color: #5f4a11;
  background: #ffffff;
  border: 1px solid rgba(161, 98, 7, 0.28);
  border-radius: 8px;
}

.copy-command-button:hover {
  background: #fffaf0;
}

.copy-command-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 24px 18px;
  color: #f4f7f5;
  background: #1d2422;
  border-right: 1px solid #101413;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: #236d59;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-name {
  font-size: 16px;
  font-weight: 800;
}

.brand-subtitle {
  margin-top: 2px;
  color: #aeb9b5;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 0 10px;
  color: #c7d2ce;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.08);
}

.nav-symbol {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
  color: #b5c4bf;
  font-size: 11px;
  font-weight: 800;
}

.nav-item.active .nav-symbol {
  background: #d9f7e8;
  color: #125a48;
}

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #c7d2ce;
  background: rgba(255, 255, 255, 0.05);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #87918d;
}

.status-dot.ok {
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(19, 132, 94, 0.16);
}

.status-dot.bad {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(189, 43, 43, 0.16);
}

.main {
  min-width: 0;
  padding: 24px;
}

.eyebrow {
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  margin-top: 4px;
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  font-size: 17px;
  line-height: 1.3;
}

.muted {
  margin: 4px 0 0;
  color: var(--muted);
}

.token-strip {
  display: grid;
  grid-template-columns: minmax(220px, 340px) auto auto;
  align-items: end;
  gap: 8px;
  width: min(100%, 560px);
  margin-top: 14px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(23, 32, 38, 0.04);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.toolbar,
.panel-header,
.table-tools,
.submit-actions,
.config-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.toolbar {
  margin-bottom: 16px;
}

.section-side-label {
  color: #38454d;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}


.update-note {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.update-status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.update-status-grid > div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.update-status-grid span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.update-status-grid strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.metric-card,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(23, 32, 38, 0.04);
}

.metric-card {
  display: grid;
  gap: 8px;
  min-height: 128px;
  padding: 18px;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-card strong {
  overflow-wrap: anywhere;
  font-size: 30px;
  line-height: 1.1;
}

.metric-card strong.ok {
  color: var(--ok);
}

.metric-card strong.bad {
  color: var(--danger);
}

.metric-note {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-note-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.metric-edit-button {
  min-height: 28px;
  padding: 0 6px;
  font-size: 12px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 14px;
}

.panel {
  padding: 18px;
}

.code-line {
  margin-top: 16px;
  padding: 14px;
  overflow-wrap: anywhere;
  color: #10241e;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  line-height: 1.55;
}

.mini-list {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.mini-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.mini-item code {
  overflow: hidden;
  max-width: 210px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: #38454d;
  font-size: 12px;
  font-weight: 800;
}

.field.compact {
  gap: 5px;
}

input,
textarea {
  width: 100%;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input {
  height: 40px;
  padding: 0 12px;
}

textarea {
  min-height: 120px;
  padding: 12px;
  resize: vertical;
  line-height: 1.55;
}

input:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(22, 122, 97, 0.13);
}

.primary-button,
.secondary-button,
.danger-button,
.text-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 800;
  white-space: nowrap;
}

.primary-button {
  color: #ffffff;
  background: var(--brand);
  border-color: var(--brand-dark);
}

.primary-button:hover {
  background: var(--brand-dark);
}

.secondary-button,
.icon-button {
  color: #27343b;
  background: #ffffff;
  border-color: var(--line-strong);
}

.secondary-button:hover,
.icon-button:hover {
  background: #f7f9fa;
}

.danger-button {
  color: #ffffff;
  background: var(--danger);
  border-color: #9f2222;
}

.danger-button:hover {
  background: #9f2222;
}

.text-button {
  min-height: 34px;
  padding: 0 8px;
  color: var(--brand);
  background: transparent;
}

.text-button:hover {
  background: var(--brand-soft);
}

.submit-layout {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: calc(100vh - 48px);
}

.submit-composer {
  display: grid;
  grid-template-rows: minmax(104px, 1fr) auto;
  gap: 12px;
  width: min(100%, 1040px);
  min-height: 210px;
  padding: 14px 16px;
  background: #ffffff;
  border: 1px solid #8ebdff;
  border-radius: 26px;
  box-shadow: 0 16px 34px rgba(34, 109, 233, 0.08);
}

.submit-layout.is-submitting .submit-composer {
  border-color: #bdd3f3;
  box-shadow: 0 12px 24px rgba(34, 109, 233, 0.05);
}

.submit-layout.is-submitting .reference-button,
.submit-layout.is-submitting .ratio-picker,
.submit-layout.is-submitting .image-item {
  cursor: not-allowed;
  opacity: 0.56;
}

.submit-layout.is-submitting .reference-button {
  pointer-events: none;
}

.composer-main {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
}

.composer-main textarea {
  min-height: 82px;
  padding: 0 6px;
  color: #202a31;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  resize: vertical;
  font-size: 17px;
  line-height: 1.6;
}

.composer-main textarea:focus {
  border-color: transparent;
  box-shadow: none;
}

.composer-main textarea::placeholder {
  color: #a8b0b8;
}

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.composer-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  min-width: 0;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 5px;
  width: fit-content;
  max-width: 100%;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.segmented button {
  min-width: 58px;
  min-height: 34px;
  padding: 0 12px;
  color: #4f5c64;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  font-weight: 800;
}

.segmented button.active {
  color: var(--brand-dark);
  background: #ffffff;
  border-color: var(--line-strong);
  box-shadow: 0 5px 14px rgba(23, 32, 38, 0.08);
}

.reference-button {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 6px;
  color: #151f26;
  border-radius: 8px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  line-height: 1;
}

.reference-button:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.plus-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 12px;
  height: 16px;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
}

.ratio-picker {
  position: relative;
}

.ratio-trigger {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  padding: 0 8px;
  color: #151f26;
  background: transparent;
  border: 0;
  border-radius: 8px;
  font-weight: 800;
  line-height: 1;
}

.ratio-trigger::after {
  content: "";
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  margin-left: 1px;
  transform: translateY(-1px) rotate(45deg);
}

#ratioValue {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.ratio-trigger:hover,
.ratio-picker.open .ratio-trigger {
  color: var(--accent);
  background: var(--accent-soft);
}

.ratio-options {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 5;
  display: none;
  min-width: 118px;
  padding: 6px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.ratio-picker.open .ratio-options {
  display: grid;
  gap: 4px;
}

.ratio-options button {
  min-height: 32px;
  padding: 0 10px;
  color: #38454d;
  background: transparent;
  border: 0;
  border-radius: 7px;
  font-weight: 800;
  text-align: left;
}

.ratio-options button:hover,
.ratio-options button.active {
  color: var(--brand-dark);
  background: var(--brand-soft);
}

.image-list {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.image-list:empty {
  display: none;
}

.image-item {
  position: relative;
  display: flex;
  align-items: center;
  width: 64px;
  height: 64px;
  padding: 0;
  background: #eef2f5;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 11px;
  background: #e2e8ee;
}

.image-meta {
  display: none;
}

.image-item .icon-button {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 22px;
  min-height: 22px;
  width: 22px;
  height: 22px;
  padding: 0;
  color: #ffffff;
  background: rgba(23, 32, 38, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 999px;
  font-size: 0;
}

.image-item .icon-button::before {
  content: "x";
  font-size: 12px;
  line-height: 1;
}

.composer-state {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.submit-arrow-button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  padding: 0;
  color: #ffffff;
  background: #126fff;
  border: 0;
  border-radius: 999px;
  line-height: 1;
  box-shadow: 0 10px 20px rgba(18, 111, 255, 0.22);
}

.submit-arrow-button svg {
  display: block;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.submit-arrow-button:hover {
  background: #075bd8;
}

.submit-arrow-button:disabled {
  opacity: 0.58;
  box-shadow: none;
}

.table-tools {
  margin-bottom: 14px;
}

.search-field {
  width: min(420px, 100%);
}

.task-table-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-left: auto;
}

.pager {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.quota-panel .quota-table-wrap {
  margin-top: 12px;
}

.quota-entry-note {
  max-width: 620px;
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.client-entry-box {
  display: grid;
  grid-template-columns: auto minmax(260px, 420px) auto;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  color: var(--muted);
  font-weight: 800;
}

.client-entry-box input {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  color: #25313a;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

.task-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  table-layout: fixed;
}

.quota-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  table-layout: fixed;
}

.task-table .task-col {
  width: 23%;
}

.task-table .status-col {
  width: 9%;
}

.task-table .result-col {
  width: 32%;
}

.task-table .video-col {
  width: 13%;
}

.task-table .action-col {
  width: 23%;
}

.quota-table .token-col {
  width: 36%;
}

.quota-table .quota-col,
.quota-table .used-col,
.quota-table .remain-col {
  width: 10%;
}

.quota-table .time-col {
  width: 18%;
}

.quota-table .quota-action-col {
  width: 16%;
}

.task-table th,
.task-table td,
.quota-table th,
.quota-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
}

.quota-table th,
.quota-table td {
  vertical-align: middle;
}

.task-table th,
.quota-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #46535b;
  background: var(--surface-strong);
  font-size: 12px;
  text-transform: uppercase;
}

.task-table th:nth-child(2),
.task-table td:nth-child(2),
.task-table th:nth-child(4),
.task-table td:nth-child(4) {
  text-align: center;
}

.task-table th:nth-child(5),
.task-table td:nth-child(5) {
  text-align: right;
}

.quota-table th:nth-child(2),
.quota-table td:nth-child(2),
.quota-table th:nth-child(3),
.quota-table td:nth-child(3),
.quota-table th:nth-child(4),
.quota-table td:nth-child(4),
.quota-table th:nth-child(5),
.quota-table td:nth-child(5),
.quota-table th:nth-child(6),
.quota-table td:nth-child(6) {
  text-align: center;
}

.task-table tbody tr:hover,
.quota-table tbody tr:hover {
  background: #fbfcfd;
}

.task-table tbody tr:last-child td,
.quota-table tbody tr:last-child td {
  border-bottom: 0;
}

.temp-token-cell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 38px;
}

.temp-token-cell code {
  overflow: hidden;
  color: #53616b;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.token-copy-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 0 8px;
  color: var(--brand);
  background: #eaf2ff;
  border: 1px solid #c7dcff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.quota-limit-input {
  display: block;
  width: 86px;
  margin: 0 auto;
  padding: 7px 8px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}

.quota-row-actions {
  align-items: center;
  justify-content: center;
}

.task-id {
  display: grid;
  gap: 4px;
}

.task-prompt-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.task-prompt {
  max-width: 100%;
  overflow: hidden;
  color: #1c2a30;
  font-weight: 800;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-copy-prompt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 22px;
  padding: 0 7px;
  border: 1px solid #d7e1e7;
  border-radius: 999px;
  background: #f7fafb;
  color: #55707b;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.task-copy-prompt:hover {
  border-color: #b9cbd4;
  background: #edf5f7;
  color: #1f6d62;
}

.task-id code {
  overflow-wrap: anywhere;
  color: #79858d;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

.task-time {
  color: var(--muted);
  font-size: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.chip.unknown {
  color: #52606a;
  background: #eef2f5;
}

.chip.success {
  color: var(--ok);
  background: var(--ok-soft);
}

.chip.failed {
  color: var(--danger);
  background: var(--danger-soft);
}

.chip.running {
  color: var(--warning);
  background: var(--warning-soft);
}

.result-text {
  max-width: 100%;
  color: #38454d;
  line-height: 1.45;
}

.result-text-button {
  display: block;
  width: 100%;
  padding: 0;
  color: #38454d;
  background: transparent;
  border: 0;
  line-height: 1.45;
  text-align: left;
}

.result-text-preview {
  display: -webkit-box;
  max-height: 2.9em;
  overflow: hidden;
  white-space: normal;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.result-text-button.has-detail {
  cursor: pointer;
}

.result-text-button.has-detail:hover {
  color: var(--accent);
}

.url-cell {
  max-width: 100%;
  overflow-wrap: anywhere;
  text-align: center;
}

.video-actions {
  display: grid;
  justify-items: center;
  gap: 4px;
}

.url-cell a,
.video-link-button {
  min-width: 56px;
  height: 20px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  font-weight: 800;
  font-size: 11px;
  line-height: 1;
  text-decoration: none;
}

.video-link-button[data-action="open-video"] {
  color: #1766c2;
  background: #eaf3ff;
  border-color: #c8defa;
}

.video-link-button[data-action="copy-url"] {
  color: #1f7a5a;
  background: #e9f7f0;
  border-color: #c5e7d6;
}

.video-link-button[data-action="download-video"] {
  color: #9b5a10;
  background: #fff2dc;
  border-color: #f2d3a2;
}

.url-cell a:hover,
.video-link-button:hover {
  filter: saturate(1.08) brightness(0.98);
}

.row-actions {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 6px;
  min-width: max-content;
}

.docs-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 14px;
}


.docs-entry-panel {
  max-width: 720px;
}

.docs-entry {
  display: grid;
  gap: 16px;
  justify-items: start;
}

.docs-entry p {
  max-width: 620px;
  margin: 0;
  color: #46535b;
  line-height: 1.65;
}

.docs-open-button {
  min-width: 168px;
  min-height: 42px;
  text-decoration: none;
}

.docs-panel {
  display: grid;
  align-content: start;
  gap: 16px;
  min-width: 0;
}

.docs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.docs-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  color: var(--brand-dark);
  background: var(--brand-soft);
  border: 1px solid #cde7dc;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.api-list,
.command-list {
  display: grid;
  gap: 10px;
}

.api-item,
.command-item {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 12px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.api-item > div:not(.api-example) {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.api-item p {
  margin: 0;
  color: #46535b;
  line-height: 1.55;
}

.api-example {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.api-example span {
  color: #52606a;
  font-size: 12px;
  font-weight: 800;
}

.api-example code {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 10px;
  overflow-x: auto;
  color: #d9edf7;
  background: #14384b;
  border-radius: 6px;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: nowrap;
}

.method {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 900;
}

.method.get {
  color: #174ea6;
  background: #e9f1ff;
}

.method.post {
  color: #0f6848;
  background: #e6f4ef;
}

.method.delete {
  color: #9f2222;
  background: var(--danger-soft);
}

.api-item > div:not(.api-example) code,
.api-item p code,
.command-item code {
  overflow-wrap: anywhere;
  color: #14251f;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

.api-example code {
  color: #ffffff;
}

.api-item p code {
  padding: 2px 5px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.command-item span {
  color: #38454d;
  font-size: 12px;
  font-weight: 800;
}

.command-item code {
  display: block;
  padding: 10px 12px;
  color: #dce8e2;
  background: #17211f;
  border-radius: 8px;
  line-height: 1.5;
}

.config-panel {
  display: grid;
  gap: 18px;
  max-width: 940px;
}

.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 10px;
  z-index: 50;
  width: min(380px, calc(100vw - 36px));
}

.toast {
  padding: 12px 14px;
  color: #172026;
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--brand);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.toast.error {
  border-left-color: var(--danger);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(12, 18, 22, 0.38);
}

.modal-panel {
  display: grid;
  gap: 18px;
  width: min(100%, 420px);
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.text-modal-panel {
  width: min(100%, 720px);
}

.video-modal-panel {
  width: min(100%, 620px);
}

.video-title-row {
  display: inline-flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}

.video-frame {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #0b1115;
  border: 1px solid #111b21;
  border-radius: 8px;
}

.video-loading {
  padding: 18px;
  color: #d7e0e5;
  font-weight: 800;
}

.video-player {
  width: 100%;
  height: 100%;
  background: #000000;
  object-fit: contain;
}

.decoder-help-link {
  color: #126fff;
  background: transparent;
  border: 0;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}

.decoder-help-link:hover {
  color: #075bd8;
}

.full-text-content {
  max-height: min(58vh, 520px);
  margin: 0;
  padding: 14px;
  overflow: auto;
  color: #1f2c33;
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, "Microsoft YaHei", monospace;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.modal-header,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: #38454d;
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  font-size: 20px;
  line-height: 1;
}

.modal-close:hover {
  background: #f7f9fa;
}

.modal-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.empty-state {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1120px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 14px;
  }

  .nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .nav-item {
    justify-content: center;
    min-height: 38px;
    padding: 0 6px;
  }

  .nav-symbol,
  .brand-subtitle,
  .sidebar-status {
    display: none;
  }

  .main {
    padding: 16px;
  }

  .toolbar,
  .table-tools,
  .submit-actions,
  .config-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .token-strip {
    grid-template-columns: 1fr auto auto;
    width: 100%;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .docs-layout {
    grid-template-columns: 1fr;
  }

  .docs-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .proxy-header-actions {
    justify-content: stretch;
  }

  .proxy-header-actions button {
    flex: 1 1 140px;
  }

  .task-table-actions {
    align-items: stretch;
    flex-direction: column;
    margin-left: 0;
  }

  .pager {
    justify-content: flex-end;
  }

  .toolbar-actions {
    justify-content: stretch;
  }

  .client-entry-box {
    grid-template-columns: 1fr;
    width: 100%;
    margin-left: 0;
  }

  .update-status-grid {
    grid-template-columns: 1fr;
  }

  .toolbar-actions button,
  .submit-actions button,
  .config-actions button {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .nav {
    grid-template-columns: 1fr;
  }

  .login-panel {
    padding: 20px;
  }

  .login-actions {
    grid-template-columns: 1fr;
  }

  .token-strip {
    grid-template-columns: 1fr;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .primary-button,
  .secondary-button,
  .danger-button,
  .icon-button {
    width: 100%;
  }
}
