/* VPS Manager 在线中心 — Apple.com 风格（ADR-0008 · apple-design/emil-design-eng 值表） */
:root {
  color-scheme: light dark;
  --surface: #f5f5f7;         /* apple.com 区块灰 */
  --panel: #ffffff;
  --panel-2: #fbfbfd;
  --ink: #1d1d1f;             /* apple.com 正文 */
  --muted: #6e6e73;           /* apple.com 次要文本 */
  --faint: #86868b;
  --line: #d2d2d7;            /* apple 发线 */
  --line-soft: #e8e8ed;
  --accent: #0071e3;          /* apple.com 蓝 */
  --accent-hover: #0077ed;
  --accent-soft: rgba(0, 113, 227, .12);
  --danger: #d70015;
  --danger-soft: rgba(215, 0, 21, .08);
  --ok: #248a3d;
  --track: #e8e8ed;           /* iOS 分段控件底色 */
  --shadow-card: 0 4px 16px rgba(0, 0, 0, .04);
  --shadow-hover: 0 12px 32px rgba(0, 0, 0, .1);
  --radius-card: 18px;
  --radius-field: 12px;
  --term-bg: #1c1c1e;
}
@media (prefers-color-scheme: dark) {
  :root {
    --surface: #000000;       /* apple.com 深色页 */
    --panel: #161617;
    --panel-2: #1d1d1f;
    --ink: #f5f5f7;
    --muted: #a1a1a6;
    --faint: #6e6e73;
    --line: #3d3d41;
    --line-soft: #2d2d2f;
    --accent: #2997ff;        /* apple.com 深色模式链接蓝 */
    --accent-hover: #47a9ff;
    --accent-soft: rgba(41, 151, 255, .16);
    --danger: #ff453a;
    --danger-soft: rgba(255, 69, 58, .12);
    --ok: #32d74b;
    --track: #2d2d2f;
    --shadow-card: 0 4px 16px rgba(0, 0, 0, .35);
    --shadow-hover: 0 12px 32px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font: 16px/1.47 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "Microsoft YaHei", sans-serif;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s ease, color .3s ease;
}
main { max-width: 1020px; margin: auto; padding: 56px 24px 80px; }
::selection { background: var(--accent-soft); }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.resource, #connect, #pair-pending, #scope-plan, #device-confirm, #upload-plan, #notice {
  animation: rise .3s cubic-bezier(.23, 1, .32, 1);
}

/* ---------- 头部与分段控件 ---------- */
header, .row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; }
header { padding-bottom: 28px; margin-bottom: 32px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 34px; font-weight: 700; line-height: 1.1; letter-spacing: -.022em; }
h2 { font-size: 20px; font-weight: 600; letter-spacing: -.014em; margin-bottom: 14px; }
h3 { font-size: 15px; font-weight: 600; letter-spacing: -.01em; margin-bottom: 10px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); margin-bottom: 4px; }

nav.segmented { display: inline-flex; padding: 2px; background: var(--track); border-radius: 980px; }
nav.segmented button {
  min-height: 32px; padding: 5px 18px; border: 0; border-radius: 980px;
  background: transparent; color: var(--ink); font-size: 14px; font-weight: 500;
  transition: background-color .2s ease;
}
nav.segmented button[aria-pressed="true"] { background: var(--panel); box-shadow: 0 2px 8px rgba(0, 0, 0, .12), 0 0 0 .5px rgba(0, 0, 0, .04); }

/* ---------- 卡片 ---------- */
section, #admin-tools { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
#admin-tools section, #pairing, #connect, #owner-login, .resource {
  background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius-card);
  padding: 22px 24px; box-shadow: var(--shadow-card);
}
.resource { transition: transform .25s ease, box-shadow .25s ease; }
.resource:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }

/* ---------- 表单与按钮 ---------- */
form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
label { display: grid; gap: 6px; min-width: 0; font-size: 13px; font-weight: 500; color: var(--muted); }
form > label { flex: 1 1 240px; max-width: 460px; }
input, select, button { font: inherit; min-height: 44px; padding: 10px 14px; }
input, select { width: 100%; }
input, select {
  border: 1px solid var(--line); border-radius: var(--radius-field);
  background: var(--panel-2); color: var(--ink); font-size: 15px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
input::placeholder { color: var(--faint); }

button {
  cursor: pointer; border: 0; border-radius: 980px;
  background: var(--track); color: var(--ink);
  font-size: 15px; font-weight: 500; white-space: nowrap;
  transition: transform .1s ease-out, background-color .15s ease, opacity .15s ease;
}
button:hover { background: var(--line); }
button:active { transform: scale(.96); }
button.primary { background: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-hover); }
button:disabled { opacity: .5; cursor: wait; transform: none; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: none; box-shadow: 0 0 0 4px var(--accent-soft);
}
#execute input[name="command"], input[name="code"], input[name="bootstrap"] {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: .02em;
}
#devices button { background: none; color: var(--danger); min-height: 36px; padding: 6px 12px; font-size: 14px; }
#devices button:hover { background: var(--danger-soft); }

/* ---------- 通知条 ---------- */
#notice {
  border-radius: var(--radius-field); background: var(--panel);
  border: 1px solid var(--line-soft); border-left: 4px solid var(--accent);
  padding: 12px 16px; margin-bottom: 20px; overflow-wrap: anywhere;
  box-shadow: var(--shadow-card); font-size: 14px;
}
#notice.error { border-left-color: var(--danger); background: var(--danger-soft); }

/* ---------- 配对码 / 终端 / 结果 ---------- */
.pair-code {
  display: inline-block; margin: 8px 0;
  font: 600 26px/1.2 ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: .14em; padding: 14px 22px;
  background: var(--panel-2); border: 1px dashed var(--line); border-radius: var(--radius-field);
}

#connect { gap: 16px; }
#terminal-surface {
  background: var(--term-bg); border-radius: var(--radius-card);
  padding: 0 12px 12px; overflow: hidden;
  box-shadow: var(--shadow-card);
}
.term-bar { display: flex; align-items: center; gap: 10px; padding: 13px 4px 10px; }
.term-bar .dots {                    /* macOS 窗口圆点 */
  flex: none; width: 11px; height: 11px; border-radius: 50%;
  background: #ff5f57; box-shadow: 19px 0 #febc2e, 38px 0 #28c840;
  margin: 0 38px 0 4px;              /* 让元素盒 = 三圆点视觉宽度 */
}
#terminal-status {
  flex: 1; min-width: 0; margin: 0; color: #a1a1a6; font-size: 13px;
  display: flex; align-items: center; gap: 8px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#terminal-status::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: #86868b; }
#terminal-status[data-state="connecting"]::before { background: #ffd60a; }
#terminal-status[data-state="live"]::before { background: #30d158; }
#terminal-status[data-state="down"]::before, #terminal-status[data-state="denied"]::before { background: #ff453a; }
#terminal { height: min(56vh, 480px); min-height: 200px; width: 100%; min-width: 0; overflow: hidden; }
#connect > *, .resource > *, #terminal-surface > * { min-width: 0; }
pre, #result {
  border: 1px solid var(--line-soft); border-radius: var(--radius-field);
  background: var(--panel-2); padding: 14px 16px; margin: 0;
  font: 13px/1.5 ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
#result { max-height: 320px; overflow: auto; }

/* ---------- 资源卡 ---------- */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); }
.grid > .empty {
  grid-column: 1 / -1; text-align: center; color: var(--muted);
  border: 1px dashed var(--line); border-radius: var(--radius-card); padding: 32px 20px;
}
.resource { display: grid; gap: 10px; justify-items: start; overflow-wrap: anywhere; align-content: start; }
.resource h3 { margin-bottom: 0; }
.resource p, #passkey-state { color: var(--muted); margin-bottom: 0; font-size: 14px; }
.resource .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.resource .actions button { min-height: 36px; padding: 7px 16px; font-size: 14px; }

/* ---------- 管理区 ---------- */
#admin-tools > section > p, #admin-tools section label { font-size: 13px; }
#devices { padding: 0; margin: 12px 0 0; list-style: none; display: grid; gap: 0; }
#devices li + li { border-top: 1px solid var(--line-soft); }
#devices li { padding: 10px 0; }
.chip {
  display: inline-block; padding: 2px 10px; border-radius: 980px;
  background: var(--track); color: var(--muted); font-size: 12px; font-weight: 500;
}
.chip.revoked { background: var(--danger-soft); color: var(--danger); }
.device-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
#scope-options { width: 100%; display: grid; gap: 8px; padding: 4px 0; max-height: 240px; overflow: auto; }
#scope-options label { display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: 14px; }
#scope-options input { min-height: 0; width: 18px; height: 18px; accent-color: var(--accent); }
#scope-reviewed, #device-reviewed, #upload-reviewed { font-size: 14px; color: var(--muted); margin-bottom: 10px; }
#scope-plan, #device-confirm, #upload-plan {
  background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: var(--radius-field);
  padding: 16px; margin-top: 8px;
}
#upload-host-key { max-height: 120px; overflow: auto; }

/* ---------- 动效收敛 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
  .resource:hover { transform: none; }
}

@media (max-width: 560px) {
  main { padding: 32px 16px 56px; }
  h1 { font-size: 26px; }
  #admin-tools section, #pairing, #connect, #owner-login, .resource { padding: 18px; }
  form label { flex: 1 1 100%; max-width: none; }
  input, select { width: 100%; }
  #terminal { height: min(46vh, 360px); }
}
