:root {
  --bg: #0f1724;
  --panel: #162033;
  --card: #1c2a40;
  --line: #2b3c57;
  --text: #e8eef8;
  --muted: #93a4bd;
  --accent: #2f7dd1;
  --gold: #c9a24d;
  --danger: #d45656;
  --ok: #3ca56b;
  --radius: 14px;
  font-family: "Segoe UI", Tahoma, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 10% -10%, #1b3a63 0%, var(--bg) 45%);
  color: var(--text);
  min-height: 100vh;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: #ff8f8f; min-height: 1.2em; }
.hint { color: var(--muted); margin-top: 18px; }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card, .card, .editor {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  width: min(420px, 100%);
}
.login-card h1 { margin: 0 0 8px; font-size: 1.35rem; }
label { display: grid; gap: 6px; margin: 12px 0; font-size: .92rem; }
input, select, textarea, button {
  font: inherit;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  padding: 10px 12px;
}
textarea { min-height: 90px; resize: vertical; }
button { cursor: pointer; }
button.primary, .login-card button[type=submit] {
  background: var(--accent);
  border-color: transparent;
  color: white;
  font-weight: 600;
}
button.ghost { background: transparent; }
button.danger { background: var(--danger); border-color: transparent; color: #fff; }
button.ok { background: var(--ok); border-color: transparent; color: #fff; }

.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: rgba(12, 20, 34, .92);
  border-left: 1px solid var(--line);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.brand {
  font-weight: 700;
  padding: 10px 12px;
  color: var(--gold);
  margin-bottom: 8px;
}
.nav {
  text-align: right;
  background: transparent;
  border: 0;
  padding: 12px;
  color: var(--muted);
}
.nav.active, .nav:hover { background: var(--card); color: var(--text); }
.logout { margin-top: auto; }

.main { padding: 22px; }
.top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 18px; }
.top h2 { margin: 0; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.stat .n { font-size: 1.6rem; font-weight: 700; }
.stat .l { color: var(--muted); margin-top: 4px; font-size: .9rem; }

.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input { flex: 1; min-width: 180px; }

.table { display: grid; gap: 10px; }
.row {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 12px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
}
.row img {
  width: 72px;
  height: 54px;
  object-fit: cover;
  border-radius: 8px;
  background: #0b1220;
}
.row h4 { margin: 0 0 4px; font-size: 1rem; }
.meta { color: var(--muted); font-size: .85rem; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.badge {
  font-size: .75rem;
  padding: 3px 8px;
  border-radius: 999px;
  background: #24344f;
}
.badge.off { background: #4a2a2a; color: #ffb4b4; }
.badge.on { background: #1f3d2d; color: #b6f0c8; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: end; }
.actions button { padding: 8px 10px; font-size: .85rem; }

dialog {
  border: 0;
  border-radius: 16px;
  padding: 0;
  background: transparent;
  color: var(--text);
  width: min(720px, calc(100vw - 24px));
}
dialog::backdrop { background: rgba(0,0,0,.55); }
.editor { width: 100%; }
.fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  max-height: 60vh;
  overflow: auto;
  padding-inline-end: 4px;
}
.fields .full { grid-column: 1 / -1; }
.editor-actions { display: flex; justify-content: flex-start; gap: 8px; margin-top: 14px; }
.code {
  background: #0b1220;
  border-radius: 10px;
  padding: 12px;
  overflow: auto;
  direction: ltr;
  text-align: left;
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { border-left: 0; border-bottom: 1px solid var(--line); }
  .fields { grid-template-columns: 1fr; }
  .row { grid-template-columns: 64px 1fr; }
  .actions { grid-column: 1 / -1; }
}
