:root {
  --ink: #17211d;
  --muted: #65736d;
  --line: #dce3dc;
  --paper: #f4f6f1;
  --panel: #ffffff;
  --brand: #1f7a54;
  --brand-dark: #145f42;
  --blue: #2563eb;
  --coral: #d74d38;
  --gold: #a96f16;
  --shadow: 0 14px 34px rgba(34, 46, 39, 0.1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--paper);
  color: var(--ink);
}

button,
input,
select,
textarea {
  min-width: 0;
  font: inherit;
}

button,
a {
  min-height: 38px;
  border-radius: 8px;
}

button {
  border: 0;
  background: var(--brand);
  color: #fff;
  padding: 0 14px;
  font-weight: 850;
  cursor: pointer;
}

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

a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  text-decoration: none;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.admin-shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 42px;
}

.admin-bar,
.panel-head,
.admin-actions,
.metrics {
  display: flex;
  align-items: center;
}

.admin-bar {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  padding: 14px;
  box-shadow: 0 8px 22px rgba(34, 46, 39, 0.06);
}

.admin-brand {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.admin-brand span,
.admin-brand small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.admin-brand strong {
  display: block;
  font-size: 22px;
  line-height: 1.2;
}

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

.login-panel {
  min-height: calc(100vh - 104px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 16px;
  align-items: stretch;
}

.brand-card,
.login-panel form,
.users-panel,
.detail-panel,
.settings-panel,
.brand-strip {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.brand-card {
  display: grid;
  align-content: center;
  gap: 16px;
  padding: clamp(22px, 5vw, 52px);
  background: #fbfcf8;
}

.brand-card > span,
.brand-strip span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.brand-card h1 {
  max-width: 680px;
  margin: 0;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.02;
}

.brand-card p {
  max-width: 620px;
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  font-weight: 750;
  line-height: 1.65;
}

.brand-card a {
  width: max-content;
}

.brand-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.brand-tags span {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  border: 1px solid #cfd9d0;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 900;
  text-transform: none;
}

.login-panel form {
  display: grid;
  align-content: center;
  gap: 14px;
  padding: 24px;
}

.login-panel h1 {
  margin: 0 0 4px;
  font-size: 26px;
}

#loginStatus,
#userSaveStatus,
.save-state,
.empty {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.dashboard {
  display: grid;
  gap: 14px;
}

.metrics {
  gap: 10px;
  flex-wrap: wrap;
}

.metrics article {
  min-width: 150px;
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px 14px;
}

.metrics span,
.metrics strong {
  display: block;
}

.metrics span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.metrics strong {
  margin-top: 2px;
  font-size: 28px;
  line-height: 1;
}

.brand-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  box-shadow: 0 8px 22px rgba(34, 46, 39, 0.06);
}

.brand-strip > div:first-child {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  min-width: 0;
}

.brand-strip strong {
  overflow-wrap: anywhere;
}

.brand-strip a {
  min-height: 30px;
}

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
  box-shadow: 0 8px 22px rgba(34, 46, 39, 0.05);
}

.admin-tabs button {
  flex: 1 1 150px;
  border: 1px solid transparent;
  background: #f2f6ef;
  color: var(--muted);
}

.admin-tabs button.active {
  border-color: rgba(31, 122, 84, 0.38);
  background: var(--brand);
  color: #fff;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.users-panel,
.detail-panel,
.settings-panel {
  min-width: 0;
  padding: 14px;
}

.panel-head {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-head h2,
.logs-grid h3,
.setting-card h3 {
  margin: 0;
}

.panel-head h2 {
  font-size: 18px;
}

.panel-head > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

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

.danger-small {
  min-height: 32px;
  border: 1px solid rgba(215, 77, 56, 0.32);
  background: #fff4f1;
  color: var(--coral);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 900;
}

.danger-small:hover {
  background: #ffe7e1;
}

.danger-small:disabled {
  cursor: wait;
  opacity: 0.62;
}

.panel-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.45;
}

.create-user {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.user-list {
  display: grid;
  gap: 8px;
  max-height: min(62vh, 640px);
  overflow: auto;
  padding-right: 2px;
}

.user-item {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 76px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-align: left;
  padding: 10px 12px;
}

.user-item.selected {
  border-color: rgba(31, 122, 84, 0.7);
  background: #f0f8f4;
}

.user-item.needs-key,
.user-item.needs-attention {
  border-color: rgba(215, 77, 56, 0.55);
  background: #fff7f4;
}

.user-item strong,
.user-item span,
.user-item small {
  min-width: 0;
  overflow-wrap: anywhere;
}

.user-item span,
.user-item small {
  color: var(--muted);
  font-weight: 750;
}

.user-item b {
  font-weight: 900;
}

.weak-meta {
  opacity: 0.78;
}

.key-ok {
  color: var(--brand);
}

.key-missing {
  color: var(--coral);
}

.primary-field {
  color: var(--ink);
}

.user-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.user-form .full {
  grid-column: 1 / -1;
}

#userSaveStatus {
  align-self: center;
  grid-column: span 2;
}

.service-key-field {
  grid-column: 1 / -1;
}

.user-split-key-field {
  gap: 10px;
}

.user-service-key-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.service-key-field {
  grid-column: 1 / -1;
  align-content: start;
  gap: 14px;
  border: 1px solid rgba(31, 122, 84, 0.16);
  border-radius: 8px;
  background: linear-gradient(180deg, #fbfffd, #f6fbf8);
  padding: 14px;
}

.service-key-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.service-key-heading div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.service-key-heading strong {
  color: var(--ink);
  font-size: 16px;
  line-height: 1.2;
}

.service-key-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.user-key-mode-toggle {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid rgba(31, 122, 84, 0.22);
  border-radius: 7px;
  background: #fff;
  padding: 0 12px;
  cursor: pointer;
}

.user-key-mode-toggle input {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--brand);
}

.user-key-mode-toggle span {
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 900;
}

.user-platform-service-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  border: 1px solid rgba(31, 122, 84, 0.16);
  border-radius: 7px;
  background: #edf8f1;
  padding: 10px 12px;
}

.user-platform-service-notice strong {
  flex: 0 0 auto;
  color: var(--brand-dark);
  font-size: 13px;
}

.user-platform-service-notice span {
  color: var(--muted);
  font-size: 12px;
}

.user-custom-service-fields {
  display: grid;
  gap: 12px;
}

#saveUserKeysBtn {
  flex: 0 0 auto;
  min-height: 36px;
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
  box-shadow: 0 8px 18px rgba(31, 122, 84, 0.14);
}

#saveUserKeysBtn:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
  box-shadow: none;
}

.user-service-key-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 12px;
}

.user-service-key-grid label {
  display: grid;
  gap: 8px;
  min-width: 0;
  border: 1px solid rgba(101, 115, 109, 0.16);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.user-service-key-grid input {
  min-height: 42px;
}

.service-key-field span {
  color: var(--brand);
  font-size: 12px;
  font-weight: 850;
}

.service-key-field span.key-missing {
  color: var(--coral);
}

.service-key-field span.key-ok {
  color: var(--brand);
}

.service-key-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-items: center;
}

.service-key-actions button {
  min-height: 34px;
  border: 1px solid rgba(31, 122, 84, 0.34);
  background: #edf8f1;
  color: var(--brand-dark);
  padding: 0 12px;
}

.service-key-actions button:hover {
  background: #dff1e7;
}

.service-key-actions button:disabled {
  cursor: wait;
  opacity: 0.62;
  transform: none;
}

#userServiceKeyTestStatus {
  flex: 1 1 520px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  line-height: 1.45;
}

.key-test-status {
  display: grid;
  gap: 4px;
  min-width: min(100%, 320px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
  padding: 10px 12px;
}

.key-test-status strong {
  color: var(--ink);
  font-size: 13px;
}

.key-test-status span,
.key-test-status small {
  color: inherit;
  font-size: 12px;
  font-weight: 800;
}

.key-test-status small {
  color: var(--muted);
}

.key-test-detail {
  word-break: break-word;
}

.key-test-status .key-test-suggestion {
  color: var(--ink);
}

.key-test-result-list {
  display: grid;
  gap: 6px;
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
}

.key-test-result-list li {
  display: grid;
  grid-template-columns: minmax(140px, 0.8fr) minmax(0, 1.4fr);
  gap: 8px;
  border-top: 1px solid rgba(101, 115, 109, 0.18);
  padding-top: 6px;
}

.key-test-result-list b,
.key-test-result-list span {
  min-width: 0;
  overflow-wrap: anywhere;
}

#userServiceKeyTestStatus.key-test-ok {
  color: var(--brand);
  border-color: rgba(31, 122, 84, 0.24);
  background: #f2fbf5;
}

#userServiceKeyTestStatus.key-test-warn {
  color: var(--gold);
  border-color: rgba(169, 111, 22, 0.26);
  background: #fffaf0;
}

#userServiceKeyTestStatus.key-test-error {
  color: var(--coral);
  border-color: rgba(215, 77, 56, 0.24);
  background: #fff6f3;
}

.advanced-fields {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
  padding: 10px 12px;
}

.advanced-fields summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
}

.advanced-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.logs-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.logs-grid article {
  min-width: 0;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  color: var(--muted);
  background: #fbfcf8;
  font-weight: 900;
}

td {
  max-width: 340px;
  overflow-wrap: anywhere;
}

.pill {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  background: #eef2f1;
  color: var(--muted);
  padding: 2px 9px;
  font-weight: 850;
}

.pill.completed,
.pill.active {
  background: #e9f7ef;
  color: var(--brand);
}

.pill.failed,
.pill.expired {
  background: #fff0ec;
  color: var(--coral);
}

.pill.running,
.pill.queued,
.pill.pending {
  background: #fff7df;
  color: var(--gold);
}

@media (max-width: 980px) {
  .login-panel,
  .workspace,
  .logs-grid,
  .advanced-grid,
  .user-form,
  .brand-strip {
    grid-template-columns: 1fr;
  }

  .service-key-field,
  #userSaveStatus {
    grid-column: 1;
  }

  .user-service-key-grid {
    grid-template-columns: 1fr;
  }

  .brand-strip > div:first-child {
    display: grid;
  }
}

@media (max-width: 640px) {
  .admin-shell {
    width: min(100% - 20px, 100%);
    padding: 10px 0 28px;
  }

  .admin-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-brand strong {
    font-size: 20px;
  }

  .admin-actions {
    width: 100%;
    justify-content: stretch;
  }

  .admin-actions a,
  .admin-actions button {
    flex: 1 1 0;
    padding: 0 8px;
    white-space: nowrap;
  }

  .brand-card {
    padding: 22px;
  }

  .brand-card h1 {
    font-size: 34px;
  }

  .brand-card p {
    font-size: 15px;
  }

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

  .metrics article {
    min-width: 0;
    padding: 11px;
  }

  .metrics strong {
    font-size: 24px;
  }

  .admin-tabs {
    gap: 6px;
  }

  .admin-tabs button {
    flex-basis: calc(50% - 6px);
    min-width: 0;
    padding: 0 8px;
  }

  .service-key-actions button {
    flex: 1 1 180px;
  }

  .key-test-result-list li {
    grid-template-columns: 1fr;
  }

  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-head button {
    width: 100%;
  }

  .user-list {
    max-height: none;
  }

  .users-panel,
  .detail-panel,
  .settings-panel,
  .login-panel form {
    padding: 12px;
  }

  table {
    min-width: 560px;
  }
}

/* Commercial admin UI polish */
:root {
  --ink: #101817;
  --muted: #64706d;
  --line: #d8e2dc;
  --paper: #f3f7f6;
  --panel: #ffffff;
  --brand: #18a06f;
  --brand-dark: #073b30;
  --blue: #2f6df6;
  --coral: #d85a45;
  --gold: #d6a037;
  --shadow: 0 18px 42px rgba(12, 36, 32, 0.1);
}

body {
  background:
    linear-gradient(180deg, rgba(9, 30, 27, 0.055), rgba(243, 247, 246, 0) 360px),
    linear-gradient(120deg, #eef5f3 0%, #f8faf7 54%, #eef7fa 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(7, 59, 48, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(47, 109, 246, 0.035) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.8), transparent 620px);
}

.admin-shell {
  width: min(1440px, calc(100% - 32px));
}

.admin-bar {
  position: sticky;
  top: 12px;
  z-index: 20;
  border-color: rgba(255, 255, 255, 0.14);
  background: linear-gradient(135deg, rgba(8, 22, 20, 0.98), rgba(8, 50, 42, 0.95) 58%, rgba(9, 69, 76, 0.94));
  color: #eefbf5;
  box-shadow: 0 18px 42px rgba(5, 24, 21, 0.2);
}

.admin-brand span,
.admin-brand small {
  color: rgba(238, 251, 245, 0.7);
}

.admin-brand strong {
  color: #fff;
}

.admin-actions a,
.admin-actions button {
  border-color: rgba(24, 160, 111, 0.36);
  background: rgba(255, 255, 255, 0.09);
  color: #d9fff1;
}

.admin-actions button:hover,
.admin-actions a:hover {
  background: rgba(24, 160, 111, 0.2);
}

.brand-card,
.login-panel form,
.users-panel,
.detail-panel,
.settings-panel,
.brand-strip,
.metrics article,
.admin-tabs {
  border-color: rgba(7, 59, 48, 0.1);
  box-shadow: var(--shadow);
}

.brand-card {
  color: #f3fff8;
  background:
    linear-gradient(135deg, rgba(8, 22, 20, 0.98), rgba(8, 56, 47, 0.94) 66%, rgba(9, 69, 76, 0.92));
}

.brand-card > span,
.brand-card p {
  color: rgba(243, 255, 248, 0.72);
}

.brand-card a {
  border-color: rgba(24, 160, 111, 0.34);
  background: rgba(255, 255, 255, 0.09);
  color: #d9fff1;
}

.brand-card .brand-tags span {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.09);
  color: #eefbf5;
}

.brand-strip .brand-tags span {
  border-color: rgba(7, 59, 48, 0.12);
  background: rgba(255, 255, 255, 0.72);
  color: var(--brand-dark);
}

.login-panel {
  min-height: min(660px, calc(100vh - 104px));
}

.login-panel form {
  align-self: center;
  background: rgba(255, 255, 255, 0.96);
}

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

.metrics article {
  min-width: 0;
  background: linear-gradient(180deg, #ffffff, #f5fbf8);
}

.metrics strong {
  color: var(--brand-dark);
}

.brand-strip {
  border-color: rgba(22, 183, 200, 0.18);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(232, 248, 251, 0.84));
  box-shadow: inset 3px 0 0 rgba(22, 183, 200, 0.8), 0 10px 28px rgba(12, 36, 32, 0.075);
}

.admin-tabs {
  background: rgba(255, 255, 255, 0.9);
}

.admin-tabs button.active {
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
}

.workspace {
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
}

.users-panel,
.detail-panel,
.settings-panel {
  background: rgba(255, 255, 255, 0.94);
}

.user-item {
  border-radius: 8px;
}

.user-item.selected {
  border-color: rgba(47, 109, 246, 0.64);
  background: #edf4ff;
  box-shadow: 0 0 0 3px rgba(47, 109, 246, 0.11);
}

.user-item .quota-unlimited-meta {
  color: #00784a;
  font-weight: 900;
}

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

.service-key-field {
  grid-column: 1 / -1;
}

.user-form .full,
.advanced-fields {
  grid-column: 1 / -1;
}

#userSaveStatus {
  grid-column: span 3;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(24, 160, 111, 0.12);
}

button,
a,
.user-item {
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

button:not(:disabled):hover,
a:hover,
.user-item:hover {
  transform: translateY(-1px);
}

@media (max-width: 1080px) {
  .metrics,
  .workspace,
  .logs-grid,
  .advanced-grid,
  .user-form,
  .brand-strip {
    grid-template-columns: 1fr;
  }

  .service-key-field,
  #userSaveStatus {
    grid-column: 1;
  }

  .user-service-key-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .admin-shell {
    width: min(100% - 16px, 100%);
    padding-top: 10px;
  }

  .admin-bar {
    position: relative;
    top: 0;
    padding: 12px;
  }

  .login-panel {
    min-height: 0;
  }

  .brand-card {
    padding: 18px;
  }

  .brand-card h1 {
    font-size: 30px;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .metrics article {
    padding: 10px;
  }

  .users-panel,
  .detail-panel,
  .settings-panel,
  .login-panel form {
    padding: 12px;
  }
}

/* Admin information architecture refresh */
.dashboard {
  gap: 12px;
}

.metrics article {
  position: relative;
  overflow: hidden;
  padding: 11px 14px;
}

.metrics article::after {
  content: "";
  position: absolute;
  inset: auto 12px 0 12px;
  height: 3px;
  border-radius: 999px 999px 0 0;
  background: linear-gradient(90deg, var(--brand), #16b7c8, var(--blue));
}

.brand-strip {
  padding: 10px 14px;
}

.admin-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(136px, 1fr));
  gap: 7px;
  padding: 7px;
}

.admin-tabs button {
  flex: none;
  min-height: 40px;
  white-space: nowrap;
}

.admin-tabs button:not(.active) {
  background: rgba(7, 59, 48, 0.055);
  color: var(--brand-dark);
}

.admin-tabs button:not(.active):hover {
  border-color: rgba(24, 160, 111, 0.28);
  background: rgba(24, 160, 111, 0.11);
}

.settings-panel {
  display: grid;
  gap: 12px;
}

.admin-accounts-layout,
.relay-form {
  display: grid;
  gap: 14px;
}

.relay-center-card,
.relay-code-panel {
  display: grid;
  gap: 12px;
  border: 1px solid rgba(7, 59, 48, 0.12);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(238, 251, 245, 0.92), rgba(255, 255, 255, 0.96));
  padding: 12px;
}

.relay-center-card {
  grid-template-columns: minmax(220px, 0.6fr) minmax(360px, 1.4fr);
  align-items: end;
}

.relay-center-actions,
.relay-code-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.relay-center-actions button,
.relay-code-actions button {
  min-height: 40px;
  border-color: rgba(24, 160, 111, 0.24);
  background: #f4fbf7;
  color: var(--brand-dark);
}

.relay-probe-status,
.relay-model-list,
.relay-code-actions span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.45;
}

.relay-probe-status {
  grid-column: 1 / -1;
  border-left: 3px solid rgba(24, 160, 111, 0.36);
  padding-left: 10px;
}

.relay-probe-status.ok {
  color: var(--brand);
}

.relay-probe-status.error {
  color: var(--coral);
}

.relay-model-list {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.relay-model-list button {
  min-height: 34px;
  border-color: rgba(47, 109, 246, 0.24);
  background: #f4f7ff;
  color: var(--blue);
  padding: 0 10px;
}

.relay-code-panel textarea {
  min-height: 140px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
}

.admin-create-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  border-top: 1px solid rgba(7, 59, 48, 0.08);
  padding-top: 12px;
}

.admin-create-form button {
  min-width: 132px;
}

#adminCreateStatus,
#relaySaveStatus,
#quotaRulesStatus {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
}

#adminCreateStatus {
  grid-column: 1 / -1;
}

.admin-account-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}

.admin-account-card {
  position: relative;
  display: grid;
  gap: 5px;
  min-width: 0;
  border: 1px solid rgba(7, 59, 48, 0.1);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f5fbf9);
  padding: 12px;
}

.admin-account-card.has-delete {
  padding-right: 52px;
}

body.admin-authenticated .admin-account-delete {
  position: absolute;
  top: 9px;
  right: 9px;
  display: grid;
  place-items: center;
  width: 32px;
  min-width: 32px;
  min-height: 32px;
  border-color: rgba(221, 92, 76, 0.35);
  background: #fff7f5;
  color: #b04435;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

body.admin-authenticated .admin-account-delete:hover {
  border-color: #dd5c4c;
  background: #fff0ed;
}

.admin-account-card.current {
  border-color: rgba(47, 109, 246, 0.36);
  box-shadow: inset 3px 0 0 var(--blue);
}

.admin-account-card strong,
.admin-account-card span,
.admin-account-card small {
  min-width: 0;
  overflow-wrap: anywhere;
}

.admin-account-card span,
.admin-account-card small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.relay-url-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.relay-key-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.relay-key-grid label {
  display: grid;
  gap: 8px;
  border: 1px solid rgba(7, 59, 48, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  padding: 12px;
}

.relay-key-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.relay-key-grid span.key-ok {
  color: var(--brand);
}

.relay-key-grid span.key-missing {
  color: var(--coral);
}

.relay-key-card {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(220px, 0.75fr);
  gap: 12px;
  align-items: end;
  border: 1px solid rgba(7, 59, 48, 0.12);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(24, 160, 111, 0.06), rgba(255, 255, 255, 0.92));
  padding: 12px;
}

.relay-key-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.relay-key-card span.key-ok {
  color: var(--brand);
}

.relay-key-card span.key-missing {
  color: var(--coral);
}

.maintenance-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.maintenance-grid article {
  display: grid;
  gap: 4px;
  min-width: 0;
  border: 1px solid rgba(7, 59, 48, 0.1);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f5fbf9);
  padding: 12px;
}

.maintenance-grid span,
.maintenance-grid small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.35;
}

.maintenance-grid strong {
  color: var(--brand-dark);
  font-size: 24px;
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.maintenance-warning {
  border: 1px solid rgba(216, 90, 69, 0.22);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(216, 90, 69, 0.07), rgba(255, 255, 255, 0.9));
  padding: 12px;
}

.maintenance-warning strong {
  color: var(--coral);
  font-size: 14px;
}

.maintenance-warning p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.55;
}

#maintenanceStatus {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
}

.relay-model-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  border: 1px solid rgba(22, 183, 200, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(7, 59, 48, 0.045), rgba(22, 183, 200, 0.07)),
    #fbfffd;
  padding: 10px;
}

.relay-model-strip span {
  display: grid;
  gap: 3px;
  min-width: 0;
  border-left: 2px solid rgba(24, 160, 111, 0.32);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.35;
  padding: 2px 0 2px 8px;
}

.relay-model-strip strong {
  color: var(--brand-dark);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.relay-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid rgba(7, 59, 48, 0.08);
  padding-top: 12px;
}

.relay-brand {
  display: grid;
  gap: 4px;
  min-width: min(420px, 100%);
  margin-right: auto;
}

.relay-brand span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  overflow-wrap: anywhere;
  text-transform: uppercase;
}

.relay-brand a {
  width: max-content;
  min-height: 30px;
}

.recharge-code-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  border: 1px solid rgba(7, 59, 48, 0.1);
  border-radius: 8px;
  background: #f6fbf8;
  padding: 10px 12px;
}

.recharge-code-summary span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.recharge-code-summary strong {
  margin-left: 5px;
  color: var(--brand-dark);
  font-size: 16px;
}

.recharge-code-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 10px;
  align-items: end;
  border: 1px solid rgba(24, 160, 111, 0.18);
  border-radius: 8px;
  background: #fbfffd;
  padding: 12px;
}

.recharge-code-form button {
  min-height: 42px;
  grid-column: span 2;
}

.recharge-code-form input[readonly] {
  background: #f3f6f4;
  color: var(--muted);
}

#rechargeCodeStatus {
  grid-column: 1 / -1;
  min-height: 18px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.latest-recharge-code {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(47, 109, 246, 0.24);
  border-radius: 8px;
  background: #f4f7ff;
  padding: 10px 12px;
}

.latest-recharge-code[hidden] {
  display: none;
}

.latest-recharge-code span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.latest-recharge-code code {
  color: var(--blue);
  font-size: 16px;
  font-weight: 950;
  letter-spacing: 0;
}

.latest-recharge-code button {
  min-height: 34px;
  margin-left: auto;
  padding: 0 12px;
}

.recharge-code-table-wrap code {
  color: var(--brand-dark);
  font-weight: 900;
  letter-spacing: 0;
  white-space: nowrap;
}

.recharge-code-table-wrap table {
  min-width: 1380px;
}

.model-cost-settings {
  display: grid;
  gap: 12px;
  border: 1px solid rgba(22, 183, 200, 0.18);
  border-radius: 8px;
  background: #f8fcfa;
  padding: 14px;
}

.quota-advanced-settings {
  overflow: hidden;
  border: 1px solid rgba(7, 59, 48, 0.12);
  border-radius: 8px;
  background: #fbfdfc;
}

.quota-advanced-settings > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  padding: 14px;
  color: var(--ink);
  font-weight: 900;
}

.quota-advanced-settings > summary small {
  color: var(--muted);
  font-size: 12px;
}

.quota-advanced-body {
  display: grid;
  gap: 14px;
  border-top: 1px solid rgba(7, 59, 48, 0.08);
  padding: 14px;
}

.announcement-form {
  display: grid;
  gap: 14px;
}

.announcement-message-field {
  display: grid;
  gap: 7px;
}

.announcement-message-field textarea {
  min-height: 132px;
  resize: vertical;
}

.announcement-enabled-control {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  width: fit-content;
  color: var(--ink);
  font-weight: 850;
}

.announcement-enabled-control input {
  width: auto;
  accent-color: var(--brand);
}

.model-cost-settings h3,
.model-cost-settings p {
  margin: 0;
}

.model-cost-settings p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.model-cost-rows {
  display: grid;
  gap: 10px;
}

.model-cost-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) repeat(3, minmax(150px, 0.7fr));
  gap: 10px;
  align-items: end;
  border-top: 1px solid rgba(7, 59, 48, 0.09);
  padding-top: 10px;
}

.model-cost-row > div {
  display: grid;
  gap: 4px;
  align-self: center;
}

.model-cost-row > div span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.model-cost-row > div strong {
  overflow-wrap: anywhere;
  color: var(--brand-dark);
}

.task-financial-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.task-financial-summary span {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbf9;
  color: var(--muted);
  padding: 10px;
  font-size: 12px;
  font-weight: 850;
}

.task-financial-summary strong {
  color: var(--brand-dark);
  font-size: 17px;
}

#taskLogPanel table {
  min-width: 1780px;
}

.task-cost-input {
  width: 112px;
  min-height: 34px;
  padding: 6px 8px;
}

.task-cost-save {
  min-height: 34px;
  white-space: nowrap;
}

.task-margin.negative,
#taskFailedCostTotal {
  color: #bd3f31;
}

.task-margin.positive {
  color: var(--brand-dark);
}

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

.recharge-status.unused {
  background: #eef7ff;
  color: var(--blue);
}

.recharge-status.redeemed {
  background: #eaf8f0;
  color: var(--brand);
}

.recharge-status.disabled {
  background: #fff1ee;
  color: var(--coral);
}

.recharge-redemption-cell small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.recharge-row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.recharge-row-actions button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.recharge-row-actions .disable {
  border-color: rgba(215, 77, 56, 0.28);
  background: #fff5f2;
  color: var(--coral);
}

.recharge-row-actions .enable {
  border-color: rgba(24, 160, 111, 0.28);
  background: #f3fbf6;
  color: var(--brand-dark);
}

.recharge-row-actions .delete {
  border-color: rgba(215, 77, 56, 0.34);
  background: #fff;
  color: var(--coral);
}

.recharge-row-actions .delete:hover {
  background: #ffece7;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
  transform: none !important;
}

@media (max-width: 1180px) {
  .relay-key-card,
  .relay-key-grid,
  .relay-url-grid,
  .relay-model-strip,
  .maintenance-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

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

  .task-financial-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .recharge-code-form button {
    width: 100%;
    grid-column: 1 / -1;
  }

  .admin-create-form button {
    width: 100%;
  }
}

@media (max-width: 760px) {
  .admin-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-tabs button {
    min-height: 38px;
    padding: 0 8px;
  }

  .relay-key-card,
  .relay-key-grid,
  .relay-url-grid,
  .relay-model-strip,
  .maintenance-grid,
  .admin-create-form,
  .recharge-code-form {
    grid-template-columns: 1fr;
  }

  .model-cost-row,
  .task-financial-summary {
    grid-template-columns: 1fr;
  }

  .latest-recharge-code {
    align-items: stretch;
    flex-direction: column;
  }

  .latest-recharge-code button {
    width: 100%;
    margin-left: 0;
  }

  .relay-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .relay-footer button,
  .relay-brand a {
    width: 100%;
  }

  .admin-account-list {
    grid-template-columns: 1fr;
  }
}

/* 2026 control-deck redesign: shared with the user workspace */
:root {
  --admin-shell: #152127;
  --admin-shell-soft: #1c2b31;
  --admin-canvas: #f5f7f6;
  --admin-surface: #ffffff;
  --admin-line: #dfe5e2;
  --admin-ink: #18211f;
  --admin-muted: #68736f;
  --admin-green: #237a56;
  --admin-green-soft: #e8f2ed;
  --admin-cyan: #1b8f9c;
  --admin-gold: #c48a24;
  --admin-coral: #c95c49;
}

body.admin-authenticated {
  background: var(--admin-canvas);
  color: var(--admin-ink);
}

body.admin-authenticated .admin-shell {
  width: 100%;
  min-height: 100vh;
  margin: 0;
  padding: 0 0 44px 224px;
}

body.admin-authenticated .admin-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: 72px;
  margin: 0;
  border: 0;
  border-bottom: 1px solid var(--admin-line);
  border-radius: 0;
  background: #ffffff;
  box-shadow: none;
  padding: 12px 24px;
}

body.admin-authenticated .admin-brand span {
  color: var(--admin-green);
  font-size: 10px;
}

body.admin-authenticated .admin-brand strong {
  color: var(--admin-ink);
  font-size: 19px;
}

body.admin-authenticated .admin-brand small {
  color: var(--admin-muted);
  font-size: 11px;
}

body.admin-authenticated .admin-actions a,
body.admin-authenticated .admin-actions button {
  min-height: 36px;
  border: 1px solid var(--admin-line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--admin-muted);
  box-shadow: none;
}

body.admin-authenticated .admin-actions button {
  background: #eef3f0;
  color: var(--admin-green);
}

body.admin-authenticated .dashboard {
  display: block;
}

body.admin-authenticated .admin-tabs {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 70;
  width: 224px;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 5px;
  overflow-y: auto;
  margin: 0;
  border: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0;
  background: var(--admin-shell);
  box-shadow: none;
  padding: 24px 18px 18px;
}

.admin-sidebar-brand {
  display: grid;
  justify-items: center;
  gap: 4px;
  margin-bottom: 20px;
  text-align: center;
}

.admin-sidebar-brand img {
  width: 72px;
  height: 72px;
  display: block;
  margin-bottom: 7px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background: #ffffff;
  object-fit: contain;
}

.admin-sidebar-brand span {
  color: #dce7e3;
  font-size: 14px;
  font-weight: 900;
}

.admin-sidebar-brand strong {
  color: #8fa19b;
  font-size: 11px;
}

.admin-sidebar-section {
  margin: 0 10px 5px;
  color: #71827c;
  font-size: 10px;
  font-weight: 900;
}

body.admin-authenticated .admin-tabs button {
  flex: 0 0 auto;
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #a0b0aa;
  padding: 0 12px;
  box-shadow: none;
  text-align: left;
}

body.admin-authenticated .admin-tabs button:hover {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
}

body.admin-authenticated .admin-tabs button.active {
  border-color: rgba(81, 177, 128, 0.28);
  background: var(--admin-green);
  color: #ffffff;
}

.admin-sidebar-footer {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  padding-top: 12px;
}

.admin-sidebar-footer a {
  width: 100%;
  min-height: 40px;
  border-color: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: #a7b7b1;
  font-size: 12px;
}

body.admin-authenticated .metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 18px 24px 10px;
}

body.admin-authenticated .metrics article {
  min-width: 0;
  min-height: 70px;
  border: 1px solid var(--admin-line);
  border-radius: 6px;
  background: #ffffff;
  box-shadow: none;
  padding: 12px 14px;
}

body.admin-authenticated .metrics article::after {
  display: none;
}

body.admin-authenticated .metrics article:nth-child(1) {
  border-top: 3px solid var(--admin-gold);
}

body.admin-authenticated .metrics article:nth-child(2) {
  border-top: 3px solid var(--admin-green);
}

body.admin-authenticated .metrics article:nth-child(3) {
  border-top: 3px solid var(--admin-cyan);
}

body.admin-authenticated .metrics article:nth-child(4) {
  border-top: 3px solid var(--admin-coral);
}

body.admin-authenticated .metrics span {
  color: var(--admin-muted);
  font-size: 11px;
}

body.admin-authenticated .metrics strong {
  color: var(--admin-ink);
  font-size: 24px;
}

body.admin-authenticated .brand-strip {
  margin: 0 24px 14px;
  border: 1px solid var(--admin-line);
  border-radius: 6px;
  background: #ffffff;
  box-shadow: none;
  padding: 10px 14px;
}

body.admin-authenticated .brand-strip > div:first-child > span {
  color: var(--admin-green);
}

body.admin-authenticated .brand-tags span {
  border-color: var(--admin-line);
  border-radius: 5px;
  background: #f7f9f8;
  color: var(--admin-muted);
}

body.admin-authenticated .workspace,
body.admin-authenticated .settings-panel {
  margin: 0 24px;
}

body.admin-authenticated .workspace {
  grid-template-columns: minmax(250px, 300px) minmax(0, 1fr);
  gap: 12px;
}

body.admin-authenticated .users-panel,
body.admin-authenticated .detail-panel,
body.admin-authenticated .settings-panel,
body.admin-authenticated .admin-account-card,
body.admin-authenticated .setting-card {
  border-color: var(--admin-line);
  border-radius: 6px;
  background: var(--admin-surface);
  box-shadow: none;
}

body.admin-authenticated .users-panel,
body.admin-authenticated .detail-panel,
body.admin-authenticated .settings-panel {
  padding: 16px;
}

body.admin-authenticated .panel-head {
  min-height: 42px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--admin-line);
  padding-bottom: 12px;
}

body.admin-authenticated .panel-head h2 {
  color: var(--admin-ink);
  font-size: 17px;
}

body.admin-authenticated button,
body.admin-authenticated a,
body.admin-authenticated input,
body.admin-authenticated select,
body.admin-authenticated textarea {
  border-radius: 6px;
}

body.admin-authenticated input,
body.admin-authenticated select,
body.admin-authenticated textarea {
  border-color: var(--admin-line);
  background: #ffffff;
}

body.admin-authenticated button {
  background: var(--admin-green);
  box-shadow: none;
}

body.admin-authenticated button:hover {
  background: #1c6849;
}

body.admin-authenticated .user-list article,
body.admin-authenticated .user-list button,
body.admin-authenticated .advanced-fields,
body.admin-authenticated .quota-mode-card,
body.admin-authenticated .relay-key-card,
body.admin-authenticated .relay-model-grid,
body.admin-authenticated .relay-url-grid,
body.admin-authenticated .maintenance-warning,
body.admin-authenticated .recharge-code-summary,
body.admin-authenticated .recharge-code-form,
body.admin-authenticated .latest-recharge-code {
  border-color: var(--admin-line);
  border-radius: 6px;
  background: #fbfcfb;
  box-shadow: none;
}

body.admin-authenticated .table-wrap {
  border: 1px solid var(--admin-line);
  border-radius: 6px;
  background: #ffffff;
}

body.admin-authenticated table th {
  background: #f4f7f5;
  color: var(--admin-muted);
}

body.admin-authenticated table td,
body.admin-authenticated table th {
  border-color: var(--admin-line);
}

@media (max-width: 980px) {
  body.admin-authenticated .admin-shell {
    padding-top: 118px;
    padding-left: 0;
  }

  body.admin-authenticated .admin-bar {
    position: fixed;
    min-height: 64px;
    inset: 0 0 auto 0;
    padding: 8px 12px;
  }

  body.admin-authenticated .admin-tabs {
    position: fixed;
    top: 64px;
    right: 0;
    left: 0;
    width: 100%;
    height: 54px;
    display: flex;
    flex-direction: row;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: var(--admin-shell-soft);
    padding: 7px 12px;
    scrollbar-width: none;
  }

  body.admin-authenticated .admin-tabs::-webkit-scrollbar {
    display: none;
  }

  .admin-sidebar-brand,
  .admin-sidebar-section,
  .admin-sidebar-footer {
    display: none;
  }

  body.admin-authenticated .admin-tabs button {
    flex: 0 0 auto;
    width: auto;
    min-height: 38px;
    padding: 0 13px;
  }

  body.admin-authenticated .metrics,
  body.admin-authenticated .brand-strip,
  body.admin-authenticated .workspace,
  body.admin-authenticated .settings-panel {
    margin-right: 14px;
    margin-left: 14px;
  }

  body.admin-authenticated .metrics {
    margin-top: 14px;
  }

  body.admin-authenticated .workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  body.admin-authenticated .admin-brand span {
    display: none;
  }

  body.admin-authenticated .admin-brand strong {
    font-size: 15px;
  }

  body.admin-authenticated .admin-actions a:first-child {
    display: none;
  }

  body.admin-authenticated .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin-right: 8px;
    margin-left: 8px;
  }

  body.admin-authenticated .brand-strip,
  body.admin-authenticated .workspace,
  body.admin-authenticated .settings-panel {
    margin-right: 8px;
    margin-left: 8px;
  }

  body.admin-authenticated .brand-strip {
    grid-template-columns: 1fr;
  }

  body.admin-authenticated .users-panel,
  body.admin-authenticated .detail-panel,
  body.admin-authenticated .settings-panel {
    padding: 12px;
  }
}

/* 2026 responsive admin entry: command header direction */
.admin-header-logo {
  display: none;
}

body:not(.admin-authenticated) {
  --admin-entry-shell: #172029;
  --admin-entry-green: #176b4a;
  --admin-entry-green-strong: #0f5b3d;
  --admin-entry-line: #dce3df;
  --admin-entry-muted: #64706b;
  min-height: 100vh;
  min-height: 100dvh;
  background: #f5f7f6;
}

body:not(.admin-authenticated) .admin-shell {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  padding: 20px;
}

body:not(.admin-authenticated) .admin-bar {
  position: static;
  min-height: 74px;
  justify-content: flex-start;
  gap: 12px;
  margin: 0;
  border: 0;
  border-radius: 6px 6px 0 0;
  background: var(--admin-entry-shell);
  box-shadow: none;
  padding: 12px clamp(18px, 3vw, 34px);
}

body:not(.admin-authenticated) .admin-header-logo {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  display: block;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 5px;
  background: #ffffff;
  object-fit: contain;
}

body:not(.admin-authenticated) .admin-brand {
  flex: 1;
}

body:not(.admin-authenticated) .admin-brand strong {
  color: #ffffff;
  font-size: 18px;
}

body:not(.admin-authenticated) .admin-brand span,
body:not(.admin-authenticated) .admin-brand small {
  color: #9caaa5;
  font-size: 11px;
}

body:not(.admin-authenticated) .admin-actions {
  margin-left: auto;
}

body:not(.admin-authenticated) .admin-actions a {
  min-height: 36px;
  border-color: rgba(255, 255, 255, 0.12);
  border-radius: 5px;
  background: transparent;
  color: #d7e1de;
  box-shadow: none;
  font-size: 12px;
}

body:not(.admin-authenticated) .admin-actions a:hover,
body:not(.admin-authenticated) .admin-actions a:focus-visible {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

body:not(.admin-authenticated) .login-panel {
  min-height: calc(100vh - 114px);
  min-height: calc(100dvh - 114px);
  grid-template-columns: minmax(360px, 0.9fr) minmax(430px, 1.1fr);
  gap: 0;
  align-items: stretch;
  border: 1px solid var(--admin-entry-line);
  border-top: 0;
  border-radius: 0 0 6px 6px;
  background: #ffffff;
  overflow: hidden;
}

body:not(.admin-authenticated) .brand-card,
body:not(.admin-authenticated) .login-panel form {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

body:not(.admin-authenticated) .brand-card {
  display: grid;
  align-content: center;
  gap: 18px;
  border-right: 1px solid var(--admin-entry-line);
  background: #fbfcfb;
  color: #18211e;
  padding: clamp(42px, 7vw, 92px);
}

body:not(.admin-authenticated) .brand-card > span {
  color: var(--admin-entry-green);
  font-size: 11px;
}

body:not(.admin-authenticated) .brand-card h1 {
  max-width: 540px;
  color: #18211e;
  font-size: clamp(26px, 2.25vw, 34px);
  line-height: 1.25;
}

.admin-access-steps {
  display: grid;
}

.admin-access-steps li {
  min-width: 0;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  border-bottom: 1px solid #e3e9e6;
  padding: 19px 0;
}

.admin-access-steps li:last-child {
  border-bottom: 0;
}

.admin-access-steps li > span {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--admin-entry-green);
  color: #ffffff;
  font-size: 12px;
  font-weight: 900;
}

.admin-access-steps strong {
  display: block;
  color: #1b2521;
  font-size: 15px;
}

.admin-access-steps p {
  margin: 5px 0 0;
  color: var(--admin-entry-muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.55;
}

body:not(.admin-authenticated) .login-panel form {
  width: min(100%, 500px);
  align-self: center;
  justify-self: center;
  align-content: center;
  gap: 15px;
  background: #ffffff;
  padding: clamp(38px, 6vw, 76px) clamp(28px, 5vw, 58px);
}

.admin-login-eyebrow {
  color: var(--admin-entry-green);
  font-size: 11px;
  font-weight: 900;
}

body:not(.admin-authenticated) .login-panel h1 {
  margin: 0;
  color: #18211e;
  font-size: clamp(28px, 2.6vw, 36px);
  line-height: 1.2;
}

.admin-login-description {
  margin: -7px 0 7px;
  color: var(--admin-entry-muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.55;
}

body:not(.admin-authenticated) .login-panel label {
  gap: 7px;
  color: #4f5b56;
  font-size: 12px;
}

body:not(.admin-authenticated) .login-panel input {
  min-height: 50px;
  border-color: #cfd8d3;
  border-radius: 5px;
  background: #ffffff;
  padding: 0 14px;
  box-shadow: none;
}

body:not(.admin-authenticated) .login-panel input:focus {
  border-color: var(--admin-entry-green);
  outline: 3px solid rgba(23, 107, 74, 0.12);
}

body:not(.admin-authenticated) .login-panel button[type="submit"] {
  min-height: 50px;
  border-radius: 5px;
  background: var(--admin-entry-green);
  box-shadow: none;
}

body:not(.admin-authenticated) .login-panel button[type="submit"]:hover {
  background: var(--admin-entry-green-strong);
}

body:not(.admin-authenticated) #loginStatus {
  min-height: 35px;
  margin: 2px 0 0;
  border-top: 1px solid var(--admin-entry-line);
  padding-top: 12px;
  color: var(--admin-entry-muted);
  font-size: 12px;
  line-height: 1.5;
}

body.admin-authenticated .admin-header-logo {
  display: none;
}

@media (max-width: 760px) {
  body:not(.admin-authenticated) .admin-shell {
    padding: 0;
  }

  body:not(.admin-authenticated) .admin-bar {
    min-height: 108px;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    align-content: center;
    align-items: center;
    gap: 8px 12px;
    border-radius: 0;
    padding: 10px 18px;
  }

  body:not(.admin-authenticated) .admin-header-logo {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
  }

  body:not(.admin-authenticated) .admin-brand strong {
    font-size: 15px;
  }

  body:not(.admin-authenticated) .admin-brand span {
    display: none;
  }

  body:not(.admin-authenticated) .admin-actions {
    grid-column: 1 / -1;
    width: 100%;
    justify-content: space-between;
    margin-left: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.09);
    padding-top: 8px;
  }

  body:not(.admin-authenticated) .admin-actions a {
    min-height: 30px;
    border: 0;
    padding: 0;
    font-size: 11px;
  }

  body:not(.admin-authenticated) .login-panel {
    min-height: calc(100vh - 108px);
    min-height: calc(100dvh - 108px);
    grid-template-columns: 1fr;
    border: 0;
    border-radius: 0;
  }

  body:not(.admin-authenticated) .login-panel form {
    order: 1;
    width: 100%;
    padding: 34px 20px 26px;
  }

  body:not(.admin-authenticated) .brand-card {
    order: 2;
    min-height: auto;
    gap: 10px;
    border: 0;
    border-top: 1px solid var(--admin-entry-line);
    background: #f7f9f8;
    padding: 22px 20px 30px;
  }

  body:not(.admin-authenticated) .brand-card h1 {
    font-size: 19px;
  }

  .admin-access-steps {
    display: none;
  }
}

@media (max-width: 400px) {
  body:not(.admin-authenticated) .login-panel form,
  body:not(.admin-authenticated) .brand-card {
    padding-right: 16px;
    padding-left: 16px;
  }
}

.upstream-manager {
  display: grid;
  gap: 14px;
  margin-top: 4px;
}

.upstream-simple-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  border: 1px solid rgba(7, 59, 48, 0.12);
  border-radius: 8px;
  background: #f4f8f6;
  padding: 6px;
}

body.admin-authenticated .upstream-simple-tabs button {
  min-height: 42px;
  border: 0;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}

body.admin-authenticated .upstream-simple-tabs button.active {
  background: #fff;
  color: var(--brand-dark);
  box-shadow: 0 5px 16px rgba(7, 59, 48, 0.09);
}

.upstream-simple-current {
  display: grid;
  gap: 14px;
  border: 1px solid rgba(7, 59, 48, 0.14);
  border-radius: 8px;
  background: #fff;
  padding: 20px;
  box-shadow: 0 12px 30px rgba(7, 59, 48, 0.06);
}

.upstream-simple-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.upstream-simple-heading h3 {
  margin: 0 0 5px;
  color: var(--ink);
  font-size: 20px;
}

.upstream-simple-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.upstream-simple-heading > span {
  flex: 0 0 auto;
  border: 1px solid rgba(31, 122, 84, 0.2);
  border-radius: 999px;
  background: #edf8f1;
  color: var(--brand-dark);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 900;
}

.upstream-simple-profile-list {
  display: grid;
  gap: 9px;
}

.upstream-simple-profile-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(7, 59, 48, 0.13);
  border-radius: 8px;
  background: #fff;
  padding: 12px 14px;
}

.upstream-simple-profile-item.active {
  border-color: var(--brand);
  background: #edf8f1;
  box-shadow: inset 3px 0 0 var(--brand);
}

.upstream-simple-profile-choice {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  min-width: 0;
  cursor: pointer;
}

.upstream-simple-profile-choice input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--brand);
}

.upstream-simple-profile-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.upstream-simple-profile-copy strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upstream-simple-profile-copy span,
.upstream-simple-profile-copy small {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upstream-simple-profile-copy small {
  color: var(--brand-dark);
}

body.admin-authenticated .upstream-simple-remove {
  min-width: 0;
  min-height: 32px;
  border-color: rgba(221, 92, 76, 0.26);
  background: #fff7f5;
  color: #b04435;
  padding: 5px 9px;
  box-shadow: none;
}

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

body.admin-authenticated .upstream-simple-details {
  min-width: 0;
  min-height: 32px;
  border-color: rgba(31, 122, 84, 0.25);
  background: #f4fbf7;
  color: var(--brand-dark);
  padding: 5px 10px;
  box-shadow: none;
}

.upstream-current-recognition {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px 12px;
  border-top: 1px solid rgba(7, 59, 48, 0.1);
  margin-top: 12px;
  padding-top: 12px;
}

.upstream-current-recognition > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.upstream-current-detected-models {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  border: 1px solid rgba(31, 122, 84, 0.16);
  border-radius: 8px;
  background: #f7fbf8;
  padding: 10px;
}

.upstream-current-detected-models > strong {
  color: var(--brand-dark);
  font-size: 12px;
}

.upstream-current-detected-models > div {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

body.admin-authenticated .upstream-current-detected-models button {
  min-height: 30px;
  border-radius: 999px;
  background: #fff;
  color: var(--brand-dark);
  padding: 4px 9px;
  box-shadow: none;
}

.upstream-auto-connect {
  display: grid;
  gap: 14px;
  border: 1px solid rgba(7, 59, 48, 0.14);
  border-radius: 8px;
  background: linear-gradient(135deg, #f5fbf8 0%, #ffffff 64%);
  padding: 20px;
  box-shadow: 0 12px 30px rgba(7, 59, 48, 0.07);
}

.upstream-auto-connect-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.upstream-auto-connect-head h3 {
  margin: 0 0 5px;
  color: var(--ink);
  font-size: 20px;
  letter-spacing: 0;
}

.upstream-auto-connect-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.upstream-auto-connect-head > span {
  flex: 0 0 auto;
  border: 1px solid rgba(22, 163, 112, 0.25);
  border-radius: 999px;
  background: #eaf8f1;
  color: var(--brand-dark);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 900;
}

.upstream-auto-connect-form {
  display: grid;
  grid-template-columns: minmax(260px, 1.2fr) minmax(260px, 1.2fr) minmax(180px, auto);
  gap: 12px;
  align-items: end;
}

.upstream-auto-models {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  align-items: end;
  border-top: 1px solid rgba(7, 59, 48, 0.1);
  padding-top: 14px;
}

body.admin-authenticated .upstream-auto-models button {
  grid-column: 1 / -1;
  min-height: 44px;
  white-space: nowrap;
}

.upstream-auto-model-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

body.admin-authenticated .upstream-auto-model-actions button {
  grid-column: auto;
  min-width: 160px;
}

body.admin-authenticated #upstreamRediscoverModelsBtn {
  border-color: rgba(7, 59, 48, 0.18);
  background: #f3f7f5;
  color: var(--brand-dark);
  box-shadow: none;
}

.upstream-detected-models {
  display: grid;
  gap: 10px;
  border: 1px solid rgba(7, 59, 48, 0.12);
  border-radius: 8px;
  background: #fbfdfc;
  padding: 14px;
}

.upstream-detected-heading,
.upstream-detected-model-group > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.upstream-detected-heading strong,
.upstream-detected-model-group strong {
  color: var(--ink);
}

.upstream-detected-heading span,
.upstream-detected-model-group span,
.upstream-detected-model-group p {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.upstream-detected-model-groups {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.upstream-detected-model-group {
  min-width: 0;
  border: 1px solid rgba(7, 59, 48, 0.1);
  border-radius: 6px;
  background: #fff;
  padding: 10px;
}

.upstream-detected-model-group ul {
  max-height: 190px;
  overflow: auto;
  display: grid;
  gap: 5px;
  margin: 9px 0 0;
  padding: 0;
  list-style: none;
}

.upstream-detected-model-group li {
  min-width: 0;
  border-radius: 4px;
  background: #f4f8f6;
  padding: 6px 7px;
}

.upstream-detected-model-group code {
  display: block;
  overflow-wrap: anywhere;
  color: var(--brand-dark);
  font-size: 11px;
}

body.admin-authenticated .upstream-auto-connect-form button {
  min-height: 44px;
  white-space: nowrap;
}

.upstream-auto-status {
  border-left: 3px solid #c8d7d1;
  color: var(--muted);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 850;
}

.upstream-auto-status.ok {
  border-color: var(--brand);
  color: var(--brand-dark);
}

.upstream-auto-status.error {
  border-color: #dd5c4c;
  color: #b04435;
}

.upstream-expert-manager {
  overflow: hidden;
  border: 1px solid rgba(7, 59, 48, 0.14);
  border-radius: 8px;
  background: #fff;
}

.upstream-expert-manager > summary,
.upstream-advanced-details > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
  color: var(--ink);
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 950;
}

.upstream-expert-manager > summary::-webkit-details-marker,
.upstream-advanced-details > summary::-webkit-details-marker {
  display: none;
}

.upstream-expert-manager > summary::after,
.upstream-advanced-details > summary::after {
  content: "+";
  margin-left: auto;
  color: var(--brand);
  font-size: 21px;
  line-height: 1;
}

.upstream-expert-manager[open] > summary::after,
.upstream-advanced-details[open] > summary::after {
  content: "−";
}

.upstream-expert-manager > summary small,
.upstream-advanced-details > summary small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.upstream-expert-body {
  display: grid;
  gap: 14px;
  border-top: 1px solid rgba(7, 59, 48, 0.1);
  padding: 14px;
}

.upstream-route-bar,
.upstream-workspace,
.legacy-relay-details {
  border: 1px solid rgba(7, 59, 48, 0.14);
  border-radius: 8px;
  background: #fff;
}

.upstream-route-bar {
  display: grid;
  gap: 12px;
  padding: 14px;
  box-shadow: 0 10px 28px rgba(7, 59, 48, 0.06);
}

.upstream-section-heading,
.upstream-sidebar-head,
.upstream-subhead,
.upstream-editor-footer,
.upstream-probe-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.upstream-section-heading > div {
  display: grid;
  gap: 3px;
}

.upstream-section-heading strong,
.upstream-sidebar-head strong,
.upstream-subhead strong {
  color: var(--ink);
  font-size: 15px;
  font-weight: 950;
}

.upstream-section-heading span,
.upstream-subhead span,
.upstream-editor-footer span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.upstream-route-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.upstream-workspace {
  display: grid;
  grid-template-columns: minmax(190px, 230px) minmax(0, 1fr);
  min-height: 560px;
  overflow: hidden;
}

.upstream-profile-sidebar {
  border-right: 1px solid rgba(7, 59, 48, 0.12);
  background: #f5faf7;
  padding: 12px;
}

.upstream-sidebar-head {
  margin-bottom: 10px;
}

.upstream-sidebar-head button,
.upstream-subhead button {
  min-height: 34px;
  padding: 6px 11px;
}

.upstream-profile-list {
  display: grid;
  gap: 7px;
}

body.admin-authenticated .upstream-profile-item {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 1px solid rgba(7, 59, 48, 0.12);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 10px;
  text-align: left;
}

body.admin-authenticated .upstream-profile-item:hover,
body.admin-authenticated .upstream-profile-item.active {
  border-color: var(--brand);
  background: #e9f7f0;
  color: var(--brand-dark);
}

.upstream-profile-item strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upstream-profile-item span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.upstream-profile-item .disabled {
  color: #b04435;
}

.upstream-editor-shell {
  min-width: 0;
  padding: 14px;
}

.upstream-empty-state {
  display: grid;
  min-height: 240px;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.upstream-editor {
  display: grid;
  gap: 14px;
}

.upstream-quick-card {
  display: grid;
  gap: 12px;
  border: 1px solid rgba(22, 183, 200, 0.2);
  border-radius: 7px;
  background: #f3fbfb;
  padding: 14px;
}

.upstream-quick-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.upstream-quick-heading > div {
  display: grid;
  gap: 3px;
}

.upstream-quick-heading strong {
  color: var(--ink);
  font-size: 15px;
  font-weight: 950;
}

.upstream-quick-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.upstream-quick-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.upstream-quick-url,
.upstream-quick-grid .upstream-key-field {
  grid-column: span 2;
}

.upstream-quick-heading .upstream-operation-enabled {
  margin-left: 0;
  padding: 0;
}

.upstream-quick-import {
  padding: 10px 12px;
}

.upstream-advanced-details {
  overflow: hidden;
  border: 1px solid rgba(7, 59, 48, 0.11);
  border-radius: 7px;
  background: #fbfdfc;
}

.upstream-advanced-body {
  display: grid;
  gap: 12px;
  border-top: 1px solid rgba(7, 59, 48, 0.08);
  padding: 12px;
}

.upstream-profile-fields,
.upstream-operation-grid,
.upstream-response-grid,
.upstream-polling-fields {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.upstream-notes-field,
.upstream-key-field {
  grid-column: span 2;
}

.upstream-key-field small {
  min-height: 16px;
  color: var(--brand);
}

.upstream-capability-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  border-block: 1px solid rgba(7, 59, 48, 0.1);
  padding-block: 10px;
}

body.admin-authenticated .upstream-capability-tabs button {
  min-height: 40px;
  border-color: transparent;
  background: #f0f4f2;
  color: var(--muted);
}

body.admin-authenticated .upstream-capability-tabs button.active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.upstream-operation-toolbar {
  display: flex;
  align-items: end;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(22, 183, 200, 0.2);
  border-radius: 7px;
  background: #f3fbfb;
}

.upstream-operation-toolbar label:first-child {
  min-width: min(320px, 45%);
}

.upstream-operation-enabled,
.upstream-async-toggle {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.upstream-operation-enabled {
  margin-left: auto;
  padding-bottom: 10px;
}

.upstream-operation-enabled input,
.upstream-async-toggle input {
  width: auto;
  accent-color: var(--brand);
}

.upstream-mapping-section,
.upstream-probe-section,
.upstream-curl-import {
  display: grid;
  gap: 10px;
  border: 1px solid rgba(7, 59, 48, 0.11);
  border-radius: 7px;
  background: #fbfdfc;
  padding: 12px;
}

.upstream-parameter-head,
.upstream-parameter-row {
  display: grid;
  grid-template-columns: minmax(140px, 1.2fr) minmax(150px, 1.1fr) minmax(150px, 1.4fr) minmax(90px, 0.7fr) 38px;
  gap: 7px;
  align-items: center;
}

.upstream-parameter-head {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.upstream-parameter-rows {
  display: grid;
  gap: 7px;
}

.upstream-parameter-row input,
.upstream-parameter-row select {
  min-width: 0;
}

.upstream-parameter-remove {
  width: 38px;
  min-width: 38px;
  min-height: 38px;
  padding: 0;
  border-color: #efb5ad;
  background: #fff7f5;
  color: #b04435;
  font-size: 20px;
}

.upstream-polling-fields {
  padding-top: 10px;
  border-top: 1px solid rgba(7, 59, 48, 0.08);
}

.upstream-curl-import summary {
  cursor: pointer;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.upstream-curl-import textarea {
  margin-top: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}

.upstream-curl-import button {
  justify-self: start;
}

.upstream-probe-actions {
  flex-wrap: wrap;
  justify-content: flex-start;
}

.upstream-probe-actions label {
  min-width: 220px;
  margin-left: auto;
}

.upstream-probe-status {
  border-left: 3px solid #c8d7d1;
  color: var(--muted);
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 850;
}

.upstream-probe-status.ok {
  border-color: var(--brand);
  color: var(--brand-dark);
}

.upstream-probe-status.error {
  border-color: #dd5c4c;
  color: #b04435;
}

.upstream-response-paths {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 190px;
  overflow: auto;
}

.upstream-response-paths button {
  min-height: 30px;
  border-color: rgba(47, 109, 246, 0.25);
  background: #f4f7ff;
  color: #315fbd;
  padding: 5px 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
}

.upstream-response-sample {
  max-height: 260px;
  overflow: auto;
  margin: 0;
  border: 1px solid rgba(7, 59, 48, 0.1);
  border-radius: 6px;
  background: #10231f;
  color: #d8f4e7;
  padding: 10px;
  font-size: 11px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.upstream-editor-footer {
  border-top: 1px solid rgba(7, 59, 48, 0.1);
  padding-top: 12px;
}

.upstream-editor-footer span {
  flex: 1;
}

.legacy-relay-details {
  padding: 12px;
}

.legacy-relay-details > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.legacy-relay-details[open] > summary {
  margin-bottom: 12px;
  color: var(--ink);
}

@media (max-width: 1100px) {
  .upstream-auto-connect-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .upstream-auto-connect-form button {
    grid-column: 1 / -1;
  }

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

  .upstream-detected-model-groups {
    grid-template-columns: 1fr;
  }

  .upstream-auto-models button {
    grid-column: 1 / -1;
  }

  .upstream-route-grid,
  .upstream-profile-fields,
  .upstream-quick-grid,
  .upstream-operation-grid,
  .upstream-response-grid,
  .upstream-polling-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .upstream-workspace {
    grid-template-columns: 190px minmax(0, 1fr);
  }

  .upstream-parameter-head {
    display: none;
  }

  .upstream-parameter-row {
    grid-template-columns: repeat(2, minmax(0, 1fr)) 38px;
    padding: 8px;
    border: 1px solid rgba(7, 59, 48, 0.08);
    border-radius: 6px;
  }
}

@media (max-width: 760px) {
  .service-key-heading,
  .user-platform-service-notice,
  .upstream-simple-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .user-key-mode-toggle,
  .upstream-simple-heading > span {
    align-self: flex-start;
  }

  .upstream-simple-current {
    padding: 14px;
  }

  .upstream-simple-profile-item {
    grid-template-columns: minmax(0, 1fr);
  }

  body.admin-authenticated .upstream-simple-remove {
    width: 100%;
  }

  .upstream-simple-profile-actions,
  .upstream-current-recognition {
    grid-template-columns: 1fr;
  }

  .upstream-simple-profile-actions {
    display: grid;
  }

  body.admin-authenticated .upstream-simple-details,
  body.admin-authenticated .upstream-simple-remove,
  body.admin-authenticated #upstreamRediscoverCurrentBtn {
    width: 100%;
  }

  .upstream-auto-connect {
    padding: 14px;
  }

  .upstream-auto-connect-head,
  .upstream-quick-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .upstream-auto-connect-head > span {
    align-self: flex-start;
  }

  .upstream-auto-connect-form {
    grid-template-columns: 1fr;
  }

  .upstream-auto-models {
    grid-template-columns: 1fr;
  }

  .upstream-auto-model-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  body.admin-authenticated .upstream-auto-model-actions button {
    width: 100%;
    min-width: 0;
  }

  .upstream-auto-connect-form button {
    grid-column: auto;
  }

  .upstream-auto-models button {
    grid-column: auto;
  }

  .quota-advanced-settings > summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .upstream-expert-manager > summary,
  .upstream-advanced-details > summary {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .upstream-expert-manager > summary small,
  .upstream-advanced-details > summary small {
    width: calc(100% - 30px);
  }

  .upstream-section-heading,
  .upstream-operation-toolbar,
  .upstream-editor-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .upstream-section-heading button,
  .upstream-editor-footer button {
    width: 100%;
  }

  .upstream-route-grid,
  .upstream-profile-fields,
  .upstream-quick-grid,
  .upstream-operation-grid,
  .upstream-response-grid,
  .upstream-polling-fields {
    grid-template-columns: 1fr;
  }

  .upstream-workspace {
    grid-template-columns: 1fr;
  }

  .upstream-profile-sidebar {
    border-right: 0;
    border-bottom: 1px solid rgba(7, 59, 48, 0.12);
  }

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

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

  .upstream-operation-toolbar label:first-child,
  .upstream-probe-actions label {
    min-width: 0;
    margin-left: 0;
  }

  .upstream-operation-enabled {
    margin-left: 0;
    padding: 4px 0;
  }

  .upstream-notes-field,
  .upstream-quick-url,
  .upstream-key-field {
    grid-column: auto;
  }

  .upstream-parameter-row {
    grid-template-columns: 1fr 38px;
  }

  .upstream-parameter-row > :not(.upstream-parameter-remove) {
    grid-column: 1;
  }

  .upstream-parameter-remove {
    grid-column: 2;
    grid-row: 1;
  }
}
