/* ==========================================================================
   授权中心 · 控制台样式
   设计原则：中性灰底、发丝边框、单一强调色，不用渐变与装饰性阴影
   ========================================================================== */

:root {
  --bg: #f2f3f5;
  --surface: #ffffff;
  --surface-muted: #f7f8f9;
  --border: #e3e5e8;
  --border-strong: #cfd3d8;
  --border-input: #8b929c;

  --text: #15181c;
  --text-2: #525a64;
  --text-3: #656c76;

  --ink: #1b1f24;
  --ink-hover: #2f353d;
  --ink-active: #0d1014;

  --accent: #265f8f;
  --accent-soft: #eef3f8;

  --green: #18704f;
  --green-soft: #e9f4ee;
  --amber: #8a5a10;
  --amber-soft: #fbf3e1;
  --red: #a03a2d;
  --red-soft: #fbeeec;
  --gray-soft: #f2f3f5;

  --radius-sm: 5px;
  --radius: 7px;
  --radius-lg: 9px;

  --shadow-sm: 0 1px 1px rgba(16, 24, 40, 0.03);
  --shadow-md: 0 10px 28px rgba(16, 24, 40, 0.1);
  --mono: "SFMono-Regular", ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: rgba(38, 95, 143, 0.16); }

.hidden { display: none !important; }
.muted { color: var(--text-3); font-size: 12.5px; }
.right { text-align: right; }
.mono-sm { font-family: var(--mono); font-size: 12px; }
.row-inline { display: flex; align-items: center; gap: 10px; }
.pad-inline { padding: 8px 0; }
.mt-6 { margin-top: 6px; }
.notes-body { white-space: pre-wrap; }
.notice {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid #d8e4ef;
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: #1d4c73;
  font-size: 12.5px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------------- 登录 ---------------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 372px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 32px 30px 24px;
  text-align: center;
}

.login-mark {
  width: 44px;
  height: 44px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  background: var(--ink);
  border-radius: 10px;
  color: #fff;
}
.login-mark svg { width: 23px; height: 23px; }

.login-card h1 {
  font-size: 18px;
  margin: 0 0 6px;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.login-sub { color: var(--text-3); font-size: 12.5px; margin: 0 0 24px; }

.field { display: block; text-align: left; margin-bottom: 14px; }
.field > span {
  display: block;
  font-size: 12.5px;
  color: var(--text-2);
  margin-bottom: 6px;
  font-weight: 500;
}

input[type="text"], input[type="password"], input[type="number"], input[type="search"], input[type="date"], select, textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder, textarea::placeholder { color: #6f7680; }

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(38, 95, 143, 0.1);
}

textarea { resize: vertical; min-height: 66px; padding: 8px 11px; }

input[type="search"] { appearance: none; }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }

.login-error { color: var(--red); font-size: 12.5px; min-height: 18px; margin: 10px 0 0; }


/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 33px;
  padding: 0 13px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--ink-hover); }
.btn-primary:active { background: var(--ink-active); }

.btn-ghost { background: #fff; border-color: var(--border-strong); color: var(--text-2); }
.btn-ghost:hover { border-color: #aeb4bc; color: var(--text); background: var(--surface-muted); }

.btn-danger { background: #fff; border-color: #e6c7c1; color: var(--red); }
.btn-danger:hover { background: var(--red-soft); border-color: #d9b0a8; }
.btn-danger-solid { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger-solid:hover { background: #8a2f24; border-color: #8a2f24; }

.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------------- 布局 ---------------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 236px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 12px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; }
.brand-mark {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: var(--ink);
  border-radius: 7px;
  color: #fff;
}
.brand-mark svg { width: 17px; height: 17px; }
.brand-name { font-weight: 600; font-size: 14px; letter-spacing: 0.2px; line-height: 1.3; }
.brand-sub { font-size: 10.5px; color: var(--text-3); letter-spacing: 0.35px; line-height: 1.4; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  color: var(--text-2);
  font-size: 13.5px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.nav-icon { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.72; }
.nav-item:hover { background: var(--surface-muted); color: var(--text); }
.nav-item:hover .nav-icon { opacity: 0.9; }
.nav-item.active { background: #eceef1; color: var(--text); font-weight: 600; }
.nav-item.active .nav-icon { opacity: 1; }
.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  bottom: 9px;
  width: 2px;
  border-radius: 2px;
  background: var(--ink);
}

.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; }
.api-hint { margin-bottom: 10px; padding: 8px 9px; background: var(--surface-muted); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.api-hint-title { font-size: 10.5px; color: var(--text-3); margin-bottom: 3px; letter-spacing: 0.2px; }
.api-hint code { font-family: var(--mono); font-size: 10.5px; color: var(--text-2); word-break: break-all; line-height: 1.5; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 12px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar-title { min-width: 0; }
.topbar h2 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: 0.2px; }
.page-desc { margin: 3px 0 0; font-size: 12.5px; color: var(--text-3); }
.topbar-actions { display: flex; gap: 8px; flex-shrink: 0; }

.page { padding: 24px 32px 64px; width: 100%; max-width: 1320px; margin: 0 auto; }

/* ---------------- 统计 ---------------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}

.stat { background: var(--surface); padding: 15px 18px; min-width: 0; }
.stat-label { font-size: 11.5px; color: var(--text-3); margin-bottom: 5px; }
.stat-value {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.6px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.stat-foot { font-size: 11.5px; color: var(--text-3); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat.accent .stat-value { color: var(--accent); }
.stat.warn .stat-value { color: var(--amber); }
.stat.good .stat-value { color: var(--green); }

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
}
.card-head h3 { margin: 0; font-size: 13.5px; font-weight: 600; }
.search {
  max-width: 248px;
  padding-left: 30px !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6.5'/%3E%3Cpath d='M15.5 15.5L20 20'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 9px center;
  background-size: 15px;
}

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left;
  font-weight: 500;
  color: var(--text-3);
  font-size: 11.5px;
  letter-spacing: 0.3px;
  padding: 9px 18px;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 11px 18px; border-bottom: 1px solid #eef0f2; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background 0.1s ease; }
.table tbody tr:hover { background: #fafbfc; }

.code-cell { font-family: var(--mono); font-size: 12.5px; font-weight: 500; letter-spacing: 0.2px; }
.code-cell .copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-left: 4px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: none;
  color: var(--text-3);
  cursor: pointer;
  vertical-align: -4px;
  opacity: 0.45;
  transition: opacity 0.12s ease, background 0.12s ease, color 0.12s ease;
}
.code-cell .copy svg { width: 13px; height: 13px; }
.code-cell .copy:hover { opacity: 1; color: var(--accent); background: var(--accent-soft); }
.table tbody tr:hover .copy { opacity: 0.8; }

.domains { display: flex; flex-wrap: wrap; gap: 4px; }
.domain-chip {
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.6;
  padding: 1px 6px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
}
.domain-chip.empty-chip { color: var(--text-3); background: none; border-style: dashed; }

/* ---------------- 状态标签 ---------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 8px;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.7;
  white-space: nowrap;
}
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge-active { background: var(--green-soft); color: var(--green); }
.badge-expiring { background: var(--amber-soft); color: var(--amber); }
.badge-expired { background: var(--red-soft); color: var(--red); }
.badge-suspended { background: var(--gray-soft); color: #5b626b; }
.badge-revoked { background: #f4e8e6; color: #7d2b20; }

/* ---------------- 空状态 / 列表 ---------------- */
.empty { padding: 48px 20px; text-align: center; color: var(--text-3); font-size: 13px; }

.list { padding: 2px 0; }
.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 18px;
  border-bottom: 1px solid #f1f2f4;
}
.list-row:last-child { border-bottom: none; }
.list-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.list-title { font-size: 13px; font-weight: 500; }
.list-sub { font-size: 11.5px; color: var(--text-3); font-family: var(--mono); }

.logs { padding: 2px 0; max-height: 70vh; overflow-y: auto; }
.log-row {
  display: grid;
  grid-template-columns: 132px 118px 190px minmax(0, 1fr);
  gap: 14px;
  padding: 9px 18px;
  border-bottom: 1px solid #f2f3f5;
  font-size: 12.5px;
  align-items: baseline;
}
.log-row:last-child { border-bottom: none; }
.log-time { color: var(--text-3); font-family: var(--mono); font-size: 11.5px; white-space: nowrap; }
.log-action { font-weight: 500; }
.log-code { font-family: var(--mono); color: var(--text-2); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; }
.log-detail { color: var(--text-3); font-size: 11.5px; word-break: break-all; }

/* ---------------- 弹窗 ---------------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(18, 21, 25, 0.46);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  pointer-events: auto;
  animation: fade 0.14s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  animation: pop 0.15s ease;
}
@keyframes pop { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }

.modal:focus { outline: none; }
.modal.modal-wide { max-width: 680px; }
.confirm-mask { z-index: 1200; }
.confirm-modal { max-width: 420px; }
.confirm-text { margin: 0; font-size: 13.5px; color: var(--text-2); line-height: 1.7; white-space: pre-wrap; }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 14.5px; font-weight: 600; }
.modal-close {
  border: none;
  background: none;
  font-size: 19px;
  line-height: 1;
  padding: 2px 5px;
  border-radius: var(--radius-sm);
  color: var(--text-3);
  cursor: pointer;
}
.modal-close:hover { color: var(--text); background: var(--surface-muted); }
.modal-body { padding: 18px 20px; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 13px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-muted);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.hint { font-size: 11.5px; color: var(--text-3); margin: 4px 0 0; line-height: 1.5; }

/* 详情面板 */
.detail-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}
.detail-code { font-family: var(--mono); font-size: 15px; font-weight: 600; letter-spacing: 0.4px; }
.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px 12px;
  margin-bottom: 18px;
}
.detail-item { min-width: 0; }
.detail-item .k { font-size: 11.5px; color: var(--text-3); margin-bottom: 2px; }
.detail-item .v { font-size: 13.5px; font-weight: 500; overflow-wrap: anywhere; }

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.4px;
  margin: 20px 0 8px;
}
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.actions-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

.domain-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}
.domain-row .d-name { font-family: var(--mono); font-size: 12.5px; }
.domain-row .d-meta { font-size: 11px; color: var(--text-3); }

.inline-form { display: flex; gap: 8px; margin-top: 8px; }
.inline-form input { flex: 1; min-width: 0; }
.inline-form.compact input[type="number"] { flex: 0 0 108px; max-width: 108px; }

.domain-row.machine-row .d-name {
  font-size: 11.5px;
  line-height: 1.5;
  word-break: break-all;
}

.renew-list { font-size: 12.5px; }
.renew-item { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dashed #eceef1; }
.renew-item:last-child { border-bottom: none; }
.renew-item span:last-child { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); white-space: nowrap; }

/* ---------------- Toast ---------------- */
.toast-root {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 1100;
  pointer-events: none;
}
.toast {
  background: var(--ink);
  color: #fff;
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  box-shadow: 0 6px 18px rgba(16, 24, 40, 0.16);
  animation: pop 0.16s ease;
  max-width: 80vw;
}
.toast.error { background: #8f2f24; }
.toast.success { background: #14624a; }

/* ---------------- 滚动条 ---------------- */
.logs::-webkit-scrollbar, .modal-body::-webkit-scrollbar, .table-wrap::-webkit-scrollbar { width: 8px; height: 8px; }
.logs::-webkit-scrollbar-thumb, .modal-body::-webkit-scrollbar-thumb, .table-wrap::-webkit-scrollbar-thumb {
  background: #d4d8dd;
  border-radius: 4px;
}
.logs::-webkit-scrollbar-track, .modal-body::-webkit-scrollbar-track, .table-wrap::-webkit-scrollbar-track { background: transparent; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1100px) {
  .log-row { grid-template-columns: 120px 110px 160px minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 9px 16px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .brand { padding: 0; margin-right: auto; }
  .brand-sub { display: none; }
  .nav { flex: 0 0 auto; flex-direction: row; gap: 4px; }
  .nav-item { height: 32px; padding: 0 9px; font-size: 13px; }
  .nav-item.active::before { display: none; }
  .sidebar-foot { display: none; }
  .topbar { position: static; padding: 14px 16px; }
  .page { padding: 16px 16px 48px; }
  .log-row { grid-template-columns: 108px minmax(0, 1fr); gap: 2px 10px; }
  .log-code, .log-detail { grid-column: 2; }
}

@media (max-width: 620px) {
  .topbar { flex-wrap: wrap; }
  .topbar-actions { width: 100%; }
  .brand-text { display: none; }
  .nav { flex: 1; justify-content: flex-start; overflow-x: auto; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .stat-foot { display: none; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .card-head { flex-wrap: wrap; }
  .search { max-width: none; }
  .inline-form { flex-wrap: wrap; }
  .inline-form .btn { flex-shrink: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
