:root {
  --bg: #f5f6f8; --card: #fff; --fg: #1d2330; --muted: #6b7385; --line: #e3e6ec; --accent: #2f6fde;
  --red: #d64545; --orange: #e08a1e; --green: #2e9d5b; --blue: #3a78d8; --purple: #8a4fd0; --grey: #8a90a0;
  --chip: #eef1f6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --card: #1b1f27; --fg: #e4e7ee; --muted: #959cad; --line: #2b313d; --accent: #6a9cf0;
    --chip: #262c37;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .ip { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
h1 { font-size: 20px; margin: 0 0 10px; } h2 { font-size: 15px; margin: 0 0 10px; }

header { display: flex; align-items: center; gap: 18px; padding: 10px 20px; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; position: sticky; top: 0; z-index: 2; }
header .brand { font-weight: 700; font-size: 16px; color: var(--fg); }
header nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
header nav a { padding: 6px 10px; border-radius: 6px; color: var(--muted); }
header nav a.active, header nav a:hover { background: var(--chip); color: var(--fg); text-decoration: none; }
header .user { color: var(--muted); }
main { padding: 18px 20px; max-width: 1600px; margin: 0 auto; }
footer { color: var(--muted); font-size: 12px; text-align: center; padding: 20px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 16px; overflow-x: auto; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(460px, 1fr)); gap: 16px; }
.cols > .card { margin-bottom: 0; } .cols { margin-bottom: 16px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--grey); border-radius: 10px; padding: 12px 14px; color: var(--fg); display: flex; flex-direction: column; }
.tile:hover { text-decoration: none; border-color: var(--accent); }
.tile span { color: var(--muted); font-size: 12px; } .tile b { font-size: 24px; margin: 2px 0; } .tile small { color: var(--muted); }
.tile.red { border-left-color: var(--red); } .tile.blue { border-left-color: var(--blue); } .tile.purple { border-left-color: var(--purple); }
.tile.orange { border-left-color: var(--orange); } .tile.green { border-left-color: var(--green); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; white-space: nowrap; }
table.dense td { padding: 4px 8px; font-size: 13px; }
td.msg { word-break: break-all; max-width: 640px; } td.nowrap { white-space: nowrap; }
td.actions { white-space: nowrap; } td.empty { color: var(--muted); text-align: center; padding: 20px; }
tr:hover td { background: color-mix(in srgb, var(--chip) 50%, transparent); }

.badge { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11.5px; font-weight: 600; color: #fff; background: var(--grey); white-space: nowrap; }
.badge.red { background: var(--red); } .badge.orange { background: var(--orange); } .badge.green { background: var(--green); }
.badge.blue { background: var(--blue); } .badge.purple { background: var(--purple); }
.chip { display: inline-block; background: var(--chip); border-radius: 6px; padding: 1px 6px; margin: 1px 0; font-size: 12px; white-space: nowrap; }

.btn { display: inline-block; border: 1px solid var(--line); background: var(--card); color: var(--fg); padding: 6px 12px; border-radius: 6px; cursor: pointer; font: inherit; }
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.small { padding: 2px 8px; font-size: 12px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, var(--line)); }
button.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font: inherit; }
form.inline { display: inline; margin: 0 2px; }
.hidden { display: none !important; }

.filters { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.filters h2 { width: 100%; }
label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
label.cb { flex-direction: row; align-items: center; gap: 4px; color: var(--fg); font-size: 13px; }
input, select { font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--fg); }
fieldset.types { border: 1px solid var(--line); border-radius: 6px; display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 6px 10px; margin: 0; width: 100%; }
fieldset.types legend { font-size: 12px; color: var(--muted); }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.toolbar h2 { margin: 0; flex: 1; }
.pager { margin-top: 10px; display: flex; gap: 8px; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid var(--line); background: var(--card); }
.flash.ok { border-left: 4px solid var(--green); } .flash.err { border-left: 4px solid var(--red); }
pre.copy { background: var(--chip); padding: 8px 10px; border-radius: 6px; white-space: pre-wrap; word-break: break-all; cursor: copy; margin: 6px 0; }
pre.copy.copied { outline: 2px solid var(--green); }

svg.chart { width: 100%; height: 190px; display: block; }
svg.chart text { font-size: 11px; fill: var(--muted); }
svg.chart .hit { fill: transparent; } svg.chart .hit:hover { fill: color-mix(in srgb, var(--fg) 6%, transparent); }
.c-red { fill: var(--red); } .c-orange { fill: var(--orange); } .c-blue { fill: var(--blue); }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-top: 4px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.legend i.c-red { background: var(--red); } .legend i.c-orange { background: var(--orange); } .legend i.c-blue { background: var(--blue); }

body.login { display: grid; place-items: center; min-height: 100vh; }
.loginbox { width: 320px; display: flex; flex-direction: column; gap: 12px; }
.loginbox h1 { text-align: center; }

@media (max-width: 700px) {
  main { padding: 12px; } .cols { grid-template-columns: 1fr; } header { gap: 8px; }
}
