/* ============================================================
   丝路购授权后台 · 样式
   与扩展面板同一套设计语言：浅灰画布 + 白卡片 + 品牌蓝 #0060f0
   ============================================================ */
:root {
  --canvas: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #f9fbfd;
  --line: #e3e8f0;
  --line-strong: #cbd5e1;
  --brand: #0060f0;
  --brand-2: #4d94ff;
  --brand-soft: #eaf2ff;
  --text: #101a26;
  --text-2: #33415c;
  --muted: #6b7a90;
  --ok: #0b8457;
  --ok-soft: #e8f7ef;
  --err: #c8364a;
  --err-soft: #fdeef1;
  --warn: #a86a12;
  --warn-soft: #fdf5e6;
  --shadow-sm: 0 1px 2px rgba(16, 26, 38, 0.05);
  --shadow: 0 16px 48px rgba(16, 26, 38, 0.18);
  --r: 10px;
}

* { box-sizing: border-box; }

/* 关键：`.modal` / `.login-wrap` 用了 display:flex，会覆盖浏览器对 [hidden] 的
   display:none，导致弹窗和登录页永远可见。这里统一让 hidden 优先。 */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--canvas);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

code {
  font-family: Consolas, Monaco, monospace;
  background: #f3f6fb;
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 12px;
}

.muted { color: var(--muted); font-size: 12.5px; }
.spacer { flex: 1; }
.right { text-align: right; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 26px;
}

.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 22px; }

.login-logo, .logo {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #082454, #0060f0 55%, #37d0ff);
  color: #fff;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex: 0 0 auto;
}

.login-title { font-size: 16px; font-weight: 700; }
.login-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field span { font-size: 12.5px; font-weight: 600; color: var(--text-2); }

.input, .field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  padding: 9px 11px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}

.input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.login-error {
  background: var(--err-soft);
  border: 1px solid #f0c7cd;
  color: var(--err);
  border-radius: var(--r);
  padding: 9px 11px;
  font-size: 12.5px;
  margin-bottom: 12px;
}

/* ---------- 按钮 ---------- */
.btn {
  border-radius: var(--r);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 14px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color .15s, border-color .15s, box-shadow .15s, transform .06s;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(180deg, var(--brand-2), var(--brand));
  border-color: #0052cc;
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 96, 240, .28);
}
.btn-primary:hover { background: linear-gradient(180deg, #62a2ff, #0057e0); }
.btn-primary:active { transform: translateY(1px); }

.btn-ghost { background: #fff; border-color: var(--line); color: var(--text-2); box-shadow: var(--shadow-sm); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--line-strong); color: var(--text); }

.btn-danger { background: #fff; border-color: #f0c7cd; color: var(--err); }
.btn-danger:hover { background: var(--err-soft); border-color: #e6a8b3; }

.btn-sm { padding: 5px 9px; font-size: 12px; }
.btn-block { width: 100%; }

.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.icon-btn {
  border: none; background: transparent; font-size: 20px; line-height: 1;
  color: var(--muted); cursor: pointer; padding: 2px 6px; border-radius: 8px;
}
.icon-btn:hover { background: #eef2f7; color: var(--text); }

/* ---------- 顶栏 ---------- */
.topbar {
  height: 58px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 18px;
  padding: 0 18px;
  position: sticky; top: 0; z-index: 20;
}

.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-title { font-weight: 700; font-size: 14px; }

.tabs { display: flex; gap: 4px; margin-left: 8px; }

.tab {
  border: none; background: transparent; color: var(--muted);
  font-size: 13px; font-weight: 600; padding: 8px 12px;
  border-radius: var(--r); cursor: pointer;
}
.tab:hover { background: var(--surface-2); color: var(--text-2); }
.tab.is-active { background: var(--brand-soft); color: #0a54c4; }

.topbar-right { margin-left: auto; display: flex; gap: 8px; }

/* ---------- 主体 ---------- */
.main { padding: 18px; max-width: 1320px; margin: 0 auto; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
  overflow: hidden;
}

.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fff, #fafcfe);
}
.card-head h2 { margin: 0; font-size: 14px; font-weight: 700; }
.card-head .muted { margin-left: auto; }

/* ---------- 统计卡 ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-size: 26px; font-weight: 800; margin-top: 4px; letter-spacing: .3px; }
.stat-value.ok { color: var(--ok); }
.stat-value.warn { color: var(--warn); }
.stat-value.err { color: var(--err); }

/* ---------- 工具栏 ---------- */
.toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.toolbar .input { max-width: 280px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }

.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }

.table thead th {
  text-align: left;
  font-size: 12px; font-weight: 700; color: var(--text-2);
  background: linear-gradient(180deg, #fbfcfe, #f4f7fb);
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  white-space: nowrap;
}

.table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid #eef2f7;
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f8fbff; }

.code-cell { font-family: Consolas, Monaco, monospace; font-weight: 600; letter-spacing: .3px; }

/* ---------- 状态徽标 ---------- */
.badge {
  display: inline-block;
  font-size: 11.5px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-active { background: var(--ok-soft); color: var(--ok); border-color: #b7e6c8; }
.badge-expiring { background: var(--warn-soft); color: var(--warn); border-color: #f0d9a8; }
.badge-expired { background: #f3f5f8; color: var(--muted); border-color: var(--line); }
.badge-disabled { background: var(--err-soft); color: var(--err); border-color: #f0c7cd; }

/* ---------- 分页 ---------- */
.pager { display: flex; align-items: center; gap: 8px; padding: 12px 16px; }
.pager button {
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 6px 11px; font-size: 12.5px; cursor: pointer; color: var(--text-2);
}
.pager button:disabled { opacity: .45; cursor: not-allowed; }
.pager .page-info { font-size: 12.5px; color: var(--muted); margin-left: auto; }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(11, 20, 33, .45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  width: 100%; max-width: 520px;
  max-height: 88vh;
  display: flex; flex-direction: column;
  opacity: 1;
  animation: pop .14s cubic-bezier(.2,.9,.3,1) both;
}

@keyframes pop {
  from { opacity: .85; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 14px; font-weight: 700; }
.modal-head .icon-btn { margin-left: auto; }

.modal-body { padding: 16px; overflow-y: auto; }
.modal-foot {
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  display: flex; gap: 8px; justify-content: flex-end;
}

/* ---------- 公告 ---------- */
.notice-list { padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }

.notice-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fff;
}
.notice-item.is-on { border-color: #b7e6c8; background: #fbfefc; }
.notice-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.notice-title { font-weight: 700; font-size: 13.5px; }
.notice-body { font-size: 12.5px; color: var(--text-2); line-height: 1.7; white-space: pre-wrap; }
.notice-meta { font-size: 11.5px; color: var(--muted); margin-top: 6px; }

.hint {
  margin: 0; padding: 12px 16px;
  font-size: 12.5px; color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}

/* ---------- 版本发布 ---------- */
.release-current {
  padding: 14px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.release-current .rc-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 6px;
}

.release-current .rc-row {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.8;
}

.release-form { padding: 16px; }

.release-h3 {
  font-size: 13px;
  margin: 0 0 8px;
  color: var(--text);
}

.release-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.release-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
}

.release-row textarea.input { flex: 1; min-width: 260px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: #101a26; color: #fff;
  padding: 10px 16px; border-radius: 10px;
  font-size: 13px; z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  opacity: 1;
}
.toast.is-err { background: var(--err); }
.toast.is-ok { background: var(--ok); }

/* ---------- 设备列表 ---------- */
.device-row {
  display: flex; gap: 10px; align-items: flex-start;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 8px;
}
.device-main { flex: 1; min-width: 0; }
.device-name { font-weight: 600; font-size: 13px; }
.device-meta { font-size: 11.5px; color: var(--muted); margin-top: 3px; word-break: break-all; }

.empty {
  padding: 28px 16px; text-align: center;
  color: var(--muted); font-size: 13px;
}

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 12px; gap: 10px; }
  .tabs { order: 3; width: 100%; overflow-x: auto; }
  .topbar-right { margin-left: auto; }
  .main { padding: 12px; }
}
