/* ============================================================
   Outlook 邮件管理 — 现代国风设计系统
   主色：砖红 / 墨绿 / 金黄 / 宣纸米白
   ============================================================ */

/* ---------- CSS 变量 ---------- */
:root {
  --clr-primary:        #B85C38;
  --clr-primary-dark:   #8E3E22;
  --clr-primary-light:  #D4795A;
  --clr-accent:         #C8963E;
  --clr-jade:           #3A7D44;
  --clr-jade-light:     #5AA35F;
  --clr-danger:         #C0392B;
  --clr-success:        #27AE60;
  --clr-warn:           #E67E22;

  --bg:                 #F5EDE0;
  --bg-card:            #FDFAF5;
  --bg-sidebar:         #2C1A0E;
  --text:               #2C1810;
  --text-secondary:     #6B4226;
  --text-muted:         #9E7A5A;
  --border:             #D9C4A8;
  --border-light:       #EDE0CE;
  --bg-hover:           rgba(184,92,56,0.06);
  --shadow:             rgba(44, 24, 16, 0.12);

  --font-sans: 'PingFang SC', 'Noto Sans SC', 'Microsoft YaHei', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', Consolas, 'Courier New', monospace;

  --radius:     10px;
  --radius-sm:  6px;
  --transition: 0.22s ease;
  --sidebar-w:  220px;
}

[data-theme="dark"] {
  --bg:             #1A1208;
  --bg-card:        #241A0F;
  --bg-sidebar:     #120C04;
  --text:           #EDD9BE;
  --text-secondary: #C9A97A;
  --text-muted:     #8C7058;
  --border:         #3D2C1E;
  --border-light:   #2E2014;
  --bg-hover:        rgba(184,92,56,0.1);
  --shadow:         rgba(0, 0, 0, 0.4);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
  line-height: 1.6;
}
a { color: var(--clr-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

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

/* ===== 登录页 ===== */
#auth-page {
  flex: 1; display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--bg); position: relative; overflow: hidden;
}
#auth-page::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 60% 50% at 80% 20%, rgba(184, 92, 56, 0.12) 0%, transparent 60%),
    radial-gradient(ellipse 40% 40% at 20% 80%, rgba(58, 125, 68, 0.10) 0%, transparent 55%);
}
.auth-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 2.5rem 2.2rem; width: 100%; max-width: 420px;
  box-shadow: 0 8px 40px var(--shadow); position: relative; z-index: 1;
}
.auth-logo { text-align: center; margin-bottom: 1.8rem; }
.auth-logo .logo-icon {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--clr-primary), var(--clr-accent));
  border-radius: 14px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.6rem; margin-bottom: 0.7rem;
  box-shadow: 0 4px 16px rgba(184,92,56,0.35);
}
.auth-logo h1 { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.auth-logo p  { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.2rem; }

/* ===== Sidebar ===== */
#main-layout { display: flex; flex: 1; }

.sidebar {
  width: var(--sidebar-w); min-height: 100vh; background: var(--bg-sidebar);
  display: flex; flex-direction: column; flex-shrink: 0;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  transition: width 0.25s ease;
}
.sidebar-logo {
  padding: 1.4rem 1.2rem 1rem; border-bottom: 1px solid rgba(255,255,255,0.07);
  display: flex; align-items: center; gap: 0.7rem;
}
.sidebar-logo .logo-mark {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--clr-primary), var(--clr-accent));
  border-radius: 9px; display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0;
}
.sidebar-logo span { font-size: 1.05rem; font-weight: 700; color: #FAEBD7; letter-spacing: 0.02em; }
.sidebar-logo small { display: block; font-size: 0.65rem; color: rgba(250,235,215,0.45); margin-top: -2px; }

.sidebar-nav { flex: 1; padding: 0.8rem 0; }
.nav-section {
  padding: 0.5rem 1rem 0.2rem; font-size: 0.68rem; font-weight: 600;
  letter-spacing: 0.1em; color: rgba(250,235,215,0.35); text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.55rem 1.2rem; font-size: 0.875rem;
  color: rgba(250,235,215,0.65); border: none; background: none;
  width: 100%; text-align: left; cursor: pointer; border-radius: 0;
  transition: color var(--transition), background var(--transition); position: relative;
}
.nav-item:hover { color: #FAEBD7; background: rgba(255,255,255,0.06); }
.nav-item.active { color: #FAEBD7; background: rgba(184,92,56,0.22); }
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--clr-primary); border-radius: 0 2px 2px 0;
}
.nav-item .nav-icon { width: 18px; text-align: center; font-size: 0.95rem; }

.sidebar-bottom { padding: 0.8rem 1rem; border-top: 1px solid rgba(255,255,255,0.07); }
.user-chip {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.5rem 0.7rem; background: rgba(255,255,255,0.06);
  border-radius: var(--radius-sm); margin-bottom: 0.5rem;
}
.user-avatar {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, var(--clr-primary), var(--clr-accent));
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; color: white; flex-shrink: 0;
}
.user-chip-info { overflow: hidden; }
.user-chip-name { font-size: 0.8rem; color: #FAEBD7; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip-role { font-size: 0.65rem; color: rgba(250,235,215,0.4); }

.btn-logout {
  width: 100%; padding: 0.45rem;
  background: rgba(184,92,56,0.2); border: 1px solid rgba(184,92,56,0.35);
  border-radius: var(--radius-sm); color: rgba(250,235,215,0.7); font-size: 0.78rem;
  transition: all var(--transition);
}
.btn-logout:hover { background: rgba(184,92,56,0.35); color: #FAEBD7; }
.btn-github {
  width: 100%; padding: 0.45rem;
  background: rgba(88,166,255,0.15); border: 1px solid rgba(88,166,255,0.3);
  border-radius: var(--radius-sm); color: rgba(88,166,255,0.9); font-size: 0.78rem;
  margin-top: 0.4rem; transition: all var(--transition);
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  text-decoration: none;
}
.btn-github:hover { background: rgba(88,166,255,0.25); color: #58A6FF; }
.btn-github svg { flex-shrink: 0; }
.btn-theme {
  width: 100%; padding: 0.45rem;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm); color: rgba(250,235,215,0.55); font-size: 0.78rem;
  margin-top: 0.4rem; transition: all var(--transition);
}
.btn-theme:hover { background: rgba(255,255,255,0.12); color: #FAEBD7; }

/* ===== Content Area ===== */
.content { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow-x: hidden; }

.topbar {
  background: var(--bg-card); border-bottom: 1px solid var(--border);
  padding: 0.8rem 1.8rem; display: flex; align-items: center;
  justify-content: space-between; gap: 1rem; flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.topbar-title { font-size: 1.05rem; font-weight: 700; color: var(--text); }
.topbar-subtitle { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.05rem; }
#topbar-actions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

.page { flex: 1; padding: 1.8rem; overflow-y: auto; }
.page.page-no-padding { padding: 0; overflow: hidden; }
.page-hidden { display: none !important; }

/* ===== 三栏主布局（账号管理页） ===== */
.mailbox-layout { display: flex; height: calc(100vh - 52px); gap: 0; }

.groups-column {
  width: 220px; flex-shrink: 0; background: var(--bg-card);
  border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden;
}
.accounts-column {
  width: 280px; flex-shrink: 0; background: var(--bg);
  border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden;
}
.emails-column {
  flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden;
}

/* Resize handles */
.resize-handle {
  width: 4px; flex-shrink: 0; cursor: col-resize; background: transparent;
  position: relative; z-index: 5; transition: background 0.2s;
}
.resize-handle:hover, .resize-handle.active {
  background: var(--clr-primary);
}
.resize-handle::after {
  content: ''; position: absolute; top: 0; bottom: 0; left: -3px; right: -3px;
}

.column-header {
  padding: 0.8rem 1rem; border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  flex-shrink: 0;
}
.column-title { font-size: 0.9rem; font-weight: 600; color: var(--text); }
.column-search {
  padding: 0.5rem 1rem; border-bottom: 1px solid var(--border-light); flex-shrink: 0;
}
.column-search input {
  width: 100%; padding: 0.45rem 0.7rem; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-size: 0.82rem; outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.column-search input:focus {
  border-color: var(--clr-primary); box-shadow: 0 0 0 3px rgba(184,92,56,0.15);
}
.column-body { flex: 1; overflow-y: auto; }

/* ===== 通用组件 ===== */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 2px 10px var(--shadow);
}
.card-header {
  padding: 1rem 1.3rem; border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 0.5rem;
}
.card-title {
  font-size: 0.95rem; font-weight: 600; color: var(--text);
  display: flex; align-items: center; gap: 0.5rem;
}
.card-body { padding: 1.3rem; }

/* stat-cards (Dashboard) */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem; margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.3rem; display: flex; flex-direction: column; gap: 0.4rem;
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px var(--shadow); }
.stat-label { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--text); line-height: 1; }
.stat-note  { font-size: 0.72rem; color: var(--text-muted); }
.stat-card.stat-success { border-left: 3px solid var(--clr-jade); }
.stat-card.stat-danger  { border-left: 3px solid var(--clr-danger); }
.stat-card.stat-accent  { border-left: 3px solid var(--clr-accent); }

/* Dashboard 两列布局 */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.dashboard-grid .card { overflow: hidden; }
.dashboard-list { list-style: none; }
.dashboard-list li {
  padding: 0.6rem 1rem; border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.85rem;
}
.dashboard-list li:last-child { border-bottom: none; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 1rem; border-radius: var(--radius-sm);
  font-size: 0.85rem; font-weight: 500; border: none;
  transition: all var(--transition); white-space: nowrap; cursor: pointer;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--clr-primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--clr-primary-dark); }
.btn-success { background: var(--clr-jade); color: white; }
.btn-success:hover:not(:disabled) { background: #2D6035; }
.btn-accent  { background: var(--clr-accent); color: white; }
.btn-accent:hover:not(:disabled)  { background: #A67E3A; }
.btn-danger  { background: var(--clr-danger); color: white; }
.btn-danger:hover:not(:disabled)  { background: #992B20; }
.btn-ghost {
  background: transparent; color: var(--text-secondary); border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--border-light); color: var(--text); }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.78rem; }
.btn-icon { padding: 0.4rem; font-size: 0.9rem; background: none; border: none; color: var(--text-muted); border-radius: var(--radius-sm); }
.btn-icon:hover { background: var(--border-light); color: var(--text); }

/* 表单 */
.form-group { margin-bottom: 1.1rem; }
.form-label { display: block; font-size: 0.82rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 0.4rem; }
.form-input {
  display: block; width: 100%; padding: 0.6rem 0.85rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-size: 0.88rem; outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-input:focus { border-color: var(--clr-primary); box-shadow: 0 0 0 3px rgba(184,92,56,0.15); }
.form-select {
  display: block; width: 100%; padding: 0.6rem 0.85rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-size: 0.88rem; outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-select:focus { border-color: var(--clr-primary); box-shadow: 0 0 0 3px rgba(184,92,56,0.15); }
textarea.form-input {
  min-height: 160px; resize: vertical; font-family: 'Courier New', monospace; font-size: 0.82rem;
}
.form-hint { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.3rem; }
.form-error { font-size: 0.72rem; color: var(--clr-danger); margin-top: 0.3rem; }

/* Color Picker */
.color-picker-group { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 0.5rem; }
.color-option {
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; transition: transform 0.15s, border-color 0.15s;
}
.color-option:hover { transform: scale(1.15); }
.color-option.selected { border-color: var(--text); transform: scale(1.15); }
.custom-color-row { display: flex; align-items: center; gap: 8px; margin-top: 0.5rem; }
.custom-color-input { width: 36px; height: 30px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; padding: 0; }
.custom-color-label { font-size: 0.8rem; color: var(--text-secondary); }
.custom-color-hex { width: 90px; padding: 4px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 0.82rem; color: var(--text); background: var(--bg); }

/* Badge */
.badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.2rem 0.55rem; border-radius: 100px; font-size: 0.7rem; font-weight: 600;
}
.badge-green { background: rgba(58,125,68,0.15); color: var(--clr-jade); }
.badge-red   { background: rgba(192,57,43,0.15); color: var(--clr-danger); }
.badge-gold  { background: rgba(200,150,62,0.15); color: var(--clr-accent); }
.badge-gray  { background: rgba(0,0,0,0.07); color: var(--text-muted); }
[data-theme="dark"] .badge-gray { background: rgba(255,255,255,0.08); }
.badge-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 10px; font-size: 0.68rem; font-weight: 600;
  background: var(--border-light); color: var(--text-muted);
}

/* ===== 分组列表 ===== */
.group-item {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.6rem 1rem; cursor: pointer;
  transition: background var(--transition); border-left: 3px solid transparent;
}
.group-item:hover { background: rgba(184,92,56,0.06); }
.group-item.active {
  background: rgba(184,92,56,0.1); border-left-color: var(--clr-primary);
}
.group-color-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.group-name { flex: 1; font-size: 0.85rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-count { font-size: 0.72rem; color: var(--text-muted); flex-shrink: 0; }
.group-actions { display: flex; gap: 2px; opacity: 0; transition: opacity var(--transition); }
.group-item:hover .group-actions { opacity: 1; }

/* ===== 账号列表（卡片式） ===== */
.account-card {
  margin: 0.5rem 0.6rem; padding: 0.8rem 1rem;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  position: relative; overflow: hidden;
}
.account-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--clr-primary), var(--clr-accent));
  opacity: 0; transition: opacity var(--transition);
}
.account-card:hover { border-color: var(--clr-primary-light); box-shadow: 0 4px 16px rgba(184,92,56,0.12); transform: translateY(-1px); }
.account-card:hover::before { opacity: 1; }
.account-card.active { border-color: var(--clr-primary); background: rgba(184,92,56,0.04); }
.account-card.active::before { opacity: 1; }

.account-card-top { display: flex; align-items: flex-start; gap: 0.7rem; }
.account-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--clr-accent), var(--clr-primary));
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; color: white; font-weight: 600;
}
.account-info { flex: 1; min-width: 0; }
.account-email { font-family: var(--font-mono); font-size: 0.8rem; color: var(--clr-primary); font-weight: 600; word-break: break-all; }
.account-group-name { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.15rem; }
.account-token-badge { position: absolute; top: 0.6rem; right: 0.6rem; }

.account-card-bottom {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 0.6rem; padding-top: 0.5rem; border-top: 1px solid var(--border-light);
  font-size: 0.72rem; color: var(--text-muted);
}
.account-meta { display: flex; align-items: center; gap: 0.5rem; }
.account-api-tag {
  padding: 0.1rem 0.4rem; border-radius: 3px; font-size: 0.65rem; font-weight: 600;
  background: rgba(184,92,56,0.08); color: var(--clr-primary);
}
.account-actions {
  display: flex; gap: 2px; opacity: 0; transition: opacity var(--transition);
}
.account-card:hover .account-actions { opacity: 1; }
.account-select-checkbox { margin-right: 0.3rem; }

/* 批量操作栏 */
.batch-action-bar {
  padding: 0.6rem 1rem; background: var(--bg-card); border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; flex-wrap: wrap;
}
.batch-action-bar .btn { font-size: 0.78rem; padding: 0.3rem 0.6rem; }

/* ===== 邮件列表 ===== */
.email-tabs {
  display: flex; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.email-tab {
  padding: 0.6rem 1.2rem; font-size: 0.85rem; font-weight: 500;
  color: var(--text-muted); background: none; border: none;
  border-bottom: 2px solid transparent; cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}
.email-tab.active { color: var(--clr-primary); border-bottom-color: var(--clr-primary); }
.email-tab .tab-count {
  margin-left: 0.3rem; padding: 0.1rem 0.4rem; border-radius: 8px;
  font-size: 0.68rem; background: var(--clr-danger); color: white;
}

.email-item {
  display: flex; align-items: flex-start; gap: 0.9rem;
  padding: 0.85rem 1.2rem; border-bottom: 1px solid var(--border-light);
  cursor: pointer; transition: background var(--transition);
}
.email-item:last-child { border-bottom: none; }
.email-item:hover { background: rgba(184,92,56,0.05); }
.email-item.active { background: rgba(184,92,56,0.08); }
.email-item.unread { background: rgba(184,92,56,0.04); }
.email-item.unread .email-from { font-weight: 700; }

.email-avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--clr-accent), var(--clr-primary));
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; color: white;
}
.email-meta { flex: 1; min-width: 0; }
.email-from { font-size: 0.85rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.email-subject { font-size: 0.82rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 0.1rem; }
.email-preview { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 0.1rem; }
.email-time { font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; flex-shrink: 0; margin-top: 0.1rem; }
.email-unread-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--clr-primary);
  flex-shrink: 0; margin-top: 0.3rem;
}

/* 邮件详情 */
#emailDetailSection {
  flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}
.email-detail-container { flex: 1; overflow-y: auto; background: var(--bg-card); }
.email-detail-header { padding: 1.3rem; border-bottom: 1px solid var(--border); }
.email-subject-big { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.7rem; color: var(--text); }
.email-info-row { display: flex; gap: 0.4rem; font-size: 0.82rem; color: var(--text-secondary); flex-wrap: wrap; align-items: center; }
.email-info-row strong { color: var(--text); }
.email-body-frame {
  width: 100%; border: none; min-height: 400px; background: white;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}
.email-body-text {
  padding: 1.3rem; font-size: 0.88rem; white-space: pre-wrap;
  color: var(--text); line-height: 1.8; font-family: var(--font-mono);
}
.email-detail-toolbar {
  padding: 0.6rem 1rem; border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--bg-card); flex-shrink: 0; position: sticky; top: 0; z-index: 2;
}
.email-detail-toolbar .btn { font-size: 0.78rem; }

/* 验证码高亮框 */
.verification-code-box {
  margin: 0.8rem 1.3rem; padding: 1rem 1.2rem;
  background: rgba(58,125,68,0.08); border: 1px solid rgba(58,125,68,0.25);
  border-radius: var(--radius); display: flex; align-items: center;
  justify-content: space-between; gap: 1rem;
}
.verification-code {
  font-size: 1.8rem; font-weight: 700; font-family: var(--font-mono);
  color: var(--clr-jade); letter-spacing: 0.15em;
}

/* ===== 临时邮箱（邮箱卡片网格） ===== */
.mailbox-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem;
}
.mailbox-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  position: relative; overflow: hidden;
}
.mailbox-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--clr-primary), var(--clr-accent));
  opacity: 0; transition: opacity var(--transition);
}
.mailbox-card:hover { border-color: var(--clr-primary); box-shadow: 0 4px 20px rgba(184,92,56,0.15); transform: translateY(-2px); }
.mailbox-card:hover::before { opacity: 1; }
.mailbox-address { font-family: var(--font-mono); font-size: 0.82rem; color: var(--clr-primary); font-weight: 600; word-break: break-all; }
.mailbox-stats { font-size: 0.76rem; color: var(--text-muted); margin-top: 0.4rem; }
.mailbox-actions { display: flex; gap: 0.5rem; margin-top: 0.8rem; flex-wrap: wrap; }

/* ===== 进度条（全量刷新） ===== */
.refresh-progress-bar {
  background: var(--bg-card); border-bottom: 1px solid var(--border);
  padding: 0.6rem 1.8rem; display: flex; align-items: center; gap: 1rem;
  font-size: 0.82rem; color: var(--text-secondary);
}
.refresh-progress-bar .progress-track {
  flex: 1; height: 8px; background: var(--border-light); border-radius: 4px; overflow: hidden;
}
.refresh-progress-bar .progress-fill {
  height: 100%; background: linear-gradient(90deg, var(--clr-jade), var(--clr-jade-light));
  border-radius: 4px; transition: width 0.3s ease;
}
.refresh-progress-bar .progress-text { font-size: 0.78rem; white-space: nowrap; }

/* ===== Toast ===== */
#toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999;
  display: flex; flex-direction: column; gap: 0.5rem; pointer-events: none;
}
.toast {
  min-width: 220px; max-width: 340px; padding: 0.7rem 1rem;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: 0 4px 20px var(--shadow); font-size: 0.84rem; color: var(--text);
  display: flex; align-items: center; gap: 0.6rem;
  pointer-events: auto; animation: slideIn 0.25s ease;
  border-left: 3px solid var(--clr-primary);
}
.toast.success { border-left-color: var(--clr-success); }
.toast.error   { border-left-color: var(--clr-danger); }
.toast.warn    { border-left-color: var(--clr-warn); }
@keyframes slideIn {
  from { transform: translateX(30px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 1rem; backdrop-filter: blur(2px);
}
/* .modal as overlay (existing modals.html pattern) */
.modal {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.45);
  display: none; align-items: center; justify-content: center;
  z-index: 1000; padding: 1rem; backdrop-filter: blur(2px);
}
.modal.show { display: flex; }
.modal-content, .modal > .modal-box {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.8rem; max-width: 560px; width: 100%; margin: 0 auto;
  box-shadow: 0 12px 60px var(--shadow); position: relative; max-height: 90vh; overflow-y: auto;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.modal-header h3 { font-size: 1.05rem; font-weight: 700; color: var(--text); margin: 0; }
.modal-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 1.2rem; color: var(--text); }
.modal-close {
  position: absolute; top: 1rem; right: 1rem;
  background: none; border: none; font-size: 1.2rem;
  color: var(--text-muted); cursor: pointer; line-height: 1;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--text); }
.modal-body { margin-bottom: 1rem; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1.3rem;
  padding-top: 1rem; border-top: 1px solid var(--border-light);
}

/* Fullscreen Email Modal */
.fullscreen-email-modal {
  position: fixed; inset: 0; background: var(--bg-card); z-index: 2000;
  display: none; flex-direction: column;
}
.fullscreen-email-modal.show { display: flex; }
.fullscreen-email-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.5rem; border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}
.fullscreen-email-title { font-size: 1rem; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fullscreen-close-btn {
  background: none; border: none; font-size: 1.5rem; color: var(--text-muted);
  cursor: pointer; padding: 0.2rem 0.5rem; border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.fullscreen-close-btn:hover { background: var(--bg-hover); color: var(--text); }
.fullscreen-email-content { flex: 1; overflow-y: auto; padding: 1.5rem; }
.fullscreen-email-content iframe { width: 100%; border: none; }

/* Utilities */
.text-muted { color: var(--text-muted); }
.hidden { display: none !important; }
.show { display: block !important; }

/* ===== Missing Component Styles ===== */

/* Buttons — secondary/warning */
.btn-secondary {
  background: var(--bg); color: var(--text-secondary); border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--border-light); color: var(--text); }
.btn-warning { background: var(--clr-warn); color: white; }
.btn-warning:hover:not(:disabled) { background: #CF6D11; }

/* Email checkbox */
.email-checkbox-wrapper {
  display: flex; align-items: center; justify-content: center;
  width: 28px; flex-shrink: 0; cursor: pointer;
}
.email-checkbox { width: 16px; height: 16px; cursor: pointer; accent-color: var(--clr-primary); }

/* Email detail view */
.email-detail-subject { font-size: 1.1rem; font-weight: 700; color: var(--text); margin-bottom: 0.8rem; }
.email-detail-meta { font-size: 0.82rem; color: var(--text-secondary); }
.email-detail-meta-row { display: flex; gap: 0.6rem; align-items: baseline; margin-bottom: 0.35rem; }
.email-detail-meta-label { font-weight: 600; color: var(--text-muted); min-width: 50px; flex-shrink: 0; }
.email-detail-meta-value { color: var(--text); word-break: break-all; }
.email-detail-body { padding: 1rem; }
.email-detail-body iframe { width: 100%; border: none; min-height: 300px; }
#emailBodyFrame { width: 100%; border: none; min-height: 300px; background: #fff; }

/* Sort buttons */
.sort-btn {
  padding: 0.3rem 0.7rem; font-size: 0.78rem; border-radius: var(--radius-sm);
  background: var(--bg); border: 1px solid var(--border); color: var(--text-secondary);
  cursor: pointer; transition: all var(--transition);
}
.sort-btn:hover { border-color: var(--clr-primary-light); color: var(--clr-primary); }
.sort-btn.active {
  background: var(--clr-primary); border-color: var(--clr-primary); color: white;
}

/* Folder tabs */
.folder-tab {
  padding: 0.45rem 1rem; font-size: 0.82rem; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg); color: var(--text-secondary);
  cursor: pointer; transition: all var(--transition);
}
.folder-tab.active { background: var(--clr-primary); border-color: var(--clr-primary); color: white; }

/* Refresh button */
.refresh-btn {
  padding: 0.45rem 0.9rem; font-size: 0.82rem; border-radius: var(--radius-sm);
  background: var(--clr-jade); border: none; color: white; cursor: pointer;
  transition: all var(--transition);
}
.refresh-btn:hover:not(:disabled) { background: #2D6035; }
.refresh-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Error detail modal content */
.error-card {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 1rem; margin-bottom: 0.8rem;
}
.error-card-title { font-size: 0.88rem; font-weight: 600; color: var(--text); margin-bottom: 0.4rem; }
.error-message-box {
  background: rgba(192,57,43,0.06); border: 1px solid rgba(192,57,43,0.2);
  border-radius: var(--radius-sm); padding: 0.6rem 0.8rem;
  font-family: var(--font-mono); font-size: 0.78rem; color: var(--clr-danger);
  word-break: break-all;
}
.solution-list { list-style: none; padding: 0; margin-top: 0.5rem; }
.solution-list li { padding: 0.3rem 0; font-size: 0.82rem; color: var(--text-secondary); }
.solution-list li::before { content: '💡 '; }

/* Tag badge (legacy compat) */
.tag-badge {
  display: inline-flex; padding: 0.12rem 0.45rem; border-radius: 100px;
  font-size: 0.65rem; font-weight: 500; color: white;
}

/* Tag filter checkbox */
.tag-filter-checkbox { accent-color: var(--clr-primary); cursor: pointer; }

/* New email indicator dot */
.new-email-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--clr-danger);
  position: absolute; top: 6px; right: 6px;
  animation: pulse-dot 1.5s infinite;
}
.new-email-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 18px; height: 18px; padding: 0 4px;
  background: var(--clr-danger); color: white;
  border-radius: 9px; font-size: 0.65rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Form compat (Bootstrap-style fallback) */
.form-control {
  display: block; width: 100%; padding: 0.6rem 0.85rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-size: 0.88rem; outline: none;
}
.form-control:focus { border-color: var(--clr-primary); box-shadow: 0 0 0 3px rgba(184,92,56,0.15); }
.form-textarea { min-height: 180px; resize: vertical; font-family: var(--font-mono); font-size: 0.84rem; line-height: 1.6; padding: 0.75rem 0.9rem; width: 100%; display: block; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); outline: none; transition: border-color var(--transition), box-shadow var(--transition); }
.form-textarea:focus { border-color: var(--clr-primary); box-shadow: 0 0 0 3px rgba(184,92,56,0.15); }

/* 表格 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
th {
  text-align: left; padding: 0.65rem 1rem; font-size: 0.72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted);
  background: var(--bg); border-bottom: 1px solid var(--border);
}
td { padding: 0.7rem 1rem; border-bottom: 1px solid var(--border-light); color: var(--text); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(184,92,56,0.04); }

/* 空状态 */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 0.8rem; display: block; }
.empty-state p { font-size: 0.88rem; }
.empty-state .btn { margin-top: 1rem; }

/* loading spinner */
.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid var(--border); border-top-color: var(--clr-primary);
  border-radius: 50%; animation: spin 0.7s linear infinite; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay {
  display: flex; align-items: center; justify-content: center;
  padding: 2rem; color: var(--text-muted); font-size: 0.85rem; gap: 0.5rem;
}

/* toggle switch */
.toggle-wrap { display: flex; align-items: center; gap: 0.8rem; padding: 0.8rem 0; }
.toggle-label { font-size: 0.88rem; color: var(--text); }
.toggle-desc  { font-size: 0.75rem; color: var(--text-muted); display: block; margin-top: 0.15rem; }
.toggle { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--border); border-radius: 12px; transition: background var(--transition);
}
.toggle-slider::before {
  content: ''; position: absolute; width: 18px; height: 18px;
  left: 3px; bottom: 3px; background: white; border-radius: 50%;
  transition: transform var(--transition);
}
.toggle input:checked + .toggle-slider { background: var(--clr-jade); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* divider */
.divider { height: 1px; background: var(--border); margin: 1.2rem 0; }

/* code-box */
.code-box {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem; font-family: var(--font-mono); font-size: 0.8rem;
  color: var(--clr-primary); word-break: break-all;
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
}
.copy-btn {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  padding: 0.2rem; border-radius: 4px; transition: color var(--transition);
  flex-shrink: 0; font-size: 0.85rem;
}
.copy-btn:hover { color: var(--clr-primary); }

/* 颜色选择器 */
.custom-color-wrapper { display: flex; align-items: center; gap: 0.5rem; }
.custom-color-hex {
  width: 80px; padding: 0.4rem 0.6rem; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.82rem; font-family: var(--font-mono); color: var(--text);
}

/* tag styles */
.tag {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.15rem 0.5rem; border-radius: 100px; font-size: 0.68rem;
  font-weight: 500; background: var(--border-light); color: var(--text-secondary);
}
.tag-remove { cursor: pointer; font-size: 0.75rem; color: var(--text-muted); }
.tag-remove:hover { color: var(--clr-danger); }

/* ===== 汉堡按钮 ===== */
.hamburger-btn {
  display: inline-flex; align-items: center; background: none; border: none; color: var(--text);
  font-size: 1.35rem; line-height: 1; padding: 0.3rem 0.45rem;
  cursor: pointer; border-radius: var(--radius-sm); transition: background var(--transition);
  flex-shrink: 0;
}
.hamburger-btn:hover { background: var(--border-light); }

/* Sidebar collapsed state (desktop) */
.sidebar-collapsed .sidebar {
  width: 60px; overflow: hidden;
}
.sidebar-collapsed .sidebar .nav-item span:not(.nav-icon),
.sidebar-collapsed .sidebar-logo span,
.sidebar-collapsed .sidebar-logo small,
.sidebar-collapsed .user-chip-info,
.sidebar-collapsed .nav-section { display: none; }
.sidebar-collapsed .sidebar-logo { justify-content: center; padding: 1rem 0.5rem; }
.sidebar-collapsed .sidebar .nav-item { justify-content: center; padding: 0.7rem; }
.sidebar-collapsed .sidebar .nav-item .nav-icon { font-size: 1.15rem; }
.sidebar-collapsed .sidebar-bottom { padding: 0.5rem; }
.sidebar-collapsed .sidebar .user-chip { justify-content: center; }

.sidebar-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.45); z-index: 199; backdrop-filter: blur(1px);
}
.sidebar-backdrop.show { display: block; }

/* ===== 响应式：平板（icon-only 侧边栏） ===== */
@media (max-width: 1024px) and (min-width: 769px) {
  .sidebar { width: 60px; overflow: hidden; }
  .sidebar .nav-item span:not(.nav-icon),
  .sidebar-logo span, .sidebar-logo small,
  .user-chip-info, .nav-section { display: none; }
  .sidebar-logo { justify-content: center; padding: 1rem 0.5rem; }
  .nav-item { justify-content: center; padding: 0.7rem; }
  .sidebar-bottom { padding: 0.5rem; }
  .user-chip { justify-content: center; }
  .btn-logout, .btn-github, .btn-theme { font-size: 0; padding: 0.45rem 0; }
  .page { padding: 1rem; }
  .groups-column { width: 180px; }
  .accounts-column { width: 240px; }
}

/* ===== 响应式：手机（抽屉式侧边栏） ===== */
@media (max-width: 768px) {
  .hamburger-btn { display: inline-flex; align-items: center; }

  .sidebar {
    position: fixed !important; left: -240px !important;
    width: 220px !important; z-index: 200; height: 100vh;
    transition: left 0.25s ease; overflow-y: auto; overflow-x: hidden;
  }
  .sidebar.mob-open { left: 0 !important; box-shadow: 6px 0 30px rgba(0,0,0,0.5); }
  .sidebar .nav-item span, .sidebar-logo span, .sidebar-logo small,
  .user-chip-info, .nav-section { display: block !important; }
  .sidebar-logo { justify-content: flex-start !important; padding: 1.4rem 1.2rem 1rem !important; }
  .nav-item { justify-content: flex-start !important; padding: 0.55rem 1.2rem !important; gap: 0.65rem !important; }
  .sidebar-bottom { padding: 0.8rem 1rem !important; }
  .user-chip { justify-content: flex-start !important; }
  .btn-logout, .btn-theme { font-size: 0.78rem !important; padding: 0.45rem !important; }

  .content { width: 100vw; min-width: 0; }
  .topbar { padding: 0.6rem 0.85rem; gap: 0.4rem; }
  .topbar-title { font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .page { padding: 0.85rem; }

  .mailbox-layout { flex-direction: column; height: auto; }
  .groups-column { width: 100%; height: auto; max-height: 200px; border-right: none; border-bottom: 1px solid var(--border); }
  .accounts-column { width: 100%; height: auto; max-height: 300px; border-right: none; border-bottom: 1px solid var(--border); }
  .emails-column { width: 100%; }

  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 0.65rem; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .mailbox-grid { grid-template-columns: 1fr; }

  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    border-radius: var(--radius) var(--radius) 0 0;
    max-height: 88vh; max-width: 100%; padding: 1.4rem 1.2rem 2rem;
  }

  #toast-container { bottom: 0.8rem; right: 0.8rem; left: 0.8rem; }
  .toast { max-width: 100%; min-width: 0; }
}

/* 装饰纹路 (国风) */
.grain-bg {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4'%3E%3Crect width='1' height='1' fill='%23000' opacity='.03'/%3E%3C/svg%3E");
}

/* ===== 兼容旧版 class 名（过渡用） ===== */
.navbar { display: none; }
