/* Portal page frame (part 1 of 4): top bar with view tabs and avatar menu, notice placement, content padding.
   Loaded after console.css. It overrides the old portal rules in the shared style.css, which is not edited. */

/* top bar: sticky 52px at 900px and wider; two rows below (brand and avatar, then the tabs). style.css spreads
   .portal-top with space-between, which would centre the tabs; they follow the brand instead. */
.portal-body .portal-top{position:static;display:flex;flex-wrap:wrap;justify-content:flex-start;align-items:center;gap:0 12px;min-height:52px;padding:0 12px;margin:0;background:var(--page);border-bottom:1px solid var(--rule)}
@media (min-width:900px){.portal-body .portal-top{position:sticky;top:0;z-index:30;height:52px;flex-wrap:nowrap;padding:0 20px}}
@media (min-width:1280px){.portal-body .portal-top{padding:0 32px}}

.portal-body .portal-top .brand{display:inline-flex;align-items:center;gap:10px;color:var(--ink);text-decoration:none;font-family:var(--f-serif);font-size:15px;font-weight:600;white-space:nowrap}
.portal-body .portal-top .brand-icon{display:inline-flex;align-items:center}
.portal-body .portal-top .brand-logo{display:block;width:24px;height:14px;fill:var(--accent)}
/* the product name stays visible on phones (style.css hides it below 900px); the subtitle sits on the same line */
.portal-body .portal-top .brand>span:last-child{display:inline}
.portal-body .portal-top .brand small{display:inline;margin:0 0 0 8px;letter-spacing:0;font-family:var(--f-sans);font-size:12px;font-weight:400;color:var(--muted)}

/* view tabs: plain text, accent with a 2px underline when selected; no filled block */
.portal-body .portal-view-tabs{display:flex;align-items:stretch;gap:20px;min-width:0;height:100%;margin-left:28px;margin-right:auto}
.portal-body .portal-view-tab{display:inline-flex;align-items:center;gap:6px;flex:0 0 auto;height:100%;min-height:36px;margin:0;padding:0 2px;border:0;border-bottom:2px solid transparent;border-radius:0;background:none;color:var(--muted);font-family:var(--f-sans);font-size:13px;font-weight:500;white-space:nowrap;cursor:pointer}
.portal-body .portal-view-tab:hover:not(:disabled){background:none;color:var(--ink)}
.portal-body .portal-view-tab[aria-selected=true]{background:none;color:var(--accent);border-bottom-color:var(--accent)}
/* counts are small plain text: style.css draws them as filled pills with hard-coded colours */
.portal-body .portal-view-count{padding:0;border-radius:0;background:none;line-height:inherit;font-size:12px;font-weight:400;color:var(--muted);font-variant-numeric:tabular-nums}
.portal-body .portal-view-tab[aria-selected=true] .portal-view-count{background:none;color:var(--accent)}
.portal-body .portal-view-count:empty{display:none}
@media (pointer:coarse){.portal-body .portal-view-tab{min-height:44px}}

/* phones: tabs take the second row and scroll sideways without a visible scrollbar */
@media (max-width:899px){
  .portal-body .portal-view-tabs{order:3;flex:0 0 100%;width:100%;margin:0;gap:20px;height:auto;overflow-x:auto;overflow-y:hidden;scrollbar-width:none;-webkit-overflow-scrolling:touch}
  .portal-body .portal-view-tabs::-webkit-scrollbar{display:none}
}

/* avatar and account menu on the right. An auto margin on the wa-dropdown host does not move it, so the item
   before it takes the free space: the tabs from 900px (above), the brand below 900px, where the tabs wrap. */
@media (max-width:899px){.portal-body .portal-top .brand{margin-right:auto}}
.portal-body .portal-top button.avatar{width:32px;height:32px;min-width:32px;display:inline-grid;place-items:center;border:1px solid var(--rule);border-radius:50%}
@media (pointer:coarse){.portal-body .portal-top button.avatar{width:44px;height:44px;min-width:44px}}

/* content: full width; side padding 32px from 1280, 20px from 900, 12px below; top padding 16px */
.portal-body .portal-main{width:100%;max-width:none;margin:0;padding:16px 12px}
@media (min-width:900px){.portal-body .portal-main{padding:16px 20px}}
@media (min-width:1280px){.portal-body .portal-main{padding:16px 32px}}

/* server cards (part 2a): two per row from 900px, one below; a 1px rule frame with no shadow and no fill but --page.
   The status mark, the four-step stepper, the guide box, the outline action and the 更多 menu follow spec 2.3. */
.portal-body .server-cards{display:grid;grid-template-columns:1fr;gap:12px}
@media (min-width:900px){.portal-body .server-cards{grid-template-columns:1fr 1fr}}
.portal-body .server-card{position:relative;display:grid;gap:12px;padding:16px;border:1px solid var(--rule);border-radius:0;background:var(--page);box-shadow:none}
.portal-body .server-card-head{display:flex;justify-content:space-between;align-items:flex-start;gap:12px}
.portal-body .server-card-title{display:grid;gap:2px;min-width:0}
.portal-body .server-name{font-family:var(--f-serif);font-size:16px;font-weight:600;color:var(--ink)}
.portal-body .server-address{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px;color:var(--muted);overflow-wrap:anywhere}
.portal-body .server-group{font-size:12px;color:var(--muted)}
.portal-body .server-card-head .state-mark{flex:none}
/* steps: a progress indicator, not buttons. Below 480px the four wrap to two rows. Not named .card-steps,
   because style.css still draws that class as filled pills with counters, and .step-running is coloured there too. */
.portal-body .card-steps{display:flex;flex-wrap:wrap;gap:6px 16px;margin:0;padding:0;list-style:none;font-size:13px}
@media (max-width:479px){.portal-body .card-steps{display:grid;grid-template-columns:1fr 1fr}}
.portal-body .card-steps li{display:inline-flex;align-items:center;gap:6px;padding:2px 0 4px;color:var(--muted);border-bottom:2px solid transparent}
.portal-body .card-steps .done{color:var(--ink)}
.portal-body .card-steps .current{color:var(--ink);font-weight:600}
.portal-body .card-steps .current.blocked{border-bottom-color:var(--blocked)}
.portal-body .card-steps .current.attention,.portal-body .card-steps .current.running{border-bottom-color:var(--attention)}
.portal-body .step-mark{display:inline-flex;align-items:center;justify-content:center;flex:none;width:12px;height:12px;font-size:11px;line-height:1}
.portal-body .card-steps .done .step-mark{color:var(--accent)}
.portal-body .card-steps .muted-mark{color:var(--muted)}
.portal-body .step-num{display:inline-flex;justify-content:center;width:12px;color:var(--muted)}
.portal-body .step-mark-blocked{width:8px;height:8px;background:var(--blocked);border-radius:0}
.portal-body .step-mark-attention{width:7px;height:7px;background:var(--attention);transform:rotate(45deg)}
.portal-body .step-mark-running{width:7px;height:7px;border:2px solid var(--attention);border-radius:50%;box-sizing:border-box}
.portal-body .sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
/* guide: a tinted box for blocked and attention (3px start border), muted text for running and healthy */
.portal-body .guide-box{margin:0;padding:8px 10px;font-size:13px;color:var(--ink);border-inline-start:3px solid var(--rule)}
.portal-body .guide-box.blocked{background:var(--blocked-tint);border-inline-start-color:var(--blocked)}
.portal-body .guide-box.attention{background:var(--attention-tint);border-inline-start-color:var(--attention)}
.portal-body .guide-box ol{margin:0;padding-inline-start:1.3em}
.portal-body .guide.muted{margin:0;font-size:13px;color:var(--muted)}
.portal-body .install-line{font-size:13px;color:var(--ink)}
.portal-body .install-progress{--track-height:4px;--track-color:var(--sunken);--indicator-color:var(--accent);display:block;width:100%;margin:6px 0}
/* actions: one outlined button, a disabled 处理中… while busy, and the 更多 icon button on the right */
.portal-body .card-actions{position:relative;display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.portal-body .card-actions .more-button{margin-left:auto;min-width:32px;min-height:32px;padding:0;border:1px solid transparent;border-radius:4px;background:none;color:var(--muted);font-size:18px;line-height:1;cursor:pointer}
.portal-body .card-actions .more-button:hover{color:var(--ink);border-color:var(--rule)}
.portal-body .card-actions > .menu{position:absolute;right:0;top:calc(100% + 4px);z-index:25}
@media (pointer:coarse){.portal-body .card-actions .more-button{min-width:44px;min-height:44px}}
/* notice: a wa-callout that sticks under the top bar; a bottom toast below 900px */
.portal-body wa-callout.notice{position:sticky;top:52px;z-index:20;margin-bottom:12px}
@media (max-width:899px){.portal-body wa-callout.notice{position:fixed;top:auto;left:12px;right:12px;bottom:12px;margin:0;z-index:60;box-shadow:var(--shadow)}}

/* part 2b: title row, promos and steps copy, empty state, recent-request tables, phone row cards */
.portal-body .portal-heading{display:flex;flex-wrap:wrap;align-items:flex-start;justify-content:space-between;gap:12px;margin:0 0 12px}
.portal-body .portal-title{display:flex;flex-wrap:wrap;align-items:baseline;gap:6px 12px;min-width:0}
.portal-body .portal-title h1{margin:0;font-family:var(--f-serif);font-size:24px;font-weight:600;color:var(--ink)}
.portal-body .portal-title small{font-size:13px;color:var(--muted);font-variant-numeric:tabular-nums}
.portal-body .portal-heading-actions{display:flex;flex-wrap:wrap;align-items:center;gap:12px;margin-left:auto}
.portal-body .quota-note{margin:0;font-size:12px;line-height:1.5;color:var(--muted)}

/* promos and the full-steps block share one frame: 1px rule, square corners, no fill, no shadow */
.portal-body .promo-box,.portal-body .tutorial{margin:12px 0 0;border:1px solid var(--rule);border-radius:0;background:none;box-shadow:none}
.portal-body .promo-box{padding:12px 16px}
.portal-body .promo-box h2{margin:0 0 4px;font-family:var(--f-serif);font-size:16px;font-weight:600}
.portal-body .promo-link{color:var(--accent);font-weight:600}
@media (pointer:coarse){.portal-body .promo-link{display:inline-flex;align-items:center;min-height:44px}}
.portal-body .tutorial{padding:0 16px}
.portal-body .tutorial summary{padding:12px 0;min-height:0;font-family:var(--f-sans);font-size:13px;font-weight:600;color:var(--ink)}

/* part 4a: API 组 tab. Intro notes drop the old bordered note look; entry rows use line icons, and actions sit right, or below the info under 768px */
.portal-body .portal-note{margin:0;padding:0;border:0;font-size:13px;line-height:1.6;color:var(--muted)}
.portal-body #poolList .pool-item{display:flex;align-items:flex-start;gap:12px;padding:12px 0;border-bottom:1px solid var(--rule);background:none}
.portal-body #poolList .pool-info{flex:1 1 auto;min-width:0}
.portal-body #poolList .pool-info p{margin:2px 0 0;font-size:12px;color:var(--muted);font-variant-numeric:tabular-nums}
.portal-body #poolList .card-actions{flex:none;justify-content:flex-end}
/* the list opens with a rule; the 更多 button sits beside 管理成员 instead of being pushed away by the card rule's auto margin */
.portal-body #poolList{margin-top:12px;border-top:1px solid var(--rule)}
.portal-body #poolList .card-actions .more-button{margin-left:0}
/* phones: the icon stays beside the name and the actions take their own row, right-aligned */
@media (max-width:767px){.portal-body #poolList .pool-item{flex-wrap:wrap}.portal-body #poolList .pool-info{flex:1 1 0}.portal-body #poolList .card-actions{flex:1 1 100%;justify-content:flex-end}}

/* empty state: the linear server glyph is muted, not accent */
.portal-body .empty-icon{display:block;margin:0 auto 8px;color:var(--muted)}

/* request tables: numbers right-aligned with tabular figures; the note line under each table */
.portal-body .data-table .num,.portal-body .data-table th.num{text-align:right;font-variant-numeric:tabular-nums}
.portal-body .table-note{margin:6px 0 0;font-size:12px;color:var(--muted)}

/* below 768px the request tables become row cards: column name from data-label, no horizontal scroll.
   Cells pair up as 时间 | 状态, API 组 | 服务器, 模型, HTTP | 折算 $; 模型 takes a full row only beside an API 组 cell.
   Everything is left-aligned: a card has no column for the numbers to line up in. */
@media (max-width:767px){
.portal-body .data-table.server-table--cards{min-width:0}
.portal-body .server-table--cards thead{display:none}
.portal-body .server-table--cards tr{display:grid;grid-template-columns:1fr 1fr;column-gap:12px;row-gap:8px;padding:12px 0;border-bottom:1px solid var(--rule)}
.portal-body .server-table--cards td{display:block;padding:0;border:0;min-height:0;text-align:left;overflow-wrap:anywhere;white-space:normal}
.portal-body .server-table--cards td::before{content:attr(data-label);display:block;margin-bottom:2px;font-size:12px;color:var(--muted)}
.portal-body .server-table--cards td:first-child,.portal-body .server-table--cards td:last-child{grid-column:auto}
.portal-body .server-table--cards td:nth-child(4),.portal-body .server-table--cards td.num{text-align:left}
.portal-body .server-table--cards td[data-label="状态"]{order:1}
.portal-body .server-table--cards td[data-label="API 组"]{order:2}
.portal-body .server-table--cards td[data-label="服务器"]{order:3}
.portal-body .server-table--cards td[data-label="模型"]{order:4}
.portal-body .server-table--cards td[data-label="HTTP"]{order:5}
.portal-body .server-table--cards td[data-label="折算 $"]{order:6}
.portal-body .server-table--cards tr:has(td[data-label="API 组"]) td[data-label="模型"]{grid-column:1/-1}
}

/* part 4b1: native text and password inputs inside a wa-dialog take the wa-input look of Manager. Values come from the
   console.css label>input rule (--hit height, 10px side padding, control border, 4px radius, raised fill, 13px text),
   the focus ring from its .search:focus-within rule, and 44px height on coarse pointers. */
.portal-body wa-dialog label>input:not([type=checkbox]){min-height:var(--hit);padding:0 10px;margin-top:4px;border:1px solid var(--border-control);border-radius:4px;background:var(--raised);color:var(--ink);font-size:13px;font-weight:400}
.portal-body wa-dialog label>input:not([type=checkbox]):focus{border-color:var(--focus);box-shadow:0 0 0 1px var(--focus)}
@media (pointer:coarse){.portal-body wa-dialog label>input:not([type=checkbox]){min-height:44px}}
/* the env-var block in API 连接信息: style.css paints .usage with a fixed light fill, which left its text unreadable in dark.
   It takes the .copy-value surface instead. */
.portal-body wa-dialog pre.usage{margin:4px 0 0;padding:8px 10px;border:0;border-radius:4px;background:var(--sunken);color:var(--ink);font-family:var(--f-mono);font-size:12px;line-height:1.6;white-space:pre-wrap;overflow-wrap:anywhere}

/* part 3: 用量与日志. The title row, metrics and blocks reuse part 2b and console.css; these rules only place them. */
.portal-body .usage-meta{display:inline-flex;flex-wrap:wrap;gap:0 8px;font-size:12px;color:var(--muted);font-variant-numeric:tabular-nums}
/* the coverage note follows the update time; a dot keeps the two from reading as one run of numbers */
.portal-body .usage-meta #overviewNote:not(:empty)::before{content:'·';margin-right:8px;color:var(--muted)}
.portal-body .portal-heading-actions .usage-range{flex:none}

/* primary metrics: three ruled columns that stay in one row at 390; overrides console.css auto-fit */
.portal-body .stats-grid.usage-primary{grid-template-columns:repeat(3,minmax(0,1fr));margin:16px 0 0}
.portal-body .usage-primary article{min-width:0;padding:10px 16px 12px}
.portal-body .usage-primary article:first-child{padding-left:0}
.portal-body .usage-primary strong{overflow-wrap:anywhere}
.portal-body .usage-primary p{display:block;margin:0;font-size:12px;color:var(--muted);white-space:normal}
.portal-body .usage-primary article>span{white-space:normal;overflow-wrap:anywhere}

/* secondary row: one line of small text that wraps between items, never inside one */
.portal-body .usage-secondary{margin:10px 0 0;font-size:12px;line-height:1.7;color:var(--muted);font-variant-numeric:tabular-nums}
.portal-body .usage-item{white-space:nowrap}
.portal-body .usage-secondary strong{font-size:13px;font-weight:600;color:var(--ink)}
.portal-body .usage-cold-note{margin:4px 0 0;font-size:12px;color:var(--muted)}

/* blocks: 24px apart, no fill, no shadow, full width, like the 最近请求 block */
.portal-body .usage-block{margin:24px 0 0;padding:0;border:0;border-radius:0;background:none;box-shadow:none}
.portal-body .usage-block .panel-toolbar{min-height:0;padding:0 0 8px;border-bottom:1px solid var(--rule)}
.portal-body .usage-block .panel-toolbar strong{font-family:var(--f-serif);font-size:16px;font-weight:600}

/* request-log filters: visible labels, 32px on fine pointers and 44px on coarse ones */
.portal-body .usage-filter{display:flex;flex-wrap:wrap;align-items:flex-end;gap:12px;padding:12px 0}
.portal-body .filter-field{display:grid;min-width:0}
.portal-body .usage-filter wa-select{display:block;width:180px;max-width:100%;margin:0;font-size:13px}
@media (min-width:768px){.portal-body .usage-filter wa-select::part(combobox){min-height:32px}}
@media (pointer:coarse){.portal-body .usage-filter wa-select::part(combobox){min-height:44px}}

/* phones, part 3: 按服务器 cards keep DOM order with 服务器 on a full row, and each filter takes a full row with its
   label above at 44px. This block comes after the base rules above, which would otherwise win at equal specificity. */
@media (max-width:767px){
.portal-body .server-table--cards.usage-servers-table td[data-label]{order:0}
.portal-body .server-table--cards.usage-servers-table td:first-child,.portal-body .server-table--cards.usage-servers-table td[colspan]{grid-column:1/-1}
.portal-body .usage-filter{display:grid;grid-template-columns:minmax(0,1fr);gap:10px}
.portal-body .usage-filter wa-select{width:100%}
.portal-body .usage-filter wa-select::part(combobox){min-height:44px}
.portal-body .stats-grid.usage-primary article{padding:8px 10px}
.portal-body .stats-grid.usage-primary article:first-child{padding-left:0}
}

/* part 4b2: add-server dialog. Name and the secret groups take a full row of #serverForm's grid; the save hint sits at the left of the action row. */
.portal-body #serverForm>wa-input[name=name],.portal-body #serverForm>#passwordFields,.portal-body #serverForm>#keyFields{grid-column:1/-1}
.portal-body #serverDialog{width:min(720px,calc(100vw - 24px))}
.portal-body .save-hint{margin-right:auto;align-self:center;font-size:12px;line-height:1.5;color:var(--muted)}
/* phones: one column, and the save hint takes its own row above the buttons instead of a three-line strip beside them */
@media (max-width:599px){.portal-body #serverForm{grid-template-columns:minmax(0,1fr)}.portal-body #serverForm .dialog-actions{flex-wrap:wrap}.portal-body #serverForm .save-hint{flex:1 1 100%;margin-right:0}}

/* part 4c: login and register keep their layout and animation; console.css section 17 themes the shell for both
   consoles. 登录 / 邀请码注册 is a quiet segmented control, so the submit stays the only solid button on the page. */
.portal-body .portal-tabs{gap:0;padding:2px;border-radius:4px;background:var(--sunken)}
.portal-body .portal-tab{min-height:32px;border:0;border-radius:3px;background:transparent;color:var(--muted);font-size:13px;font-weight:500}
.portal-body .portal-tab.active,.portal-body .portal-tab[aria-pressed=true]{background:var(--raised);color:var(--ink);font-weight:600;box-shadow:0 0 0 1px var(--rule)}
@media (pointer:coarse){.portal-body .portal-tab{min-height:44px}}
