/* Mail Protection Portal. No inline styles anywhere (strict CSP). */

:root {
  color-scheme: light dark;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --border: #e2e6ec;
  --border-strong: #cdd3dc;
  --text: #18202b;
  --muted: #5d6878;
  --faint: #8a94a3;
  --accent: #2456d3;
  --accent-hover: #1d47b3;
  --accent-soft: #e9effc;
  --accent-contrast: #ffffff;
  --ok: #17794a;
  --ok-soft: #e4f4eb;
  --warn: #8f5400;
  --warn-soft: #fdf1dc;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --info: #2456d3;
  --info-soft: #e9effc;
  --muted-soft: #eef0f3;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --logo-mark: #ffffff;
  --sidebar-w: 232px;
  --topbar-h: 56px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --surface: #161a21;
    --surface-2: #1b2029;
    --border: #29303b;
    --border-strong: #3a4350;
    --text: #e6e9ee;
    --muted: #9aa4b2;
    --faint: #6f7a89;
    --accent: #7aa5ff;
    --accent-hover: #9bbcff;
    --accent-soft: #1c2742;
    --accent-contrast: #0e1116;
    --ok: #4cc38a;
    --ok-soft: #12291e;
    --warn: #f0b456;
    --warn-soft: #2f2412;
    --danger: #ff8073;
    --danger-soft: #341816;
    --info: #7aa5ff;
    --info-soft: #1c2742;
    --muted-soft: #222833;
    --shadow: none;
    --logo-mark: #161a21;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; line-height: 1.25; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 600; }
h3 { font-size: 13.5px; margin: 18px 0 8px; font-weight: 600; }
p { margin: 0 0 12px; }
ul { margin: 0 0 12px; padding-left: 20px; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- App layout ---------- */

.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 650; font-size: 15px; }
.brand:hover { text-decoration: none; }
.logo { width: 26px; height: 26px; color: var(--accent); flex: none; }
.logo .mark { stroke: var(--logo-mark); }
/* A reseller's own logo in place of the shield. */
img.logo { width: auto; max-width: 160px; height: 30px; object-fit: contain; }
.logo-preview img { max-width: 100%; max-height: 64px; padding: 8px; border-radius: 8px; background: var(--muted-soft); }
.who { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--muted); }
.who-name { color: var(--text); font-weight: 550; }
.role { padding: 2px 9px; border-radius: 999px; background: var(--muted-soft); font-size: 12px; }

.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: calc(100vh - var(--topbar-h)); }
.sidebar {
  position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); overflow-y: auto;
  padding: 18px 12px; background: var(--surface); border-right: 1px solid var(--border);
}
.nav-section + .nav-section { margin-top: 20px; }
.nav-title { padding: 0 10px 6px; font-size: 11px; font-weight: 650; letter-spacing: .07em; text-transform: uppercase; color: var(--faint); }
.sidebar a { display: block; padding: 7px 10px; border-radius: var(--radius-sm); color: var(--text); font-weight: 500; }
.sidebar a:hover { background: var(--surface-2); text-decoration: none; }
.sidebar a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.content { width: 100%; max-width: 1320px; padding: 26px 30px 56px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin: 6px 0 0; color: var(--muted); max-width: 72ch; }
.back { display: inline-block; margin-bottom: 10px; font-size: 13px; }

/* ---------- Bare layout: sign-in and public pages ---------- */

body.bare { display: flex; min-height: 100vh; }
.bare-main { width: 100%; max-width: 440px; margin: auto; padding: 40px 16px; }
body.wide .bare-main { max-width: 680px; }
.bare-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 22px; font-weight: 650; font-size: 17px; }
.bare-brand .logo { width: 32px; height: 32px; }
.bare-brand img.logo { width: auto; max-width: 220px; height: 40px; }
.bare-main h1 { margin-bottom: 6px; }

/* ---------- Cards, grids ---------- */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; }
.card.flush { padding: 0; overflow: hidden; }
.card.danger-zone { border-color: var(--danger-soft); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head h2 { margin: 0; }
.card-body { padding: 16px 18px; }
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.side { grid-template-columns: minmax(0, 1.75fr) minmax(300px, 1fr); align-items: start; }
.grid > * { min-width: 0; }

/* ---------- Dashboard ---------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { display: block; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat .value { margin-top: 4px; font-size: 27px; font-weight: 650; line-height: 1.15; font-variant-numeric: tabular-nums; }
a.stat:hover { text-decoration: none; border-color: var(--accent); }
.stat.highlight { background: var(--accent-soft); border-color: transparent; }
.stat.highlight .value { color: var(--accent); }

.meter { margin-bottom: 12px; }
.meter-row { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
progress { -webkit-appearance: none; appearance: none; width: 100%; height: 8px; border: 0; border-radius: 999px; background: var(--muted-soft); overflow: hidden; display: block; }
progress::-webkit-progress-bar { background: var(--muted-soft); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 999px; }
progress.clean::-webkit-progress-value { background: var(--ok); }
progress.clean::-moz-progress-bar { background: var(--ok); }
progress.quarantined::-webkit-progress-value, progress.deferred::-webkit-progress-value { background: var(--warn); }
progress.quarantined::-moz-progress-bar, progress.deferred::-moz-progress-bar { background: var(--warn); }
progress.rejected::-webkit-progress-value { background: var(--danger); }
progress.rejected::-moz-progress-bar { background: var(--danger); }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
table.data th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data .num { text-align: right; }
table.data .sel { width: 38px; padding-right: 0; }
table.data.compact th, table.data.compact td { padding: 6px 10px; }
.trunc { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.subject a { color: var(--text); font-weight: 550; }
.stack > * + * { margin-top: 4px; }
td .actions { margin: 0; justify-content: flex-end; }

dl.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 9px 20px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
dl.kv + p, dl.kv + form, dl.kv + .actions { margin-top: 16px; }

/* ---------- Badges, dots ---------- */

.badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.6; white-space: nowrap; background: var(--muted-soft); color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badges { display: flex; flex-wrap: wrap; gap: 4px; }
.dot { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: var(--faint); vertical-align: 1px; }
.dot.ok { background: var(--ok); }
.dot.danger { background: var(--danger); }

/* ---------- Forms ---------- */

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; }
.hint { font-size: 12.5px; font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], input[type=url], input[type=password], input[type=search], input[type=number],
input[type=date], input[type=file], select, textarea {
  width: 100%; min-height: 36px; padding: 7px 10px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
input[type=file] { padding: 6px; }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.checkline { display: flex; align-items: flex-start; gap: 9px; margin-bottom: 12px; cursor: pointer; }
.checkline .badge { margin-left: auto; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 14px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; }
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin-bottom: 16px; }
.filters input, .filters select { width: auto; min-width: 140px; }
.filters input[type=search] { flex: 1 1 240px; min-width: 200px; }
.filters label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
fieldset { border: 0; margin: 0 0 6px; padding: 0; }
legend { font-size: 13px; font-weight: 600; margin-bottom: 8px; padding: 0; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 6px 14px;
  font: inherit; font-weight: 600; color: var(--text); white-space: nowrap; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { color: var(--accent-contrast); background: var(--accent); border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--danger); background: transparent; border-color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.small { min-height: 30px; padding: 3px 10px; font-size: 13px; }
.btn.block { width: 100%; }
button.link { padding: 0; font: inherit; color: var(--accent); background: none; border: 0; cursor: pointer; }
button.link:hover { text-decoration: underline; }
form.inline { display: inline; margin: 0; }

/* ---------- Messages ---------- */

.flashes { display: grid; gap: 8px; margin-bottom: 18px; }
.flash { padding: 10px 14px; border-radius: var(--radius-sm); font-weight: 500; }
.flash.ok { color: var(--ok); background: var(--ok-soft); }
.flash.error { color: var(--danger); background: var(--danger-soft); }
.flash.info { color: var(--info); background: var(--info-soft); }
.notice { padding: 12px 14px; margin-bottom: 16px; border-radius: var(--radius-sm); color: var(--warn); background: var(--warn-soft); }
.notice.info { color: var(--info); background: var(--info-soft); }
.notice.danger { color: var(--danger); background: var(--danger-soft); }
.notice a { color: inherit; font-weight: 600; }
ul.plain { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 4px; }

/* ---------- Misc components ---------- */

.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.bulkbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
pre.preview { margin: 0; padding: 12px 14px; max-height: 440px; overflow: auto; white-space: pre-wrap; word-break: break-word; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 22px; margin: 0 0 16px; padding: 16px 18px; list-style: none; font-family: var(--mono); font-size: 15px; background: var(--surface-2); border-radius: var(--radius-sm); }
.qr { display: inline-block; padding: 8px; line-height: 0; background: #ffffff; border-radius: var(--radius-sm); }
.qr svg { width: 190px; height: 190px; }
.secret { font-family: var(--mono); font-size: 15px; letter-spacing: .06em; word-break: break-all; }
.token { padding: 12px 14px; font-family: var(--mono); font-size: 13px; word-break: break-all; background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }
.setup { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 22px; align-items: start; }
details > summary { cursor: pointer; font-weight: 600; }
details[open] > summary { margin-bottom: 12px; }
.steps { padding-left: 18px; }
.steps li + li { margin-top: 6px; }
.error-card { text-align: center; }
.error-card .code { color: var(--muted); font-size: 13px; margin-bottom: 4px; }

/* ---------- Small screens ---------- */

@media (max-width: 960px) {
  .grid.side, .grid.two { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: sticky; top: var(--topbar-h); z-index: 15; height: auto; display: flex; gap: 2px;
    overflow-x: auto; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--border);
  }
  .nav-section { display: flex; gap: 2px; }
  .nav-section + .nav-section { margin-top: 0; }
  .nav-title { display: none; }
  .sidebar a { white-space: nowrap; }
  .content { padding: 18px 16px 44px; }
  .who-name, .role { display: none; }
  .topbar { padding: 0 16px; }
  .setup { grid-template-columns: minmax(0, 1fr); }
  .codes { grid-template-columns: minmax(0, 1fr); }
  .trunc { max-width: 200px; }
}
