/* Polybit 云平台。令牌与设备网页同源（polybit 仓库 web/DESIGN.md §3），浅色 / 深色：theme.js 在渲染前给 <html> 设 data-theme（没选过就跟随系统），右上角按钮切换。
   不引外部字体 / 图片 / CDN；中文字体用各平台自带。 */

:root {
  --brand: #2F6BFF;
  --brand-soft: rgba(47, 107, 255, .1);
  --grad: linear-gradient(135deg, #4F7CFF 0%, #16C2D5 100%);
  --bg: #F3F5F9;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --border: #E4E8EF;
  --border-strong: #CDD3DE;
  --text: #101828;
  --text-2: #475467;
  --text-3: #98A2B3;
  --sider: #0B1220;
  --ok: #12B76A;
  --warn: #F79009;
  --err: #F04438;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 24px 48px -12px rgba(16, 24, 40, .25);
  --font: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Source Han Sans SC", "Hiragino Sans GB", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --brand-soft: rgba(79, 124, 255, .16);
  --bg: #0A0E16;
  --surface: #111723;
  --surface-2: #161E2D;
  --border: #222C3D;
  --border-strong: #2E3A50;
  --text: #E6EAF2;
  --text-2: #A3ADBF;
  --text-3: #6B778C;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 14px; line-height: 1.6; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; }
p { margin: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.mono { font-family: var(--mono); font-size: .92em; letter-spacing: .01em; }
.muted { color: var(--text-3); }
.sub { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.nowrap { white-space: nowrap; }
.ta-r { text-align: right; }
.tone-ok { color: var(--ok); }
.tone-err { color: var(--err); }
.tone-brand { color: var(--brand); }
[hidden] { display: none !important; }

.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* 启动中 */
.boot { min-height: 100vh; display: grid; place-items: center; background: var(--sider); }
.boot__mark svg { width: 56px; height: 56px; animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .5; transform: scale(.94); } }

/* ---------- 按钮 / 输入 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px; padding: 0 14px;
  border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s, opacity .15s;
}
.btn:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.btn:focus-visible, .icon-btn:focus-visible, .input:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn:disabled { opacity: .45; cursor: not-allowed; border-color: var(--border-strong); color: var(--text); }
.btn .ico { width: 16px; height: 16px; }
.btn--primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn--primary:hover { background: #2559DB; border-color: #2559DB; color: #fff; }
.btn--primary:disabled { background: var(--brand); color: #fff; }
.btn--danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn--danger:hover { background: #D92D20; border-color: #D92D20; color: #fff; }
.btn--danger-ghost { color: var(--err); }
.btn--danger-ghost:hover { border-color: var(--err); color: var(--err); background: rgba(240, 68, 56, .06); }
.btn--sm { min-height: 28px; padding: 0 10px; font-size: 13px; }
.btn--block { width: 100%; min-height: 42px; font-size: 15px; }
.btn.is-busy { cursor: progress; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn .ico { width: 18px; height: 18px; }

.form { display: flex; flex-direction: column; gap: 16px; }
.form__row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form__actions { display: flex; justify-content: flex-end; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field__label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.field__hint { font-size: 12px; color: var(--text-3); }
.input {
  width: 100%; min-height: 38px; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px; transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.input[readonly] { background: var(--surface-2); color: var(--text-2); }
textarea.input { resize: vertical; line-height: 1.6; }
.check { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--brand); }
.form-error { padding: 10px 12px; border-radius: 8px; font-size: 13px; color: var(--err); background: rgba(240, 68, 56, .08); border: 1px solid rgba(240, 68, 56, .25); }

/* ---------- 登录 / 注册 ---------- */
.auth { display: grid; grid-template-columns: minmax(380px, 5fr) 7fr; min-height: 100vh; }
.auth__brand {
  position: relative; display: flex; flex-direction: column; justify-content: space-between; padding: 40px 48px; color: #fff; overflow: hidden;
  background: radial-gradient(700px 400px at 100% 0%, rgba(47, 107, 255, .35), transparent 60%),
              radial-gradient(500px 300px at 0% 100%, rgba(22, 194, 213, .2), transparent 70%), #0A0E16;
}
.auth__brand::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px) 0 0 / 40px 40px,
              linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px) 0 0 / 40px 40px;
  -webkit-mask-image: linear-gradient(180deg, #000, transparent); mask-image: linear-gradient(180deg, #000, transparent);
}
.auth__logo { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 10px; color: #fff; font-size: 20px; font-weight: 700; }
.auth__logo:hover { text-decoration: none; }
.auth__mark { width: 32px; height: 32px; }
.auth__mark--sm { width: 40px; height: 40px; margin-bottom: 20px; }
.auth__pitch { position: relative; z-index: 1; max-width: 420px; }
.auth__pitch h1 { font-size: 34px; font-weight: 800; letter-spacing: .01em; }
.auth__pitch p { margin-top: 14px; font-size: 16px; color: rgba(255, 255, 255, .7); line-height: 1.8; }
.auth__points { list-style: none; padding: 0; margin: 28px 0 0; display: flex; flex-direction: column; gap: 12px; }
.auth__points li { position: relative; padding-left: 28px; font-size: 15px; color: rgba(255, 255, 255, .88); }
.auth__points li::before { content: ""; position: absolute; left: 0; top: .32em; width: 16px; height: 16px; border-radius: 50%; background: var(--grad); }
.auth__points li::after { content: ""; position: absolute; left: 5.5px; top: calc(.32em + 3.5px); width: 4px; height: 7px; border: solid #fff; border-width: 0 1.8px 1.8px 0; transform: rotate(45deg); }
.auth__copy { position: relative; z-index: 1; font-size: 12px; color: rgba(255, 255, 255, .4); }
.auth__panel { position: relative; display: grid; place-items: center; padding: 48px 24px; background: var(--surface); }
.auth__theme { position: absolute; top: 16px; right: 16px; }
.auth__box { width: 100%; max-width: 420px; }
.auth__box h2 { font-size: 24px; font-weight: 700; }
.auth__sub { margin: 6px 0 28px; color: var(--text-2); }
.auth__foot { margin-top: 24px; text-align: center; color: var(--text-2); }
.auth__foot a { margin-left: 4px; font-weight: 500; }

/* ---------- 外壳 ---------- */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--sider); color: rgba(255, 255, 255, .7); padding: 18px 12px; }
.side__brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; color: #fff; }
.side__brand:hover { text-decoration: none; }
.side__mark { width: 30px; height: 30px; }
.side__name { font-size: 18px; font-weight: 700; }
.side__tag { margin-left: auto; font-size: 11px; padding: 1px 8px; border-radius: 99px; color: #9CE8F1; background: rgba(22, 194, 213, .14); border: 1px solid rgba(22, 194, 213, .35); }
.side__nav { display: flex; flex-direction: column; gap: 2px; }
.side__item { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px; border-radius: 8px; color: rgba(255, 255, 255, .68); font-size: 14px; }
.side__item:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.side__item.is-active { background: linear-gradient(90deg, rgba(47, 107, 255, .32), rgba(47, 107, 255, .12)); color: #fff; box-shadow: inset 2px 0 0 #4F7CFF; }
.side__foot { margin-top: auto; padding: 0 12px; }
.side__ext { font-size: 12px; color: rgba(255, 255, 255, .45); }
.side__ext:hover { color: #fff; }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--border); }
.top__menu { display: none; }
.top__spacer { flex: 1; }
.top__user { display: flex; align-items: center; gap: 10px; }
.avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--grad); color: #fff; font-weight: 700; font-size: 14px; }
.top__who { display: flex; flex-direction: column; line-height: 1.25; }
.top__who b { font-size: 13px; font-weight: 600; }
.top__who small { font-size: 12px; color: var(--text-3); }
.content { width: 100%; max-width: 1280px; margin: 0 auto; padding: 28px 32px 48px; }
.scrim { display: none; }

/* ---------- 页面组件 ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; font-weight: 700; }
.page-head p { margin-top: 4px; color: var(--text-2); }
.page-head__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 14px; color: var(--text-2); font-size: 13px; }
.back .ico { width: 16px; height: 16px; }
.back:hover { color: var(--brand); text-decoration: none; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px 22px; box-shadow: var(--shadow); }
.card + .card, .grid-2 + .card, .card + .grid-2 { margin-top: 16px; }
.card--flush { padding: 0; overflow: hidden; }
.card--note { background: var(--surface-2); box-shadow: none; }
.card--note h3 { font-size: 14px; margin-bottom: 6px; }
.card--note p { color: var(--text-2); font-size: 13px; }
.card__title { font-size: 15px; font-weight: 600; margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2 > .card + .card { margin-top: 0; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 20px; box-shadow: var(--shadow); }
.stat small { display: block; color: var(--text-2); font-size: 13px; }
.stat b { display: inline-block; margin-top: 6px; font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat span { margin-left: 8px; font-size: 12px; color: var(--text-3); }

.banner { padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 13px; }
.banner--warn { color: #B54708; background: rgba(247, 144, 9, .1); border: 1px solid rgba(247, 144, 9, .3); }
.banner--info { color: var(--text-2); background: var(--brand-soft); border: 1px solid rgba(47, 107, 255, .25); }
[data-theme="dark"] .banner--warn { color: #FDB022; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th { text-align: left; font-size: 12px; font-weight: 500; color: var(--text-3); background: var(--surface-2); padding: 10px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table th.ta-r { text-align: right; }
.dev-name { font-weight: 600; color: var(--text); }
.dev-name:hover { color: var(--brand); }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill--ok { color: #067647; background: rgba(18, 183, 106, .12); }
.pill--err { color: #B42318; background: rgba(240, 68, 56, .1); }
.pill--warn { color: #B54708; background: rgba(247, 144, 9, .14); }
.pill--muted { color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); }
[data-theme="dark"] .pill--ok { color: #47CD89; }
[data-theme="dark"] .pill--err { color: #F97066; }
[data-theme="dark"] .pill--warn { color: #FDB022; }

.kv { margin: 0; }
.kv > div { display: grid; grid-template-columns: 120px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.kv > div:last-child { border-bottom: 0; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; min-width: 0; word-break: break-all; }
.inline { display: inline-flex; align-items: center; gap: 4px; }
.inline .icon-btn { width: 26px; height: 26px; }
.inline .icon-btn .ico { width: 15px; height: 15px; }

.empty { display: flex; flex-direction: column; align-items: center; padding: 56px 24px; text-align: center; }
.empty__art { display: grid; place-items: center; width: 72px; height: 72px; border-radius: 20px; background: var(--brand-soft); margin-bottom: 18px; }
.empty__ico { width: 34px; height: 34px; fill: none; stroke: var(--brand); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.empty h3 { font-size: 17px; }
.empty p { margin: 8px 0 20px; color: var(--text-2); max-width: 380px; }
.loading { padding: 48px; text-align: center; color: var(--text-3); }

.help { padding: 12px 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; color: var(--text-2); }
.help b { color: var(--text); font-weight: 600; }
.steps { margin: 6px 0 0; padding-left: 20px; }
.steps li { margin-top: 2px; }
.demo-codes { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--text-2); }
.chip { padding: 2px 8px; border-radius: 6px; border: 1px dashed var(--border-strong); background: var(--surface); color: var(--text-2); font-size: 11px; cursor: pointer; }
.chip:hover { border-color: var(--brand); color: var(--brand); }

/* ---------- 对话框 / 提示 ---------- */
.overlay { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: rgba(10, 14, 22, .5); opacity: 0; transition: opacity .18s; }
.overlay.is-in { opacity: 1; }
.modal { width: 100%; max-width: 480px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); transform: translateY(8px) scale(.98); transition: transform .18s; }
.overlay.is-in .modal { transform: none; }
.modal--wide { max-width: 640px; }
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 0 22px; }
.modal__head h3 { font-size: 16px; font-weight: 600; }
.modal__body { padding: 16px 22px; overflow-y: auto; }
.modal__msg { color: var(--text-2); line-height: 1.8; }
.modal__foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 22px 20px; }

.toasts { position: fixed; top: 16px; left: 50%; z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px; transform: translateX(-50%); pointer-events: none; }
.toast { max-width: min(560px, calc(100vw - 32px)); padding: 10px 16px; border-radius: 10px; background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-size: 14px; opacity: 0; transform: translateY(-6px); transition: opacity .2s, transform .2s; }
.toast.is-in { opacity: 1; transform: none; }
.toast--ok { border-left: 3px solid var(--ok); }
.toast--err { border-left: 3px solid var(--err); }

/* 演示模式下的「设备网页」占位页 */
.fake-device { display: grid; place-items: center; min-height: 100vh; }
.fake-device main { max-width: 520px; padding: 32px; text-align: center; }
.fake-device h1 { font-size: 22px; margin-bottom: 12px; }
.fake-device p { color: var(--text-2); margin-top: 8px; }

/* ---------- 响应式 ---------- */
@media (max-width: 1080px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-2 > .card + .card { margin-top: 0; }
}
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth__brand { display: none; }
  .auth__panel { padding: 40px 16px; align-items: start; }
  .layout { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; z-index: 50; width: 248px; transform: translateX(-100%); transition: transform .2s; }
  body.side-open .side { transform: none; }
  body.side-open .scrim { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(10, 14, 22, .45); }
  .top { padding: 0 12px 0 8px; }
  .top__menu { display: inline-grid; }
  .content { padding: 20px 16px 40px; }
}
@media (max-width: 640px) {
  .top__who { display: none; }
  .form__row { grid-template-columns: 1fr; }
  .stats { gap: 10px; }
  .stat { padding: 12px 14px; }
  .stat b { font-size: 22px; }
  .kv > div { grid-template-columns: 96px 1fr; }
  .page-head__actions { width: 100%; }
  .page-head__actions .btn { flex: 1; }
  .table td, .table th { padding: 10px 12px; }
}
