/* 线路调度 · web shell
   Full-page app frame around the shared views: a translucent sidebar (a drawer
   on phones), page headers, segmented sub-navigation, and grouped panels.
   Colours, radii and controls come from the design tokens in cloud-exit.css. */

html { background: #f5f5f7; -webkit-text-size-adjust: 100%; }
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
.ce-app.shell-body { max-width: none; margin: 0; padding: 0; min-height: 100vh; background: var(--c-surface-2); font-size: 14px; }
.shell-body a { color: inherit; }
.shell-glyph { display: inline-flex; width: 18px; height: 18px; flex: none; }
.shell-glyph svg { width: 100%; height: 100%; display: block; }

/* ---------- frame ---------- */
body.shell-signed { display: grid; grid-template-columns: 252px minmax(0, 1fr); grid-template-rows: auto 1fr; }
body.shell-signed #shell-header { grid-column: 1; grid-row: 1 / span 2; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 18px 14px 14px; overflow-y: auto; overscroll-behavior: contain;
  background: rgba(255,255,255,.72); -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%); box-shadow: inset -.5px 0 0 var(--c-line); z-index: 60; }
body.shell-signed #shell-status { grid-column: 2; grid-row: 1; }
body.shell-signed #main { grid-column: 2; grid-row: 2; }
#main { min-width: 0; width: 100%; max-width: 1640px; margin: 0 auto; padding: 30px clamp(16px, 3.2vw, 44px) 56px; outline: none; }
/* Form-like pages keep a readable measure, left-aligned with the status line. */
#main[data-page="account"] > *, #main[data-page="admin"] > *, #main[data-page="home"] > *, #main[data-page="updates"] > * { max-width: min(100%, 1080px); }
#main > .ce-app { padding-top: 0; }

/* brand */
.shell-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 6px; }
.ce-app .shell-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--c-label); text-decoration: none; }
.shell-brand strong { font-size: 16px; font-weight: 700; letter-spacing: .01em; }
.shell-mark { width: 32px; height: 32px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; color: #fff; background: linear-gradient(150deg, #34aadc, #007aff 55%, #5856d6); box-shadow: 0 4px 12px rgba(0,122,255,.28), inset 0 0 0 .5px rgba(255,255,255,.25); }
.shell-mark .shell-glyph { width: 19px; height: 19px; }
.ce-app .shell-menu { display: none; }

/* drawer content */
.shell-drawer { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; margin-top: 18px; }
.shell-device { position: relative; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: var(--c-surface); box-shadow: var(--sh-panel); cursor: pointer; }
.shell-device:hover { box-shadow: var(--sh-raise); }
.shell-device-icon { width: 30px; height: 30px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; background: var(--c-green-tint); color: var(--c-green-text); flex: none; }
.shell-device.shell-offline .shell-device-icon { background: var(--c-surface-2); color: var(--c-label-3); }
.shell-device-icon .shell-glyph { width: 17px; height: 17px; }
.shell-device-text { display: grid; min-width: 0; flex: 1; }
.shell-device-text small { font-size: 11px; font-weight: 600; color: var(--c-green-text); line-height: 1.3; }
.shell-device.shell-offline .shell-device-text small { color: var(--c-label-3); }
.ce-app .shell-device-select { -webkit-appearance: none; appearance: none; width: 100%; padding: 0 18px 0 0; font-size: 13.5px; font-weight: 600; color: var(--c-label); cursor: pointer; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; }
.shell-device .shell-chev { position: absolute; right: 12px; width: 13px; height: 13px; color: var(--c-label-3); pointer-events: none; }

.shell-nav { display: flex; flex-direction: column; }
.shell-group-k { padding: 0 10px; margin: 20px 0 6px; font-size: 11.5px; font-weight: 600; color: var(--c-label-3); letter-spacing: .02em; }
.ce-app .shell-link { display: flex; align-items: center; gap: 11px; height: 36px; padding: 0 10px; margin: 1px 0; border-radius: 9px; color: var(--c-label); font-size: 14px; font-weight: 500; text-decoration: none; transition: background-color .15s; }
.shell-link .shell-glyph { color: var(--c-label-2); }
.ce-app .shell-link:hover { background: rgba(0,0,0,.045); }
.ce-app .shell-link[aria-current=page] { background: var(--c-accent); color: #fff; font-weight: 600; }
.shell-link[aria-current=page] .shell-glyph { color: #fff; }

.shell-foot { margin-top: auto; padding-top: 18px; display: grid; gap: 8px; }
.ce-app .ce-btn.shell-tool { width: 100%; height: 34px; justify-content: flex-start; padding: 0 12px; border-radius: 10px; background: transparent; color: var(--c-label-2); font-weight: 500; }
.ce-app .ce-btn.shell-tool:hover { background: rgba(0,0,0,.045); }
.ce-app #shell-update.shell-update-found { background: var(--c-accent-tint); color: var(--c-accent-text); font-weight: 600; }
#shell-update.shell-update-found::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c-accent); flex: none; }
.shell-me { display: flex; align-items: center; gap: 10px; padding: 10px 6px 0 8px; border-top: .5px solid var(--c-line); }
.shell-me .ce-avatar { width: 28px; height: 28px; font-size: 12px; }
.shell-me-name { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ce-app .ce-btn.shell-out { color: var(--c-label-2); }

/* signed-out pages */
body:not(.shell-signed) #shell-header { display: flex; justify-content: center; padding: 9vh 16px 0; }

/* ---------- status line ---------- */
#shell-status:empty { display: none; }
#shell-status { width: calc(100% - 2 * clamp(16px, 3.2vw, 44px)); max-width: calc(1640px - 2 * clamp(16px, 3.2vw, 44px)); margin: 18px auto 0; padding: 10px 14px; border-radius: 12px; background: var(--c-orange-tint); color: var(--c-orange-text); font-size: 13px; font-weight: 500; }
#shell-status.shell-status-preview { background: var(--c-accent-tint); color: var(--c-accent-text); }
#shell-status { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; }
.shell-status-text { flex: 1 1 auto; }
.shell-status-acts { display: flex; gap: 6px; }
.ce-app .shell-status-acts .ce-btn { background: var(--c-surface); color: var(--c-accent-text); box-shadow: var(--sh-panel); }
body.shell-signed #shell-status + #main { padding-top: 22px; }

/* ---------- page header (the views' .ce-hero becomes the same header) ---------- */
.shell-head, #main .ce-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; margin: 0 0 22px; padding: 4px 0 0; background: none; box-shadow: none; border-radius: 0; }
.shell-head-text { display: grid; gap: 4px; min-width: 0; }
.shell-body .ce-title, #main .ce-hero .ce-title { font-size: 30px; font-weight: 700; letter-spacing: -.024em; line-height: 1.15; margin: 0; }
.shell-head-sub, #main .ce-hero-sub { font-size: 14px; color: var(--c-label-2); margin: 0; }
.shell-head-side { display: flex; gap: 8px; flex-wrap: wrap; }
#main .ce-hero-side .ce-chip-s { background: var(--c-surface); box-shadow: var(--sh-panel); }
/* Live totals belong on the server/device pages, not on forms and logs. */
#main[data-page="settings"] .ce-strip, #main[data-page="tasks"] .ce-strip { display: none; }
#main[data-page="settings"] .ce-body, #main[data-page="settings"] .ce-strip ~ .ce-banner { max-width: 920px; }

/* segmented sub-navigation */
.shell-seg { display: flex; width: max-content; max-width: 100%; gap: 2px; padding: 3px; margin: 0 0 20px; border-radius: 11px; background: var(--c-surface-3); overflow-x: auto; scrollbar-width: none; }
.shell-seg::-webkit-scrollbar { display: none; }
.ce-app .shell-seg a { flex: none; display: inline-flex; align-items: center; height: 30px; padding: 0 15px; border-radius: 8px; color: var(--c-label); font-size: 13px; font-weight: 500; white-space: nowrap; text-decoration: none; transition: background-color .15s; }
.ce-app .shell-seg a:hover { background: rgba(255,255,255,.45); }
.ce-app .shell-seg a[aria-current=page] { background: var(--c-surface); font-weight: 600; box-shadow: 0 3px 8px rgba(0,0,0,.08), 0 0 0 .5px rgba(0,0,0,.05); }

/* ---------- panels, lists, stats ---------- */
.shell-panel { padding: 20px 22px; }
.shell-panel + .shell-panel, .shell-stats-panel + .shell-panel { margin-top: 16px; }
.shell-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; margin-bottom: 16px; }
.shell-panel-head .ce-h2 { margin: 0; }
.shell-panel-head .ce-caption { margin-top: 3px; }
.shell-panel-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 18px; }
.shell-panel-note { margin-top: 20px !important; padding-top: 16px; border-top: .5px solid var(--c-line); }
.shell-text { font-size: 13.5px; line-height: 1.7; color: var(--c-label-2); }
.shell-dim { color: var(--c-label-3); }
.shell-empty { padding: 34px 16px; text-align: center; font-size: 13.5px; color: var(--c-label-3); }

.shell-list { display: flex; flex-direction: column; margin: 0 -22px; }
.shell-list > * + * { box-shadow: inset 0 .5px 0 var(--c-line); }
.shell-list:last-child { margin-bottom: -20px; }
.shell-li { display: flex; align-items: center; gap: 12px 14px; flex-wrap: wrap; padding: 13px 22px; min-height: 60px; }
.shell-li-main { flex: 1 1 200px; min-width: 0; display: grid; gap: 3px; }
.shell-li-title { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.shell-li-sub { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12.5px; color: var(--c-label-2); }
.shell-li-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.shell-li-acts { display: flex; align-items: center; gap: 6px; }
.shell-user-row { display: grid; gap: 10px; padding: 14px 22px; }
.shell-user-row > .shell-li { padding: 0; min-height: 0; }
.shell-chips { display: flex; gap: 6px; flex-wrap: wrap; padding-left: 48px; }
.shell-chips .ce-chip-s { height: 26px; }
.shell-grant { display: flex; gap: 8px; flex-wrap: wrap; padding-left: 48px; }
.ce-app .shell-qty { width: 88px; flex: none; }
.ce-app .shell-reason { flex: 1 1 160px; max-width: 280px; }

.shell-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.shell-stats-panel { padding: 18px 22px; }
.shell-stats-panel .shell-stat:first-child { padding-left: 0; }
.shell-stat { display: grid; gap: 4px; align-content: start; padding: 2px 20px; min-width: 0; }
.shell-stat + .shell-stat { box-shadow: inset .5px 0 0 var(--c-line); }
.shell-panel .shell-stats .shell-stat:first-child { padding-left: 0; }
.shell-stat-k { font-size: 12.5px; font-weight: 500; color: var(--c-label-2); }
.shell-stat-v { font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.shell-stat-n { font-size: 12px; color: var(--c-label-3); }
.shell-stat-v.shell-accent { color: var(--c-accent-text); }
.shell-stat-v.shell-green { color: var(--c-green-text); }
.shell-stat-v.shell-orange { color: var(--c-orange-text); }
.shell-meter { height: 8px; margin: 20px 0 4px; border-radius: 999px; background: var(--c-surface-3); overflow: hidden; }
.shell-meter i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #34aadc, var(--c-accent)); transition: width .4s ease; }
.shell-buy { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-top: 22px; padding-top: 18px; border-top: .5px solid var(--c-line); }
.shell-buy-k { display: grid; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--c-label-2); }
.shell-notes { margin-top: 18px; padding: 14px 16px; border-radius: 12px; background: var(--c-surface-2); display: grid; gap: 6px; font-size: 13.5px; line-height: 1.6; white-space: pre-line; }

/* ---------- forms ---------- */
.shell-form { display: grid; gap: 16px; max-width: 560px; }
.shell-form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.shell-field { display: grid; gap: 6px; min-width: 0; }
.shell-field-label { display: grid; gap: 6px; min-width: 0; }
.shell-field-k { font-size: 12.5px; font-weight: 600; color: var(--c-label-2); }
.shell-field-hint { font-size: 12px; color: var(--c-label-3); line-height: 1.5; }
.ce-app .shell-field .ce-input, .ce-app .shell-buy .ce-input, .ce-app .shell-grant .ce-input, .ce-app .shell-buy .ce-btn, .ce-app .shell-grant .ce-btn { height: 38px; }
.ce-app .shell-field .ce-input:disabled { color: var(--c-label-3); }
.shell-select-wrap { position: relative; display: block; }
.ce-app .shell-select { -webkit-appearance: none; appearance: none; padding-right: 34px; cursor: pointer; }
.shell-select-wrap .shell-glyph { position: absolute; right: 12px; top: 50%; width: 14px; height: 14px; margin-top: -7px; color: var(--c-label-3); pointer-events: none; }
.ce-app .shell-file { font-size: 13px; color: var(--c-label-2); }
.ce-app .shell-file::file-selector-button { margin-right: 12px; height: 32px; padding: 0 14px; border: 0; border-radius: 999px; background: var(--c-surface-2); color: var(--c-label); font: inherit; font-weight: 600; cursor: pointer; }
.shell-affix { display: flex; min-width: 0; }
.ce-app .shell-affix .ce-input { flex: 1; min-width: 0; border-radius: 10px 0 0 10px; }
.shell-suffix { display: inline-flex; align-items: center; padding: 0 14px; border-radius: 0 10px 10px 0; background: var(--c-surface-3); color: var(--c-label-2); font-size: 13.5px; white-space: nowrap; }
.shell-domain-url { display: grid; gap: 4px; margin-bottom: 18px; padding: 14px 16px; border-radius: 12px; background: var(--c-green-tint); }
.shell-domain-url:empty { display: none; }
.shell-domain-url a { font-size: 14px; font-weight: 600; color: var(--c-green-text); overflow-wrap: anywhere; }
.shell-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.shell-actions .ce-caption { flex: 1 1 100%; }
.shell-check-row { display: flex; align-items: center; gap: 10px; font-size: 13.5px; cursor: pointer; }
.ce-app .shell-check { width: 18px; height: 18px; accent-color: var(--c-accent); }
.shell-error { font-size: 13px; color: var(--c-red-text); white-space: pre-line; overflow-wrap: anywhere; }
.shell-error:empty { display: none; }
.shell-codes { display: grid; gap: 8px; margin-bottom: 20px; }
.shell-codes code { display: block; padding: 11px 14px; border-radius: 10px; background: var(--c-surface-2); font: 600 14px var(--f-mono); user-select: all; overflow-wrap: anywhere; }
.shell-codes .shell-code-big { font-size: 26px; letter-spacing: .14em; text-align: center; }

/* ---------- standalone cards (sign-in, first setup, errors) ---------- */
.shell-card { width: 100%; max-width: 420px; margin: 28px auto; padding: 32px 30px 28px; }
.shell-card-title { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.shell-card-sub { margin: 6px 0 22px !important; font-size: 13.5px; line-height: 1.65; color: var(--c-label-2); }
.shell-card .shell-form { max-width: none; }
.ce-app .ce-btn.shell-submit { width: 100%; height: 42px; margin-top: 4px; font-size: 15px; font-weight: 600; }
.shell-alt { display: flex; align-items: center; justify-content: center; gap: 2px; margin-top: 16px; font-size: 13px; color: var(--c-label-2); }
.modal .shell-card { margin: 0; max-width: none; box-shadow: none; }

/* ---------- loading, toasts, dialogs ---------- */
.shell-loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 18vh 0; color: var(--c-label-2); font-size: 13.5px; }
.shell-spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--c-surface-3); border-top-color: var(--c-accent); animation: shell-spin .8s linear infinite; }
@keyframes shell-spin { to { transform: rotate(360deg); } }
#notifications { position: fixed; right: 20px; bottom: 20px; z-index: 2100000; display: grid; gap: 8px; max-width: min(400px, calc(100vw - 32px)); }
.shell-toast { padding: 12px 16px; border-radius: 14px; background: rgba(255,255,255,.92); -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%); box-shadow: 0 0 0 .5px rgba(0,0,0,.08), 0 10px 30px rgba(0,0,0,.14); font-size: 13.5px; color: #1d1d1f; animation: shell-toast .25s cubic-bezier(.2,.8,.2,1); }
.shell-toast.error { color: #d70015; }
@keyframes shell-toast { from { opacity: 0; transform: translateY(8px) scale(.98); } }
#modal_overlay { position: fixed; inset: 0; z-index: 900; overflow-y: auto; background: rgba(20,24,33,.32); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); padding: 28px 16px; }
.modal { width: 100%; max-width: 760px; margin: 3vh auto; padding: 0; background: #fff; border-radius: 22px; }
.modal > h4 { display: none; }

/* ---------- narrower screens ---------- */
@media (max-width: 1100px) { body.shell-signed { grid-template-columns: 224px minmax(0, 1fr); } }
@media (max-width: 900px) {
  body.shell-signed { display: block; }
  /* No backdrop-filter here: it would become the containing block of the fixed drawer. */
  body.shell-signed #shell-header { position: sticky; top: 0; height: auto; padding: 10px 16px; overflow: visible; box-shadow: inset 0 -.5px 0 var(--c-line); background: #fbfbfd; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .ce-app .shell-menu { display: inline-flex; flex-direction: column; justify-content: center; gap: 5px; width: 38px; height: 38px; padding: 0 10px; border-radius: 10px; cursor: pointer; }
  .ce-app .shell-menu:hover { background: rgba(0,0,0,.045); }
  .shell-menu i { display: block; height: 2px; border-radius: 2px; background: var(--c-label); transition: transform .2s ease; }
  .shell-open .shell-menu i:first-child { transform: translateY(3.5px) rotate(45deg); }
  .shell-open .shell-menu i:last-child { transform: translateY(-3.5px) rotate(-45deg); }
  body.shell-signed .shell-drawer { display: none; position: fixed; left: 0; right: 0; top: 58px; bottom: 0; margin: 0; padding: 14px 16px calc(20px + env(safe-area-inset-bottom)); overflow-y: auto; background: var(--c-surface-2); animation: shell-drawer .2s ease; }
  body.shell-signed .shell-open .shell-drawer { display: flex; }
  .ce-app .shell-link { height: 44px; font-size: 15px; }
  body.shell-locked { overflow: hidden; }
  #shell-status { width: calc(100% - 32px); margin-top: 14px; }
  #main { padding: 22px 16px 44px; }
  .shell-body .ce-title, #main .ce-hero .ce-title { font-size: 26px; }
  #main .ce-hero { margin-bottom: 18px; }
}
@keyframes shell-drawer { from { opacity: 0; transform: translateY(-6px); } }
@media (max-width: 600px) {
  .shell-form-grid { grid-template-columns: 1fr; }
  .shell-panel { padding: 18px 16px; }
  .shell-list { margin: 0 -16px; }
  .shell-list:last-child { margin-bottom: -18px; }
  .shell-li, .shell-user-row { padding-left: 16px; padding-right: 16px; }
  .shell-chips, .shell-grant { padding-left: 0; }
  .shell-stats { grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); }
  .shell-stat { padding: 2px 12px; }
  .shell-stat-v { font-size: 24px; }
  .shell-card { padding: 26px 20px 22px; margin-top: 12px; }
  #notifications { left: 16px; right: 16px; bottom: 16px; max-width: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
