/* ============================================================
   证书工坊 · 设计令牌
   单色系：墨绿（主色）+ 薄荷绿（唯一强调色）
   红色仅用于危险，黄色仅用于等待中
   ============================================================ */
:root {
  color-scheme: light dark;

  --paper:      #f4f7f5;
  --surface:    #ffffff;
  --surface-2:  #f7faf8;
  --line:       #e2eae6;
  --line-strong:#cfdcd6;

  --ink:        #14201d;
  --ink-2:      #4e615b;
  --ink-3:      #83918c;

  --accent:      #0f9d76;
  --accent-dark: #0b7a5c;
  --accent-soft: #e6f6f0;
  --accent-line: #bfe5d5;

  --danger:      #d6453c;
  --danger-soft: #fdeeec;
  --warn:        #b8860f;
  --warn-soft:   #fdf5e3;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-full: 999px;

  --shadow-sm: 0 1px 2px rgb(15 32 28 / 6%);
  --shadow-md: 0 1px 2px rgb(15 32 28 / 4%), 0 10px 28px -14px rgb(15 32 28 / 14%);
  --shadow-lg: 0 2px 4px rgb(15 32 28 / 5%), 0 22px 48px -22px rgb(15 32 28 / 22%);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  font-family: var(--font);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:      #0e1512;
    --surface:    #161e1a;
    --surface-2:  #1b2521;
    --line:       #26332e;
    --line-strong:#384a44;

    --ink:        #e9f1ed;
    --ink-2:      #a8b7b1;
    --ink-3:      #7c8d87;

    --accent:      #2ec294;
    --accent-dark: #46d9a9;
    --accent-soft: #16332a;
    --accent-line: #245443;

    --danger:      #e8706a;
    --danger-soft: #3a1f1d;
    --warn:        #d9a53a;
    --warn-soft:   #33280f;

    --shadow-sm: 0 1px 2px rgb(0 0 0 / 30%);
    --shadow-md: 0 1px 2px rgb(0 0 0 / 24%), 0 10px 28px -14px rgb(0 0 0 / 50%);
    --shadow-lg: 0 2px 4px rgb(0 0 0 / 28%), 0 22px 48px -22px rgb(0 0 0 / 62%);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
}

button, input, select, textarea { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
h1, h2, h3, p { margin-top: 0; }

.boot-screen { min-height: 100dvh; display: grid; place-items: center; color: var(--ink-3); }

/* ============================================================ 顶栏 */
.topbar {
  height: 68px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  padding: 0 max(28px, calc((100vw - 1140px) / 2));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: inline-flex; align-items: center; gap: 11px; width: fit-content; min-width: 0; }
.brand-mark {
  display: grid; place-items: center;
  width: 38px; aspect-ratio: 1;
  border-radius: var(--r-md);
  background: linear-gradient(150deg, var(--ink), #2c4a42);
  color: #fff; font-size: 18px; font-weight: 800;
  box-shadow: var(--shadow-sm);
}
.brand strong { display: block; font-size: 15px; line-height: 1.2; letter-spacing: .2px; }
.brand small { display: block; margin-top: 3px; color: var(--ink-3); font-size: 9px; font-weight: 600; letter-spacing: 1.2px; }

.topnav { display: flex; align-items: center; gap: 4px; height: 100%; justify-self: center; }
.nav-tab {
  position: relative; border: 0; background: transparent;
  height: 38px; padding: 0 16px; border-radius: var(--r-full);
  color: var(--ink-2); font-size: 13.5px; font-weight: 600;
  transition: background .18s ease, color .18s ease;
}
.nav-tab:hover { background: var(--surface-2); color: var(--ink); }
.nav-tab.active { color: var(--accent-dark); background: var(--accent-soft); }

.admin-link { justify-self: end; color: var(--ink-2); font-size: 12px; font-weight: 600; }
.admin-link span { color: var(--accent); margin-left: 3px; }

.button-plain {
  justify-self: end;
  padding: 8px 15px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-full);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12px; font-weight: 600;
  transition: border-color .15s ease, color .15s ease;
}
.button-plain:hover { border-color: var(--accent); color: var(--accent-dark); }

/* ============================================================ 布局 */
.page-shell, .admin-shell { max-width: 1040px; margin: 0 auto; padding: 30px 26px 40px; }

.intro-row { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin: 0 0 22px; }
.eyebrow, .section-kicker {
  margin: 0 0 8px; color: var(--accent-dark);
  font-size: 10px; font-weight: 750; letter-spacing: 1.2px;
}
.intro-row h1, .admin-title h1 { margin: 0; font-size: 28px; line-height: 1.2; letter-spacing: -.4px; font-weight: 800; }
.intro-copy { margin: 8px 0 0; color: var(--ink-2); font-size: 14px; max-width: 52ch; }

.flow-steps { display: flex; align-items: center; gap: 10px; padding-bottom: 4px; color: var(--ink-3); font-size: 12px; white-space: nowrap; }
.flow-steps span { position: relative; padding-left: 15px; font-weight: 600; }
.flow-steps span::before {
  content: ""; position: absolute; left: 0; top: 50%;
  width: 7px; height: 7px; transform: translateY(-50%);
  border-radius: 50%; background: var(--line-strong);
  transition: background .2s ease;
}
.flow-steps span.current { color: var(--ink); }
.flow-steps span.current::before { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.flow-steps span.done::before { background: var(--accent-dark); }
.flow-steps i { width: 22px; height: 1px; background: var(--line); }

/* ============================================================ 面板 */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  margin-bottom: 18px;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.device-panel, .apps-panel, .admin-panel { padding: 22px 24px; }
.panel-heading { display: flex; justify-content: space-between; align-items: start; gap: 16px; margin-bottom: 18px; }
.panel-heading h2 { margin: 0; font-size: 18px; line-height: 1.25; font-weight: 750; letter-spacing: -.2px; }
.panel-heading .section-kicker { margin-bottom: 6px; }
.step-count {
  display: grid; place-items: center;
  min-width: 32px; height: 28px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  color: var(--ink-3); font-size: 11px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ============================================================ 表单 */
.device-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px 10px; align-items: end; }
.field { display: grid; gap: 8px; min-width: 0; }
.field > span { color: var(--ink-2); font-size: 12.5px; font-weight: 650; }

.field input, .field select, .field textarea {
  width: 100%; min-width: 0; min-height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: 12px 14px;
  color: var(--ink); outline: none;
  font-size: 14px;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.field textarea { min-height: 60px; resize: vertical; }
.field input::placeholder { color: var(--ink-3); }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.field small { color: var(--ink-3); font-size: 12px; line-height: 1.5; }
.field select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
  cursor: pointer;
}

.card-field { grid-column: 1 / 2; }
.input-with-action { position: relative; display: block; }
.input-with-action input { padding-right: 58px; }
.input-action {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  border: 0; background: none; padding: 7px 9px; border-radius: var(--r-sm);
  color: var(--accent-dark); font-size: 12px; font-weight: 650;
  transition: background .15s ease;
}
.input-action:hover { background: var(--accent-soft); }

/* ============================================================ 按钮 */
.button {
  display: inline-flex; justify-content: center; align-items: center; gap: 9px;
  min-height: 46px; padding: 0 20px;
  border: 1px solid transparent; border-radius: var(--r-md);
  font-size: 14px; font-weight: 700; text-align: center; white-space: nowrap;
  transition: background .16s ease, border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.button:active:not(:disabled) { transform: translateY(1px); }
.button:disabled { box-shadow: none; }

.button-primary { color: #fff; background: var(--ink); box-shadow: var(--shadow-sm); }
.button-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--ink) 86%, var(--accent)); box-shadow: var(--shadow-md); }

.button-outline { background: var(--surface); border-color: var(--line-strong); color: var(--ink-2); }
.button-outline:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-dark); background: var(--accent-soft); }

.button-accent { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.button-accent:hover:not(:disabled) { background: var(--accent-dark); box-shadow: var(--shadow-md); }

.get-udid, .verify-button { height: 46px; min-width: 158px; }
.get-udid span { color: var(--accent); font-size: 18px; line-height: 0; }

.text-button {
  border: 0; background: none; padding: 6px 0;
  color: var(--accent-dark); font-size: 12.5px; font-weight: 650;
  border-radius: 4px;
  transition: color .15s ease;
}
.text-button:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.danger-text { color: var(--danger); }
.danger-text:hover { color: color-mix(in srgb, var(--danger) 78%, #000); }

/* ============================================================ 设备 / 状态 */
.status-region { margin-top: 18px; }

.card-info {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px;
  margin-top: 14px; padding: 12px 14px;
  border-left: 3px solid var(--accent);
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  color: var(--ink-2); font-size: 12.5px;
}
.card-info strong { color: var(--ink); font-size: 13.5px; }
.card-info-label { color: var(--ink-3); }
.bound-note { margin-left: auto; color: var(--warn); font-weight: 600; }

.empty-status {
  display: flex; align-items: center; gap: 10px;
  min-height: 48px; padding: 0 14px;
  border: 1px dashed var(--line-strong); border-radius: var(--r-md);
  color: var(--ink-3); font-size: 13px;
}
.state-light { display: inline-block; width: 8px; height: 8px; flex: 0 0 8px; border-radius: 50%; background: var(--ink-3); }

.status-card { padding: 14px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line); }
.status-card.is-ready { background: var(--accent-soft); border-color: var(--accent-line); }
.status-card.is-pending { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 28%, transparent); }
.status-card.is-ready .state-light { background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.status-card.is-pending .state-light { background: var(--warn); }
.status-card-top { display: flex; align-items: center; gap: 9px; min-width: 0; font-size: 13px; }
.status-card-top strong { flex: 0 0 auto; }
.status-detail { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-meta { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0 0 17px; color: var(--ink-2); font-size: 12px; }
.status-meta code { color: var(--ink); font-family: var(--mono); font-size: 11px; }

.device-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; }
.device-actions > span { color: var(--ink-3); font-size: 12px; }
.device-actions > div { display: flex; gap: 20px; }

/* ============================================================ 应用列表 */
.app-list { display: grid; gap: 10px; }
.app-row {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto 18px;
  align-items: center; gap: 14px; min-height: 66px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease;
}
.app-row:hover { border-color: var(--line-strong); background: var(--surface-2); }
.app-row.selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 3px var(--accent-soft); }
.app-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }

.app-mark {
  display: grid; place-items: center;
  width: 40px; aspect-ratio: 1; border-radius: var(--r-md);
  background: var(--accent-soft); color: var(--accent-dark);
  font-size: 16px; font-weight: 800;
}
.app-icon { display: block; width: 40px; aspect-ratio: 1; object-fit: cover; border-radius: var(--r-md); background: var(--surface-2); }
.app-main { display: grid; gap: 4px; min-width: 0; }
.app-main strong { overflow: hidden; color: var(--ink); font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.app-main small { overflow: hidden; color: var(--ink-3); font-size: 11.5px; text-overflow: ellipsis; white-space: nowrap; }
.app-size { color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }

.radio-indicator {
  width: 18px; height: 18px;
  border: 1.5px solid var(--line-strong); border-radius: 50%;
  position: relative; transition: border-color .16s ease;
}
.app-row.selected .radio-indicator { border-color: var(--accent); }
.app-row.selected .radio-indicator::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--accent); }

.app-footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 16px; color: var(--ink-3); font-size: 12px; }
.app-footer .button { min-width: 180px; }

.empty-list { padding: 26px 12px; text-align: center; color: var(--ink-3); font-size: 13px; }

/* ============================================================ 说明 / 提示 */
.guide-panel { margin: 18px 0; padding: 0 18px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.guide-panel summary {
  display: flex; justify-content: space-between; align-items: center;
  min-height: 52px; cursor: pointer;
  color: var(--ink); font-size: 13.5px; font-weight: 700; list-style: none;
}
.guide-panel summary::-webkit-details-marker { display: none; }
.summary-chevron {
  display: grid; place-items: center;
  width: 24px; aspect-ratio: 1; border-radius: var(--r-sm);
  background: var(--accent-soft); color: var(--accent-dark); font-size: 16px; font-weight: 700;
  transition: transform .2s ease;
}
.guide-panel[open] .summary-chevron { transform: rotate(45deg); }
.guide-content { max-width: 760px; padding: 0 0 14px; color: var(--ink-2); font-size: 13px; line-height: 1.75; }
.guide-content p { margin: 0 0 8px; }

.site-footer { display: flex; justify-content: space-between; gap: 16px; padding-top: 18px; color: var(--ink-3); font-size: 11px; }

.notice {
  position: relative; padding: 12px 40px 12px 14px; margin: 0 0 16px;
  border: 1px solid var(--accent-line); border-radius: var(--r-md);
  background: var(--accent-soft); color: var(--accent-dark);
  font-size: 13px; line-height: 1.55;
}
.notice.error { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); background: var(--danger-soft); }
.notice.info { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); background: var(--warn-soft); }
.notice button { position: absolute; top: 6px; right: 10px; border: 0; background: transparent; color: inherit; font-size: 18px; line-height: 1; opacity: .7; }
.notice button:hover { opacity: 1; }

.install-result {
  display: flex; justify-content: space-between; align-items: center; gap: 24px;
  padding: 20px 22px; margin-bottom: 18px;
  border: 1px solid var(--accent-line); border-radius: var(--r-lg);
  background: var(--accent-soft);
}
.install-result h2 { margin: 0 0 5px; font-size: 17px; font-weight: 750; }
.install-result p:not(.section-kicker) { margin: 0; color: var(--ink-2); font-size: 13px; }
.install-actions { display: flex; gap: 10px; }

/* ============================================================ 管理端 */
.admin-shell { max-width: 1040px; }
.admin-title { display: flex; justify-content: space-between; align-items: end; margin: 0 0 22px; }
.admin-form { display: grid; gap: 16px; }
.form-two, .form-three { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-actions { display: flex; align-items: center; gap: 14px; }
.form-actions span { color: var(--ink-3); font-size: 12px; }
.form-submit { display: flex; align-items: end; }

.key-output {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px 16px;
  padding: 15px; border: 1px solid color-mix(in srgb, var(--warn) 32%, transparent);
  border-radius: var(--r-md); background: var(--warn-soft);
}
.key-output > div { display: grid; gap: 5px; }
.key-output strong { color: var(--ink); font-size: 13px; }
.key-output small { color: var(--ink-2); font-size: 12px; }
.key-output textarea {
  grid-column: 1 / -1; min-height: 68px; resize: vertical; padding: 11px;
  border: 1px solid color-mix(in srgb, var(--warn) 26%, transparent); border-radius: var(--r-sm);
  color: var(--ink); background: var(--surface);
  font-family: var(--mono); font-size: 12.5px; line-height: 1.7;
}

.count-badge {
  display: inline-grid; place-items: center;
  min-width: 24px; height: 21px; margin-left: 6px; padding: 0 6px;
  border-radius: var(--r-full);
  background: var(--accent-soft); color: var(--accent-dark);
  font-size: 11px; font-weight: 700; vertical-align: 2px;
}

.table-wrap { overflow-x: auto; margin: 0 -6px; padding: 0 6px; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 12.5px; }
th {
  padding: 10px 12px; border-bottom: 1px solid var(--line);
  color: var(--ink-3); font-size: 11px; font-weight: 700;
  letter-spacing: .4px; white-space: nowrap;
}
td { padding: 13px 12px; border-bottom: 1px solid var(--line); color: var(--ink-2); vertical-align: middle; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td small { display: block; margin-top: 4px; color: var(--ink-3); font-size: 11px; }
td code { color: var(--ink); font-family: var(--mono); font-size: 11px; }

.table-status { display: inline-flex; align-items: center; gap: 7px; color: var(--accent-dark); font-weight: 600; }
.table-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.table-status.disabled { color: var(--ink-3); }
.table-status.disabled::before { background: var(--ink-3); }

.upload-zone {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 18px; border: 1px dashed var(--line-strong);
  border-radius: var(--r-md); background: var(--surface-2);
}
.upload-label { display: flex; align-items: center; gap: 14px; min-width: 0; cursor: pointer; }
.upload-label > span:nth-child(2) { display: grid; gap: 5px; }
.upload-label strong { font-size: 14px; }
.upload-label small { color: var(--ink-3); font-size: 12px; }
.upload-label input { display: block; max-width: 100%; margin-top: 8px; color: var(--ink-2); font-size: 12px; }
.upload-mark {
  display: grid; place-items: center;
  width: 42px; height: 42px; flex: 0 0 42px;
  border-radius: var(--r-md); background: var(--accent-soft); color: var(--accent-dark);
  font-size: 24px; font-weight: 700;
}

.admin-app-list { display: grid; }
.admin-app-row { display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 10px 4px; border-bottom: 1px solid var(--line); border-radius: var(--r-sm); transition: background .15s ease; }
.admin-app-row:last-child { border-bottom: 0; }
.admin-app-row:hover { background: var(--surface-2); }
.admin-app-row .text-button { margin-left: auto; }

.admin-auth-shell {
  display: grid; grid-template-columns: minmax(220px, 1fr) minmax(300px, 420px) minmax(220px, 1fr);
  align-items: start; gap: 30px; max-width: 1120px; margin: 0 auto; padding: 40px 26px;
}
.admin-auth-shell > .brand { grid-column: 1; }
.admin-auth { grid-column: 2; width: 100%; padding: 28px; margin: 20px 0 0; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-lg); }
.admin-auth h1 { margin-bottom: 8px; font-size: 22px; font-weight: 800; }
.admin-auth .muted { margin-bottom: 20px; color: var(--ink-2); font-size: 13px; }
.admin-auth .button { width: 100%; margin-top: 18px; }
.back-link { display: inline-block; margin-top: 14px; color: var(--ink-3); font-size: 12px; }
.back-link:hover { color: var(--accent-dark); }
.form-message { min-height: 18px; margin-top: 8px; color: var(--danger); font-size: 12px; }

/* 卡密明文：等宽、点击即复制 */
.card-key {
  display: inline-block; padding: 4px 8px;
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  letter-spacing: .06em; white-space: nowrap;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.card-key:hover { background: var(--accent); color: #fff; }
.card-key:active { transform: scale(.97); }

/* ============================================================ 响应式 */
@media (max-width: 700px) {
  body { font-size: 14px; }
  .topbar { height: auto; min-height: 60px; grid-template-columns: 1fr auto; gap: 0 12px; padding: 0 16px; }
  .brand { gap: 9px; }
  .brand-mark { width: 34px; border-radius: var(--r-sm); }
  .brand strong { font-size: 14px; }
  .brand small { font-size: 8px; }
  .topnav { grid-column: 1 / -1; grid-row: 2; justify-content: center; height: 44px; border-top: 1px solid var(--line); }
  .nav-tab { flex: 1; max-width: 180px; font-size: 13px; height: 34px; }
  .admin-link { grid-column: 2; grid-row: 1; }

  .page-shell, .admin-shell { padding: 22px 15px 30px; }
  .intro-row { align-items: start; flex-direction: column; gap: 16px; margin-bottom: 18px; }
  .intro-row h1, .admin-title h1 { font-size: 24px; }
  .intro-copy { font-size: 13px; }
  .flow-steps { padding-left: 2px; font-size: 11px; }

  .device-panel, .apps-panel, .admin-panel { padding: 18px 16px; }
  .panel { border-radius: var(--r-md); }
  .panel-heading h2 { font-size: 16px; }

  .device-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .get-udid, .verify-button { width: 100%; }
  .card-field { grid-column: auto; }
  .get-udid { grid-row: 2; }
  .card-field { grid-row: 3; }
  .verify-button { grid-row: 4; }

  .app-row { grid-template-columns: 40px minmax(0, 1fr) 18px; grid-template-rows: 1fr auto; gap: 4px 12px; padding: 12px; }
  .app-main { grid-column: 2; grid-row: 1; min-height: 38px; justify-content: center; }
  .app-mark { grid-column: 1; grid-row: 1 / span 2; }
  .app-size { grid-column: 2; grid-row: 2; }
  .radio-indicator { grid-column: 3; grid-row: 1 / span 2; }

  .app-footer { align-items: stretch; flex-direction: column; gap: 12px; }
  .app-footer .button { width: 100%; }
  .install-result { align-items: stretch; flex-direction: column; gap: 16px; padding: 18px; }
  .install-actions { display: grid; grid-template-columns: 1fr; }
  .site-footer { flex-direction: column; gap: 6px; }

  .form-two, .form-three { grid-template-columns: 1fr; }
  .form-actions { align-items: start; flex-direction: column; gap: 10px; }
  .key-output { grid-template-columns: 1fr; }
  .upload-zone { align-items: stretch; flex-direction: column; }
  .upload-zone > .button { width: 100%; }
  .admin-title { align-items: start; flex-direction: column; gap: 8px; }
  .admin-auth-shell { display: flex; flex-direction: column; gap: 24px; padding: 28px 16px; }
  .admin-auth { margin: 0; padding: 22px 18px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  table { min-width: 640px; }
  .device-actions { align-items: start; flex-direction: column; gap: 6px; }
  .device-actions > div { gap: 20px; }
  .bound-note { margin-left: 0; }
  .status-card-top { flex-wrap: wrap; }
  .status-detail { white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* ============================================================ 使用教程卡片 */
.tutorial-card {
  margin: 18px 0;
  border: 1px solid var(--accent-line);
  border-radius: var(--r-lg);
  background: var(--accent-soft);
  overflow: hidden;
}
.tutorial-summary {
  display: flex; justify-content: space-between; align-items: center;
  min-height: 52px; padding: 0 18px; cursor: pointer; list-style: none;
}
.tutorial-summary::-webkit-details-marker { display: none; }
.tutorial-title { display: inline-flex; align-items: center; gap: 9px; color: var(--accent-dark); font-size: 14px; font-weight: 700; }
.tutorial-chevron {
  display: grid; place-items: center; width: 26px; aspect-ratio: 1;
  border-radius: var(--r-sm); background: var(--surface); color: var(--accent-dark);
  transition: transform .2s ease;
}
.tutorial-card[open] .tutorial-chevron { transform: rotate(180deg); }
.tutorial-body { padding: 0 18px 18px; }
.tutorial-subtitle { margin: 4px 0 10px; font-size: 14px; font-weight: 750; color: var(--ink); }
.tutorial-steps { margin: 0 0 16px; padding: 0; list-style: none; display: grid; gap: 9px; counter-reset: step; }
.tutorial-steps li { position: relative; padding-left: 28px; color: var(--ink-2); font-size: 13px; line-height: 1.6; counter-increment: step; }
.tutorial-steps li::before {
  content: counter(step);
  position: absolute; left: 0; top: 2px;
  display: grid; place-items: center; width: 19px; height: 19px;
  border-radius: 50%; background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700;
}
.tutorial-links { display: flex; flex-wrap: wrap; gap: 10px; }
.tutorial-btn {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 34px; padding: 0 14px;
  border: 1px solid var(--accent-line); border-radius: var(--r-full);
  background: var(--surface); color: var(--accent-dark);
  font-size: 12.5px; font-weight: 650;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.tutorial-btn:hover { border-color: var(--accent); }
.tutorial-btn.is-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.tutorial-btn.is-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.tutorial-note { margin: 14px 0 0; color: var(--ink-3); font-size: 12px; }

/* ============================================================ 弹窗 */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 20px;
  background: rgb(10 20 17 / 45%);
  animation: modal-in .18s ease;
}
@keyframes modal-in { from { opacity: 0; } to { opacity: 1; } }
.modal-dialog {
  width: min(520px, 100%); max-height: 86vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 17px; font-weight: 750; }
.modal-close {
  border: 0; background: var(--surface-2); width: 32px; height: 32px;
  border-radius: var(--r-sm); color: var(--ink-2); font-size: 19px; line-height: 1;
  transition: background .15s ease, color .15s ease;
}
.modal-close:hover { background: var(--danger-soft); color: var(--danger); }
.modal-body { padding: 18px 20px 22px; }
.modal-lead { margin: 0 0 14px; color: var(--ink-2); font-size: 13.5px; line-height: 1.65; }
.modal-hint { margin: 14px 0 0; color: var(--ink-3); font-size: 12px; word-break: break-all; }
.modal-steps { margin: 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.modal-steps li { display: flex; gap: 12px; align-items: start; }
.modal-step-index {
  display: grid; place-items: center; flex: 0 0 26px; width: 26px; height: 26px;
  border-radius: 50%; background: var(--accent-soft); color: var(--accent-dark);
  font-size: 12px; font-weight: 750;
}
.modal-steps strong { display: block; font-size: 13.5px; color: var(--ink); }
.modal-steps small { display: block; margin-top: 3px; color: var(--ink-2); font-size: 12.5px; line-height: 1.6; }

@media (max-width: 700px) {
  .tutorial-body { padding: 0 15px 16px; }
  .tutorial-links { gap: 8px; }
  .modal-backdrop { padding: 14px; }
  .modal-dialog { max-height: 88vh; }
  .modal-head, .modal-body { padding-left: 16px; padding-right: 16px; }
}

/* ============================================================ 证书下载 */
.cert-download {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--accent-line);
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
}
.cert-download-btn { min-height: 38px; }
.cert-download-hint {
  margin: 0;
  font-size: 11.5px; line-height: 1.6; color: var(--ink-3);
}
@media (prefers-color-scheme: dark) {
  .cert-download { border-top-color: var(--accent-line); }
}
