body.upstream-view .summary,body.upstream-view #topTraffic { display:none; }
body.upstream-view #routerSelect,body.upstream-view #dataSource { opacity:.65; }
.up-subtitle,.up-footnote {color:var(--muted);font-size:13px;line-height:1.6;margin:4px 0 12px;}
.up td small,.up-path,.up td strong {display:block;}.up td small {font-size:11px;color:var(--muted);margin-top:5px;white-space:normal;max-width:300px;overflow-wrap:anywhere;}
.up-muted {color:var(--muted);font-size:12px;}.up-notice.error {color:var(--down);}.up-wide {grid-column:1/-1;}
.up-review {display:grid;grid-template-columns:1fr 2fr;gap:12px;padding:16px;background:var(--panel-2);border-radius:6px;font-size:13px;overflow-wrap:anywhere;}
.up .up-search {flex:1;min-width:180px;}.up .up-list {max-width:100%;}.up-dialog button {height:auto;}
@media(max-width:600px){.up-heading,.up-tools{align-items:stretch;}.up-heading>div,.up-actions{width:100%;}.up-actions button{flex:1;}.up .up-search,.up .up-list{width:100%;}.up-review{grid-template-columns:1fr;}.up-dialog{padding:16px;}}
.up { grid-column:1/-1; min-width:0; color:var(--text); }
.up-heading,.up-actions,.up-tools,.up-pages,.up-form-actions,.up-dialog-head { display:flex; align-items:center; gap:12px; }
.up-heading,.up-dialog-head { justify-content:space-between; flex-wrap:wrap; }
.up h2 { font-size:22px; margin:0 0 8px; }.up-updated { font-size:12px; color:var(--muted); }
.up button,.up-dialog button { border:1px solid var(--line); background:var(--panel); color:var(--text); border-radius:5px; min-height:38px; padding:8px 12px; cursor:pointer; }
.up button:disabled,.up-dialog button:disabled { opacity:.5; cursor:not-allowed; }
.up button.up-primary,.up-dialog button.up-primary { background:var(--nav-active); color:#fff; border-color:var(--nav-active); }
.up [hidden] { display:none!important; }.up-notice { margin:12px 0; font-size:13px; }.up-notice:empty { display:none; }
.up-summary { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); border-top:1px solid var(--line); border-bottom:1px solid var(--line); padding:18px 0; margin:20px 0; gap:16px; }
.up-summary span { display:block; font-size:12px; color:var(--muted); }.up-summary strong { display:block; margin-top:8px; font-size:24px; }
.up-tabs { display:flex; gap:12px; overflow:auto; border-bottom:1px solid var(--line); }
.up-tabs button { border:0; border-radius:0; border-bottom:2px solid transparent; background:none; white-space:nowrap; min-height:44px; }
.up-tabs button.active { color:var(--accent); border-bottom-color:var(--accent); }
.up-tools { margin:18px 0; flex-wrap:wrap; justify-content:space-between; }.up-search { width:340px; max-width:100%; }
.up input,.up select,.up-dialog input,.up-dialog select { min-width:0; border:1px solid var(--line); background:var(--panel); color:var(--text); border-radius:5px; padding:10px; font:inherit; }
.up-auto,.up-check { display:flex!important; align-items:center; gap:8px; font-size:13px; }.up-auto input,.up-check input { width:18px; height:18px; }
.up-scroll { max-width:100%; overflow:auto; }.up table { border-collapse:collapse; width:100%; font-size:13px; white-space:nowrap; }
.up th,.up td { padding:12px; text-align:left; border-bottom:1px solid var(--line); }.up th { background:var(--panel-2); color:var(--muted); font-size:11px; font-weight:600; }.up-row-actions button+button { margin-left:6px; }
.up-state { color:var(--muted); }.up-state.online { color:var(--up); }.up-pages { justify-content:flex-end; margin-top:16px; font-size:12px; }
.up-dialog { box-sizing:border-box; width:min(680px,calc(100% - 24px)); max-height:90vh; max-height:90dvh; padding:20px; border:1px solid var(--line); border-radius:6px; background:var(--panel); color:var(--text); overscroll-behavior:contain; }
.up-dialog::backdrop { background:#0008; }.up-dialog-head { border-bottom:1px solid var(--line); padding-bottom:12px; }.up-dialog h3 { font-size:18px; margin:0; }.up-dialog [data-close] { font-size:22px; width:42px; height:42px; padding:4px; }
.up-form { display:grid; grid-template-columns:1fr 1fr; gap:16px; margin-top:18px; }.up-form label { display:grid; gap:8px; font-size:12px; min-width:0; }.up-form input,.up-form select { width:100%; box-sizing:border-box; }
.up-form-actions,.up-form-error { grid-column:1/-1; }.up-form-actions { justify-content:flex-end; }.up-form-error { color:var(--down); font-size:13px; overflow-wrap:anywhere; margin:0; }.up-form-error:empty { display:none; }.up-dialog-body p { line-height:1.6; overflow-wrap:anywhere; }
.up-password { display:flex; gap:6px; }.up-password input { flex:1; }.up-password button { flex:0 0 42px; padding:6px; }.theme-dark .up-password img { filter:invert(1); }
@media(max-width:650px) { .up h2 { font-size:20px; }.up-summary { grid-template-columns:1fr 1fr; }.up-form { grid-template-columns:1fr; }.up input,.up select,.up-dialog input,.up-dialog select { font-size:16px; }.up-tabs { gap:2px; }.up-search { width:100%; }.up button,.up-dialog button { min-height:44px; }.up-dialog { padding:16px; } }


/* Keep provider choices in the dialog flow, including short viewports. */
.up-dialog { max-height:calc(100vh - 32px); max-height:calc(100dvh - 32px); overflow-y:auto; overflow-x:hidden; }
.up-dialog-head { flex-wrap:nowrap; gap:16px; }.up-dialog-head h3 { min-width:0; overflow-wrap:anywhere; }.up-dialog [data-close] { flex-shrink:0; }
.up-dialog input:not([type=radio]),.up-dialog select { height:auto; min-height:44px; line-height:1.4; }
.up-route-picker { grid-column:1/-1; min-width:0; margin:0; padding:0; border:0; }
.up-route-picker legend { padding:0; margin-bottom:8px; font-size:13px; }
.up-route-options { display:grid; gap:8px; max-height:240px; max-height:min(240px,45dvh); overflow-y:auto; padding:3px; overscroll-behavior:contain; }
.up-form .up-route-option { display:flex; align-items:center; gap:10px; min-height:46px; padding:10px 12px; border:1px solid var(--line); border-radius:5px; cursor:pointer; box-sizing:border-box; font-size:14px; }
.up-form .up-route-option input { flex:0 0 18px; width:18px; height:18px; min-height:18px; padding:0; margin:0; accent-color:var(--nav-active); }
.up-route-option span { min-width:0; overflow-wrap:anywhere; line-height:1.5; }.up-route-option:has(input:checked) { border-color:var(--accent); background:var(--panel-2); }.up-route-option:focus-within { outline:2px solid var(--accent); outline-offset:1px; }
.up-dialog .up-form-actions { position:sticky; bottom:-1px; background:var(--panel); padding:12px 0 2px; z-index:1; }

/* Mobile: one scrolling dialog body; actions remain in normal document flow. */
@media(max-width:650px) {
  body:has(.up-dialog[open]) { overflow:hidden; }
  .up-dialog { width:calc(100% - 16px); max-width:none; max-height:calc(100vh - 16px); max-height:calc(100dvh - 16px); margin:auto; padding:0; overflow:hidden; }
  .up-dialog[open] { display:flex; flex-direction:column; }
  .up-dialog-head { flex:0 0 auto; padding:12px 14px; margin:0; gap:12px; }
  .up-dialog h3 { font-size:17px; line-height:1.35; }
  .up-dialog [data-close] { width:44px; height:44px; }
  .up-dialog-body { flex:1 1 auto; min-height:0; overflow-y:auto; overflow-x:hidden; overscroll-behavior:contain; padding:14px 14px max(14px,env(safe-area-inset-bottom)); }
  .up-form { margin:0; gap:12px; }
  .up-dialog-body p { font-size:13px; line-height:1.5; margin:0 0 12px; }
  .up-form p { margin:0; }
  .up-current { padding:10px; background:var(--panel-2); border-radius:5px; }
  .up-route-options { max-height:none; overflow:visible; }
  .up-form .up-route-option { padding:10px; min-height:48px; }
  .up-dialog .up-form-actions { position:static; padding:4px 0 0; margin:0; }
  .up-dialog .up-form-actions button { width:100%; min-height:46px; }
  .up-review { grid-template-columns:minmax(0,1fr); gap:6px; padding:12px; margin-bottom:12px; }
  .up-review strong { margin-bottom:6px; }
  .up-tools { gap:10px; margin:12px 0; }
  .up .up-search,.up .up-list { flex:1 1 100%; width:100%; min-width:0; height:auto; min-height:44px; box-sizing:border-box; line-height:1.4; }
  .up-tabs button { flex:1; min-width:0; white-space:normal; padding:8px 6px; }
  .up-summary { gap:12px; padding:12px 0; margin:14px 0; }
  .up-summary strong { font-size:22px; }
  .up-scroll { overflow:visible; }
  .up table,.up tbody { display:block; width:100%; }
  .up thead { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }
  .up tbody tr { display:grid; grid-template-columns:minmax(0,1fr); gap:10px; border:1px solid var(--line); border-radius:6px; padding:14px; margin:0 0 12px; background:var(--panel); }
  .up td { display:block; min-width:0; border:0; padding:0; white-space:normal; overflow-wrap:anywhere; }
  .up td[data-label]::before { content:attr(data-label); display:block; font-size:11px; color:var(--muted); margin-bottom:4px; }
  .up td:first-child strong { font-size:16px; }
  .up td small { max-width:none; }
  .up td button { width:100%; min-height:44px; }
  .up-pages { flex-wrap:wrap; justify-content:space-between; gap:8px; }
}

.up-router-label {display:grid;gap:6px;max-width:520px;margin:16px 0;font-size:13px;} .up .up-router {width:100%;min-width:0;height:auto;min-height:44px;box-sizing:border-box;}
.admin-form #routerUpstreamSupport {height:auto;min-height:44px;padding:10px;box-sizing:border-box;width:100%;} body.upstream-view #routerSelect,body.upstream-view #toggleRouterIp,body.upstream-view #dataSource {display:none!important;}
