:root {
  --bg: #0f1419;
  --panel: #1a222c;
  --panel-2: #232d3a;
  --text: #e8eef5;
  --muted: #9aabbd;
  --accent: #2f6fed;
  --accent-2: #1f4fb8;
  --ok: #2f9e6b;
  --danger: #d64545;
  --border: #314052;
  --radius: 12px;
  --font: "DM Sans", system-ui, sans-serif;
  --display: "Instrument Sans", "DM Sans", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
[hidden] { display: none !important; }
body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 10% -10%, #1c3a6e55, transparent),
    radial-gradient(900px 500px at 100% 0%, #0d4d3a33, transparent),
    var(--bg);
  color: var(--text);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0 0 0.35rem;
}
h1, h2, h3 { font-family: var(--display); margin: 0; font-weight: 650; }
.subtitle, .muted, small { color: var(--muted); }
.subtitle { margin: 0.4rem 0 1.4rem; }

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login-box, .modal-card {
  width: min(440px, 100%);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  padding: 1.75rem;
  backdrop-filter: blur(8px);
}
.login-box label, .modal-card label {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
  font-size: 0.9rem;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="color"] {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 8px;
  padding: 0.7rem 0.8rem;
  font: inherit;
}
input[type="color"] { height: 42px; padding: 0.25rem; }

button, .btn-primary, .btn-ghost {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0.65rem 1rem;
}
.btn-primary, .login-box button[type="submit"] {
  background: var(--accent);
  color: white;
  width: 100%;
  font-weight: 600;
}
.btn-primary:hover, .login-box button[type="submit"]:hover { background: var(--accent-2); }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.topbar-actions .btn-primary { width: auto; }

.error {
  background: color-mix(in srgb, var(--danger) 20%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 50%, transparent);
  color: #ffd0d0;
  padding: 0.65rem 0.8rem;
  border-radius: 8px;
  margin: 0.5rem 0 1rem;
  font-size: 0.9rem;
}

.app-view { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: end;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.topbar-actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}

.table-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
}
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}
th { color: var(--muted); font-weight: 500; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
tr:last-child td { border-bottom: 0; }
.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.badge-on { background: color-mix(in srgb, var(--ok) 25%, transparent); color: #9dffc9; }
.badge-off { background: color-mix(in srgb, var(--danger) 25%, transparent); color: #ffb4b4; }
.row-actions { display: flex; gap: 0.4rem; justify-content: flex-end; }
.row-actions button { padding: 0.4rem 0.7rem; font-size: 0.85rem; }
a.link { color: #9ec1ff; text-decoration: none; }
a.link:hover { text-decoration: underline; }

.modal {
  position: fixed;
  inset: 0;
  background: #0008;
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 40;
}
.modal[hidden] { display: none !important; }
.modal-card { width: min(760px, 100%); max-height: 92vh; overflow: auto; }
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
@media (max-width: 720px) {
  .grid-2 { grid-template-columns: 1fr; }
}
.checkbox-row {
  display: flex !important;
  align-items: center;
  gap: 0.55rem;
  margin-top: 1.4rem;
}
.checkbox-row input { width: auto; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1rem;
}
.modal-actions .btn-primary { width: auto; }
h3 {
  margin: 1.2rem 0 0.8rem;
  font-size: 1rem;
  color: #c9d7e8;
}
