/* Spamvor Quarantaine */
:root {
  --accent: #156cbe;
  --accent-strong: #0f5aa3;
  --accent-soft: #e3eefb;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e3e7ee;
  --border-strong: #c9d3e0;
  --text: #1c2430;
  --text-2: #3d4756;
  --muted: #5b6676;
  --danger: #a3361c;
  --danger-soft: #fdecea;
  --success: #17663a;
  --success-soft: #e5f4ea;
  --warn-bg: #fff1d6;
  --warn-fg: #6b4a00;
  --mid-bg: #f6c9b8;
  --mid-fg: #6b200f;
  --high-bg: #8a2a15;
  --high-fg: #ffffff;
  --radius: 12px;
  --radius-sm: 8px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #4d9ae6;
    --accent-strong: #79b4ef;
    --accent-soft: #1b2d44;
    --bg: #11151b;
    --surface: #181d25;
    --border: #2a313c;
    --border-strong: #3a4352;
    --text: #e6eaf0;
    --text-2: #c5ccd6;
    --muted: #9aa5b4;
    --danger: #f08c74;
    --danger-soft: #3a1d17;
    --success: #7fd3a0;
    --success-soft: #16301f;
    --warn-bg: #3a2e12;
    --warn-fg: #f3d58c;
    --mid-bg: #4a2418;
    --mid-fg: #f6c9b8;
    --high-bg: #c2492b;
    --high-fg: #ffffff;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent-strong); }
a:hover { text-decoration: none; }
h1 { font-size: 26px; line-height: 1.2; margin: 0; letter-spacing: -0.3px; }
h2 { font-size: 16px; margin: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 8px 0; width: 100%; }
code { font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--muted); }
.muted { color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* top bar */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none; }
.brand-sub { font-weight: 500; color: var(--muted); }
.brand-mark { width: 30px; height: 30px; }
.brand-mark rect { fill: var(--accent); }
.brand-mark path { fill: none; stroke: #fff; stroke-width: 2; stroke-linejoin: round; }
.brand-lg { font-size: 20px; margin-bottom: 24px; }
.user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user form { margin: 0; }
.lang-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.lang-switch button {
  min-height: 30px; padding: 0 9px; border: 0; background: transparent; color: var(--text-2);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.lang-switch button + button { border-left: 1px solid var(--border); }
.lang-switch button:hover { background: var(--accent-soft); }
.lang-switch button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.user-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; font-size: 13px; flex: none;
}

/* layout */
.shell { display: flex; flex-wrap: wrap; gap: 24px; padding: 24px; max-width: 1440px; margin: 0 auto; }
.sidenav { flex: 1 1 220px; max-width: 260px; display: flex; flex-direction: column; gap: 2px; }
.nav-title { margin: 0 0 6px 12px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }
.nav-link {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 12px; border-radius: var(--radius-sm);
  color: var(--text); text-decoration: none; font-weight: 500;
}
.nav-link:hover { background: var(--surface); }
.nav-link.is-active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.count {
  margin-left: auto; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 10px;
  background: var(--border); color: var(--text-2);
}
.nav-link.is-active .count { background: var(--accent); color: #fff; }
.nav-mobile { display: none; }
.content { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-head p { margin: 6px 0 0; max-width: 720px; }

/* panels */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.panel.stack { padding: 20px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 500; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); background: var(--danger-soft); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-sm { min-height: 34px; padding: 0 10px; font-size: 14px; }
.btn-block { width: 100%; min-height: 44px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* forms */
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 500; }
.field.grow { flex: 1 1 260px; }
input[type=text], input[type=password], input[type=search], select {
  min-height: 42px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; width: 100%;
}
input[aria-invalid=true] { border-color: var(--danger); }
.field-error { flex-basis: 100%; margin: 0; color: var(--danger); font-weight: 500; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.check { display: flex; gap: 12px; align-items: flex-start; }
.check input { margin-top: 3px; }

.search {
  display: flex; align-items: center; gap: 8px; flex: 0 1 380px; min-width: 220px; height: 42px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; color: var(--muted);
}
.search input { border: 0; min-height: 0; height: 100%; padding: 0; background: transparent; outline: none; }
.search:focus-within { outline: 3px solid var(--accent); outline-offset: 1px; }

/* flash */
.flash { padding: 12px 16px; border-radius: var(--radius-sm); font-weight: 500; border: 1px solid transparent; }
.flash-success { background: var(--success-soft); color: var(--success); }
.flash-error { background: var(--danger-soft); color: var(--danger); }
.flash-info { background: var(--accent-soft); color: var(--accent-strong); }
.flash-floating { max-width: 420px; margin: 24px auto 0; }

/* tabs */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.tab {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none; font-weight: 600;
}
.tab-count { font-size: 12px; padding: 1px 7px; border-radius: 10px; background: var(--bg); color: var(--text-2); }
.tab.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tab.is-active .tab-count { background: rgba(255, 255, 255, 0.22); color: #fff; }

/* toolbar + table */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 16px; min-height: 60px;
  border-bottom: 1px solid var(--border);
}
.toolbar.has-selection { background: var(--accent-soft); }
.toolbar-info { color: var(--muted); }
.toolbar-selected { color: var(--accent-strong); font-weight: 600; }
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.table-wrap { overflow-x: auto; }
.mail-table { width: 100%; border-collapse: collapse; min-width: 640px; }
.mail-table th {
  text-align: left; padding: 10px 8px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--muted); white-space: nowrap;
}
.mail-table th a { color: inherit; text-decoration: none; }
.mail-table th a:hover { color: var(--text); }
.mail-table td { padding: 10px 8px; border-top: 1px solid var(--border); vertical-align: middle; }
.mail-table th:first-child, .mail-table td:first-child { padding-left: 16px; }
.mail-table th:last-child, .mail-table td:last-child { padding-right: 16px; }
.mail-table tbody tr:hover { background: var(--bg); }
.mail-table tr.is-selected { background: var(--accent-soft); }
.col-check { width: 44px; }
.col-score { width: 96px; }
.col-to { width: 220px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-date { width: 130px; text-align: right; white-space: nowrap; }
.col-actions { text-align: right; white-space: nowrap; }
.col-main { max-width: 0; width: 100%; }
.row-link { display: block; text-decoration: none; color: inherit; }
.row-link .from, .row-link .subject { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-link .from { font-weight: 600; color: var(--text); }
.row-link .subject { color: var(--text-2); }
.row-link:hover .subject { color: var(--accent-strong); text-decoration: underline; }

.score { display: inline-block; min-width: 44px; text-align: center; padding: 3px 8px; border-radius: 6px; font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.score-low, .score-none { background: var(--warn-bg); color: var(--warn-fg); }
.score-mid { background: var(--mid-bg); color: var(--mid-fg); }
.score-high { background: var(--high-bg); color: var(--high-fg); }
.tag { display: inline-block; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 3px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; background: var(--danger-soft); color: var(--danger); }
.pill { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 13px; font-weight: 600; }
.pill-white { background: var(--success-soft); color: var(--success); }
.pill-black { background: var(--danger-soft); color: var(--danger); }

.empty { padding: 48px 24px; text-align: center; }
.empty-title { margin: 0; font-weight: 600; color: var(--text-2); }
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.pager-links { display: flex; gap: 6px; }

/* message */
.back { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; text-decoration: none; align-self: flex-start; }
.message-layout { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.message { flex: 999 1 560px; min-width: 0; overflow: hidden; }
.message-side { flex: 1 1 280px; display: flex; flex-direction: column; gap: 16px; }
.message-head { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 12px; }
.message-head h1 { font-size: 22px; overflow-wrap: anywhere; }
.meta { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 16px; margin: 0; color: var(--text-2); }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; overflow-wrap: anywhere; }
.view-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 16px; border-bottom: 1px solid var(--border); }
.view-tab { display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border-radius: var(--radius-sm); text-decoration: none; color: var(--text-2); }
.view-tab.is-active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.message-body { padding: 20px 24px; }
.notice { margin: 0 0 12px; font-size: 13px; color: var(--muted); }
.text-body, .raw { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: 14px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.text-body { font-family: inherit; font-size: 15px; }
.raw { font-size: 12.5px; max-height: 70vh; overflow: auto; background: var(--bg); padding: 12px; border-radius: var(--radius-sm); }
.html-body { width: 100%; height: 60vh; min-height: 320px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; }
.attachments { list-style: none; margin: 0; padding: 12px 24px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.attachments li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--text-2); }
.actions { padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.warning { margin: 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.why { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.why-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rules { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.rules li { display: flex; justify-content: space-between; gap: 12px; }
.rules li > span:first-child { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.rule-score { font-variant-numeric: tabular-nums; color: var(--text-2); font-weight: 600; }
.rule-score.is-negative { color: var(--success); }

/* lists + settings */
.add-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; padding: 16px 20px; }
.add-form .field:not(.grow) { flex: 0 1 200px; }
form.inline { display: inline; margin: 0; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; align-items: start; }
.plain { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; overflow-wrap: anywhere; }

/* login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 32px; }
.login-card h1 { font-size: 22px; }
.login-card > p { margin: 8px 0 20px; }
.login-card .flash { margin-bottom: 16px; }

/* administration */
.viewing-as {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 16px; border-radius: var(--radius);
  background: var(--warn-bg); color: var(--warn-fg); font-weight: 600;
}
.viewing-as .btn { margin-left: auto; }
.admin-tabs { margin-bottom: 4px; }
.table-foot { display: flex; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--border); }
.field-row { display: flex; flex-wrap: wrap; gap: 12px; }
.field-row .field { flex: 1 1 160px; }
.small { font-size: 13px; margin: 0; }
.filter-table td, .filter-table th { vertical-align: middle; }
.filter-table select { width: 100%; min-width: 170px; }
.domain-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr); gap: 20px; align-items: start; }
.pill-level { background: var(--bg); color: var(--text-2); }
.pill-level-S, .pill-level-A { background: var(--accent-soft); color: var(--accent-strong); }
.add-form.compact { padding: 0; }
.admin-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.admin-list li:last-child { border-bottom: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.stat-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.stat-card h3 { margin: 0; font-size: 14px; color: var(--text-2); }
.stat-total { margin: 0; font-size: 24px; font-weight: 700; }
.stat-total .muted { font-size: 14px; font-weight: 400; }
.stat-bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--bg); }
.stat-bar span { display: block; height: 100%; width: 0; }
.seg-good, .dot-good { background: #2e9d5b; }
.seg-spam, .dot-spam { background: var(--accent); }
.seg-virus, .dot-virus { background: #e0a21b; }
.stat-legend, .stat-rows { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.stat-legend li { display: flex; align-items: center; gap: 8px; }
.stat-legend .muted { margin-left: auto; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.stat-rows li { display: grid; grid-template-columns: minmax(0, 1.4fr) 1fr auto; align-items: center; gap: 10px; }
.stat-row-bar { height: 8px; border-radius: 4px; background: var(--bg); overflow: hidden; }
.stat-row-bar span { display: block; height: 100%; width: 0; background: var(--accent); }

@media (max-width: 1000px) {
  .domain-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 720px) {
  .topbar { padding: 10px 16px; }
  .user-name { display: none; }
  .shell { padding: 16px; gap: 16px; }
  .sidenav { max-width: none; flex-direction: row; overflow-x: auto; gap: 4px; }
  .sidenav .nav-title, .sidenav hr { display: none; }
  .nav-link { flex: none; }
  .search { flex: 1 1 100%; }
  .toolbar-actions { margin-left: 0; width: 100%; }
  .toolbar-actions .btn { flex: 1 1 auto; }
  .col-to { display: none; }
  .nav-q { display: none; }
  .sidenav .nav-mobile { display: flex; }
  .mail-table { min-width: 0; }
  .col-score { width: 64px; }
  .col-date { width: auto; font-size: 13px; }
  .mail-table th:first-child, .mail-table td:first-child { padding-left: 12px; }
  .mail-table th:last-child, .mail-table td:last-child { padding-right: 12px; }
  .message-head, .message-body { padding: 16px; }
  .login-card { padding: 24px; }
}
