:root {
  --bg: #0c0c0f;
  --surface: #141820;
  --raised: #1a2030;
  --text: #fff;
  --text-2: #a7b0c2;
  --accent: #3c93ff;
  --green: #2dbf7a;
  --red: #e77065;
  --border: rgba(255, 255, 255, 0.07);
  --radius: 14px;
  --glow: 0 0 0 1px rgba(60, 147, 255, 0.25), 0 0 28px rgba(60, 147, 255, 0.18);
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Onest, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(60, 147, 255, 0.14), transparent 55%),
    radial-gradient(ellipse 40% 30% at 0% 10%, rgba(45, 191, 122, 0.06), transparent 50%);
  background-attachment: fixed;
}

h1,
h2,
h3,
.brand {
  font-family: Unbounded, Onest, sans-serif;
  font-weight: 600;
  letter-spacing: -0.02em;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--accent), #6bb0ff);
  box-shadow: var(--glow);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  color: #041018;
}

.hint {
  color: var(--text-2);
  font-size: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.card h2 {
  margin: 0 0 14px;
  font-size: 0.95rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: end;
}

.grid-create {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr auto auto;
  gap: 10px;
  align-items: end;
}

@media (max-width: 900px) {
  .grid-2,
  .grid-create {
    grid-template-columns: 1fr;
  }
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--text-2);
  font-size: 12px;
}

.field {
  width: 100%;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field:focus {
  border-color: rgba(60, 147, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(60, 147, 255, 0.15);
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-2);
  font-size: 13px;
  padding-bottom: 10px;
  user-select: none;
}

.check input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 18px;
  cursor: pointer;
  background: var(--raised);
  color: var(--text);
  transition: transform 0.12s, box-shadow 0.15s, background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(180deg, #4ea0ff, var(--accent));
  color: #041018;
  font-weight: 600;
  box-shadow: var(--glow);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-2);
}

.btn-ghost:hover {
  border-color: rgba(255, 255, 255, 0.16);
  color: var(--text);
}

.btn-danger {
  background: rgba(231, 112, 101, 0.12);
  border-color: rgba(231, 112, 101, 0.3);
  color: var(--red);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.toolbar h2 {
  margin: 0;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--raised);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 12px;
}

.pill.ok {
  color: var(--green);
  border-color: rgba(45, 191, 122, 0.25);
  background: rgba(45, 191, 122, 0.08);
}

.pill.err {
  color: var(--red);
  border-color: rgba(231, 112, 101, 0.25);
  background: rgba(231, 112, 101, 0.08);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  text-align: left;
  padding: 12px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 13px;
}

th {
  color: var(--text-2);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(255, 255, 255, 0.02);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.015);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.key-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 320px;
}

.key-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
}

.badge.on {
  color: var(--green);
  background: rgba(45, 191, 122, 0.1);
  border-color: rgba(45, 191, 122, 0.28);
}

.badge.off {
  color: var(--red);
  background: rgba(231, 112, 101, 0.1);
  border-color: rgba(231, 112, 101, 0.28);
}

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.login-gate {
  max-width: 440px;
  margin: 40px auto;
}

.status {
  min-height: 18px;
  color: var(--text-2);
  font-size: 12px;
}

.status.error {
  color: var(--red);
}

.status.ok {
  color: var(--green);
}

.hidden {
  display: none !important;
}

.empty-row td {
  text-align: center;
  color: var(--text-2);
  padding: 28px 12px;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  max-width: min(360px, calc(100vw - 32px));
  display: none;
}

.toast.show {
  display: block;
  animation: fadeUp 0.2s ease;
}

.toast.error {
  border-color: rgba(231, 112, 101, 0.35);
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
