:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e2e5ea;
  --text: #16181d;
  --muted: #5f6673;
  --accent: #2f5bea;
  --accent-ink: #ffffff;
  --accent-soft: #e8eefd;
  --ok: #18794e;
  --ok-soft: #e3f4ec;
  --warn: #9a5b00;
  --warn-soft: #fdf1dc;
  --bad: #c22c2c;
  --bad-soft: #fbe7e7;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(16 24 40 / 0.06), 0 1px 3px rgb(16 24 40 / 0.08);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a20;
    --surface-2: #1e222a;
    --border: #2a2f39;
    --text: #e8eaee;
    --muted: #9aa2b1;
    --accent: #6d8dff;
    --accent-ink: #0b1020;
    --accent-soft: #1d2540;
    --ok: #4cc38a;
    --ok-soft: #12291f;
    --warn: #f0b354;
    --warn-soft: #2d2213;
    --bad: #ff7b7b;
    --bad-soft: #321a1a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; }
h1 { font-size: 2rem; letter-spacing: -0.02em; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.mono { font-family: var(--mono); font-size: 0.85em; word-break: break-all; }

/* layout */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); display: grid; place-items: center; color: var(--accent-ink); font-size: 14px; }
.topbar .spacer { flex: 1; }
.container { max-width: 1080px; margin: 0 auto; padding: 32px 24px; }
.narrow { max-width: 460px; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 760px) { .grid-3, .grid-2 { grid-template-columns: 1fr; } }
.stat-value { font-size: 1.6rem; font-weight: 700; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }

/* forms */
label { display: block; font-weight: 600; font-size: 0.88rem; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.hint { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { min-height: 220px; resize: vertical; }
.input-group { display: flex; align-items: stretch; }
.input-group input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group .suffix { padding: 9px 11px; border: 1px solid var(--border); border-left: 0; border-radius: 0 8px 8px 0; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.checkbox { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.checkbox input { width: auto; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 8px; border: 1px solid transparent; font: inherit; font-weight: 600;
  background: var(--accent); color: var(--accent-ink); cursor: pointer;
}
button:hover { filter: brightness(1.05); }
button:disabled { opacity: 0.6; cursor: wait; }
button.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
button.ghost { background: transparent; color: var(--muted); border-color: transparent; padding: 6px 10px; }
button.danger { background: var(--surface); color: var(--bad); border-color: var(--border); }
button.small { padding: 5px 10px; font-size: 0.85rem; }
button.block { width: 100%; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 24px; overflow-x: auto; }
.tab { padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab:hover { text-decoration: none; color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }

/* badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

.callout { padding: 14px 16px; border-radius: var(--radius); background: var(--accent-soft); border: 1px solid transparent; }
.callout.warn { background: var(--warn-soft); }
.callout.ok { background: var(--ok-soft); }
.copy { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.copy .mono { flex: 1; }

/* progress */
.meter { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; min-width: 80px; }
.meter > div { height: 100%; background: var(--accent); }

/* landing */
.hero { text-align: center; padding: 56px 0 32px; }
.hero h1 { font-size: 2.6rem; }
.hero p { font-size: 1.1rem; color: var(--muted); max-width: 620px; margin: 0 auto 24px; }
.plan { display: flex; flex-direction: column; }
.plan .price { font-size: 1.3rem; font-weight: 700; margin: 4px 0 12px; }
.plan ul { padding-left: 18px; margin: 0 0 16px; color: var(--muted); flex: 1; }
.plan.selected { outline: 2px solid var(--accent); }
.steps { counter-reset: step; list-style: none; padding: 0; }
.steps li { counter-increment: step; position: relative; padding-left: 36px; margin-bottom: 14px; }
.steps li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; display: grid; place-items: center; font-size: 0.8rem; }

/* webmail */
.mail { display: grid; grid-template-columns: 200px 340px 1fr; height: calc(100vh - 53px); }
.mail > * { overflow-y: auto; border-right: 1px solid var(--border); }
.mail-folders { padding: 12px; background: var(--surface); }
.folder { display: flex; justify-content: space-between; padding: 7px 10px; border-radius: 7px; color: var(--text); cursor: pointer; }
.folder:hover { background: var(--surface-2); text-decoration: none; }
.folder.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.mail-list { background: var(--surface); }
.msg { padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.msg:hover { background: var(--surface-2); }
.msg.active { background: var(--accent-soft); }
.msg.unread .msg-from, .msg.unread .msg-subject { font-weight: 700; }
.msg-from { display: flex; justify-content: space-between; gap: 8px; }
.msg-subject { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-preview { color: var(--muted); font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-reader { padding: 24px; border-right: 0; }
.mail-body { white-space: pre-wrap; word-wrap: break-word; font-size: 0.95rem; margin-top: 16px; }
@media (max-width: 900px) { .mail { grid-template-columns: 1fr; height: auto; } .mail > * { border-right: 0; } }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); margin-top: 8px; max-width: 90vw; }
.toast.error { background: var(--bad); color: #fff; }

dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 24px; width: min(520px, 92vw); box-shadow: 0 20px 50px rgb(0 0 0 / 0.25); }
dialog::backdrop { background: rgb(10 12 16 / 0.5); }
