:root {
  color-scheme: dark;
  --bg: #0b1120;
  --surface: #111a2d;
  --surface-raised: #172238;
  --border: #293750;
  --text: #f8fafc;
  --muted: #aab7ca;
  --faint: #74839b;
  --green: #34d399;
  --green-dark: #064e3b;
  --blue: #60a5fa;
  --amber: #fbbf24;
  --red: #fb7185;
  --shadow: 0 18px 45px rgb(0 0 0 / 22%);
  font-family: Inter, "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 78% -10%, rgb(37 99 235 / 17%), transparent 32rem),
    var(--bg);
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }

.shell { width: min(1440px, 100%); margin: 0 auto; padding: 0 32px 48px; }
.topbar { min-height: 96px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; color: var(--green); background: rgb(52 211 153 / 9%); border: 1px solid rgb(52 211 153 / 24%); border-radius: 12px; }
.brand-mark svg { width: 24px; }
.brand h1 { margin: 0; font-size: 18px; line-height: 1.2; letter-spacing: .01em; }
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.live-state { display: inline-flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; font-weight: 600; }
.logout-button { margin-left: 8px; padding: 6px 10px; color: var(--muted); background: transparent; border: 1px solid var(--border); border-radius: 8px; font-size: 11px; }
.logout-button:hover { color: var(--text); background: var(--surface-raised); }
.state-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); box-shadow: 0 0 0 4px rgb(116 131 155 / 12%); }
.state-dot.running { background: var(--green); box-shadow: 0 0 0 4px rgb(52 211 153 / 13%), 0 0 15px rgb(52 211 153 / 55%); }
.state-dot.error { background: var(--red); box-shadow: 0 0 0 4px rgb(251 113 133 / 12%); }

.panel { background: linear-gradient(145deg, rgb(23 34 56 / 96%), rgb(15 24 42 / 96%)); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); }
.hero { min-height: 210px; padding: 34px 38px; display: flex; align-items: center; justify-content: space-between; gap: 36px; overflow: hidden; position: relative; }
.hero::after { content: ""; position: absolute; width: 320px; height: 320px; right: -170px; top: -170px; border-radius: 50%; background: rgb(52 211 153 / 7%); border: 1px solid rgb(52 211 153 / 12%); pointer-events: none; }
.eyebrow { margin: 0 0 10px; color: var(--green); font-size: 11px; line-height: 1; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.hero h2 { margin: 0; font-size: clamp(28px, 4vw, 42px); letter-spacing: -.035em; }
.hero-description { max-width: 620px; margin: 15px 0 0; color: var(--muted); font-size: 14px; line-height: 1.75; }
.actions { width: min(430px, 100%); position: relative; z-index: 1; }
.check-row { display: flex; gap: 12px; align-items: flex-start; padding: 13px 15px; background: rgb(8 15 29 / 48%); border: 1px solid var(--border); border-radius: 12px; cursor: pointer; }
.check-row input { width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--green); cursor: pointer; }
.check-row span { display: grid; gap: 4px; }
.check-row strong { font-size: 13px; }
.check-row small { color: var(--muted); font-size: 11px; }
.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 11px; border: 1px solid transparent; font-size: 13px; font-weight: 700; transition: background-color .18s ease, border-color .18s ease, color .18s ease; }
.button svg { width: 17px; height: 17px; }
.button:focus-visible, .check-row:has(input:focus-visible) { outline: 3px solid rgb(96 165 250 / 42%); outline-offset: 3px; }
.button-primary { color: #052e23; background: var(--green); }
.button-primary:hover:not(:disabled) { background: #6ee7b7; }
.button-secondary { color: var(--text); background: var(--surface-raised); border-color: #394a66; }
.button-secondary:hover:not(:disabled) { background: #22304a; border-color: #526480; }
.button:disabled { opacity: .43; }
.action-hint { min-height: 17px; margin: 10px 3px 0; color: var(--faint); font-size: 11px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 14px 0; }
.stat-card { min-height: 125px; padding: 22px; display: flex; flex-direction: column; justify-content: center; background: rgb(17 26 45 / 88%); border: 1px solid var(--border); border-radius: 15px; }
.stat-card > span { color: var(--muted); font-size: 12px; }
.stat-card strong { margin-top: 7px; font-size: 27px; letter-spacing: -.025em; }
.stat-card small { margin-top: 6px; color: var(--faint); font-size: 10px; line-height: 1.4; }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(310px, .75fr); gap: 14px; align-items: start; }
.accounts-panel, .config-panel, .cleanup-panel { padding: 25px; }
.side-stack { display: grid; gap: 14px; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 19px; }
.panel-heading.compact { margin-bottom: 15px; }
.panel-heading h3 { margin: 0; font-size: 17px; }
.refresh-time { color: var(--faint); font-size: 10px; }
.heading-actions { display: flex; align-items: center; gap: 12px; }
.small-button, .manage-account-button { padding: 6px 9px; color: #bfdbfe; background: rgb(59 130 246 / 9%); border: 1px solid rgb(96 165 250 / 24%); border-radius: 8px; font-size: 10px; font-weight: 700; }
.small-button:hover, .manage-account-button:hover { background: rgb(59 130 246 / 17%); }
.table-wrap { overflow: auto; max-height: 510px; border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { position: sticky; top: 0; z-index: 1; padding: 12px 15px; color: var(--faint); background: #101a2c; text-align: left; font-size: 10px; font-weight: 700; letter-spacing: .06em; }
td { padding: 13px 15px; border-top: 1px solid rgb(41 55 80 / 75%); color: var(--muted); vertical-align: middle; }
tbody tr:hover { background: rgb(96 165 250 / 4%); }
.account-cell { display: grid; gap: 3px; }
.account-cell strong { color: var(--text); font-size: 12px; font-weight: 600; }
.account-cell small { color: var(--faint); font-size: 10px; }
.badge { display: inline-flex; align-items: center; gap: 6px; width: max-content; padding: 4px 8px; border-radius: 999px; font-size: 10px; font-weight: 700; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; }
.badge.waiting { color: #bfdbfe; background: rgb(59 130 246 / 11%); }
.badge.waiting::before { background: var(--blue); }
.badge.running { color: #a7f3d0; background: rgb(16 185 129 / 12%); }
.badge.running::before { background: var(--green); }
.badge.failed { color: #fecdd3; background: rgb(244 63 94 / 11%); }
.badge.failed::before { background: var(--red); }
.badge.disabled { color: #cbd5e1; background: rgb(100 116 139 / 12%); }
.badge.disabled::before { background: var(--faint); }
.empty { padding: 30px; text-align: center; color: var(--faint); }

.config-list { display: grid; gap: 0; margin: 0; }
.config-list div { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 12px; padding: 12px 0; border-top: 1px solid rgb(41 55 80 / 72%); }
.config-list div:first-child { border-top: 0; }
.config-list dt { color: var(--faint); font-size: 11px; }
.config-list dd { margin: 0; color: var(--text); font-family: Consolas, "Cascadia Mono", monospace; font-size: 11px; text-align: right; overflow-wrap: anywhere; }
.security-note { display: flex; gap: 9px; margin: 16px 0 0; padding: 11px; color: #bfdbfe; background: rgb(59 130 246 / 8%); border: 1px solid rgb(59 130 246 / 15%); border-radius: 10px; font-size: 10px; line-height: 1.6; }
.security-note svg { flex: 0 0 17px; width: 17px; margin-top: 1px; }
.cleanup-result { display: flex; justify-content: space-between; align-items: baseline; gap: 15px; padding-top: 4px; }
.cleanup-result strong { font-size: 22px; }
.cleanup-result span { color: var(--faint); font-size: 10px; text-align: right; }
.cleanup-error { margin: 12px 0 0; color: #fecdd3; font-size: 11px; line-height: 1.6; }

.toast { position: fixed; right: 24px; bottom: 24px; max-width: min(380px, calc(100vw - 48px)); padding: 13px 16px; color: var(--text); background: #1e293b; border: 1px solid #475569; border-radius: 11px; box-shadow: var(--shadow); font-size: 12px; z-index: 10; }
.toast.error { color: #fecdd3; border-color: rgb(251 113 133 / 45%); }

.login-page { display: grid; place-items: center; padding: 24px; }
.login-card { width: min(430px, 100%); padding: 34px; }
.login-brand { display: flex; align-items: center; gap: 13px; }
.login-brand h1 { margin: 0; font-size: 18px; }
.login-brand p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.login-copy { margin: 42px 0 24px; }
.login-copy h2 { margin: 0; font-size: 30px; letter-spacing: -.03em; }
.login-copy > p:last-child { margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.login-form { display: grid; gap: 9px; }
.login-form label { margin-top: 8px; color: var(--muted); font-size: 12px; font-weight: 600; }
.login-form input { width: 100%; min-height: 44px; padding: 10px 12px; color: var(--text); background: rgb(8 15 29 / 55%); border: 1px solid var(--border); border-radius: 10px; outline: none; }
.login-form input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgb(96 165 250 / 15%); }
.login-form .button { margin-top: 16px; }
.login-error { margin: 0 0 13px; padding: 10px 12px; color: #fecdd3; background: rgb(244 63 94 / 8%); border: 1px solid rgb(244 63 94 / 20%); border-radius: 9px; font-size: 12px; }

.account-dialog { width: min(820px, calc(100% - 28px)); max-height: calc(100vh - 28px); padding: 0; overflow: auto; color: var(--text); background: #111a2d; border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 28px 80px rgb(0 0 0 / 55%); }
.account-dialog::backdrop { background: rgb(3 7 18 / 72%); backdrop-filter: blur(4px); }
.account-form { padding: 28px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.dialog-heading h2 { margin: 0; font-size: 22px; }
.icon-button { width: 34px; height: 34px; color: var(--muted); background: transparent; border: 1px solid var(--border); border-radius: 9px; font-size: 22px; line-height: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.form-grid label { display: grid; gap: 7px; }
.form-grid label.wide { grid-column: 1 / -1; }
.form-grid label > span { color: var(--muted); font-size: 11px; font-weight: 600; }
.form-grid input, .form-grid select { min-width: 0; min-height: 42px; padding: 9px 11px; color: var(--text); background: rgb(8 15 29 / 55%); border: 1px solid var(--border); border-radius: 9px; outline: none; }
.form-grid input:focus, .form-grid select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgb(96 165 250 / 14%); }
.form-grid input:disabled { opacity: .55; cursor: not-allowed; }
.form-switches { display: flex; gap: 24px; margin-top: 18px; color: var(--muted); font-size: 12px; }
.form-switches input { accent-color: var(--green); }
.password-note { margin: 16px 0 0; color: var(--faint); font-size: 10px; line-height: 1.6; }
.form-section { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--border); }
.form-section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.form-section-heading .eyebrow { margin-bottom: 6px; }
.form-section-heading h3 { margin: 0; font-size: 17px; }
.smtp-status { max-width: 58%; color: var(--faint); font-size: 10px; line-height: 1.5; text-align: right; }
.smtp-status.success { color: #a7f3d0; }
.smtp-status.error { color: #fecdd3; }
.compact-switches { margin-top: 13px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.dialog-actions .button { min-width: 110px; }

@media (max-width: 960px) {
  .hero { align-items: stretch; flex-direction: column; }
  .actions { width: 100%; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content-grid { grid-template-columns: 1fr; }
  .side-stack { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .shell { padding: 0 14px 30px; }
  .topbar { min-height: 82px; }
  .brand p { display: none; }
  .live-state { font-size: 11px; }
  .hero { padding: 25px 20px; border-radius: 15px; }
  .button-row, .stats, .side-stack { grid-template-columns: 1fr; }
  .stat-card { min-height: 105px; }
  .accounts-panel, .config-panel, .cleanup-panel { padding: 18px; }
  .table-wrap { border: 0; overflow: visible; max-height: none; }
  table, tbody, tr, td { display: block; }
  thead { display: none; }
  tbody { display: grid; gap: 10px; }
  tbody tr { padding: 14px; border: 1px solid var(--border); border-radius: 11px; }
  td { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 7px 0; border: 0; text-align: right; }
  td::before { content: attr(data-label); color: var(--faint); font-size: 10px; text-align: left; }
  td:first-child { align-items: flex-start; }
  .account-cell { justify-items: end; }
  .empty { display: block; text-align: center; }
  .empty::before { content: none; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid label.wide { grid-column: auto; }
  .account-form { padding: 22px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
