/* ==========================================================================
   DCAI 设备中心 —— 清新浅色主题
   设计基调：米白底 + 森林绿 + 细线框 + 充足留白
   ========================================================================== */

:root {
  --bg: #f7f8f6;
  --surface: #ffffff;
  --surface-alt: #fbfcfb;
  --line: #e6e9e5;
  --line-strong: #d6dbd5;

  --ink: #1f2420;
  --ink-2: #4a534d;
  --ink-3: #79847d;

  --green: #2d6a4f;
  --green-dark: #235640;
  --green-soft: #eef4f0;

  --amber: #b45309;
  --amber-soft: #fdf5e9;
  --red: #b32c2c;
  --red-soft: #fdf0ef;

  --radius: 6px;
  --radius-sm: 4px;
  --shadow: 0 1px 2px rgba(31, 36, 32, .05);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--green); text-decoration: none; }
a:hover { color: var(--green-dark); text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.4; }
p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }

code, .mono, .nowrap {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas,
               "Liberation Mono", monospace;
}
.mono { font-size: 12.5px; color: var(--ink-2); }
.nowrap { white-space: nowrap; }

.muted { color: var(--ink-3); font-size: 13px; }
.subtext { color: var(--ink-3); font-size: 12.5px; margin-top: 4px; }

/* ---------------------------------------------------------------- 顶栏 */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 24px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.wordmark {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: .2px;
  white-space: nowrap;
}
.wordmark:hover { text-decoration: none; color: var(--ink); }
.wordmark span { color: var(--ink-3); font-weight: 400; }

.topbar nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}
.topbar nav a {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--ink-2);
  transition: background .12s, color .12s;
}
.topbar nav a:hover {
  background: var(--green-soft);
  color: var(--green-dark);
  text-decoration: none;
}

.account {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-3);
}
.account form { margin: 0; }
.account button,
.topbar button {
  padding: 5px 12px;
  font-size: 12.5px;
  background: transparent;
  color: var(--ink-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color .12s, color .12s;
}
.account button:hover,
.topbar button:hover {
  border-color: var(--green);
  color: var(--green);
}

/* ---------------------------------------------------------------- 布局 */
main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

.page-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.page-heading h1 {
  font-size: 20px;
  letter-spacing: -.2px;
}

.section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 18px;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.section-heading h2 {
  font-size: 15px;
  color: var(--ink);
}
.section-heading .muted { font-size: 12.5px; }

/* ---------------------------------------------------------------- 统计条 */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 18px;
}
.stats > * {
  background: var(--surface);
  padding: 16px 18px;
}
.stats .stat-value {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -.3px;
  line-height: 1.2;
}
.stats .stat-label {
  font-size: 12.5px;
  color: var(--ink-3);
  margin-top: 2px;
}

/* ---------------------------------------------------------------- 表格 */
.table-scroll {
  overflow-x: auto;
  margin: 0 -24px;
  padding: 0 24px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
thead th {
  text-align: left;
  font-weight: 500;
  font-size: 12.5px;
  color: var(--ink-3);
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-alt);
  white-space: nowrap;
}
tbody td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfa; }

.empty-cell, .empty {
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
  padding: 28px 12px;
}

/* ---------------------------------------------------------------- 徽章 */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.6;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge.authorized,
.badge.ok {
  background: var(--green-soft);
  color: var(--green-dark);
  border-color: #d8e8de;
}
.badge.revoked,
.badge.danger {
  background: var(--red-soft);
  color: var(--red);
  border-color: #f2d9d7;
}
.badge.amber,
.badge.warning {
  background: var(--amber-soft);
  color: var(--amber);
  border-color: #f4e3c8;
}
.badge.normal {
  background: #f2f4f2;
  color: var(--ink-2);
  border-color: var(--line);
}
.badge.svip {
  background: #f4f0fb;
  color: #5b3fa8;
  border-color: #e4dcf5;
}
.badge.vip {
  background: #fdf3e8;
  color: #96540d;
  border-color: #f5e2c8;
}

/* ---------------------------------------------------------------- 表单 */
input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),
select, textarea {
  width: 100%;
  padding: 9px 11px;
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(45, 106, 79, .08);
}
input::placeholder { color: #a8b0aa; }

label {
  display: block;
  font-size: 13px;
  color: var(--ink-2);
  margin-bottom: 6px;
}

button, .button {
  font-family: inherit;
  font-size: 13.5px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
button:hover { border-color: var(--green); color: var(--green); }
button:disabled {
  opacity: .55;
  cursor: not-allowed;
  border-color: var(--line);
  color: var(--ink-3);
}
button:disabled:hover { border-color: var(--line); color: var(--ink-3); }

button.primary, .button.primary {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  font-weight: 500;
}
button.primary:hover {
  background: var(--green-dark);
  border-color: var(--green-dark);
  color: #fff;
}

button.danger {
  background: var(--surface);
  border-color: #eccdca;
  color: var(--red);
}
button.danger:hover {
  background: var(--red-soft);
  border-color: #e0b6b2;
  color: var(--red);
}

.inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0;
}
.inline-form input, .inline-form select {
  width: auto;
  min-width: 130px;
}

.actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

/* ---------------------------------------------------------------- 提示 */
.muted-box, .settings, .qr-panel {
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
}

.error {
  background: var(--red-soft);
  border: 1px solid #f0dbd9;
  color: var(--red);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 13px;
  margin-bottom: 16px;
}

.warning {
  background: var(--amber-soft);
  border: 1px solid #f3e2c6;
  color: var(--amber);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 13px;
}

.account-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.browser-frame {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  padding: 6px;
  /* 宽高比锁定为截图的 1024:720：
     容器高度随宽度自动换算，画面正好铺满、无留白、无滚动条，
     也不会因图片加载而伸缩（之前 max-height+overflow 导致的抖动）。 */
  width: 100%;
  max-width: 760px;
  aspect-ratio: 1024 / 720;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* 图片等比铺满，尺寸变化不影响布局 */
.browser-frame img,
#qr-screen {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.qr-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* ---------------------------------------------------------------- 分页 */
.pager {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
  font-size: 13px;
}
.pager a {
  padding: 6px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-size: 13px;
}
.pager a:hover {
  border-color: var(--green);
  color: var(--green);
  text-decoration: none;
  background: var(--green-soft);
}
.pager .muted { color: var(--ink-3); }

/* ---------------------------------------------------------------- 登录页 */
.login, .full {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}
.full.login > form,
.login > form,
.login .card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px 30px;
  box-shadow: var(--shadow);
}
.login h1 {
  font-size: 19px;
  margin-bottom: 6px;
}
.login .subtext { margin-bottom: 22px; }
.login button[type="submit"] {
  width: 100%;
  margin-top: 6px;
  padding: 11px;
}

/* ---------------------------------------------------------------- 设备卡片 */
.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.device {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.device-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.device-heading h3 { font-size: 14.5px; }

/* ---------------------------------------------------------------- 页脚 */
footer {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px 32px;
  font-size: 12px;
  color: #a0a8a2;
  text-align: center;
}
footer span { margin: 0 6px; }

/* ---------------------------------------------------------------- 反馈 */
#feedback {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 100;
  max-width: 90vw;
}

/* ---------------------------------------------------------------- 响应式 */
@media (max-width: 720px) {
  .topbar {
    height: auto;
    padding: 10px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .topbar nav { order: 3; width: 100%; overflow-x: auto; }
  main { padding: 20px 16px 48px; }
  .section { padding: 18px 16px; }
  .table-scroll { margin: 0 -16px; padding: 0 16px; }
  .page-heading h1 { font-size: 18px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

/* ===== 授权页增量样式 ===== */
.redeem-row .name-input {
  flex: 1 1 200px;
  min-width: 160px;
}

/* 危险操作按钮（删除） */
button.danger {
  color: #b4241c;
  border-color: #f0c9c5;
  background: #fff;
}
button.danger:hover {
  background: #fdf1f0;
  border-color: #e6a49e;
}
button.danger:disabled {
  opacity: .55;
  cursor: not-allowed;
}

/* 设备操作按钮组 */
td .btn-del {
  padding: 4px 12px;
  font-size: 13px;
}

/* ============ 扫码登录：方式切换标签 ============ */
.qr-tabs {
  display: flex;
  gap: 8px;
  margin: 4px 0 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.qr-tab {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
}

.qr-tab:hover {
  border-color: var(--accent);
  color: var(--text);
}

.qr-tab.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 500;
}

.qr-method { margin-top: 4px; }

/* ============ 方式 2：应用扫码 ============ */
.qr-app-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 220px;
  margin: 8px 0 14px;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.qr-app-box img {
  display: block;
  width: 180px;
  height: 180px;
  image-rendering: pixelated;
  border-radius: 6px;
  background: #fff;
  padding: 8px;
  box-sizing: content-box;
}

/* hidden 属性必须能覆盖 display:block，否则占位但无图 */
.qr-app-box img[hidden],
.qr-app-box img:not([src]) {
  display: none !important;
}

.qr-app-hint {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  line-height: 1.7;
  max-width: 420px;
}

.qr-app-hint.is-scanned { color: var(--accent); font-weight: 500; }
.qr-app-hint.is-success { color: #2f7d32; font-weight: 500; }
.qr-app-hint.is-error   { color: #c0392b; }