/* ============================================================
   auth.wzslinker.top 管理后台样式
   纯白背景 · 细线条分层 · 高信息密度 · 蓝色重点强调
   ============================================================ */

:root {
  --bg: #ffffff;
  --text: #1a1a1a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --blue: #2563eb;
  --blue-bg: #eff6ff;
  --sidebar-bg: #f9fafb;
  --green: #16a34a;
  --green-bg: #f0fdf4;
  --gray: #9ca3af;
  --gray-bg: #f3f4f6;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --radius: 6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, textarea, select { font: inherit; color: inherit; }

/* ---------------- 登录页 ---------------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 32px 28px;
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 600;
}

.login-card .login-sub {
  margin: 0 0 24px;
  font-size: 12px;
  color: var(--muted);
}

/* ---------------- 表单元素 ---------------- */

.field { margin-bottom: 14px; }

.field label {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  color: var(--muted);
}

.input, input[type="text"], input[type="password"], input[type="number"],
input[type="date"], input[type="datetime-local"], input[type="search"],
textarea, select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--blue);
}

textarea { resize: vertical; min-height: 60px; font-family: inherit; }

select { cursor: pointer; }

.form-row {
  display: flex;
  gap: 12px;
}
.form-row .field { flex: 1; }

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 12px;
}

/* ---------------- 按钮 ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  line-height: 1.4;
  transition: background .12s, border-color .12s, color .12s;
  white-space: nowrap;
}
.btn:hover { background: var(--gray-bg); }

.btn-primary {
  background: #1a1a1a;
  color: #fff;
  border-color: #1a1a1a;
}
.btn-primary:hover { background: #000; }

.btn-blue {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}
.btn-blue:hover { background: #1d4ed8; }

.btn-danger {
  color: var(--red);
  border-color: var(--red);
  background: var(--bg);
}
.btn-danger:hover { background: var(--red-bg); }

.btn-ghost {
  border-color: transparent;
  background: transparent;
  padding: 4px 8px;
  color: var(--muted);
}
.btn-ghost:hover { background: var(--gray-bg); color: var(--text); }

.btn-sm { padding: 4px 10px; font-size: 12px; }

.btn-block { width: 100%; }

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

/* ---------------- 后台布局 ---------------- */

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 200px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
}

.sidebar-brand {
  padding: 16px 16px 14px;
  font-size: 14px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  line-height: 1.3;
}

.sidebar-brand .brand-sub {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 16px;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  border-left: 2px solid transparent;
  transition: background .12s;
}
.nav-item:hover { background: rgba(0,0,0,.03); text-decoration: none; }
.nav-item.active {
  background: var(--bg);
  border-left-color: var(--blue);
  color: var(--blue);
  font-weight: 500;
}
.nav-item .nav-ico {
  width: 15px;
  text-align: center;
  font-size: 13px;
  opacity: .8;
}

.sidebar-foot {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
}
.sidebar-foot .user-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.sidebar-foot .user-line .uname { color: var(--text); font-weight: 500; }

.main {
  flex: 1;
  margin-left: 200px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.main-head {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.main-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.main-head .head-actions { display: flex; gap: 8px; align-items: center; }

.main-body { padding: 20px 24px 40px; }

/* 移动端侧栏切换按钮 */
.menu-toggle {
  display: none;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  border-radius: var(--radius);
  padding: 5px 9px;
  cursor: pointer;
  font-size: 14px;
}

.backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.3);
  z-index: 35;
}
.backdrop.show { display: block; }

/* ---------------- 统计卡片 ---------------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.stat-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 16px 18px;
}
.stat-card .stat-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}
.stat-card .stat-value {
  font-size: 26px;
  font-weight: 600;
  line-height: 1.1;
}
.stat-card .stat-value a { color: var(--text); }
.stat-card .stat-value a:hover { color: var(--blue); }

/* ---------------- 卡片/面板 ---------------- */

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--sidebar-bg);
}
.panel-head h3 { margin: 0; font-size: 13px; font-weight: 600; }
.panel-body { padding: 14px 16px; }

/* ---------------- 表格 ---------------- */

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

table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.tbl th, table.tbl td {
  padding: 0 12px;
  height: 36px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.tbl th {
  background: var(--sidebar-bg);
  font-weight: 500;
  color: var(--muted);
  font-size: 12px;
  position: sticky;
  top: 0;
}
table.tbl tbody tr:hover { background: var(--sidebar-bg); }
table.tbl td.wrap-cell { white-space: normal; word-break: break-all; }
table.tbl .col-actions { text-align: right; }
table.tbl .mono { font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; }

/* ---------------- 筛选栏 ---------------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.toolbar .tool-grow { flex: 1; }
.toolbar select, .toolbar input { width: auto; min-width: 130px; }
.toolbar .search-input { min-width: 220px; }

/* ---------------- 徽标 ---------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.5;
  border: 1px solid transparent;
}
.badge-active { background: var(--green-bg); color: var(--green); border-color: #bbf7d0; }
.badge-inactive, .badge-unbound { background: var(--gray-bg); color: #4b5563; border-color: #e5e7eb; }
.badge-blue { background: var(--blue-bg); color: var(--blue); border-color: #bfdbfe; }
.badge-fail { background: var(--red-bg); color: var(--red); border-color: #fecaca; }

/* ---------------- 许可证卡片 ---------------- */

.lic-list { display: flex; flex-direction: column; gap: 10px; }

.lic-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  overflow: hidden;
}
.lic-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  cursor: pointer;
  user-select: none;
}
.lic-card-head:hover { background: var(--sidebar-bg); }
.lic-card-head .lic-key {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  font-weight: 600;
}
.lic-card-head .lic-cust { color: var(--text); }
.lic-card-head .lic-meta { color: var(--muted); font-size: 12px; }
.lic-card-head .lic-note { color: var(--muted); font-size: 12px; max-width: 260px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lic-card-head .chev {
  color: var(--muted); transition: transform .15s; font-size: 11px;
  margin-left: auto;
}
.lic-card.open .lic-card-head .chev { transform: rotate(90deg); }
.lic-card-head .spacer { flex: 1; }

.lic-card-body {
  display: none;
  border-top: 1px solid var(--border);
  padding: 12px 16px 14px;
  background: var(--sidebar-bg);
}
.lic-card.open .lic-card-body { display: block; }

.assign-row {
  display: grid;
  grid-template-columns: 1.5fr 70px 70px 130px 80px 1fr;
  gap: 10px;
  align-items: center;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  margin-bottom: 6px;
  font-size: 12px;
}
.assign-row .ar-code { font-family: monospace; font-weight: 600; }
.assign-row .ar-name { color: var(--text); }
.assign-row .ar-devs { color: var(--blue); font-weight: 500; }
.assign-row .ar-note { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.lic-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

/* ---------------- 弹窗 ---------------- */

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 100;
  padding: 40px 16px;
  overflow-y: auto;
}
.modal {
  width: 100%;
  max-width: 560px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
}
.modal.modal-sm { max-width: 380px; }
.modal.modal-lg { max-width: 720px; }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.modal-close {
  border: none; background: none; cursor: pointer; font-size: 18px;
  color: var(--muted); line-height: 1; padding: 2px 6px;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 18px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--sidebar-bg);
}

/* ---------------- 动态产品授权项编辑器 ---------------- */

.assign-editor { margin-bottom: 8px; }
.assign-editor .ae-row {
  display: grid;
  grid-template-columns: 1.4fr .7fr .9fr .8fr auto;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}
.assign-editor .ae-row select,
.assign-editor .ae-row input { padding: 6px 8px; font-size: 12px; }
.ae-empty { color: var(--muted); font-size: 12px; padding: 8px 0; }

/* ---------------- 杂项 ---------------- */

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

.loading { color: var(--muted); font-size: 13px; padding: 20px; text-align: center; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1a1a1a;
  color: #fff;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 200;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.toast.toast-err { background: var(--red); }

.muted { color: var(--muted); }
.mono { font-family: "SFMono-Regular", Consolas, monospace; }
.t-right { text-align: right; }
.nowrap { white-space: nowrap; }
.break-all { word-break: break-all; }
.text-blue { color: var(--blue); }
.text-red { color: var(--red); }
.text-green { color: var(--green); }
.cursor-pointer { cursor: pointer; }
.hidden { display: none !important; }

.payload-box {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
  max-height: 120px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.kv-line { display: flex; gap: 6px; font-size: 12px; margin-bottom: 4px; }
.kv-line .k { color: var(--muted); min-width: 70px; }
.kv-line .v { color: var(--text); word-break: break-all; }

/* ---------------- 产品徽标组 ---------------- */

.product-badges {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  max-width: 280px;
}
.product-badges .badge { font-size: 10px; padding: 1px 6px; }

/* ---------------- 有效期快捷按钮 ---------------- */

.quick-btns {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 5px;
}
.quick-btns .btn { padding: 3px 8px; font-size: 11px; }

/* ---------------- 总览页分区 ---------------- */

.section-title {
  font-size: 13px;
  font-weight: 600;
  margin: 24px 0 10px;
  color: var(--text);
}

.expiry-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.expiry-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 16px 18px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.expiry-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.expiry-card.expired { border-left: 3px solid var(--red); }
.expiry-card.expiring-7d { border-left: 3px solid #f97316; }
.expiry-card.expiring-30d { border-left: 3px solid #eab308; }
.expiry-card .expiry-label { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.expiry-card .expiry-value { font-size: 26px; font-weight: 600; line-height: 1.1; }
.expiry-card.expired .expiry-value { color: var(--red); }
.expiry-card.expiring-7d .expiry-value { color: #f97316; }
.expiry-card.expiring-30d .expiry-value { color: #eab308; }

/* ---------------- 距今天数颜色 ---------------- */

.text-yellow { color: #ca8a04; }
.text-orange { color: #f97316; }
.text-gray { color: var(--gray); }

/* ---------------- 响应式 ---------------- */

@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid-2 { grid-template-columns: 1fr; }
  .assign-row {
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: auto;
  }
  .assign-editor .ae-row {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: 0 0 30px rgba(0,0,0,.15);
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-flex; }
  .main-head, .main-body { padding-left: 16px; padding-right: 16px; }
}

@media (max-width: 560px) {
  .stat-grid { grid-template-columns: 1fr; }
  .lic-card-head { flex-wrap: wrap; }
  .lic-card-head .lic-note { max-width: 100%; }
}
