:root {
  --bg: #0f1115; --panel: #171a21; --panel-2: #1e222b; --border: #2a2f3a;
  --text: #e6e8ec; --muted: #8b93a3; --accent: #4f8cff; --ok: #2fbf71; --warn: #e5a23a; --err: #ef5b5b;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
a { color: var(--accent); }
h1 { font-size: 20px; margin: 0 0 16px; }
h2 { font-size: 15px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error-text { color: var(--err); min-height: 1em; }
code, .mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }

.layout { display: flex; min-height: 100vh; }
.sidebar { width: 200px; background: var(--panel); border-right: 1px solid var(--border); padding: 16px 10px;
  display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 18px; padding: 4px 10px 16px; }
.brand span { color: var(--accent); }
.sidebar a { color: var(--text); text-decoration: none; padding: 8px 10px; border-radius: 6px; }
.sidebar a:hover { background: var(--panel-2); }
.sidebar a.active { background: var(--accent); color: #fff; }
.spacer { flex: 1; }
.main { flex: 1; padding: 24px; max-width: 1200px; min-width: 0; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.grid { display: grid; gap: 12px; }
.tiles { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
.tile .v { font-size: 26px; font-weight: 700; }
.tile .l { color: var(--muted); font-size: 12px; margin-top: 2px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--panel-2); }
.trunc { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

input, textarea, select { background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: 8px 10px; font: inherit; width: 100%; }
textarea { min-height: 80px; resize: vertical; }
label { display: block; margin: 10px 0 4px; color: var(--muted); font-size: 12px; font-weight: 600; }
.check { display: flex; gap: 8px; align-items: center; margin: 10px 0; color: var(--text); font-size: 14px; font-weight: 400; }
.check input { width: auto; }

.btn { text-decoration: none; display: inline-block; background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 14px; cursor: pointer; font: inherit; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--err); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: var(--panel-2); border: 1px solid var(--border); white-space: nowrap; }
.badge.ok { color: var(--ok); border-color: #2fbf7155; }
.badge.warn { color: var(--warn); border-color: #e5a23a55; }
.badge.err { color: var(--err); border-color: #ef5b5b55; }
.badge.info { color: var(--accent); border-color: #4f8cff55; }

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

.login { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { width: 320px; display: flex; flex-direction: column; gap: 10px; }

.modal { position: fixed; inset: 0; background: #0009; display: flex; align-items: flex-start; justify-content: center;
  padding: 60px 16px; z-index: 10; overflow: auto; }
.modal-box { width: 100%; max-width: 520px; }
.toast { position: fixed; bottom: 20px; right: 20px; padding: 10px 16px; border-radius: 8px; background: var(--panel-2);
  border: 1px solid var(--border); z-index: 20; max-width: 400px; }
.toast.err { border-color: var(--err); color: var(--err); }
.toast.ok { border-color: var(--ok); }

.trace { margin: 0; padding: 8px 0 0 0; list-style: none; }
.trace li { padding: 2px 0; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.trace .t { color: var(--muted); display: inline-block; width: 80px; }
.kw { display: inline-block; background: var(--panel-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; margin: 2px; font-size: 12px; }
.reply-item { display: flex; gap: 6px; margin-bottom: 6px; }
.reply-item textarea { min-height: 60px; }

@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; }
  .brand { width: 100%; padding-bottom: 8px; }
  .spacer { display: none; }
  .main { padding: 14px; }
  .trunc { max-width: 160px; }
}
