:root {
  --bg: #0f1420;
  --panel: #1a2130;
  --panel-2: #222b3d;
  --line: #2d3852;
  --text: #e6ebf5;
  --muted: #8a97b0;
  --accent: #3b82f6;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --gray: #64748b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem 1.5rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

h1 { font-size: 1.25rem; margin: 0; }
h2 { font-size: 1.05rem; display: flex; align-items: center; gap: .5rem; }
h3 { margin-top: 0; }

.key-box { display: flex; align-items: center; gap: .5rem; }

input, select, button, textarea {
  font: inherit;
  padding: .5rem .7rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
}
input::placeholder, textarea::placeholder { color: var(--muted); }
textarea { width: 100%; resize: vertical; font-family: ui-monospace, monospace; font-size: .82rem; }

button {
  background: var(--accent);
  border-color: var(--accent);
  cursor: pointer;
  font-weight: 600;
}
button:hover { filter: brightness(1.1); }
button.ghost { background: transparent; border-color: var(--line); color: var(--text); font-weight: 500; }
button.danger { background: transparent; border-color: var(--red); color: #fca5a5; font-weight: 500; }
button.warn { background: transparent; border-color: var(--yellow); color: #fde047; font-weight: 500; }

main { max-width: 980px; margin: 0 auto; padding: 1.5rem; }

.channel { margin-bottom: 2rem; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: .8rem; margin: .8rem 0; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .9rem;
}
.card .top { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; }
.card .label { font-weight: 700; }
.card .ident { color: var(--muted); font-size: .85rem; }
.card .detail { color: var(--muted); font-size: .8rem; margin: .4rem 0; line-height: 1.5; }
.card .actions { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .6rem; }
.card .actions button { padding: .35rem .6rem; font-size: .82rem; }

.badge {
  font-size: .72rem;
  font-weight: 700;
  padding: .2rem .5rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
}
.badge.online { background: rgba(34,197,94,.15); color: var(--green); }
.badge.offline { background: rgba(100,116,139,.18); color: var(--gray); }
.badge.pending { background: rgba(234,179,8,.15); color: var(--yellow); }
.badge.owner { background: rgba(59,130,246,.15); color: #93c5fd; }
.badge.noowner { background: rgba(239,68,68,.15); color: #fca5a5; }

.pill { font-size: .78rem; color: var(--muted); font-weight: 500; }
.muted { color: var(--muted); font-size: .85rem; }

.add-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.add-form input, .add-form select { flex: 1 1 160px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 10; }
.modal[hidden] { display: none; }
.modal-box { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 1.5rem; max-width: 460px; width: 92vw; max-height: 90vh; overflow: auto; }
.modal-box img { width: 320px; max-width: 100%; height: auto; background: #fff; border-radius: 8px; display: block; margin: 0 auto; }
.modal-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; }

.efield { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .7rem; }
.efield > span { font-size: .78rem; color: var(--muted); }
.efield input, .efield select, .efield textarea { width: 100%; }
.efield.row { flex-direction: row; align-items: center; gap: .5rem; }
.efield.row input[type=checkbox] { width: auto; }
.efield.row > span { flex: 1; font-size: .88rem; color: var(--text); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem 1rem; }

.keyval { font-family: ui-monospace, monospace; font-size: .95rem; letter-spacing: .08em; word-break: break-all; cursor: pointer; color: #93c5fd; background: var(--panel-2); padding: .3rem .5rem; border-radius: 6px; display: inline-block; }

.rows { display: flex; flex-direction: column; gap: .3rem; }
.row-item {
  display: flex; align-items: center; gap: .6rem;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: .5rem .7rem; font-size: .86rem;
}
.row-item .when { color: var(--muted); font-size: .78rem; margin-left: auto; white-space: nowrap; }
.row-item .etype { font-weight: 700; font-size: .72rem; text-transform: uppercase; padding: .1rem .45rem; border-radius: 6px; background: var(--panel-2); color: var(--muted); }
.row-item .etype.blocked { background: rgba(239,68,68,.15); color: #fca5a5; }
.row-item .etype.enroll { background: rgba(34,197,94,.15); color: var(--green); }
.row-item .etype.command { background: rgba(59,130,246,.15); color: #93c5fd; }

.pkg-list { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .4rem; }
.pkg { font-family: ui-monospace, monospace; font-size: .72rem; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: .15rem .4rem; color: #cbd5e1; }
