/* Sandbox-Agent 管理后台。颜色、圆角、间距、阴影、动效都走变量；深色跟随系统。 */

:root {
  color-scheme: light dark;
  --bg: #f6f6f7;
  --surface: #ffffff;
  --surface-2: #f3f3f5;
  --raised: #ffffff;
  --border: #e5e5e9;
  --border-strong: #d4d4da;
  --text: #18181b;
  --text-2: #52525b;
  --text-3: #71717a;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-press: #3730a3;
  --primary-soft: #eef0ff;
  --on-primary: #ffffff;
  --ok: #15803d;      --ok-soft: #ecfdf3;
  --warn: #b45309;    --warn-soft: #fff8eb;
  --danger: #dc2626;  --danger-soft: #fef1f1;
  --danger-hover: #b91c1c;
  --info: #0369a1;    --info-soft: #eef8ff;
  --muted-soft: #f1f1f3;
  --focus: 0 0 0 3px color-mix(in srgb, var(--primary) 32%, transparent);
  --shadow-pop: 0 10px 30px -8px rgb(0 0 0 / .18), 0 2px 6px rgb(0 0 0 / .06);
  --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-xl: 16px;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-8: 32px;
  --sidebar-w: 224px; --rail-w: 64px; --topbar-h: 56px;
  --t-fast: 120ms; --t-med: 200ms; --t-slow: 260ms;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
          "Noto Sans CJK SC", "Noto Sans SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e11;
    --surface: #16161a;
    --surface-2: #1d1d22;
    --raised: #232329;
    --border: #2a2a31;
    --border-strong: #3a3a43;
    --text: #ececf0;
    --text-2: #b6b6bf;
    --text-3: #8b8b96;
    --primary: #8b93ff;
    --primary-hover: #a3a9ff;
    --primary-press: #bfc3ff;
    --primary-soft: rgb(139 147 255 / .14);
    --on-primary: #0e0e11;
    --ok: #4ade80;      --ok-soft: rgb(74 222 128 / .12);
    --warn: #fbbf24;    --warn-soft: rgb(251 191 36 / .12);
    --danger: #f87171;  --danger-soft: rgb(248 113 113 / .13);
    --danger-hover: #fca5a5;
    --info: #38bdf8;    --info-soft: rgb(56 189 248 / .12);
    --muted-soft: rgb(255 255 255 / .06);
    --shadow-pop: 0 0 0 1px var(--border-strong);
  }
}

/* ---------------------------------------------------------------- reset */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.55 var(--font); color: var(--text); background: var(--bg);
       -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p, dl, dd, ol, ul, figure, fieldset { margin: 0; }
ol, ul { padding: 0; list-style: none; }
fieldset { border: 0; padding: 0; min-width: 0; }
legend { padding: 0; }
a { color: var(--primary); text-decoration: none; }
@media (hover: hover) { a:hover { text-decoration: underline; text-underline-offset: 2px; } }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg { display: block; }
code, pre, .mono { font-family: var(--mono); font-size: .92em; }
code { padding: 0 .3em; border-radius: 4px; background: var(--surface-2); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
::selection { background: color-mix(in srgb, var(--primary) 28%, transparent); }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75;
        stroke-linecap: round; stroke-linejoin: round; }
.icon .fill, symbol .fill { fill: currentColor; stroke: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------------------------------------------------------------- typography */
.h2 { font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.h3 { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: var(--s-2); }
.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
.strong { font-weight: 600; }
.danger-text { color: var(--danger); }
.break { overflow-wrap: anywhere; }
.num, .stat-value, .big-number, time, .kv dd { font-variant-numeric: tabular-nums; }
.clamp-1 { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- shell */
.shell { display: flex; min-height: 100dvh; }
.sidebar { position: sticky; top: 0; height: 100dvh; width: var(--sidebar-w); flex: none; display: flex; flex-direction: column;
           background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto; z-index: 30;
           padding: var(--s-3) var(--s-2) calc(var(--s-3) + env(safe-area-inset-bottom)); }
.brand { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-2) var(--s-4); color: var(--text); font-weight: 650; }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: var(--r-md);
              background: var(--primary); color: var(--on-primary); flex: none; }
.brand-mark .icon { width: 19px; height: 19px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: var(--s-3); padding: 8px 10px; border-radius: var(--r-md);
            color: var(--text-2); font-weight: 500; transition: background var(--t-fast), color var(--t-fast); }
.nav-item .icon { color: var(--text-3); }
@media (hover: hover) { .nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; } }
.nav-item.is-active { background: var(--primary-soft); color: var(--primary); }
.nav-item.is-active .icon { color: var(--primary); }
.sidebar-foot { margin-top: auto; padding: var(--s-3) var(--s-3) 0; color: var(--text-3); font-size: 12px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: var(--s-3); min-height: var(--topbar-h);
          padding: 0 var(--s-6); padding-top: env(safe-area-inset-top); background: color-mix(in srgb, var(--bg) 88%, transparent);
          backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border); }
.page-title { font-size: 17px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { margin-left: auto; display: flex; gap: var(--s-2); }
.account { display: flex; align-items: center; gap: var(--s-2); padding-left: var(--s-3); border-left: 1px solid var(--border); }
.topbar-actions:empty + .account { margin-left: auto; border-left: 0; }
.account-name { font-weight: 500; max-width: 12em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-exp { color: var(--text-3); font-size: 12px; white-space: nowrap; }
.content { padding: var(--s-6); display: flex; flex-direction: column; gap: var(--s-5); min-width: 0;
           padding-bottom: calc(var(--s-8) + env(safe-area-inset-bottom)); }
.topbar .menu-btn, .scrim { display: none; }

/* ---------------------------------------------------------------- cards & layout */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s-5); min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); }
.card-head > div { min-width: 0; }
.card-head p { margin-top: 2px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: var(--s-5); align-items: start; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: var(--s-5); align-items: start; }
.stack { display: flex; flex-direction: column; gap: var(--s-4); min-width: 0; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.form-card { max-width: 680px; display: flex; flex-direction: column; gap: var(--s-4); }
.form-narrow { max-width: 560px; margin-top: var(--s-5); padding-top: var(--s-5); border-top: 1px solid var(--border); }
.card > .form-narrow:first-child, .card-head + .form-narrow { margin-top: 0; padding-top: 0; border-top: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--s-4); }
.stat { display: flex; flex-direction: column; gap: 2px; color: var(--text); transition: border-color var(--t-fast); }
a.stat:hover { text-decoration: none; border-color: var(--border-strong); }
.stat-label { color: var(--text-3); font-size: 12.5px; }
.stat-value { font-size: 26px; font-weight: 600; letter-spacing: -.02em; line-height: 1.25; }
.stat-value.small-value { font-size: 18px; padding: 4px 0; }
.stat-sub { color: var(--text-3); font-size: 12.5px; }
.big-number { font-size: 30px; font-weight: 600; letter-spacing: -.02em; margin-bottom: var(--s-3); }

.kv { display: grid; grid-template-columns: minmax(84px, max-content) minmax(0, 1fr); gap: 10px var(--s-5); }
.kv dt { color: var(--text-3); }
.kv dd { min-width: 0; }
.plain-list { display: flex; flex-direction: column; gap: var(--s-2); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; gap: 6px; align-items: baseline; padding: 2px 8px; border-radius: var(--r-sm);
       background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; max-width: 100%; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- setup checklist */
.setup { border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); background:
         linear-gradient(180deg, var(--primary-soft), transparent 70%), var(--surface); }
.checklist { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--s-3); }
.checklist li { display: flex; align-items: center; gap: var(--s-2); }
.check-mark { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; flex: none;
              border: 1.5px solid var(--border-strong); color: var(--text-3); font-size: 12px; font-weight: 600; }
.checklist li.is-done { color: var(--text-3); }
.checklist li.is-done .check-mark { background: var(--ok); border-color: var(--ok); color: var(--surface); }
.check-mark .icon { width: 14px; height: 14px; stroke-width: 2.4; }

/* ---------------------------------------------------------------- badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px 1px 7px; border-radius: 999px; font-size: 12px;
         font-weight: 500; line-height: 20px; white-space: nowrap; vertical-align: middle; }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok { color: var(--ok); background: var(--ok-soft); }
.badge-warn { color: var(--warn); background: var(--warn-soft); }
.badge-danger { color: var(--danger); background: var(--danger-soft); }
.badge-info { color: var(--info); background: var(--info-soft); }
.badge-muted { color: var(--text-3); background: var(--muted-soft); }

/* ---------------------------------------------------------------- callouts */
.callout { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3) var(--s-4); border-radius: var(--r-md);
           border: 1px solid transparent; }
.callout > .icon { margin-top: 2px; }
.callout > div { min-width: 0; }
.callout-danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.callout-danger > .icon, .callout-danger .h3 { color: var(--danger); }
.callout-warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.callout-warn > .icon, .callout-warn .h3 { color: var(--warn); }
.callout-info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 22%, transparent); margin-top: var(--s-4); }
.callout-info > .icon { color: var(--info); }
section.callout { display: block; }

/* ---------------------------------------------------------------- buttons */
.btn { --b-bg: var(--surface); --b-fg: var(--text); --b-bd: var(--border-strong);
       position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px;
       padding: 0 14px; border-radius: var(--r-md); border: 1px solid var(--b-bd); background: var(--b-bg); color: var(--b-fg);
       font-weight: 500; white-space: nowrap; user-select: none; text-decoration: none;
       transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform var(--t-fast); }
.btn:hover { text-decoration: none; }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-primary { --b-bg: var(--primary); --b-fg: var(--on-primary); --b-bd: var(--primary); }
.btn-secondary { --b-bg: var(--surface); }
.btn-danger { --b-bg: var(--danger); --b-fg: #fff; --b-bd: var(--danger); }
.btn-ghost { --b-bg: transparent; --b-bd: transparent; --b-fg: var(--text-2); }
@media (hover: hover) {
  .btn-primary:hover:not(:disabled) { --b-bg: var(--primary-hover); --b-bd: var(--primary-hover); }
  .btn-secondary:hover:not(:disabled) { --b-bg: var(--surface-2); }
  .btn-danger:hover:not(:disabled) { --b-bg: var(--danger-hover); --b-bd: var(--danger-hover); }
  .btn-ghost:hover:not(:disabled) { --b-bg: var(--surface-2); --b-fg: var(--text); }
}
.btn-primary:active:not(:disabled) { --b-bg: var(--primary-press); }
@media (prefers-color-scheme: dark) { .btn-danger { --b-fg: #1a0b0b; } }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading > * { visibility: hidden; }
.btn.is-loading::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
                         border: 2px solid var(--b-fg); border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-md); border: 0;
            background: transparent; color: var(--text-2); flex: none; transition: background var(--t-fast), color var(--t-fast); }
@media (hover: hover) { .icon-btn:hover { background: var(--surface-2); color: var(--text); } }
.icon-btn:active { transform: scale(.96); }

.copy-btn { position: relative; display: inline-grid; place-items: center; width: 26px; height: 26px; border: 0; border-radius: var(--r-sm);
            background: transparent; color: var(--text-3); vertical-align: middle; flex: none; }
@media (hover: hover) { .copy-btn:hover { background: var(--surface-2); color: var(--text); } }
.copy-btn .icon { width: 15px; height: 15px; }
.copy-done { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ok); opacity: 0; transition: opacity var(--t-fast); }
.copy-btn.is-copied > .icon { opacity: 0; }
.copy-btn.is-copied .copy-done { opacity: 1; }
.id-cell { display: inline-flex; align-items: center; gap: 2px; min-width: 0; max-width: 100%; }
.id-cell > .mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-group { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- forms */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.inline { flex-direction: row; align-items: center; gap: var(--s-2); }
.label { font-weight: 500; font-size: 13px; color: var(--text-2); }
.hint { color: var(--text-3); font-size: 12.5px; }
.field-error { color: var(--danger); font-size: 12.5px; }
.input, .select { width: 100%; min-height: 36px; padding: 7px 11px; border-radius: var(--r-md); border: 1px solid var(--border-strong);
                  background: var(--surface); color: var(--text); transition: border-color var(--t-fast), box-shadow var(--t-fast);
                  appearance: none; -webkit-appearance: none; }
.input::placeholder { color: var(--text-3); opacity: .8; }
.input:focus, .select:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
.input[readonly] { background: var(--surface-2); color: var(--text-2); }
.has-error .input, .has-error .select { border-color: var(--danger); }
.input.num { font-variant-numeric: tabular-nums; max-width: 220px; }
.input[type="number"]::-webkit-inner-spin-button, .input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.input[type="number"] { -moz-appearance: textfield; }
.input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
.input[type="date"]::-webkit-calendar-picker-indicator { opacity: .6; cursor: pointer; }
.input:-webkit-autofill { -webkit-text-fill-color: var(--text); box-shadow: 0 0 0 40px var(--surface) inset; caret-color: var(--text); }
.select { padding-right: 34px; cursor: pointer; background-repeat: no-repeat; background-position: right 11px center; background-size: 12px;
          background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%2371717a' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.field.inline .select, .field.inline .input { width: auto; min-width: 140px; }
.input-row { display: flex; align-items: center; gap: var(--s-3); }
.unit-preview { font-size: 12.5px; white-space: nowrap; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: var(--s-5) var(--s-6); }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }
.sticky-actions { position: sticky; bottom: 0; z-index: 5; padding: var(--s-3) var(--s-4); margin: 0 calc(-1 * var(--s-4));
                  background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(8px); border-top: 1px solid var(--border);
                  padding-bottom: calc(var(--s-3) + env(safe-area-inset-bottom)); }
.settings { display: flex; flex-direction: column; gap: var(--s-5); }

.choice-row { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); }
.choice-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--s-2); margin-top: var(--s-2);
               padding: var(--s-3); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); }
.choice-list[data-collapsed] { display: none; }
.choice { display: inline-flex; align-items: center; gap: var(--s-2); cursor: pointer; min-height: 32px; }
.choice input[type="radio"], .choice input[type="checkbox"] { appearance: none; -webkit-appearance: none; margin: 0; flex: none;
  width: 18px; height: 18px; border: 1.5px solid var(--border-strong); background: var(--surface); display: grid; place-items: center;
  transition: border-color var(--t-fast), background var(--t-fast); }
.choice input[type="radio"] { border-radius: 50%; }
.choice input[type="checkbox"] { border-radius: 5px; }
.choice input:checked { border-color: var(--primary); background: var(--primary); }
.choice input[type="radio"]:checked::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--on-primary); }
.choice input[type="checkbox"]:checked::after { content: ""; width: 5px; height: 9px; border: solid var(--on-primary); border-width: 0 2px 2px 0;
  transform: translateY(-1px) rotate(45deg); }
.choice input:focus-visible { box-shadow: var(--focus); }

.switch-field { display: flex; gap: var(--s-3); align-items: flex-start; cursor: pointer; padding: var(--s-3); border-radius: var(--r-md);
                background: var(--surface-2); }
.switch-field .hint { display: block; margin-top: 2px; }
.switch { appearance: none; -webkit-appearance: none; flex: none; margin: 2px 0 0; width: 36px; height: 20px; border-radius: 999px;
          background: var(--border-strong); position: relative; cursor: pointer; transition: background var(--t-med) var(--ease); }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff;
                 box-shadow: 0 1px 2px rgb(0 0 0 / .25); transition: transform var(--t-med) var(--ease); }
.switch:checked { background: var(--primary); }
.switch:checked::after { transform: translateX(16px); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); }
.search { position: relative; flex: 1 1 260px; max-width: 360px; display: flex; align-items: center; }
.search .icon { position: absolute; left: 10px; color: var(--text-3); pointer-events: none; }
.search .input { padding-left: 34px; }
.filters-body { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }
.filters-toggle { display: none; }

/* ---------------------------------------------------------------- tables */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 500; font-size: 12.5px; color: var(--text-3); padding: 10px var(--s-4);
            border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
.table td { padding: 10px var(--s-4); border-bottom: 1px solid var(--border); vertical-align: middle; min-width: 0; }
.table tbody tr:last-child td { border-bottom: 0; }
@media (hover: hover) { .table tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); } }
.table .num { text-align: right; white-space: nowrap; }
.table td .clamp-1 { max-width: 22em; }
.table.compact th, .table.compact td { padding: 7px var(--s-2); }
.table.compact th { background: transparent; }
.card > .table.compact { margin: 0 calc(-1 * var(--s-2)); width: calc(100% + 2 * var(--s-2)); }
.row-note td { padding-top: 0; }

.pager { display: flex; align-items: center; justify-content: center; gap: var(--s-3); }
.empty { text-align: center; padding: var(--s-8) var(--s-5); display: flex; flex-direction: column; align-items: center; gap: var(--s-2); }
.empty-title { font-weight: 600; font-size: 15px; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 30%, var(--border)); }
.danger-zone .muted { margin-bottom: var(--s-3); }

/* ---------------------------------------------------------------- selfcheck steps */
.selfcheck-summary { margin-bottom: var(--s-3); display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.steps { display: flex; flex-direction: column; }
.step { display: flex; gap: var(--s-3); padding: 8px 0; position: relative; }
.step:not(:last-child)::before { content: ""; position: absolute; left: 8.5px; top: 28px; bottom: -6px; width: 1.5px; background: var(--border); }
.step-mark { width: 19px; height: 19px; border-radius: 50%; border: 1.5px solid var(--border-strong); flex: none; margin-top: 1px;
             background: var(--surface); display: grid; place-items: center; }
.step-ok .step-mark { background: var(--ok); border-color: var(--ok); }
.step-ok .step-mark::after { content: ""; width: 4px; height: 8px; border: solid var(--surface); border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }
.step-failed .step-mark { background: var(--danger); border-color: var(--danger); }
.step-failed .step-mark::after { content: "!"; color: var(--surface); font-size: 12px; font-weight: 700; line-height: 1; }
.step-running .step-mark { border-color: var(--primary); border-right-color: transparent; animation: spin .8s linear infinite; }
.step-skipped .step-title, .step-pending .step-title { color: var(--text-3); }
.step-msg { color: var(--text-2); overflow-wrap: anywhere; }
.step-failed .step-msg { color: var(--danger); }

/* ---------------------------------------------------------------- secrets & code */
.secret-box { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4);
              border: 1px dashed var(--border-strong); border-radius: var(--r-md); background: var(--surface-2); margin: 0; }
.secret-box code { flex: 1; background: none; padding: 0; font-size: 14px; }
.usage { margin: 0; }
.usage summary { cursor: pointer; color: var(--text-2); }
.code { margin: var(--s-2) 0 0; padding: var(--s-3) var(--s-4); background: var(--surface-2); border-radius: var(--r-md); overflow-x: auto; font-size: 12.5px; }
.code code { background: none; padding: 0; }

/* ---------------------------------------------------------------- login */
body.plain { min-height: 100dvh; }
.login { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s-4);
         padding: var(--s-6) var(--s-4) calc(var(--s-6) + env(safe-area-inset-bottom)); }
.login-card { width: min(100%, 380px); padding: var(--s-8) var(--s-6); display: flex; flex-direction: column; gap: var(--s-6);
              box-shadow: 0 1px 2px rgb(0 0 0 / .04); }
.login-brand { display: flex; align-items: center; gap: var(--s-3); }
.login-brand .brand-mark { width: 40px; height: 40px; border-radius: var(--r-lg); }
.login-brand .brand-mark .icon { width: 24px; height: 24px; }
.input-code { font-family: var(--mono); font-size: 22px; letter-spacing: .35em; text-align: center; min-height: 48px; }
.login-foot { font-size: 12px; }
.center-card { min-height: 100dvh; display: grid; place-items: center; padding: var(--s-6); }
.center-card .card { max-width: 420px; display: flex; flex-direction: column; gap: var(--s-3); }

/* ---------------------------------------------------------------- toasts & dialog */
.toasts { position: fixed; right: var(--s-5); bottom: calc(var(--s-5) + env(safe-area-inset-bottom)); z-index: 60;
          display: flex; flex-direction: column; gap: var(--s-2); max-width: min(420px, calc(100vw - 2 * var(--s-4))); }
.toast { display: flex; align-items: flex-start; gap: var(--s-2); padding: 10px 10px 10px 14px; border-radius: var(--r-md);
         background: var(--raised); border: 1px solid var(--border); box-shadow: var(--shadow-pop);
         animation: toast-in var(--t-slow) var(--ease); }
.toast > .icon { margin-top: 2px; }
.toast > span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast-ok > .icon { color: var(--ok); }
.toast-error > .icon { color: var(--danger); }
.toast-info > .icon { color: var(--info); }
.toast-close { border: 0; background: none; color: var(--text-3); padding: 2px; border-radius: var(--r-sm); }
.toast-close .icon { width: 16px; height: 16px; }
.toast.is-leaving { animation: toast-out var(--t-fast) ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(4px); } }

.dialog { border: 1px solid var(--border); border-radius: var(--r-xl); padding: 0; width: min(440px, calc(100vw - 32px));
          background: var(--raised); color: var(--text); box-shadow: var(--shadow-pop); }
.dialog::backdrop { background: rgb(10 10 14 / .45); }
.dialog[open] { animation: dialog-in var(--t-med) var(--ease); }
.dialog[open]::backdrop { animation: fade-in var(--t-med) ease; }
.dialog-body { padding: var(--s-6); display: flex; flex-direction: column; gap: var(--s-4); }
.dialog-title { font-size: 16px; font-weight: 600; }
.dialog-text { color: var(--text-2); }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--s-2); flex-wrap: wrap; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(6px) scale(.98); } }
@keyframes fade-in { from { opacity: 0; } }

/* ---------------------------------------------------------------- 平板 / 窄窗口：侧栏收成图标栏 */
@media (max-width: 1100px) {
  .sidebar { width: var(--rail-w); padding-left: var(--s-2); padding-right: var(--s-2); }
  .brand { justify-content: center; padding-left: 0; padding-right: 0; }
  .brand-text, .nav-label { display: none; }
  .nav-item { justify-content: center; padding: 10px 0; }
  .grid-main { grid-template-columns: minmax(0, 1fr); }
  .col-opt { display: none; }
}

/* ---------------------------------------------------------------- 手机：单列，导航进抽屉，表格变卡片 */
@media (max-width: 720px) {
  body { font-size: 15px; }
  .input, .select { font-size: 16px; min-height: 42px; }
  .btn { min-height: 42px; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(280px, 84vw); transform: translateX(-102%);
             transition: transform var(--t-slow) var(--ease); box-shadow: var(--shadow-pop); padding-top: calc(var(--s-3) + env(safe-area-inset-top)); }
  .brand { justify-content: flex-start; padding-left: var(--s-2); }
  .brand-text, .nav-label { display: inline; }
  .nav-item { justify-content: flex-start; padding: 11px 12px; }
  body.drawer-open .sidebar { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgb(10 10 14 / .4); opacity: 0; pointer-events: none;
           transition: opacity var(--t-slow) ease; }
  body.drawer-open .scrim { opacity: 1; pointer-events: auto; }
  .topbar .menu-btn { display: inline-grid; margin-left: -8px; }
  .topbar { padding: 0 var(--s-4); gap: var(--s-2); min-height: 52px; }
  .page-title { font-size: 16px; }
  .account { border-left: 0; padding-left: 0; }
  .account-name, .account-exp { display: none; }
  .content { padding: var(--s-4) var(--s-3); gap: var(--s-4); }
  .card { padding: var(--s-4); border-radius: var(--r-lg); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
  .stat-value { font-size: 21px; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kv dd { margin-bottom: var(--s-2); }
  .topbar-actions .btn span { display: none; }
  .topbar-actions .btn { width: 42px; padding: 0; }

  .filters-toggle { display: inline-flex; }
  .filters-body { display: none; width: 100%; flex-direction: column; align-items: stretch; }
  [data-filters].filters-open .filters-body { display: flex; }
  .field.inline { flex-direction: column; align-items: stretch; }
  .field.inline .select, .field.inline .input { width: 100%; }
  .search { max-width: none; }

  .card.flush { background: transparent; border: 0; overflow: visible; }
  .table.responsive thead { display: none; }
  .table.responsive, .table.responsive tbody { display: block; }
  .table.responsive tr { display: block; margin-bottom: var(--s-3); padding: var(--s-3) var(--s-4); border: 1px solid var(--border);
                         border-radius: var(--r-lg); background: var(--surface); }
  .table.responsive td { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); padding: 3px 0; border: 0;
                         text-align: right; }
  .table.responsive td::before { content: attr(data-label); color: var(--text-3); font-size: 13px; flex: none; text-align: left; }
  .table.responsive td.cell-primary { font-weight: 600; justify-content: flex-start; text-align: left; padding-bottom: var(--s-1); }
  .table.responsive td.cell-primary::before { display: none; }
  .table.responsive td.col-opt { display: none; }
  .table.responsive td .clamp-1 { max-width: 60vw; }
  .cell-group { justify-content: flex-end; }
  .card .table.responsive tr { background: var(--surface-2); }

  .toasts { left: var(--s-3); right: var(--s-3); max-width: none; }
  .dialog { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: var(--r-xl) var(--r-xl) 0 0; border-bottom: 0; }
  .dialog-body { padding-bottom: calc(var(--s-6) + env(safe-area-inset-bottom)); }
  .dialog[open] { animation: sheet-in var(--t-slow) var(--ease); }
  .dialog-actions .btn { flex: 1; }
  .sticky-actions { margin: 0 calc(-1 * var(--s-3)); }
  .secret-box { flex-direction: column; align-items: stretch; }
}
@keyframes sheet-in { from { transform: translateY(100%); } }

/* 减少动态效果：去掉位移和缩放，只保留淡入淡出 */
@media (prefers-reduced-motion: reduce) {
  .toast, .dialog[open], .toast.is-leaving { animation-name: fade-in; }
  .toast.is-leaving { animation-direction: reverse; }
  .btn:active:not(:disabled), .icon-btn:active { transform: none; }
  .sidebar { transition: none; }
  .switch, .switch::after { transition-duration: 1ms; }
  .btn.is-loading::after, .step-running .step-mark { animation-duration: 1.6s; }
}
