:root {
  --bg: #f6f7f9; --card: #fff; --line: #e5e7eb; --text: #111827; --muted: #6b7280;
  --brand: #4f46e5; --brand-weak: #eef2ff; --ok: #059669; --warn: #d97706; --bad: #dc2626;
  --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font: inherit; }
.layout { display: flex; min-height: 100vh; }
.side { width: 210px; background: #111827; color: #d1d5db; padding: 16px 10px; flex-shrink: 0; position: sticky; top: 0; height: 100vh; }
.side h1 { font-size: 16px; color: #fff; margin: 4px 10px 18px; }
.side a { display: flex; justify-content: space-between; color: #d1d5db; padding: 8px 10px; border-radius: 8px; margin-bottom: 2px; }
.side a.active, .side a:hover { background: #1f2937; color: #fff; }
.side .badge { background: var(--bad); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 12px; }
.side .foot { position: absolute; bottom: 14px; left: 10px; right: 10px; font-size: 12px; color: #9ca3af; }
.main { flex: 1; min-width: 0; padding: 20px 24px; }
.main h2 { margin: 0 0 14px; font-size: 20px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.btn { border: 1px solid var(--line); background: #fff; padding: 7px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f3f4f6; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 8px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: default; }
input, select, textarea { border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; background: #fff; }
textarea { width: 100%; resize: vertical; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
label.f input, label.f select, label.f textarea { color: var(--text); font-size: 14px; }
.form { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.form .full { grid-column: 1 / -1; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafafa; position: sticky; top: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f9fafb; }
.tablewrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; max-height: calc(100vh - 230px); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: #f3f4f6; color: #374151; }
.pill.ok { background: #d1fae5; color: #065f46; } .pill.warn { background: #fef3c7; color: #92400e; }
.pill.bad { background: #fee2e2; color: #991b1b; } .pill.info { background: var(--brand-weak); color: #3730a3; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.filters { margin-bottom: 12px; }
.pager { margin-top: 10px; }
.stat { font-size: 24px; font-weight: 700; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--brand); border-color: var(--brand); }
.inbox { display: grid; grid-template-columns: 360px 1fr; gap: 12px; height: calc(100vh - 110px); }
.tlist { overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.titem { padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.titem:hover { background: #f9fafb; } .titem.sel { background: var(--brand-weak); }
.titem.unread .subj { font-weight: 700; }
.titem .subj { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tview { overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; }
.msg { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 10px; }
.msg.out { background: #f5f7ff; border-color: #dfe3ff; margin-left: 40px; }
.msg pre { white-space: pre-wrap; word-break: break-word; font: inherit; margin: 6px 0 0; }
.msg iframe { width: 100%; border: 0; min-height: 120px; background: #fff; }
.drawer { position: fixed; inset: 0; background: rgba(0,0,0,.3); display: flex; justify-content: flex-end; z-index: 20; }
.drawer > div { width: min(720px, 100%); background: var(--bg); height: 100%; overflow: auto; padding: 18px; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; z-index: 30; padding: 16px; }
.modal > div { background: #fff; border-radius: 12px; width: min(640px, 100%); max-height: 92vh; overflow: auto; padding: 18px; }
#toast { position: fixed; bottom: 18px; right: 18px; z-index: 50; display: flex; flex-direction: column; gap: 6px; }
#toast div { background: #111827; color: #fff; padding: 10px 14px; border-radius: 8px; max-width: 380px; }
#toast div.err { background: var(--bad); }
.login { max-width: 360px; margin: 12vh auto; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 4px 10px; }
.kv div:nth-child(odd) { color: var(--muted); }
pre.log { background: #111827; color: #d1d5db; padding: 12px; border-radius: var(--radius); max-height: 60vh; overflow: auto; font-size: 12px; }
.mobnav { display: none; }
@media (max-width: 860px) {
  .side { display: none; }
  .mobnav { display: flex; position: sticky; top: 0; z-index: 10; background: #111827; padding: 6px; gap: 4px; overflow-x: auto; }
  .mobnav a { color: #d1d5db; padding: 6px 10px; border-radius: 6px; white-space: nowrap; }
  .mobnav a.active { background: #374151; color: #fff; }
  .layout { flex-direction: column; }
  .main { padding: 12px; }
  .inbox { grid-template-columns: 1fr; height: auto; }
  .inbox.has-sel .tlist { display: none; }
  .inbox:not(.has-sel) .tview { display: none; }
  .hide-m { display: none; }
  .tablewrap { max-height: none; }
}
