:root {
  color-scheme: dark;
  --bg-top: #1b2740;
  --bg-bottom: #0d1117;
  --panel: #121a26;
  --panel-2: #0f1620;
  --border: #263041;
  --border-hi: #3b4a63;
  --fg: #e6edf3;
  --muted: #9da7b3;
  --dim: #6e7a89;
  --accent: #1f6feb;
  --accent-hi: #2b7fff;
  --link: #58a6ff;
  --ok: #3fb950;
  --ok-bg: #133d24;
  --warn: #f0883e;
  --err-bg: #2d1618;
  --err-border: #5c2b2f;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }

body {
  min-height: 100vh;
  font: 16px/1.6 system-ui, "Segoe UI", sans-serif;
  color: var(--fg);
  background: radial-gradient(1200px 600px at 50% -10%, var(--bg-top), var(--bg-bottom));
}

a { color: var(--link); text-decoration: none; }
h1, h2, h3 { margin: 0 0 10px; font-weight: 600; }
p { margin: 0 0 10px; }

.page { max-width: 880px; margin: 0 auto; padding: 36px 20px 56px; }
.page.narrow { max-width: 460px; }
.page.center { display: grid; place-items: center; min-height: 100vh; }

header.top {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 26px;
}
header.top .brand { font-size: 15px; white-space: nowrap; }
header.top .brand a { color: var(--fg); font-weight: 600; }
header.top .brand span { color: var(--muted); }
header.top .user { font-size: 13px; color: var(--muted); margin-left: auto; }
.spacer { flex: 1; }

.btn {
  display: inline-block; padding: 10px 16px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--panel); color: var(--fg);
  font: inherit; cursor: pointer;
}
.btn:hover { border-color: var(--border-hi); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hi); }
.btn.danger { background: #7d2c2c; border-color: #7d2c2c; color: #fff; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.small { padding: 6px 12px; font-size: 13px; }

.input, select, textarea {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--panel-2); color: var(--fg); font: inherit;
}
.input:focus, select:focus, textarea:focus { outline: none; border-color: var(--link); }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }

.cards {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin-top: 14px;
}
.card {
  display: block; padding: 18px 20px; border: 1px solid var(--border);
  border-radius: 14px; background: var(--panel); color: inherit;
}
.card.click { cursor: pointer; transition: border-color .15s, transform .15s; }
.card.click:hover { border-color: var(--border-hi); transform: translateY(-2px); }
.card h3 { margin: 0 0 6px; font-size: 18px; }
.card .desc { color: var(--muted); font-size: 14px; margin: 0 0 10px; }
.card .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  background: #1f2937; color: var(--muted); font-size: 12px;
}
.badge.on { background: var(--ok-bg); color: var(--ok); }
.badge.accent { background: #16283f; color: var(--link); }

.msg { min-height: 22px; margin: 12px 0 0; font-size: 14px; color: var(--warn); }
.msg.ok { color: var(--ok); }

.panel {
  position: fixed; top: 0; bottom: 0; width: min(360px, 88vw); z-index: 30;
  background: var(--panel-2); border-right: 1px solid #1d2633;
  display: flex; flex-direction: column;
  transform: translateX(-105%); transition: transform .18s ease;
}
.panel.right { right: 0; left: auto; border-right: 0; border-left: 1px solid #1d2633; transform: translateX(105%); }
.panel.open { transform: translateX(0); }
.panel-head {
  display: flex; align-items: center; gap: 8px; padding: 14px;
  border-bottom: 1px solid #1d2633; font-size: 15px; font-weight: 600;
}
.panel-head button {
  margin-left: auto; padding: 6px 10px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--panel); color: var(--muted); font: inherit;
}
.panel-list { flex: 1; overflow-y: auto; padding: 8px; }

.backdrop { position: fixed; inset: 0; background: #0008; z-index: 20; }
.backdrop[hidden] { display: none; }

.overlay {
  position: fixed; inset: 0; background: #0d1117d9; display: flex;
  align-items: center; justify-content: center; z-index: 40;
}
.overlay[hidden] { display: none; }
.overlay .box {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 28px 32px; text-align: center;
}
.overlay .box p { margin: 0 0 16px; color: var(--muted); }

.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: 13px; }

@media (max-width: 640px) {
  .page { padding: 22px 14px 40px; }
  header.top .user { margin-left: 0; }
  .cards { grid-template-columns: 1fr; }
}
