/* ==================================================================
   在线 OTA 系统 · 后台样式
   延续原型页的设计语言：Inter 字体 / 品牌蓝 #0a66c2 / 大圆角卡片
   ================================================================== */

:root {
  --brand: #0a66c2;
  --brand-dark: #084a8f;
  --brand-soft: #f0f7ff;
  --ink: #0f172a;
  --text: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-soft: #eef2f6;
  --bg: #f6f9fc;
  --ok: #0b6b3d;
  --ok-bg: #e7f6ee;
  --warn: #92400e;
  --warn-bg: #fef3c7;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --radius: 20px;
  --shadow: 0 6px 16px rgba(0, 0, 0, 0.02), 0 1px 3px rgba(0, 0, 0, 0.04);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); }

.hidden { display: none !important; }

/* ---------------- 登录页 ---------------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  background: radial-gradient(1200px 600px at 50% -10%, #e8f1fb 0%, var(--bg) 60%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border: 1px solid var(--line-soft);
  border-radius: 24px;
  box-shadow: 0 20px 40px -24px rgba(15, 43, 61, 0.35);
  padding: 2.25rem 2rem;
}

.login-card h1 {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink);
}

.login-card h1 i {
  background: linear-gradient(135deg, var(--brand), #0e7cc9);
  color: #fff;
  border-radius: 12px;
  padding: 0.45rem 0.55rem;
  font-size: 1.1rem;
  box-shadow: 0 4px 10px rgba(10, 102, 194, 0.25);
}

.login-card .sub {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0.5rem 0 1.5rem;
}

/* ---------------- 布局 ---------------- */
.app-shell { max-width: 1400px; margin: 0 auto; padding: 1.75rem 1.5rem 3rem; }

.header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.header-left h1 {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.header-left h1 i {
  background: linear-gradient(135deg, var(--brand), #0e7cc9);
  color: #fff;
  border-radius: 12px;
  padding: 0.45rem 0.55rem;
  font-size: 1.2rem;
  box-shadow: 0 4px 10px rgba(10, 102, 194, 0.25);
}

.header-left p { color: var(--muted); font-size: 0.88rem; margin-top: 0.3rem; }

.badge-ota {
  font-size: 0.72rem;
  background: var(--line);
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  font-weight: 600;
  color: #334155;
}

.header-right { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.85rem 0.35rem 0.4rem;
  font-size: 0.85rem;
}

.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), #0e7cc9);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.8rem;
}

.user-chip .role { color: var(--muted); font-size: 0.75rem; }

/* ---------------- 导航 ---------------- */
.nav-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  background: #ffffffd9;
  padding: 0.3rem;
  border-radius: 48px;
  border: 1px solid var(--line);
  margin-bottom: 1.5rem;
  width: fit-content;
}

.nav-tab {
  padding: 0.5rem 1.05rem;
  font-size: 0.86rem;
  font-weight: 500;
  border-radius: 32px;
  background: transparent;
  border: none;
  color: #475569;
  cursor: pointer;
  transition: 0.15s;
  display: flex; align-items: center; gap: 0.45rem;
  font-family: inherit;
}

.nav-tab:hover { background: #f1f5f9; color: var(--ink); }

.nav-tab.active {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 4px 10px rgba(10, 102, 194, 0.25);
}

/* ---------------- 统计卡 ---------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1.1rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.15rem 1.35rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: 0.15s;
}

.stat-card:hover { border-color: #cbd5e1; box-shadow: 0 12px 20px -8px rgba(0, 0, 0, 0.06); }

.stat-info h3 {
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.stat-info .value { font-size: 1.85rem; font-weight: 700; color: var(--ink); line-height: 1.2; }

.stat-icon {
  width: 46px; height: 46px;
  background: var(--brand-soft);
  border-radius: 15px;
  display: flex; align-items: center; justify-content: center;
  color: var(--brand);
  font-size: 1.3rem;
}

/* ---------------- 工具条 ---------------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 1.1rem;
}

.toolbar-left, .toolbar-right { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }

.search-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 40px;
  padding: 0.35rem 0.4rem 0.35rem 0.9rem;
}

.search-wrapper i { color: #94a3b8; font-size: 0.85rem; }

.search-wrapper input {
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 0.86rem;
  width: 210px;
  background: transparent;
  color: var(--text);
}

.select-plain, .input-plain {
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.5rem 0.85rem;
  border-radius: 40px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  outline: none;
}

.select-plain:focus, .input-plain:focus { border-color: var(--brand); }

/* ---------------- 按钮 ---------------- */
.btn {
  padding: 0.6rem 1.25rem;
  border-radius: 40px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: 0.15s;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(10, 102, 194, 0.25); }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }

.btn-secondary { background: #fff; border-color: #cbd5e1; color: #334155; }
.btn-secondary:hover:not(:disabled) { background: #f8fafc; border-color: #94a3b8; }

.btn-danger { background: #fff; border-color: #fca5a5; color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger-bg); }

.btn-block { width: 100%; justify-content: center; padding: 0.75rem; }

.btn-icon {
  background: #fff;
  border: 1px solid var(--line);
  color: #475569;
  padding: 0.35rem 0.7rem;
  border-radius: 8px;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: 0.15s;
}

.btn-icon:hover { background: #f1f5f9; border-color: #cbd5e1; color: var(--ink); }
.btn-icon.danger { color: var(--danger); border-color: #fecaca; }
.btn-icon.danger:hover { background: var(--danger-bg); }

/* ---------------- 表格卡片 ---------------- */
.table-card {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--line-soft);
  gap: 1rem;
  flex-wrap: wrap;
}

.table-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.table-count { font-size: 0.8rem; color: var(--muted); }

.table-responsive { overflow-x: auto; }

/* 列挤到一起时宁可横向滚动，也不要把中文压成一列竖排 */
table { width: 100%; min-width: 1040px; border-collapse: collapse; font-size: 0.86rem; }

th {
  text-align: left;
  padding: 0.75rem 1.4rem;
  background: #f8fafc;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  border-bottom: 1px solid var(--line-soft);
}

td { padding: 0.85rem 1.4rem; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafcff; }

.action-buttons { display: flex; gap: 0.35rem; flex-wrap: wrap; }

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
}

.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

/* ---------------- 标签 ---------------- */
.version-badge {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--brand-soft);
  color: var(--brand);
  border: 1px solid #d6e9fb;
  padding: 0.2rem 0.6rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.8rem;
}

.device-tag {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: #f1f5f9;
  border: 1px solid var(--line);
  padding: 0.2rem 0.6rem;
  border-radius: 8px;
  font-size: 0.78rem;
  color: #334155;
}

.status {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-active, .status-success { background: var(--ok-bg); color: var(--ok); }
.status-draft, .status-disabled { background: var(--warn-bg); color: var(--warn); }
.status-deprecated, .status-revoked, .status-failure { background: var(--danger-bg); color: var(--danger); }
.status-neutral { background: #f1f5f9; color: #475569; }

.chip {
  white-space: nowrap;
  display: inline-block;
  background: #f1f5f9;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.1rem 0.45rem;
  font-size: 0.72rem;
  color: #475569;
  margin: 0.1rem 0.15rem 0.1rem 0;
}

.chip-brand { background: var(--brand-soft); border-color: #d6e9fb; color: var(--brand); }

/* ---------------- 空状态 / 分页 ---------------- */
.empty-state { text-align: center; padding: 3rem 1.5rem; color: #94a3b8; }
.empty-state i { font-size: 2.2rem; margin-bottom: 0.7rem; opacity: 0.5; display: block; }

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 1.4rem;
  border-top: 1px solid var(--line-soft);
  font-size: 0.82rem;
  color: var(--muted);
  gap: 0.75rem;
  flex-wrap: wrap;
}

.pagination .pages { display: flex; gap: 0.35rem; }

/* ---------------- 表单 ---------------- */
.form-group { margin-bottom: 1.05rem; }

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: #334155;
}

.form-group .hint { font-size: 0.75rem; color: var(--muted); font-weight: 400; margin-top: 0.3rem; }

.form-group input[type='text'],
.form-group input[type='password'],
.form-group input[type='email'],
.form-group input[type='number'],
.form-group input[type='date'],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 0.88rem;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: 0.15s;
}

.form-group textarea { resize: vertical; min-height: 84px; }

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(10, 102, 194, 0.12);
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }

.req { color: var(--danger); }

.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.5rem; }

.checkbox-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: 0.15s;
  background: #fff;
}

.checkbox-item:hover { border-color: #94a3b8; }
.checkbox-item input { margin-top: 0.15rem; accent-color: var(--brand); }
.checkbox-item .desc { display: block; color: var(--muted); font-size: 0.72rem; margin-top: 0.15rem; }

.file-upload-area {
  border: 2px dashed #cbd5e1;
  border-radius: 14px;
  padding: 1.6rem 1rem;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: 0.15s;
  background: #fafcff;
}

.file-upload-area:hover { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.file-upload-area i { font-size: 1.7rem; display: block; margin-bottom: 0.5rem; }
.file-upload-area.has-file { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); border-style: solid; }

/* ---------------- 模态框 ---------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 3rem 1.25rem;
  z-index: 100;
  overflow-y: auto;
  backdrop-filter: blur(2px);
}

.modal-overlay.show { display: flex; }

.modal {
  background: #fff;
  border-radius: 22px;
  padding: 1.75rem;
  width: 100%;
  max-width: 560px;
  box-shadow: 0 24px 48px -16px rgba(15, 23, 42, 0.3);
  animation: modal-in 0.16s ease-out;
}

.modal.wide { max-width: 760px; }

@keyframes modal-in {
  from { transform: translateY(-8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-sub { color: var(--muted); font-size: 0.83rem; margin: 0.4rem 0 1.3rem; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.7rem;
  margin-top: 1.6rem;
  flex-wrap: wrap;
}

/* ---------------- 密钥展示 ---------------- */
.secret-box {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 14px;
  padding: 1rem 1.1rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  word-break: break-all;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.secret-box button {
  background: #1e293b;
  border: 1px solid #334155;
  color: #e2e8f0;
  border-radius: 8px;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  font-size: 0.75rem;
  font-family: inherit;
  white-space: nowrap;
}

.secret-box button:hover { background: #334155; }

.alert {
  border-radius: 14px;
  padding: 0.85rem 1rem;
  font-size: 0.83rem;
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  margin-bottom: 1.1rem;
}

.alert i { margin-top: 0.15rem; }
.alert-warn { background: var(--warn-bg); color: var(--warn); }
.alert-danger { background: var(--danger-bg); color: var(--danger); }
.alert-info { background: var(--brand-soft); color: var(--brand); }
.alert-ok { background: var(--ok-bg); color: var(--ok); }

/* ---------------- 提示条 ---------------- */
.toast-stack {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  z-index: 200;
  max-width: min(380px, calc(100vw - 2.5rem));
}

.toast {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: 14px;
  padding: 0.85rem 1rem;
  box-shadow: 0 14px 28px -12px rgba(15, 23, 42, 0.35);
  font-size: 0.85rem;
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  animation: toast-in 0.18s ease-out;
}

.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--danger); }
.toast.warn { border-left-color: #d97706; }

@keyframes toast-in {
  from { transform: translateX(12px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ---------------- 其它 ---------------- */
.footer-note {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 1.5rem 0 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.section-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
  margin: 1.5rem 0 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.code-block {
  background: #0f172a;
  color: #cbd5e1;
  border-radius: 14px;
  padding: 1rem 1.1rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  overflow-x: auto;
  white-space: pre;
  line-height: 1.6;
}

.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1.25rem; align-items: start; }

@media (max-width: 900px) {
  .two-col, .form-row { grid-template-columns: 1fr; }
  .search-wrapper input { width: 150px; }
  .app-shell { padding: 1.25rem 1rem 2.5rem; }
}
