:root {
  --bg: #f5f5f7; --card: #ffffff; --ink: #1d1d1f; --muted: #6e6e73; --line: #d2d2d7; --soft: #e8e8ed;
  --accent: #0071e3; --accent-ink: #ffffff; --warn-bg: #fff8e6; --warn: #b25000; --err: #c9302c;
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 24px; padding: 10px 20px;
  background: rgba(255, 255, 255, .85); backdrop-filter: saturate(180%) blur(12px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 600; font-size: 16px; }
.env { font-size: 11px; font-weight: 500; color: var(--warn); background: var(--warn-bg); border-radius: 4px; padding: 1px 6px; }
.env:empty { display: none; }
.tabs { display: flex; gap: 4px; }
.tab { border: 0; background: none; padding: 6px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.tab.active { background: var(--soft); color: var(--ink); font-weight: 600; }
.who { margin-left: auto; color: var(--muted); white-space: nowrap; }

main { padding: 16px 20px 40px; max-width: 1400px; margin: 0 auto; }
.boot { color: var(--muted); padding: 40px 0; text-align: center; }
.panel > .muted { margin-top: 0; }

.filters { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; margin-bottom: 14px; }
.filters .row { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: end; margin-top: 10px; }
.filters .row.first { margin-top: 0; }
.filters label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.filters label.rel, .filters label.abs { flex-direction: row; align-items: center; gap: 6px; }
.filters input, .filters select { font-size: 14px; color: var(--ink); padding: 5px 8px; border: 1px solid var(--line);
  border-radius: 7px; background: #fff; min-width: 0; }
.filters input[type=number] { width: 110px; }
.filters label.rel input { width: 64px; }
.actions { align-items: center !important; }
button { cursor: pointer; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 14px; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.link { border: 0; background: none; padding: 0 4px; color: var(--accent); }
button.small { font-size: 12px; }
.muted { color: var(--muted); }
.error { color: var(--err); min-height: 1em; margin: 6px 0 0; font-size: 13px; }

.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: auto; }
.grid { width: 100%; border-collapse: collapse; background: var(--card); }
#netGrid { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.grid th, .grid td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--soft); white-space: nowrap; }
.grid th { position: sticky; top: 0; background: #fafafa; font-size: 12px; font-weight: 600; color: var(--muted); }
.grid .num { text-align: right; font-variant-numeric: tabular-nums; }
.grid td.name { font-weight: 600; }
.grid td.sender { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.grid tr.clickable { cursor: pointer; }
.grid tr.clickable:hover td { background: #f0f6ff; }
.grid td.warn { color: var(--warn); }
.sortable { cursor: pointer; user-select: none; }
.issue { border: 0; background: none; color: var(--err); font-weight: 700; padding: 0 6px; }
.empty { text-align: center; color: var(--muted); padding: 24px; margin: 0; }
.grid.compact th, .grid.compact td { padding: 5px 8px; font-size: 13px; }

.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100%); z-index: 10; overflow: auto;
  background: var(--card); border-left: 1px solid var(--line); box-shadow: -12px 0 32px rgba(0, 0, 0, .08); padding: 16px 20px 32px; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; }
.drawer h2 { margin: 0; font-size: 20px; }
.drawer h3 { font-size: 13px; color: var(--muted); margin: 18px 0 6px; }
.facts { display: grid; grid-template-columns: repeat(4, auto 1fr); gap: 6px 12px; margin: 12px 0 0; }
.facts dt { color: var(--muted); font-size: 12px; align-self: center; }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.mailbox { margin-top: 16px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.mail-head { padding: 8px 12px; background: #fafafa; border-bottom: 1px solid var(--line); }
.mailbox pre { margin: 0; padding: 12px; white-space: pre-wrap; word-break: break-word; font: 13px/1.5 ui-monospace, Menlo, monospace; max-height: 420px; overflow: auto; }

dialog { border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; width: min(460px, 92vw); }
dialog::backdrop { background: rgba(0, 0, 0, .25); }
dialog h2 { margin: 0 0 6px; font-size: 17px; }
dialog label { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; font-size: 12px; color: var(--muted); }
dialog input, dialog textarea { font-size: 14px; color: var(--ink); padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; }
dialog .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 8px 16px; border-radius: 999px; z-index: 20; }

.stub { max-width: 460px; margin: 60px auto; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px 24px; }
.stub h1 { font-size: 18px; margin: 0 0 6px; }
.stub-users { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.stub-users button { text-align: left; padding: 10px 12px; }

@media (max-width: 720px) {
  .top { flex-wrap: wrap; gap: 8px 16px; padding: 10px 16px; }
  main { padding: 12px 16px 32px; }
  .facts { grid-template-columns: auto 1fr; }
}
