/* Claude 风格：暖白底、陶土色点缀、衬线标题、克制的边框与阴影 */

:root {
  --bg: #f5f4ed;
  --bg-soft: #f0eee6;
  --surface: #ffffff;
  --surface-2: #faf9f5;
  --border: #e6e3d8;
  --border-strong: #d8d4c6;
  --text: #1f1e1d;
  --text-2: #3d3b37;
  --muted: #6f6c64;
  --muted-2: #8f8c82;
  --accent: #c96442;
  --accent-hover: #b4522f;
  --accent-soft: #f8ece5;
  --accent-border: #ebcfc2;
  --success: #3d6b52;
  --success-soft: #e9f0ea;
  --success-border: #cfe0d4;
  --danger: #a8402f;
  --danger-soft: #f9eae6;
  --danger-border: #eccfc6;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(31, 30, 29, 0.04);
  --shadow-md: 0 8px 24px rgba(31, 30, 29, 0.06);
  --shadow-lg: 0 24px 70px rgba(31, 30, 29, 0.16);
  --serif: ui-serif, Georgia, "Iowan Old Style", "Times New Roman", "Songti SC", "Noto Serif SC", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden], .hidden { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14.5px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}

::selection { background: #f1d9cd; }

.muted { color: var(--muted); }
.tiny { font-size: 12.5px; }
.center { text-align: center; }
.right { text-align: right; }
.error-text { color: var(--danger); font-size: 13px; margin: 10px 0 0; white-space: pre-wrap; }

/* ---------- 登录 ---------- */
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 480px at 50% -20%, #fbf3ec 0%, rgba(251, 243, 236, 0) 70%),
    var(--bg);
}
.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 36px 32px;
  box-shadow: var(--shadow-md);
  text-align: center;
}
.login-card h1 {
  font: 500 27px/1.25 var(--serif);
  letter-spacing: -0.01em;
  margin: 18px 0 8px;
}
.login-card p.muted { margin: 0; font-size: 13.5px; }
.login-card .field { text-align: left; margin-top: 26px; }
.login-card .btn { margin-top: 18px; }

.logo {
  width: 50px;
  height: 50px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  border-radius: 15px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
}
.logo svg { width: 26px; height: 26px; display: block; }
.logo.small {
  width: 34px;
  height: 34px;
  margin: 0;
  border-radius: 10px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
}
.logo.small svg { width: 18px; height: 18px; }

/* ---------- 布局 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 26px;
  background: rgba(245, 244, 237, 0.9);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand strong {
  display: block;
  font: 500 16px/1.3 var(--serif);
  letter-spacing: -0.01em;
  color: var(--text);
}
.brand .tiny { display: block; color: var(--muted-2); }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.container {
  max-width: 1180px;
  margin: 26px auto 72px;
  padding: 0 26px;
  display: grid;
  gap: 20px;
}

/* ---------- 统计 ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.stat {
  padding: 18px 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  border-right: 1px solid var(--border);
}
.stat:last-child { border-right: none; }
.stat-label {
  color: var(--muted-2);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.stat strong {
  font: 500 30px/1.2 var(--serif);
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 4px 0 2px;
  font-variant-numeric: tabular-nums;
}
.stat-sub { color: var(--muted-2); font-size: 12px; }

/* ---------- 面板 ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.panel-head h2 {
  font: 600 15px/1.3 var(--sans);
  letter-spacing: -0.005em;
  margin: 0;
}
.panel-tools { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; }
.table-wrap { overflow-x: auto; }

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  padding: 10px 20px;
  text-align: left;
  font-weight: 500;
  font-size: 11.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted-2);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 13px 20px;
  text-align: left;
  border-bottom: 1px solid #f1efe7;
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background 0.12s ease; }
.table tbody tr:hover { background: var(--surface-2); }
.table .empty, .empty { padding: 30px 20px; text-align: center; color: var(--muted-2); font-size: 13.5px; }
.email { font-weight: 600; color: var(--text); overflow-wrap: anywhere; letter-spacing: -0.005em; }
.table td:first-child { min-width: 218px; }
.sub { color: var(--muted); font-size: 12px; }
.actions { display: flex; gap: 5px; justify-content: flex-end; flex-wrap: nowrap; }
.table td:last-child, .table th:last-child { white-space: nowrap; }

/* ---------- 表单 ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 15px; }
.field > span { color: var(--muted); font-size: 12px; letter-spacing: 0.01em; }
.input,
input[type="text"],
input[type="password"],
input[type="email"],
textarea,
.field input,
.field textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 12px;
  font: inherit;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  resize: vertical;
}
.field input::placeholder,
.field textarea::placeholder,
.input::placeholder { color: var(--muted-2); }
.field input:focus,
.field textarea:focus,
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(201, 100, 66, 0.13);
}
.search { flex: 0 1 240px; width: 240px; max-width: 240px; }
.nowrap { white-space: nowrap; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; cursor: pointer; }
input[type="checkbox"] { accent-color: var(--accent); }

/* ---------- 按钮 ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  border-radius: var(--radius-sm);
  padding: 7px 13px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease, transform 0.05s ease;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(201, 100, 66, 0.18); }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(107, 45, 26, 0.18);
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); }
.btn.ghost:hover { background: var(--bg-soft); color: var(--text); }
.btn.danger { color: var(--danger); border-color: var(--danger-border); background: var(--surface); }
.btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn.tiny-btn {
  padding: 4px 8px;
  font-size: 11.5px;
  border-radius: 8px;
  font-weight: 500;
  box-shadow: none;
  background: var(--surface);
}
.btn.tiny-btn:hover { background: var(--bg-soft); }
.btn.tiny-btn.danger { background: transparent; border-color: transparent; color: var(--danger); }
.btn.tiny-btn.danger:hover { background: var(--danger-soft); }
.btn.block { width: 100%; justify-content: center; padding: 10px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ---------- 徽标 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge.active { color: var(--success); background: var(--success-soft); border-color: var(--success-border); }
.badge.expired { color: var(--danger); background: var(--danger-soft); border-color: var(--danger-border); }
.badge.disabled { color: var(--muted); background: var(--bg-soft); border-color: var(--border); }

/* ---------- 取件记录 ---------- */
.codes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
  padding: 20px;
  background: var(--surface-2);
}
.code-card {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 15px 16px 13px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}
.code-card:hover { border-color: var(--accent-border); box-shadow: var(--shadow-sm); }
.code-card.used { opacity: 0.55; }
.code-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; min-width: 0; }
.code-value {
  font: 600 21px/1.15 var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 2px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.code-meta { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code-actions { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }

/* ---------- 对话框 ---------- */
.dialog {
  width: min(520px, calc(100vw - 32px));
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 26px;
  box-shadow: var(--shadow-lg);
}
.dialog.wide { width: min(1080px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(31, 30, 29, 0.32); backdrop-filter: blur(3px); }
.dialog h3 { margin: 0 0 6px; font: 500 21px/1.3 var(--serif); letter-spacing: -0.01em; }
.dialog p.muted { margin: 0 0 4px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.dialog-head h3 { margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.device-code {
  font: 600 28px/1.2 var(--mono);
  letter-spacing: 7px;
  text-align: center;
  padding: 18px;
  margin: 16px 0;
  border-radius: 12px;
  background: var(--accent-soft);
  border: 1px dashed var(--accent-border);
  color: var(--accent-hover);
  user-select: all;
}

/* ---------- 邮件 ---------- */
.message-layout {
  display: grid;
  grid-template-columns: minmax(280px, 390px) 1fr;
  gap: 14px;
  min-height: 420px;
  max-height: 66vh;
}
.message-list, .message-detail {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.message-list { background: var(--surface-2); }
.message-item {
  padding: 12px 14px;
  border-bottom: 1px solid #eeece4;
  cursor: pointer;
  border-left: 2px solid transparent;
}
.message-item:hover { background: var(--bg); }
.message-item.active { background: var(--accent-soft); border-left-color: var(--accent); }
.message-item .subject { font-size: 13px; font-weight: 600; margin-bottom: 3px; color: var(--text); }
.message-item .meta { color: var(--muted-2); font-size: 11.5px; display: flex; justify-content: space-between; gap: 8px; }
.message-body {
  padding: 16px 18px;
  font-size: 12.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-2);
}
.message-head { padding: 15px 18px; border-bottom: 1px solid var(--border); }
.message-head h4 { margin: 0 0 4px; font: 600 14.5px/1.4 var(--sans); }
.candidates { padding: 14px 18px 6px; display: flex; gap: 8px; flex-wrap: wrap; }
.candidate {
  font: 600 15px/1 var(--mono);
  padding: 7px 11px;
  border-radius: 9px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: var(--accent-hover);
  cursor: pointer;
  transition: background 0.14s ease;
}
.candidate:hover { background: #f2ddd2; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--text);
  border: 1px solid var(--text);
  color: #fbfaf7;
  padding: 10px 18px;
  border-radius: 10px;
  box-shadow: 0 16px 40px rgba(31, 30, 29, 0.25);
  z-index: 100;
  max-width: min(560px, calc(100vw - 32px));
  font-size: 13px;
}
.toast.error { background: #7d3125; border-color: #7d3125; }

/* 滚动条 */
.message-list::-webkit-scrollbar, .message-detail::-webkit-scrollbar { width: 10px; }
.message-list::-webkit-scrollbar-thumb, .message-detail::-webkit-scrollbar-thumb {
  background: #dcd8ca;
  border-radius: 8px;
  border: 3px solid var(--surface);
}


@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; padding: 10px 16px 8px; gap: 10px; }
  .brand { width: 100%; }
  .topbar-actions { width: 100%; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
  .topbar-actions .btn { flex: 0 0 auto; }
  .container { padding: 0 16px; margin: 18px auto 48px; }
  .panel-head { padding: 13px 16px; }
  .stats { border-radius: 12px; }
  .stat { padding: 15px 16px 13px; }
  .stat strong { font-size: 26px; }

  .table-wrap { overflow: visible; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 8px 0 10px; border-bottom: 1px solid var(--border); }
  .table tbody tr:last-child { border-bottom: none; }
  .table td { border: none; padding: 4px 16px; display: flex; align-items: flex-start; gap: 14px; }
  .table td::before {
    content: attr(data-label);
    flex: 0 0 52px;
    color: var(--muted-2);
    font-size: 11px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding-top: 1px;
  }
  .table td:first-child, .table td:last-child { padding-top: 6px; }
  .table td:first-child::before, .table td:last-child::before { display: none; }
  .table td:first-child { min-width: 0; }
  .actions { justify-content: flex-start; flex-wrap: wrap; }
  .table td.empty::before { display: none; }
  .table td[data-label="状态"] .sub {
    max-width: 210px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .codes { grid-template-columns: 1fr; padding: 14px; gap: 10px; }
  .dialog { padding: 20px; }
  .dialog.wide { width: calc(100vw - 16px); padding: 14px; }
  .message-layout { min-height: 0; }
}

@media (max-width: 860px) {
  .panel-tools { flex-wrap: wrap; width: 100%; }
  .panel-tools .search { flex: 1 1 100%; width: 100%; max-width: none; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(2) { border-right: none; }
  .stat:nth-child(-n + 2) { border-bottom: 1px solid var(--border); }
  .message-layout { grid-template-columns: 1fr; max-height: 72vh; }
  .message-detail { min-height: 220px; }
  .grid2 { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; }
}
