:root {
  --bg: #0e1116; --panel: #161b22; --panel2: #1c232d; --line: #2a323d;
  --text: #e6e9ee; --muted: #8b95a3; --accent: #4f8cff; --ok: #3fb97a; --warn: #e0a83a; --bad: #e5604f;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 15px; margin: 24px 0 10px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
h3 { font-size: 16px; margin: 0 0 12px; }

input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { width: 100%; resize: vertical; min-height: 70px; }
button, a.btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 7px 12px; cursor: pointer; white-space: nowrap; }
button:hover, a.btn:hover { border-color: var(--muted); text-decoration: none; }
a.btn { color: var(--text); display: inline-block; }
progress { width: 100%; height: 6px; margin-top: 5px; accent-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.danger { color: var(--bad); }
button.small { padding: 3px 8px; font-size: 13px; }
button.link { background: none; border: 0; color: var(--muted); padding: 0; }
button:disabled { opacity: .5; cursor: default; }

#login { display: grid; place-items: center; height: 100%; }
.login-box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px; width: 320px; display: grid; gap: 12px; }
.login-box label { display: grid; gap: 4px; color: var(--muted); }
.err { color: var(--bad); margin: 0; min-height: 1.4em; }

#app { display: grid; grid-template-columns: 210px 1fr; height: 100%; }
aside { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; }
.logo { font-size: 20px; font-weight: 700; padding: 0 10px 18px; }
nav { display: grid; gap: 2px; }
nav button { text-align: left; background: none; border: 0; padding: 9px 10px; display: flex; justify-content: space-between; color: var(--muted); }
nav button:hover { background: var(--panel2); color: var(--text); }
nav button.on { background: var(--panel2); color: var(--text); font-weight: 600; }
.count { background: var(--accent); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 12px; font-weight: 600; }
.side-foot { margin-top: auto; padding: 10px; display: grid; gap: 10px; color: var(--muted); font-size: 13px; }
main { overflow: auto; padding: 24px 28px 60px; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1; min-width: 180px; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; background: var(--panel2); }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel2); }
td select { padding: 3px 6px; }
.empty { padding: 30px; text-align: center; color: var(--muted); background: var(--panel); border: 1px dashed var(--line); border-radius: 8px; }

.tag { display: inline-block; border-radius: 10px; padding: 1px 8px; font-size: 12px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.tag.ok { color: var(--ok); border-color: var(--ok); }
.tag.warn { color: var(--warn); border-color: var(--warn); }
.tag.bad { color: var(--bad); border-color: var(--bad); }
.tag.info { color: var(--accent); border-color: var(--accent); }
.chan a, .chan span { margin-right: 8px; white-space: nowrap; }

.cards { display: grid; gap: 10px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; }
.card .head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.card .head b { font-size: 15px; }
.card .actions { display: flex; gap: 8px; margin-top: 10px; }
.card p { margin: 6px 0 0; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; }
.stat b { display: block; font-size: 26px; }
.stat span { color: var(--muted); }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 0; width: min(860px, 94vw); max-height: 90vh; }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
#modal-body { padding: 22px 24px; overflow: auto; max-height: 90vh; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.grid2 label, .full label, label.full { display: grid; gap: 4px; color: var(--muted); font-size: 13px; }
.grid2 .full, label.full { grid-column: 1 / -1; }
.grid2 input, .grid2 select { width: 100%; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.log { display: grid; gap: 6px; margin: 8px 0; }
.log div { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; display: flex; gap: 10px; }
.log div span:nth-child(2) { flex: 1; white-space: pre-wrap; }
.pre { white-space: pre-wrap; }

#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 16px; box-shadow: 0 6px 24px rgba(0, 0, 0, .5); z-index: 10; max-width: 80vw; }
#toast.bad { border-color: var(--bad); }
