/* MailServer shared UI — tokens, base, components */
:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f0f2f5; --border: #e3e6eb;
  --text: #1c2330; --muted: #6b7686; --accent: #3b5bdb; --accent-soft: #e8edfd; --accent-text: #ffffff;
  --danger: #d6336c; --danger-soft: #fdebf2; --success: #2b8a3e; --success-soft: #e6f4ea;
  --warn: #e67700; --warn-soft: #fff3e0; --shadow: 0 8px 28px rgba(20, 30, 50, .14);
  --radius: 8px; --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151b; --surface: #1a1e26; --surface-2: #232834; --border: #2c3240;
    --text: #e6e9ef; --muted: #8b95a7; --accent: #748ffc; --accent-soft: #252c47; --accent-text: #0d1020;
    --danger: #f06595; --danger-soft: #3a1f2b; --success: #51cf66; --success-soft: #1d3324;
    --warn: #fcc419; --warn-soft: #3a3016; --shadow: 0 8px 28px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  --bg: #12151b; --surface: #1a1e26; --surface-2: #232834; --border: #2c3240;
  --text: #e6e9ef; --muted: #8b95a7; --accent: #748ffc; --accent-soft: #252c47; --accent-text: #0d1020;
  --danger: #f06595; --danger-soft: #3a1f2b; --success: #51cf66; --success-soft: #1d3324;
  --warn: #fcc419; --warn-soft: #3a3016; --shadow: 0 8px 28px rgba(0, 0, 0, .5);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
svg.i { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* form controls */
input, select, textarea { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 7px 10px; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder, textarea::placeholder { color: var(--muted); }
textarea { width: 100%; min-height: 140px; resize: vertical; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
input[type="checkbox"] { width: 15px; height: 15px; padding: 0; accent-color: var(--accent); cursor: pointer; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 500; white-space: nowrap; transition: background .15s, border-color .15s, opacity .15s; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { opacity: .9; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.sm { padding: 3px 9px; font-size: 12.5px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.icon-btn { width: 32px; height: 32px; padding: 0; justify-content: center; }

/* badges */
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 500; background: var(--surface-2); color: var(--muted); }
.badge.ok { background: var(--success-soft); color: var(--success); }
.badge.bad { background: var(--danger-soft); color: var(--danger); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

/* login */
.login-wrap { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); z-index: 50; padding: 16px; }
.login-box { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 32px 28px; box-shadow: var(--shadow); }
.login-box h1 { font-size: 20px; margin-bottom: 4px; }
.login-box p.sub { color: var(--muted); margin-bottom: 22px; }
.login-box label { display: block; font-size: 12.5px; color: var(--muted); margin: 0 0 4px; }
.login-box input { width: 100%; margin-bottom: 14px; padding: 9px 11px; }
.login-box .btn { width: 100%; justify-content: center; padding: 10px; }
.login-box .err { color: var(--danger); font-size: 13px; min-height: 20px; margin-bottom: 8px; }

/* toast */
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 300; align-items: center; pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 99px; font-size: 13.5px; box-shadow: var(--shadow); animation: toast-in .2s ease; }
.toast.err { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(10, 14, 22, .45); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 16px; animation: fade .15s; }
.modal-box { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; width: 560px; max-width: 100%; max-height: 88vh; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.modal-box.wide { width: 820px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 600; }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
@keyframes fade { from { opacity: 0; } }

/* progress bar */
#progress { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 400; overflow: hidden; display: none; }
#progress.on { display: block; }
#progress::after { content: ""; display: block; height: 100%; width: 35%; background: var(--accent); animation: slide 1s linear infinite; }
@keyframes slide { from { margin-left: -35%; } to { margin-left: 100%; } }

.muted { color: var(--muted); }
.spacer { flex: 1; }
.row { display: flex; align-items: center; gap: 8px; }
