.channel-view { color:var(--text-primary); }
.channel-view button.channel-metric { background:transparent; border-color:transparent; box-shadow:none; min-width:72px; }
.channel-heading { display:flex;align-items:center;min-height:38px;margin-bottom:12px; }
.channel-heading h1 { margin:0;font-size:20px;line-height:1.3; }
.channel-view .toolbar { flex-wrap:wrap;margin-bottom:12px; }
.channel-view .toolbar #count { margin-right:auto;color:var(--text-secondary);font-size:13px; }
.channel-view .toolbar select { min-width:190px; }
.channel-view .toolbar .select { width:auto; }
.channel-dialog :is(input:not([type=checkbox]),textarea):not(.input) { font:inherit;color:var(--text-primary);background-color:var(--bg-inset);border:1px solid var(--border);border-radius:var(--r-md);padding:var(--sp-3); }
.channel-view button.channel-toggle.is-enabled { background:#16805b;border-color:#16805b;color:#fff; }
.channel-view button.channel-toggle.is-disabled { background:#b94035;border-color:#b94035;color:#fff; }
#channelSearch { flex:1 1 240px;min-width:0;max-width:420px; }
.channel-view .table-wrap,.channel-dialog .table-wrap { overflow:auto;border:1px solid var(--border);border-radius:var(--r-lg);background:var(--bg-elevated); }
.channel-dialog .data-table { min-width:970px; }
.channel-view .data-table { min-width:0;table-layout:fixed;width:100%; }
.channel-view td button,.channel-dialog td button { margin:2px; }
.channel-view .data-table th,.channel-view .data-table td { text-align:center;vertical-align:middle; }
.channel-view .data-table td input[type="number"] { text-align:center; }
.channel-view footer { justify-content:flex-end;padding:var(--sp-4) 0; }
.channel-view .muted,.channel-dialog .muted { color:var(--text-secondary); }
.channel-view .new-locations,.channel-dialog .new-locations { display:flex;flex-wrap:wrap;justify-content:center;gap:5px; }
.channel-view .new-badge,.channel-dialog .new-badge { display:inline-flex;align-items:center;padding:3px 7px;border:1px solid var(--pos-border);border-radius:var(--r-md);background:var(--pos-soft);color:var(--pos-on-soft);white-space:nowrap; }
.channel-view .new-badge.failed { color:var(--neg-on-soft);background:var(--neg-soft);border-color:var(--neg-border); }
.channel-view .model-warning { color:var(--warn);font-weight:800; }
.channel-dialog { width:min(690px,95vw); max-height:90dvh; overflow:auto; overscroll-behavior:contain; }
.channel-dialog p { font-size:13px;line-height:1.5; }
.channel-dialog label { display:grid;gap:5px;font-size:var(--fs-xs);font-weight:var(--fw-medium); }
.channel-dialog label input,.channel-dialog label select,.channel-dialog label textarea { width:100%;font-weight:400; }
.channel-dialog .fields { display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px; }
.channel-dialog .wide { grid-column:1/-1; }
#supplierBalanceChannels { display:grid;gap:8px;max-height:180px;overflow:auto; }
#supplierBalanceChannels label { display:flex;align-items:center;overflow-wrap:anywhere; }
#supplierBalanceChannels input { width:auto;flex-shrink:0; }
#credentialForm label:has(input[name="upstreamPat"]) { grid-column:auto; }
.channel-dialog .actions { justify-content:flex-end;margin-top:18px; }
.channel-dialog .model-choices { display:flex;flex-wrap:wrap;align-content:flex-start;gap:8px 16px;max-height:220px;overflow:auto;margin:8px 0;padding:8px;border:1px solid var(--border);border-radius:6px; }
.channel-dialog .model-choices .model-option { max-width:100%; }
.channel-dialog .model-option,.channel-dialog .switch-row { display:flex;align-items:center;gap:6px;font-weight:400;min-width:0; }
.channel-dialog .model-option input,.channel-dialog .switch-row input { width:auto;flex-shrink:0; }
.channel-dialog .model-option span { min-width:0;white-space:normal;overflow-wrap:anywhere; }
.channel-dialog .model-list { display:flex;flex-wrap:wrap;gap:8px;max-height:55dvh;overflow:auto;align-content:flex-start; }
.channel-dialog .model-chip { max-width:100%;padding:6px 9px;border:1px solid var(--border);border-radius:6px;font-size:13px;overflow-wrap:anywhere; }
.channel-dialog .channel-switches { display:flex;align-items:center;gap:18px; }
.channel-dialog .mapping-editor { display:grid;gap:8px; }
.channel-dialog .mapping-heading { display:flex;justify-content:space-between;gap:12px; }
.channel-dialog .mapping-heading p { margin:3px 0 0; }
.channel-dialog .mapping-columns,.channel-dialog .mapping-row { display:grid;grid-template-columns:minmax(0,1fr) 24px minmax(0,1fr) auto;align-items:center;gap:8px; }
.channel-dialog .mapping-columns { color:var(--text-secondary);font-size:12px; }
.channel-dialog .mapping-columns span:nth-child(2) { grid-column:3; }
.channel-dialog .mapping-row input { min-width:0;width:100%; }
.channel-dialog .mapping-arrow { text-align:center; }
.channel-dialog .mapping-empty { padding:14px;text-align:center;border:1px dashed var(--border);border-radius:6px; }
.channel-tabs { display:flex;gap:20px;border-bottom:1px solid var(--border);margin-bottom:16px; }
.channel-view .channel-tabs button { background:transparent;border:0;border-bottom:2px solid transparent;border-radius:0;box-shadow:none;padding:12px 4px; }
.channel-view .channel-tabs button[aria-selected="true"] { border-bottom-color:var(--primary-edge);font-weight:600; }
#credentialSearch { flex:1 1 220px;min-width:160px;max-width:320px; }
@media(max-width:650px) {
  .channel-view .toolbar .select { min-width:130px;max-width:100%; }
  .channel-dialog { padding:16px; }
  .channel-dialog .fields { grid-template-columns:1fr; }
  .channel-dialog .mapping-columns { display:none; }
  .channel-dialog .mapping-row { grid-template-columns:1fr auto; }
  .channel-dialog .mapping-row input[data-map-field="to"] { grid-column:1; }
  .channel-dialog .mapping-row .mapping-arrow { display:none; }
  .channel-dialog .mapping-delete { grid-column:2;grid-row:1/3; }
}
.upstream-link{color:var(--accent);text-decoration:underline;text-decoration-color:color-mix(in srgb,var(--accent) 38%,transparent);text-underline-offset:2px}
.upstream-link:hover{text-decoration-color:currentColor}
.channel-view .new-badge.checking { color:var(--muted);background:transparent;border-color:currentColor; }
#groupDialog { width:min(1040px,95vw);max-width:95vw; }
#groupDialog.single-site { width:min(560px,95vw); }
#groupDialog.single-site .new-group-grid { grid-template-columns:1fr; }
#groupDialog .new-group-grid { display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;max-height:60dvh;overflow:auto;padding:2px; }
#groupDialog .new-group-card { min-width:0;border:1px solid var(--border);border-radius:12px;padding:16px;background:var(--bg-elevated); }
#groupDialog .new-group-card.is-selected { border-color:var(--pos-border); }
#groupDialog .new-group-card.has-error { border-color:var(--neg-border); }
#groupDialog .new-group-heading { display:flex;align-items:center;justify-content:space-between;gap:12px; }
#groupDialog .new-group-heading h3 { margin:0;font-size:15px;overflow-wrap:anywhere; }
#groupDialog .new-group-heading span { font-size:12px;white-space:nowrap; }
#groupDialog .new-group-actions { display:flex;gap:8px;margin:12px 0; }
#groupDialog .new-group-actions button { padding:4px 10px;font-size:12px; }
#groupDialog .new-group-options { display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px; }
#groupDialog .model-option { padding:10px;border:1px solid var(--border);border-radius:7px;cursor:pointer; }
#groupDialog .model-option:has(input:checked) { background:var(--pos-soft);border-color:var(--pos-border); }
#groupDialog .model-option span { white-space:normal;overflow-wrap:anywhere; }
#groupDialog .new-group-card p:empty { display:none; }
@media(max-width:700px) { #groupDialog .new-group-grid { grid-template-columns:1fr; } }
#sortChannelBalance { border:0;background:transparent;color:inherit;font:inherit;font-weight:inherit;box-shadow:none;cursor:pointer; }

/* Keep the group rates heading and actions visible while the list scrolls. */
#supplierRatesDialog[open] {
  display:flex;
  flex-direction:column;
  overflow:hidden;
  max-height:90dvh;
}
#supplierRatesDialog > :not(.table-wrap) { flex-shrink:0; }
#supplierRatesDialog > .table-wrap {
  min-height:0;
  overflow:auto;
  overscroll-behavior:contain;
}
#supplierRatesDialog thead th {
  position:sticky;
  top:0;
  z-index:1;
  background:var(--bg-elevated);
}

#vaultRows .credential-actions-cell { width:auto;white-space:normal; }
#vaultRows .credential-actions { display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,76px),1fr));align-items:center;gap:5px;width:100%; }
#vaultRows .credential-actions button { padding-inline:6px;width:100%;min-width:0;margin:0;white-space:nowrap; }


.channel-view .credential-actions button.credential-status-enabled {
  color:var(--pos-on-soft);background:var(--pos-soft);border-color:var(--pos-border);
}
.channel-view .credential-actions button.credential-status-disabled {
  color:var(--neg-on-soft);background:var(--neg-soft);border-color:var(--neg-border);
}
.channel-view .credential-actions button.credential-status-mixed {
  color:var(--warn);background:transparent;border-color:var(--warn);
}
.channel-dialog .model-option[hidden]{display:none}
#modelCatalogInstance{width:auto;max-width:220px;margin:6px}
#credentialModelSearch{margin-top:8px}
#newModelPicker{width:min(900px,94vw)}
#newModelPicker .model-choices{max-height:55dvh;min-height:120px}
.model-picker-toolbar{display:flex;gap:10px;align-items:center;flex-wrap:wrap}
.model-picker-toolbar .input{flex:1;min-width:180px}
#newModelStatus{color:var(--text-muted);margin:12px 0}

/* Keep every desktop column inside the available page width. */
.channel-view .data-table th,.channel-view .data-table td{padding:8px 5px;white-space:normal;overflow-wrap:anywhere;min-width:0}
.channel-view .data-table th button{max-width:100%;min-width:0;padding-inline:0;white-space:normal}
.channel-view td button{max-width:100%;min-width:0;font-size:12px}
.channel-view button.channel-metric{min-width:0;max-width:100%;padding-inline:0;white-space:normal}
.channel-view .new-badge{max-width:100%;white-space:normal;overflow-wrap:anywhere}
.channel-view .row-actions{max-width:100%;gap:4px}
.channel-view .row-actions button{padding-inline:5px;white-space:nowrap}
.channel-view #channelsPanel table th:nth-child(1){width:18%}
.channel-view #channelsPanel table th:nth-child(2){width:10%}
.channel-view #channelsPanel table th:nth-child(3){width:24%}
.channel-view #channelsPanel table th:nth-child(4){width:8%}
.channel-view #channelsPanel table th:nth-child(5){width:14%}
.channel-view #channelsPanel table th:nth-child(6){width:12%}
.channel-view #channelsPanel table th:nth-child(7){width:14%}

.credential-site-tabs{overflow-x:auto;flex-wrap:nowrap;margin-bottom:8px;gap:6px}
.credential-site-tabs button{flex:none;white-space:nowrap}
.credential-routing-input{width:76px;max-width:100%}
@media(max-width:760px){.credential-routing-input{width:90px}}
/* Channel-owned credential workspace: names on the left, configuration on the right. */
.credential-workspace{width:min(1180px,calc(100vw - 32px));max-width:calc(100vw - 24px);max-height:90dvh;overflow:auto}
.credential-workspace .credential-workspace-grid{min-width:0}
.workspace-heading{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:16px}
.workspace-heading h2,.workspace-heading h3{margin:0;overflow-wrap:anywhere}
.credential-workspace-grid{display:grid;grid-template-columns:minmax(180px,240px) minmax(0,1fr);gap:20px;align-items:start}
.credential-sidebar,.credential-detail{min-width:0;border:1px solid var(--border);border-radius:var(--r-lg);background:var(--bg-elevated);padding:16px}
.workspace-list-tools{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:12px;align-items:center}
.workspace-list-tools #credentialSearch{flex-basis:100%;width:100%;min-width:0;max-width:none}
#credentialNameList{display:grid;gap:8px}
.credential-name{display:flex;flex-direction:column;align-items:flex-start;gap:5px;text-align:left;width:100%;min-width:0;white-space:normal;overflow-wrap:anywhere;padding:12px}
.credential-name.active{background:var(--primary-soft);border-color:var(--primary-edge)}
.credential-metrics{display:flex;flex-wrap:wrap;gap:12px 24px;margin:12px 0 20px}
.credential-metrics>div{min-width:0}.credential-metrics dt{font-size:12px;color:var(--text-secondary)}.credential-metrics dd{margin:4px 0;overflow-wrap:anywhere}
.credential-usage-control{margin:0;gap:8px}
#credentialUsageMetric{font-size:inherit}
#credentialUsageMetric .credential-usage-control{white-space:nowrap}
#editorTitle:empty,#upstreamKeyStatus:empty{display:none}
.credential-inline-editor{width:100%;max-height:none;overflow:visible;padding:0;box-shadow:none;border:0}
.credential-inline-editor .fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px 20px}
.credential-inline-editor .fields>label{display:flex;flex-direction:column;gap:7px;min-width:0}
.credential-inline-editor .fields>.wide{grid-column:1/-1}
.credential-inline-editor .fields .input,.credential-inline-editor .fields .select{width:100%;min-width:0;max-width:none}
.credential-inline-editor #credentialKeyFields>label{display:flex;flex-direction:column;gap:7px}
.credential-inline-editor #credentialModelFields{display:flex;flex-wrap:wrap;align-items:center;gap:10px}
.credential-inline-editor #credentialModelSearch,.credential-inline-editor #modelChoices{flex-basis:100%;width:100%}
.credential-inline-editor .fields>label.switch-row{flex-direction:row;align-items:center;flex-wrap:wrap;padding:12px 0;border-top:1px solid var(--border)}
.credential-inline-editor .switch-row small{flex-basis:100%;margin:0}
.credential-workspace-footer{position:sticky;bottom:-24px;display:flex;justify-content:space-between;flex-wrap:wrap;gap:12px;margin-top:20px;padding:16px 0;background:var(--bg-elevated);border-top:1px solid var(--border);z-index:2}
.credential-footer-tools,.credential-footer-submit{display:flex;flex-wrap:wrap;align-items:center;gap:8px}
.credential-footer-tools .credential-actions{display:inline-flex}
@media(max-width:760px){.credential-workspace-footer{bottom:-16px}.credential-footer-tools,.credential-footer-submit{width:100%}.credential-footer-submit{justify-content:flex-end}}
.credential-inline-editor .channel-switches{flex-wrap:wrap;gap:12px}
@media(max-width:760px){
 .credential-workspace-grid{grid-template-columns:minmax(0,1fr);gap:12px}
 .credential-sidebar,.credential-detail{padding:12px}
 #credentialNameList{grid-template-columns:repeat(2,minmax(0,1fr))}
 .credential-name{padding:10px;font-size:12px}
 .workspace-heading{align-items:flex-start;gap:8px}
 .credential-metrics{gap:10px 16px}
 .credential-inline-editor .fields{grid-template-columns:minmax(0,1fr)}
}


.channel-view .toolbar,.channel-view footer,.channel-dialog .actions{display:flex;align-items:center;gap:10px}

.site-credentials-table col.site-col-name{width:24%}
.site-credentials-table col.site-col-usage{width:12%}
.site-credentials-table col.site-col-routing{width:88px}
.site-credentials-table col.site-col-groups{width:20%}
.site-credentials-table col.site-col-actions{width:auto}
.site-credentials-table .credential-actions{display:flex;flex-wrap:wrap;justify-content:center;gap:4px}
.site-credentials-table .credential-actions>*{min-width:0}
.site-credentials-table .credential-routing-input{display:block;width:72px;max-width:100%;box-sizing:border-box;margin:0 auto;padding:6px 4px;text-align:center;font-variant-numeric:tabular-nums;appearance:textfield;-moz-appearance:textfield}
.site-credentials-table .credential-routing-input::-webkit-inner-spin-button,.site-credentials-table .credential-routing-input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}
@media(max-width:760px){
 .site-credentials-table colgroup{display:none}
 .channel-view .site-credentials-table td{width:auto;text-align:left;align-items:center}
 .site-credentials-table .credential-routing-input{margin:0;width:72px}
}

.site-navigation{display:flex;align-items:center;gap:12px;margin-bottom:12px;min-width:0}
.site-navigation .credential-site-tabs{flex:1;min-width:0;margin-bottom:0}
.site-navigation>button{flex:none}

.site-credentials-table .credential-actions{margin-inline:auto}
.site-credentials-table .credential-actions-cell{text-align:center}
.site-credentials-table .credential-status-placeholder{min-width:52px}
.common-model-dialog{width:min(800px,calc(100vw - 24px));max-height:85dvh;overflow:auto}
.common-model-dialog>.input{width:100%;max-width:none}
.common-model-dialog .model-choices{max-height:50dvh;overflow:auto;margin:12px 0}
.common-model-dialog .model-option[hidden]{display:none}
.common-model-dialog .dialog-actions{display:flex;flex-wrap:wrap;gap:8px;justify-content:flex-end}
