/* === 全局 === */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.6;
  min-height: 100vh; padding: 16px;
}
a { color: #3eaf7c; text-decoration: none; }
a:hover { text-decoration: underline; }
* { -webkit-tap-highlight-color: rgba(62,175,124,.12); }

/* === 变量（默认亮色） === */
:root {
  --primary: #3eaf7c;
  --primary-dark: #34a06c;
  --danger: #e53e3e;
  --warn: #d69e2e;
  --border: #e2e8f0;
  --border-light: #cbd5e0;
  --text: #1a1a2e;
  --text-muted: #718096;
  --card: #ffffff;
  --bg: #f6f8fb;
  --hover: rgba(62,175,124,.06);
  --shadow: 0 1px 3px rgba(0,0,0,.04);
  --code-bg: #edf2f7;
  --input-bg: #ffffff;
  --icon-hover: rgba(0,0,0,.05);
  --badge-bg: #edf2f7;
}

/* === 暗色模式（跟随系统） === */
@media (prefers-color-scheme: dark) {
  :root {
    --primary: #3eaf7c;
    --primary-dark: #34a06c;
    --danger: #f87171;
    --warn: #fbbf24;
    --border: #21262d;
    --border-light: #30363d;
    --text: #c9d1d9;
    --text-muted: #7d8590;
    --card: #161b22;
    --bg: #0d1117;
    --hover: rgba(62,175,124,.08);
    --shadow: none;
    --code-bg: #21262d;
    --input-bg: #0d1117;
    --icon-hover: rgba(255,255,255,.05);
    --badge-bg: #21262d;
  }
}

/* === 按钮 === */
button, .btn {
  padding: 8px 16px; border: 1px solid var(--border-light); border-radius: 8px;
  background: var(--card); color: var(--text); cursor: pointer; font-size: 14px;
  transition: all .15s; white-space: nowrap;
}
button:hover:not(:disabled):not(.year-chip) { border-color: var(--primary); background: var(--hover); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary {
  background: var(--primary); border-color: var(--primary); color: #fff;
}
button.primary:hover:not(:disabled) { background: var(--primary-dark); }
button.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
button.danger:hover:not(:disabled) { background: rgba(229,62,62,.08); }

/* === 输入 === */
input, select, textarea {
  width: 100%; padding: 10px 12px; background: var(--input-bg);
  border: 1px solid var(--border-light); border-radius: 8px;
  color: var(--text); font-size: 14px; margin-bottom: 12px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(62,175,124,.12);
}
label { display: block; margin-bottom: 4px; color: var(--text-muted); font-size: 13px; }

/* === 输入框图标（Apple 风格清空 × + 密码小眼睛） === */
.input-wrap { position: relative; margin-bottom: 12px; }
.input-wrap input { margin-bottom: 0; padding-right: 36px; }
.input-wrap.has-eye input { padding-right: 36px; }
.input-icon {
  position: absolute; top: 50%; transform: translateY(-50%);
  border: none; background: transparent; padding: 0;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-muted);
  transition: opacity .15s, color .15s;
  width: 28px; height: 28px; border-radius: 50%;
}
.input-icon.eye { right: 6px; }
.input-icon.clear { right: 6px; opacity: 0; pointer-events: none; }
.input-icon:hover { color: var(--text); background: var(--icon-hover); }

/* === 布局 === */
body { min-height: 100vh; }
.container { max-width: 960px; margin: 0 auto; padding: 0 24px; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 24px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 18px; margin-bottom: 16px; color: var(--text); }

/* === Modal === */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 16px; backdrop-filter: blur(2px);
}
.modal-content {
  background: var(--card); border: 1px solid var(--border-light);
  border-radius: 14px; padding: 24px; width: 100%; max-width: 440px;
  max-height: calc(100vh - 32px); overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0,0,0,.25);
  animation: modalIn .15s ease-out;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.modal-content h3 { margin: 0 0 8px; font-size: 18px; color: var(--text); }
.modal-content label { display: block; margin-bottom: 6px; color: var(--text); font-size: 13px; font-weight: 500; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.modal-actions.center { justify-content: center; }
.modal-actions.center button { min-width: 96px; justify-content: center; }

/* === 自定义下拉（续费年限 / 产品选择等） === */
.product-dropdown { position: relative; margin: 4px 0 12px; }
.product-trigger {
  width: 100%; justify-content: space-between; padding: 11px 12px;
  border: 1px solid var(--border-light); border-radius: 8px; background: var(--bg);
  color: var(--text); font-size: 14px; font-weight: 500; cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  display: flex; align-items: center;
}
.product-trigger:hover { border-color: var(--primary); }
.product-trigger .chevron { color: var(--text-muted); transition: transform .2s; flex-shrink: 0; margin-left: 8px; }
.product-trigger .chevron.up { transform: rotate(180deg); }
.product-menu {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 50;
  background: var(--card); border: 1px solid var(--border-light); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.35); overflow: hidden; padding: 4px;
  max-height: 240px; overflow-y: auto;
}
.product-menu a {
  display: block; padding: 10px 12px; border-radius: 6px;
  color: var(--text); font-size: 14px; font-weight: 500;
  transition: background .12s; text-decoration: none;
}
.product-menu a:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.product-menu a.on { background: rgba(62,175,124,.12); color: var(--primary); }
.dropdown-mask { position: fixed; inset: 0; z-index: 40; }

/* 订单：默认表格（PC），移动端显示为卡片列表 */
.order-table { display: table; }
.order-list { display: none; }
.order-card {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 14px; margin-bottom: 10px; background: var(--bg);
}
.order-card .row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; gap: 8px; }
.order-card .row .k { color: var(--text-muted); flex-shrink: 0; }
.order-card .row .v { color: var(--text); text-align: right; min-width: 0; word-break: break-all; }
.order-card .actions { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.order-card .actions button { width: 100%; }

/* 年限 chip 组（segmented control）—— PC端样式 */
.year-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.year-chip {
  flex: 1; min-width: 60px; padding: 10px 12px;
  border: 2px solid var(--border-light); border-radius: 8px;
  background: transparent; color: var(--text-muted);
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: border-color .12s, color .12s, background .12s;
  user-select: none;
}
.year-chip:hover { border-color: var(--primary); color: var(--text); }
.year-chip.on,
.year-chip.on:hover {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #ffffff !important;
  font-weight: 700;
}
@media (hover: hover) and (pointer: fine) {
  /* 仅 PC / 鼠标设备：hover 态描边提示，不影响 .on */
  .year-chip:hover:not(.on) { border-color: var(--primary); color: var(--text); }
}

/* === 窄屏（手机）适配 === */
@media (max-width: 600px) {
  body { padding: 0; font-size: 14px; }
  .container { padding: 0 12px; }
  .card { padding: 16px; border-radius: 10px; }
  .card h2 { font-size: 16px; margin-bottom: 12px; }
  input, select, textarea { padding: 11px 12px; font-size: 16px; }  /* 16px 防止 iOS 自动放大 */
  button, .btn { padding: 10px 14px; font-size: 14px; }
  .topbar { padding: 8px 0 16px; }
  .topbar .brand { font-size: 15px; }
  .topbar nav a { margin-left: 12px; font-size: 13px; }
  /* 手机：设备项 - 水平布局，按钮保留文字 */
  .device-item { flex-direction: row; align-items: center; padding: 12px; gap: 10px; }
  .device-item .actions { flex-direction: row; min-width: auto; margin-left: 0; gap: 6px; }
  .device-item .actions button { flex: 1; min-width: 0; padding: 8px 10px; font-size: 13px; }
  /* 移动端：表格变卡片 */
  .order-table { display: none !important; }
  .order-list { display: block !important; }
  /* 弹窗 */
  .modal-content { padding: 20px; border-radius: 14px; }
  /* 弹窗样式与 PC 保持一致：按钮自适应宽度、统一居中，不因移动端而堆叠全宽 */
  .modal-actions, .modal-actions.center { gap: 8px; flex-direction: row; justify-content: center; }
  .modal-actions button, .modal-actions.center button { width: auto; min-width: 100px; }
  /* 移动端 chip：按下立即显示 .on 颜色，不依赖 hover；点击后保持选中 */
  .year-chips { flex-wrap: nowrap; }
  .year-chip {
    min-width: 0; padding: 10px 6px; font-size: 13px;
    -webkit-tap-highlight-color: transparent;
  }
  .year-chip:active { background: var(--primary); border-color: var(--primary); color: #fff; }
}

/* === 顶栏 === */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0 24px;
}
.topbar .brand { font-weight: 600; font-size: 16px; color: var(--text); }
.topbar .brand em { color: var(--primary); font-style: normal; font-weight: 400; margin-left: 6px; }
.topbar nav a { margin-left: 16px; font-size: 14px; }

/* === 提示 === */
.alert {
  padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-size: 13px;
  max-width: 480px; margin-left: auto; margin-right: auto;
}
.alert.error { background: rgba(229,62,62,.06); border: 1px solid rgba(229,62,62,.2); color: var(--danger); }
.alert.success { background: rgba(62,175,124,.06); border: 1px solid rgba(62,175,124,.2); color: var(--primary); }
.alert.info { background: rgba(66,153,225,.06); border: 1px solid rgba(66,153,225,.2); color: #3182ce; }
.alert.warn { background: rgba(214,158,46,.06); border: 1px solid rgba(214,158,46,.2); color: var(--warn); }

/* === 设备列表 === */
.device-item {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 16px 18px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px;
  background: var(--bg);
  transition: border-color .15s;
}
.device-item:hover { border-color: var(--border-light); }
.device-item .info { flex: 1; min-width: 0; }
.device-item .name { font-weight: 600; color: var(--text); font-size: 15px; }
.device-item .mac { font-family: "SF Mono", monospace; color: var(--text-muted); font-size: 12px; margin-top: 4px; }
.device-item .time { color: var(--text-muted); font-size: 12px; margin-top: 6px; line-height: 1.5; }
.device-item .actions {
  display: flex; flex-direction: column; gap: 6px;
  min-width: 96px; margin-left: 12px;
}
.device-item .actions button { width: 100%; justify-content: center; padding: 8px 12px; }
.device-item .actions .local-control { color: var(--primary); border-color: var(--primary); }
.local-control-help { color: var(--text-muted); font-size: 12px; margin-top: 6px; line-height: 1.5; }
.local-control-help details { display: inline; margin-left: 4px; }
.local-control-help summary { display: inline; color: var(--primary); cursor: pointer; }
.local-control-help details[open] { display: block; margin: 4px 0 0; }
.local-control-help details[open] summary { margin-right: 4px; }

/* === 滑块人机校验 === */
.captcha-box { margin: 8px 0 12px; }
.captcha-canvas { position: relative; margin-bottom: 8px; border-radius: 6px; overflow: hidden; }
.captcha-canvas img { display: block; }
.captcha-track {
  position: relative; height: 40px; background: var(--badge-bg);
  border-radius: 20px; overflow: hidden; user-select: none; cursor: pointer;
}
.captcha-track-text {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--text-muted); pointer-events: none;
}
.captcha-handle {
  position: absolute; top: 0; left: 0; height: 40px;
  background: var(--primary); color: #fff; border-radius: 20px;
  display: flex; align-items: center; justify-content: center; cursor: grab;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.captcha-handle:active { cursor: grabbing; }
.captcha-ok {
  padding: 8px 12px; border-radius: 6px; background: rgba(62,175,124,.12);
  color: var(--primary); font-size: 13px; text-align: center;
}

/* === 徽章 === */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px;
  background: var(--badge-bg); color: var(--text-muted);
}
.badge.free { background: var(--badge-bg); color: var(--text-muted); }
.badge.annual { background: rgba(62,175,124,.1); color: var(--primary); }
.badge.verified { background: rgba(62,175,124,.1); color: var(--primary); }
.badge.unverified { background: rgba(229,62,62,.1); color: var(--danger); }

/* === 杂项 === */
.hint { color: var(--text-muted); font-size: 12px; margin-top: 8px; }
code {
  font-family: "SF Mono", monospace; font-size: 12px;
  background: var(--code-bg); padding: 1px 6px; border-radius: 4px; color: var(--text);
}
table { border-collapse: collapse; width: 100%; }
th, td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--text-muted); font-weight: 500; font-size: 12px; }
/* 窄屏表格滚动 */
.card { overflow-x: auto; }
.card > table { min-width: 600px; }

/* === 密码强度 === */
.pwd-strength { margin-bottom: 12px; }
.pwd-bar {
  height: 3px; border-radius: 2px; transition: width .2s, background .2s;
  background: var(--border);
}
.pwd-bar.weak { background: var(--danger); }
.pwd-bar.medium { background: var(--warn); }
.pwd-bar.strong { background: var(--primary); }
.pwd-label { font-size: 11px; margin-top: 4px; display: inline-block; }
.pwd-label.weak { color: var(--danger); }
.pwd-label.medium { color: var(--warn); }
.pwd-label.strong { color: var(--primary); }

/* === 表单 === */
form button[type="submit"] { width: 100%; }

/* === Tab 切换 === */
.tab-row { display: flex; gap: 0; margin-bottom: 18px; background: var(--bg-muted, #f5f5f5); border-radius: 10px; padding: 3px; }
.tab-btn {
  flex: 1; padding: 9px 12px; border: none; background: none; cursor: pointer;
  font-size: 14px; color: var(--text-muted); border-radius: 8px;
  transition: all .2s; font-weight: 500;
}
.tab-btn.active { color: var(--primary); background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,.12); font-weight: 600; }
.tab-btn:hover:not(.active) { color: var(--text); }
@media (prefers-color-scheme: dark) {
  .tab-row { background: #21262d; }
  .tab-btn.active { background: #0d1117; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
}
