/* Hub owns its console surface; shared legacy console styles are intentionally isolated. */
:root {
  color-scheme: light;
  --canvas: #f6f7f9;
  --surface: #fff;
  --surface-2: #f0f2f6;
  --surface-3: #e9edf2;
  --ink: #202633;
  --ink-2: #3f495b;
  --muted: #657084;
  --line: #dde2e9;
  --accent: #6551bf;
  --accent-ink: #503b9f;
  --accent-soft: #eeeafa;
  --green: #246c50;
  --green-soft: #e9f4ed;
  --amber: #825715;
  --amber-soft: #fbf2df;
  --red: #ac3434;
  --red-soft: #fbeaea;
  --radius: 12px;
  --radius-sm: 8px;
  font:
    15px/1.55 -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    'PingFang SC',
    'Microsoft YaHei',
    sans-serif;
  color: var(--ink);
  background: var(--canvas);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
[hidden] {
  display: none !important;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1 {
  font-size: 25px;
  line-height: 1.35;
  font-weight: 650;
}
h2 {
  font-size: 18px;
  font-weight: 650;
}
h3 {
  font-size: 15px;
  font-weight: 600;
}
a {
  color: var(--accent-ink);
  text-underline-offset: 3px;
}
code,
pre,
.money,
.hub-token {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}
code {
  font-size: 12px;
  overflow-wrap: anywhere;
}
button,
input,
select,
textarea {
  font: inherit;
}
button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  text-decoration: none;
  transition:
    background 160ms,
    border-color 160ms;
}
button:hover,
.btn:hover {
  background: var(--surface-2);
  border-color: #b8c0cd;
}
button:active,
.btn:active {
  background: var(--surface-3);
}
button.primary,
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
button.primary:hover,
.btn.primary:hover {
  background: var(--accent-ink);
}
button:disabled {
  cursor: wait;
  opacity: 0.55;
}
input,
select,
textarea {
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid #bcc5d2;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  min-width: 0;
}
input::placeholder,
textarea::placeholder {
  color: var(--muted);
}
input,
textarea {
  caret-color: var(--accent);
}
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
::selection {
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.muted {
  color: var(--muted);
}
.actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.skip-link {
  position: fixed;
  top: -70px;
  left: 250px;
  z-index: 100;
  padding: 12px;
  background: white;
}
.skip-link:focus {
  top: 12px;
}
.sidebar {
  width: 232px;
  height: 100dvh;
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  padding: 30px 16px 20px;
  background: #edf0f5;
  border-right: 1px solid var(--line);
  z-index: 40;
}
.brand {
  display: flex;
  text-decoration: none;
  color: var(--ink);
  font-size: 19px;
  font-weight: 700;
  padding: 0 12px 28px;
}
.brand-sub {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  margin-top: 4px;
}
.sidebar nav {
  overflow-y: auto;
  flex: 1;
}
.nav-label {
  color: var(--muted);
  font-size: 12px;
  padding: 12px 12px 8px;
}
.hub-admin .nav-label {
  margin-top: 18px;
}
.sidebar nav button {
  width: 100%;
  min-height: 44px;
  text-align: left;
  justify-content: flex-start;
  margin: 2px 0;
  padding: 10px 12px;
  border-color: transparent;
  background: transparent;
  font-weight: 450;
}
.sidebar nav button:hover {
  background: #e2e6ee;
}
.sidebar nav button.active {
  color: var(--accent-ink);
  background: #e4dff5;
  font-weight: 650;
}
.nav-icon {
  width: 18px;
  height: 18px;
  margin-right: 11px;
  flex: 0 0 auto;
}
.sidebar-foot {
  margin-top: 20px;
  padding: 16px 12px 0;
  border-top: 1px solid var(--line);
}
.side-user {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}
.sidebar-foot button {
  padding: 5px 9px;
  min-height: 32px;
  font-size: 12px;
}
.environment {
  margin-top: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
}
.workspace {
  margin-left: 232px;
  max-width: 1900px;
  padding: 38px 40px 60px;
  min-width: 0;
}
.page-head {
  display: flex;
  align-items: center;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 30px;
}
.page-heading {
  flex: 1;
  min-width: 0;
}
.page-head p {
  margin-top: 8px;
  font-size: 14px;
  color: var(--muted);
  max-width: 72ch;
}
.header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.hub-toolbar {
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 13px;
}
.hub-toolbar p {
  max-width: 80ch;
}
.hub-filters {
  display: flex;
  align-items: end;
  gap: 12px;
  margin: 20px 0 16px;
  flex-wrap: wrap;
}
.hub-filters label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--ink-2);
  font-size: 13px;
}
.hub-filters label:first-child {
  flex: 1;
  min-width: 180px;
  max-width: 420px;
}
.result-count {
  color: var(--muted);
  font-size: 13px;
  margin-left: auto;
  padding-bottom: 10px;
}
.hub-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.hub-table-scroll {
  overflow-x: auto;
}
.hub-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.hub-table th,
.hub-table td {
  padding: 16px 18px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.hub-table th {
  color: var(--muted);
  background: #f8f9fb;
  font-size: 12px;
  font-weight: 550;
  white-space: nowrap;
}
.hub-table td {
  overflow-wrap: anywhere;
  max-width: 320px;
  min-width: 100px;
}
.hub-table td:last-child {
  min-width: 120px;
}
.hub-table tr:last-child td {
  border-bottom: 0;
}
.hub-table tbody tr:hover {
  background: #fafbfc;
}
.hub-table .actions {
  display: flex;
  min-width: 170px;
}
.hub-table .money {
  white-space: nowrap;
}
.hub-key-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 5px;
  overflow-wrap: anywhere;
}
.hub-model-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 70px minmax(120px, 0.5fr) 60px;
  padding: 20px 22px;
  gap: 24px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}
.hub-model-row:last-child {
  border-bottom: 0;
}
.hub-model-row h3 {
  margin-bottom: 3px;
}
.hub-state {
  display: inline-flex;
  padding: 3px 8px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 12px;
  white-space: nowrap;
  font-weight: 500;
}
.hub-state.active,
.hub-state.approved,
.hub-state.settled {
  color: var(--green);
  background: var(--green-soft);
}
.hub-state.pending,
.hub-state.pending_config,
.hub-state.uncertain,
.hub-state.reserved {
  color: var(--amber);
  background: var(--amber-soft);
}
.hub-state.rejected,
.hub-state.disabled {
  color: var(--red);
  background: var(--red-soft);
}
.hub-copy {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin: 0 0 22px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.hub-copy span {
  color: var(--muted);
  font-size: 12px;
  margin-right: 16px;
}
.hub-empty {
  padding: 48px 24px;
  text-align: center;
  background: var(--surface);
}
.hub-empty h2 {
  font-size: 17px;
  margin-bottom: 8px;
}
.hub-empty p {
  color: var(--muted);
  margin: 0 auto 16px;
  max-width: 62ch;
  font-size: 14px;
}
.hub-request {
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}
.hub-request:last-child {
  border-bottom: 0;
}
.hub-request header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}
.hub-request p {
  font-size: 14px;
  margin-bottom: 12px;
  overflow-wrap: anywhere;
}
.hub-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 40px;
  padding: 8px 0 24px;
  font-variant-numeric: tabular-nums;
}
.hub-summary div {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
}
.hub-summary strong {
  font-size: 23px;
  font-weight: 600;
}
.routing-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.routing-master {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  max-height: 70vh;
  overflow-y: auto;
}
.routing-master button {
  width: 100%;
  border: 0;
  border-radius: 6px;
  display: block;
  text-align: left;
  padding: 12px;
  font-weight: 450;
}
.routing-master button.active {
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.routing-master code {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}
.routing-master small {
  font-size: 12px;
  color: var(--muted);
}
.hub-route header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  padding: 22px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.hub-route header h2 {
  font-size: 17px;
}
.channel-row {
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}
.channel-row:last-child {
  border-bottom: 0;
}
.channel-heading {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
}
.channel-data {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  margin-top: 18px;
  font-size: 13px;
}
.channel-data div {
  min-width: 90px;
}
.channel-data dt {
  color: var(--muted);
  margin-bottom: 4px;
  font-size: 12px;
}
.channel-data dd {
  margin: 0;
}
.channel-pricing {
  font-size: 13px;
  padding-top: 12px;
  color: var(--ink-2);
}
.route-note {
  font-size: 13px;
  padding: 16px 22px;
  color: var(--muted);
  background: #f8f9fb;
  border-bottom: 1px solid var(--line);
}
.hub-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 20px;
  padding-top: 24px;
}
.hub-form label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13px;
  color: var(--ink-2);
}
.hub-form .full {
  grid-column: 1/-1;
}
.hub-form input,
.hub-form select,
.hub-form textarea {
  width: 100%;
}
.hub-form small {
  color: var(--muted);
  font-size: 12px;
}
.hub-form h3 {
  border-top: 1px solid var(--line);
  padding-top: 22px;
  margin-top: 6px;
}
.form-section {
  grid-column: 1/-1;
  border-top: 1px solid var(--line);
  padding-top: 18px;
  margin-top: 4px;
}
.form-section summary {
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  min-height: 32px;
}
.form-section .section-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 20px;
  padding-top: 14px;
}
.model-choices {
  max-height: 240px;
  overflow: auto;
  border: 1px solid #bcc5d2;
  border-radius: var(--radius-sm);
  padding: 6px 10px;
}
.model-choices label {
  display: flex;
  flex-direction: row;
  align-items: center;
  min-height: 40px;
  gap: 10px;
  font-size: 14px;
}
.model-choices input {
  width: 17px;
  min-height: 17px;
  height: 17px;
  accent-color: var(--accent);
}
.model-choices small {
  margin-left: auto;
}
.model-choice-filter {
  margin-bottom: 8px;
}
.hub-form-actions {
  display: flex;
  justify-content: end;
  gap: 8px;
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.error {
  color: var(--red);
  background: var(--red-soft);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 14px;
  margin-bottom: 20px;
}
.error:empty {
  display: none;
}
dialog {
  border: 0;
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  padding: 28px;
  box-shadow: 0 24px 80px rgb(20 30 50 / 22%);
  max-height: 88dvh;
  overflow: auto;
}
#editor {
  width: min(740px, calc(100vw - 32px));
}
#secretDialog {
  width: min(620px, calc(100vw - 32px));
}
dialog::backdrop {
  background: rgb(22 30 45 / 45%);
}
#secretDialog p {
  margin-top: 12px;
}
#secretDialog button {
  margin: 12px 6px 0 0;
}
#secretValue {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: 16px;
  background: var(--surface-2);
  user-select: all;
  border-radius: var(--radius-sm);
}
.login {
  max-width: 560px;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-top: 48px;
}
.login p {
  margin: 12px 0 24px;
}
.login details {
  border-top: 1px solid var(--line);
  margin-top: 30px;
  padding-top: 20px;
  font-size: 13px;
}
summary {
  cursor: pointer;
}
#tokenForm {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}
#loading {
  color: var(--muted);
  font-size: 14px;
  padding: 16px 0 24px;
}
.loading-line {
  height: 50px;
  border-radius: 8px;
  background: #e7ebf0;
  margin-top: 14px;
}
.loading-line:last-child {
  width: 72%;
}
.toast {
  position: fixed;
  bottom: 28px;
  left: calc(50% + 116px);
  transform: translateX(-50%) translateY(12px);
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: white;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 160ms,
    transform 160ms;
  z-index: 60;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.mobile-only,
.nav-backdrop {
  display: none;
}
@media (max-width: 1200px) {
  .workspace {
    padding: 30px 28px 50px;
  }
  .routing-layout {
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 16px;
  }
  .page-head {
    align-items: start;
    flex-wrap: wrap;
  }
}
@media (max-width: 1000px) {
  .routing-layout {
    grid-template-columns: 1fr;
  }
  .routing-master {
    max-height: 225px;
  }
  .hub-model-row {
    grid-template-columns: minmax(150px, 1fr) 60px 60px;
    gap: 16px;
  }
  .hub-model-row .hub-key-meta {
    grid-row: 2;
    grid-column: 1/-1;
    margin: 0;
  }
}
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 180ms;
    width: 260px;
  }
  body.nav-open .sidebar {
    transform: translateX(0);
  }
  body.nav-open {
    overflow: hidden;
  }
  .mobile-only {
    display: inline-flex;
  }
  #closeNav {
    align-self: end;
    margin-bottom: 12px;
  }
  .nav-backdrop:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
    background: rgb(22 30 45 / 45%);
    z-index: 35;
  }
  .workspace {
    margin-left: 0;
    padding: 24px;
  }
  .page-head {
    gap: 14px;
    margin-bottom: 24px;
  }
  .page-heading {
    flex-basis: calc(100% - 90px);
  }
  .header-actions {
    margin-left: auto;
  }
  .toast {
    left: 50%;
  }
  .skip-link {
    left: 20px;
  }
  button,
  .btn {
    min-height: 42px;
  }
}
@media (max-width: 640px) {
  .workspace {
    padding: 20px 16px 40px;
  }
  h1 {
    font-size: 22px;
  }
  .page-head p {
    line-height: 1.6;
  }
  .header-actions {
    width: 100%;
    justify-content: end;
  }
  .hub-copy {
    align-items: start;
    padding: 14px;
  }
  .hub-copy span {
    display: block;
    margin-bottom: 4px;
  }
  .hub-copy button {
    flex-shrink: 0;
    font-size: 12px;
  }
  .hub-model-row {
    padding: 18px 16px;
    gap: 12px;
    grid-template-columns: minmax(0, 1fr) 45px 50px;
  }
  .hub-table thead {
    display: none;
  }
  .hub-table,
  .hub-table tbody,
  .hub-table tr,
  .hub-table td {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: none;
  }
  .hub-table tr {
    padding: 16px;
    border-bottom: 1px solid var(--line);
  }
  .hub-table tr:last-child {
    border: 0;
  }
  .hub-table td {
    padding: 6px 0;
    border: 0;
  }
  .hub-table td::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 3px;
  }
  .hub-table td.actions {
    display: flex;
  }
  .hub-table td.actions::before {
    width: 100%;
  }
  .hub-form,
  .form-section .section-fields {
    grid-template-columns: 1fr;
  }
  .hub-form label {
    grid-column: 1/-1;
  }
  dialog {
    padding: 22px 18px;
  }
  .channel-row,
  .hub-route header,
  .route-note,
  .hub-request {
    padding: 18px 16px;
  }
  .hub-route header .actions {
    width: 100%;
  }
  .channel-heading {
    flex-wrap: wrap;
  }
  .result-count {
    width: 100%;
    margin: 0;
    padding: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

.channel-weight {
  margin: 0;
}
.weight-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}
.weight-controls input {
  width: 105px;
  min-height: 38px;
  padding: 7px 10px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}
.weight-controls button {
  white-space: nowrap;
}
.weight-error {
  color: var(--red);
  font-size: 12px;
  margin-top: 6px;
  max-width: 260px;
}
.weight-error:empty {
  display: none;
}
