/* ============================================================
   卡密授权管理后台 · 样式
   基调：温暖纸张质感、天然材质色、安静留白
   全部为纯 CSS，不依赖任何外部资源
   ============================================================ */

:root {
  /* 纸张与墨色 */
  --paper:      #f6f2ea;
  --paper-2:    #fdfbf7;
  --paper-3:    #f1ece2;
  --ink:        #2f2a24;
  --ink-2:      #5b5348;
  --muted:      #8d8375;
  --line:       #e3dccf;
  --line-soft:  #ece6da;

  /* 主色：温暖的陶土棕 */
  --accent:      #8a6a45;
  --accent-dark: #6d5334;
  --accent-soft: #f3eade;

  /* 语义色：苔绿 / 赤陶红 */
  --ok:        #5f7350;
  --ok-soft:   #edf1e6;
  --danger:    #a8564a;
  --danger-soft: #f7ebe7;
  --warn:      #97793d;
  --warn-soft: #f7f0df;

  --radius:    10px;
  --radius-sm: 7px;
  --shadow:    0 1px 2px rgba(80, 68, 52, 0.05), 0 6px 20px rgba(80, 68, 52, 0.06);
  --shadow-lg: 0 10px 40px rgba(60, 50, 38, 0.16);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-serif: Georgia, "Songti SC", "SimSun", "Noto Serif SC", serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

[v-cloak] { display: none; }

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

body {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--ink);
  background-color: var(--paper);
  /* 极淡的纸纹：两层错位的点阵，不需要图片 */
  background-image:
    radial-gradient(rgba(140, 118, 88, 0.055) 1px, transparent 1px),
    radial-gradient(rgba(140, 118, 88, 0.035) 1px, transparent 1px);
  background-size: 17px 17px, 23px 23px;
  background-position: 0 0, 8px 11px;
  -webkit-font-smoothing: antialiased;
}

.mono  { font-family: var(--font-mono); }
.strong { font-weight: 600; }
.small { font-size: 12.5px; }
.muted { color: var(--muted); }

/* ============================================================
   依赖加载失败兜底
   ============================================================ */
.boot-error {
  max-width: 520px;
  margin: 14vh auto;
  padding: 34px 32px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
  line-height: 1.8;
}
.boot-error h2 { margin: 0 0 10px; font-family: var(--font-serif); font-weight: 500; }

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

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 40px 36px 30px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-logo {
  width: 54px;
  height: 54px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 1px solid #e2d4c0;
  color: var(--accent-dark);
  font-family: var(--font-serif);
  font-size: 24px;
  line-height: 52px;
}

.login-card h1 {
  margin: 0 0 6px;
  font-family: var(--font-serif);
  font-size: 21px;
  font-weight: 500;
  letter-spacing: 0.5px;
}

.login-sub {
  margin: 0 0 26px;
  color: var(--muted);
  font-size: 13px;
}

.login-error {
  margin: 4px 0 12px;
  color: var(--danger);
  font-size: 13px;
}

.login-tip {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

/* ============================================================
   表单元素
   ============================================================ */
.field { display: block; text-align: left; margin-bottom: 16px; }

.field > span {
  display: block;
  margin-bottom: 7px;
  font-size: 12.5px;
  color: var(--ink-2);
  letter-spacing: 0.3px;
}

.input {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:hover { border-color: #d6cdba; }
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(138, 106, 69, 0.12);
}
.input.sm { min-height: 34px; font-size: 13px; padding: 0 10px; }
.input.search { min-width: 210px; }

select.input {
  appearance: none;
  padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 17px, calc(100% - 11px) 17px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

/* ============================================================
   按钮
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 18px;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.08s;
}
.btn:hover:not(:disabled) { background: var(--paper-3); border-color: #d6cdba; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.primary {
  color: #fdfbf7;
  background: var(--accent);
  border-color: var(--accent);
  letter-spacing: 0.5px;
}
.btn.primary:hover:not(:disabled) { background: var(--accent-dark); border-color: var(--accent-dark); }

.btn.danger {
  color: #fdfbf7;
  background: var(--danger);
  border-color: var(--danger);
}
.btn.danger:hover:not(:disabled) { background: #93473d; border-color: #93473d; }

.btn.ghost { background: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--paper-3); }

.btn.sm { min-height: 34px; padding: 0 13px; font-size: 13px; }
.btn.block { width: 100%; margin-top: 6px; }

/* 表格里的文字按钮 */
.link {
  padding: 4px 2px;
  font-family: inherit;
  font-size: 13px;
  color: var(--accent);
  background: none;
  border: none;
  border-bottom: 1px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.link:hover { border-bottom-color: currentColor; }
.link.danger { color: var(--danger); }

/* ============================================================
   主界面骨架
   ============================================================ */
.layout { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 26px;
  padding: 0 26px;
  height: 62px;
  background: rgba(246, 242, 234, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-serif);
  font-size: 16px;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.brand .logo {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 1px solid #e2d4c0;
  color: var(--accent-dark);
  font-size: 14px;
  line-height: 28px;
  text-align: center;
}

.tabs { display: flex; gap: 4px; }
.tabs button {
  padding: 7px 16px;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink-2);
  background: none;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.tabs button:hover { background: var(--paper-3); }
.tabs button.active {
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-color: #e2d4c0;
}

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.api-badge {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 5px 11px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
  background: var(--paper-3);
  border-radius: 999px;
}

.panel {
  flex: 1;
  width: 100%;
  max-width: 1560px;
  margin: 0 auto;
  padding: 24px 26px 40px;
}

/* ============================================================
   工具条
   ============================================================ */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}
.filters, .actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.filters .input { width: auto; }
.filters .input.search { width: 250px; }
.filters select.input { min-width: 132px; }

/* ============================================================
   表格
   ============================================================ */
.table-wrap {
  overflow-x: auto;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 13px 14px;
  font-weight: 500;
  font-size: 12.5px;
  color: var(--ink-2);
  text-align: left;
  letter-spacing: 0.4px;
  white-space: nowrap;
  background: var(--paper-3);
  border-bottom: 1px solid var(--line);
}

tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.12s; }
tbody tr:hover { background: #fbf8f2; }

.col-idx { width: 52px; color: var(--muted); }
.col-num { text-align: right; white-space: nowrap; }
.col-ops { white-space: nowrap; width: 1%; }
.col-ops .link + .link { margin-left: 12px; }

.remark {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty {
  padding: 46px 0 !important;
  text-align: center;
  color: var(--muted);
}

/* 状态与标签 */
.tag {
  display: inline-block;
  padding: 2px 9px;
  font-size: 12px;
  color: var(--ink-2);
  background: var(--paper-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
}

.status {
  display: inline-block;
  padding: 3px 10px;
  font-size: 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.st-unused    { color: var(--muted);   background: var(--paper-3);   border: 1px solid var(--line); }
.st-activated { color: var(--ok);      background: var(--ok-soft);   border: 1px solid #dde4d2; }
.st-expired   { color: var(--warn);    background: var(--warn-soft); border: 1px solid #ece0c4; }
.st-disabled  { color: var(--danger);  background: var(--danger-soft); border: 1px solid #eed9d4; }

/* ============================================================
   分页
   ============================================================ */
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  font-size: 13px;
}
.pager-btns { display: flex; align-items: center; gap: 10px; }

/* ============================================================
   弹窗
   ============================================================ */
.mask {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(47, 42, 36, 0.38);
  backdrop-filter: blur(2px);
}

.modal {
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 28px 28px 22px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
}
.modal.wide-modal { max-width: 660px; }

.modal h3 {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 500;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
  margin-top: 18px;
}
.form-grid .field.wide { grid-column: 1 / -1; }

.modal-error {
  margin: 8px 0 0;
  color: var(--danger);
  font-size: 13px;
}

.confirm-text {
  margin: 6px 0 22px;
  color: var(--ink-2);
  line-height: 1.8;
}

.codes {
  width: 100%;
  height: 300px;
  margin: 14px 0 4px;
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.9;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  resize: vertical;
}

.modal-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

/* ============================================================
   轻提示
   ============================================================ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  z-index: 100;
  transform: translateX(-50%);
  max-width: 80vw;
  padding: 11px 22px;
  font-size: 13.5px;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
}
.toast-ok  { color: #fdfbf7; background: var(--ok); }
.toast-err { color: #fdfbf7; background: var(--danger); }

.toast-enter-active, .toast-leave-active { transition: opacity 0.25s, transform 0.25s; }
.toast-enter-from, .toast-leave-to { opacity: 0; transform: translate(-50%, 12px); }

/* ============================================================
   窄屏适配
   ============================================================ */
@media (max-width: 1080px) {
  .topbar { gap: 16px; padding: 0 16px; }
  .brand span:not(.logo) { display: none; }
  .api-badge { display: none; }
  .panel { padding: 18px 16px 32px; }
  .filters .input.search { width: 100%; }
}

@media (max-width: 640px) {
  .toolbar { flex-direction: column; align-items: stretch; }
  .filters, .actions { flex-direction: column; align-items: stretch; }
  .filters .input, .filters select.input { width: 100%; }
  .actions .btn { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
}
