/* 店铺邮箱 Web 客户端 — 无框架单页样式 */
:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --line: #e3e8f0;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --ok: #059669;
  --warn: #d97706;
  --sidebar: #101827;
  --sidebar-text: #9ca3af;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 39, .08), 0 8px 24px rgba(16, 24, 39, .06);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}
.hidden { display: none !important; }
h1, h2, h3 { margin: 0 0 12px; }
a { color: var(--primary); text-decoration: none; }

/* ---------- 登录 ---------- */
.login-layer {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #101827 0%, #1e3a8a 100%);
}
.login-card {
  width: 380px; max-width: calc(100vw - 32px);
  background: var(--panel); border-radius: 14px; padding: 28px;
  box-shadow: var(--shadow);
}
.login-brand { display: flex; gap: 14px; align-items: center; margin-bottom: 22px; }
.login-brand h1 { font-size: 18px; margin: 0; }
.login-brand p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.login-card label { display: block; margin-bottom: 14px; font-weight: 500; }
.login-card input {
  width: 100%; margin-top: 6px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 8px; font-size: 14px;
}
.login-card input:focus { outline: 2px solid #bfdbfe; border-color: var(--primary); }
.login-error {
  background: #fef2f2; color: var(--danger);
  border: 1px solid #fecaca; border-radius: 8px; padding: 8px 12px; margin-bottom: 12px;
  font-size: 13px;
}

/* ---------- 布局 ---------- */
.app { display: flex; height: 100vh; }
.sidebar {
  width: 210px; flex: none; background: var(--sidebar);
  display: flex; flex-direction: column; padding: 16px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff;
         font-weight: 700; font-size: 16px; padding: 4px 10px 16px; }
#nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
#nav a {
  color: var(--sidebar-text); padding: 9px 12px; border-radius: 8px;
  font-weight: 500; transition: background .15s, color .15s;
}
#nav a:hover { color: #e5e7eb; background: rgba(255,255,255,.06); }
#nav a.active { color: #fff; background: var(--primary); }
.sidebar-footer { display: flex; flex-direction: column; gap: 8px; }
.sync-meta { color: #6b7280; font-size: 11px; padding: 0 4px; word-break: break-all; }

.main { flex: 1; overflow: auto; padding: 22px 26px; }
.page-head { display: flex; align-items: center; justify-content: space-between;
             gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h2 { font-size: 19px; margin: 0; }
.page-head .sub { color: var(--muted); font-size: 12px; }

/* ---------- 通用组件 ---------- */
.panel { background: var(--panel); border: 1px solid var(--line);
         border-radius: var(--radius); box-shadow: var(--shadow); }
.btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  padding: 6px 14px; border-radius: 8px; cursor: pointer; font-size: 13px;
  transition: background .15s, border-color .15s;
}
.btn:hover { border-color: #c3cbd9; background: #f8fafc; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; border-color: #fca5a5; }
.btn-ghost { background: transparent; border-color: rgba(255,255,255,.14); color: var(--sidebar-text); }
.btn-ghost:hover { color: #e5e7eb; background: rgba(255,255,255,.06); }
.btn-block { width: 100%; }
.btn-sm { padding: 3px 10px; font-size: 12px; }

input[type="text"], input[type="password"], input[type="number"], select, textarea {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 13px; background: #fff; color: var(--text); font-family: inherit;
}
textarea { width: 100%; font-family: var(--mono); font-size: 12px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--primary); }

.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge.amazon { background: #fef3c7; color: #92400e; }
.badge.otp { background: #dbeafe; color: #1e40af; font-family: var(--mono); }
.badge.unread { background: #ede9fe; color: #5b21b6; }
.badge.cat-告警, .badge.cat-侵权 { background: #fee2e2; color: #991b1b; }
.badge.cat-扣款 { background: #ffedd5; color: #9a3412; }
.badge.cat-绩效, .badge.cat-货件, .badge.cat-客户 { background: #ffedd5; color: #9a3412; }
.badge.cat-回款 { background: #d1fae5; color: #065f46; }
.badge.cat-广告, .badge.cat-其他 { background: #e5e7eb; color: #4b5563; }
.badge.status-ok { background: #d1fae5; color: #065f46; }
.badge.status-error { background: #fee2e2; color: #991b1b; }
.badge.status-auth_error { background: #fee2e2; color: #991b1b; }
.badge.status-skipped { background: #f3f4f6; color: #6b7280; }

/* ---------- 筛选条 ---------- */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
              padding: 12px 14px; margin-bottom: 14px; }
.filter-bar .grow { flex: 1; min-width: 180px; }
.check { display: inline-flex; align-items: center; gap: 5px; color: var(--muted);
         font-size: 13px; cursor: pointer; user-select: none; }
.check input { accent-color: var(--primary); }

/* ---------- 表格 ---------- */
table.list { width: 100%; border-collapse: collapse; font-size: 13px; }
table.list th, table.list td { padding: 9px 12px; text-align: left;
                               border-bottom: 1px solid var(--line); }
table.list th { color: var(--muted); font-weight: 600; font-size: 12px;
                position: sticky; top: 0; background: var(--panel); }
table.list tbody tr { cursor: default; }
table.list tbody tr.clickable { cursor: pointer; }
table.list tbody tr.clickable:hover { background: #f8fafc; }
table.list td.num { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row-sub { color: var(--muted); font-size: 12px; }
.subject-unread { font-weight: 700; }
.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end;
         padding: 10px 14px; color: var(--muted); font-size: 12px; }

/* ---------- 验证码卡片 ---------- */
.otp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
            gap: 14px; }
.otp-card { padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; }
.otp-card .store { font-weight: 700; }
.otp-card .mail { color: var(--muted); font-size: 12px; }
.otp-code {
  font-family: var(--mono); font-size: 34px; letter-spacing: 6px;
  font-weight: 700; color: var(--primary); display: flex; align-items: center;
  gap: 12px; flex-wrap: wrap;
}
.otp-code.empty { color: #cbd5e1; font-size: 18px; letter-spacing: 0; }
.otp-meta { font-size: 12px; color: var(--muted); }
.otp-meta .fresh { color: var(--ok); font-weight: 600; }
.otp-meta .stale { color: var(--warn); }

/* ---------- 抽屉(邮件详情) ---------- */
.drawer-mask { position: fixed; inset: 0; background: rgba(16,24,39,.45); z-index: 60; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(680px, 92vw);
  background: var(--panel); z-index: 61; box-shadow: -12px 0 40px rgba(16,24,39,.18);
  display: flex; flex-direction: column;
}
.drawer-head { padding: 16px 20px 12px; border-bottom: 1px solid var(--line); }
.drawer-head h3 { font-size: 16px; margin: 0 0 8px; word-break: break-all; }
.drawer-head .meta { color: var(--muted); font-size: 12px; display: flex;
                     flex-direction: column; gap: 2px; word-break: break-all; }
.drawer-body { flex: 1; overflow: auto; padding: 16px 20px; }
.drawer-body pre.body-text {
  white-space: pre-wrap; word-break: break-word; font-family: inherit;
  font-size: 14px; margin: 0;
}
.drawer-body iframe.html-view { width: 100%; height: 60vh; border: 1px solid var(--line);
                                border-radius: 8px; background: #fff; }
.drawer-actions { padding: 10px 20px; border-top: 1px solid var(--line);
                  display: flex; gap: 10px; }

/* ---------- 模态 ---------- */
.modal {
  position: fixed; z-index: 70; left: 50%; top: 12vh; transform: translateX(-50%);
  width: min(560px, 92vw); background: var(--panel); border-radius: 14px;
  box-shadow: var(--shadow); padding: 22px 24px; max-height: 78vh; overflow: auto;
}
.modal h3 { margin-bottom: 16px; }
.modal .field { margin-bottom: 14px; }
.modal .field label { display: block; font-weight: 500; margin-bottom: 5px; }
.modal .field input, .modal .field select { width: 100%; }
.modal .field .hint { color: var(--muted); font-size: 12px; margin-top: 3px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.key-reveal {
  background: #0f172a; color: #a5f3fc; font-family: var(--mono);
  padding: 14px; border-radius: 8px; word-break: break-all; margin: 10px 0;
}

/* ---------- 提示 ---------- */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 90;
          display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #101827; color: #f9fafb; padding: 10px 16px; border-radius: 10px;
  box-shadow: var(--shadow); font-size: 13px; max-width: 420px;
  animation: slide-in .18s ease-out;
}
.toast.error { background: var(--danger); }
@keyframes slide-in { from { transform: translateY(8px); opacity: 0; }
                      to { transform: none; opacity: 1; } }

/* ---------- 空态 ---------- */
.empty { padding: 46px 20px; text-align: center; color: var(--muted); }

@media (max-width: 760px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; padding: 8px; }
  .brand { padding: 0 8px; }
  #nav { flex-direction: row; flex: 1; overflow-x: auto; }
  #nav a { white-space: nowrap; }
  .sidebar-footer { flex-direction: row; }
  .sync-meta { display: none; }
  .main { padding: 14px; }
}
