:root {
  --bg-0: #07151c;
  --bg-1: #0d2430;
  --bg-2: #123445;
  --surface: rgba(255, 255, 255, 0.08);
  --surface-strong: rgba(255, 255, 255, 0.12);
  --border: rgba(168, 230, 207, 0.22);
  --text: #f3faf7;
  --muted: #9db8b0;
  --accent: #2fd6a4;
  --accent-2: #ff7a59;
  --accent-3: #4ecbff;
  --danger: #ff6b7a;
  --ok: #3dffb5;
  --warn: #ffc857;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Outfit", "Avenir Next", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  font-family: var(--font-body);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(47, 214, 164, 0.22), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(255, 122, 89, 0.18), transparent 50%),
    radial-gradient(700px 400px at 50% 100%, rgba(78, 203, 255, 0.12), transparent 55%),
    linear-gradient(160deg, var(--bg-0), var(--bg-1) 45%, var(--bg-2));
  background-attachment: fixed;
}

a { color: var(--accent-3); text-decoration: none; }
a:hover { color: var(--accent); }

.shell {
  width: min(1200px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.25rem 0 3rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  animation: rise 0.55s ease both;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
}

.brand:hover { color: inherit; }

.brand-logo {
  display: block;
  height: clamp(2.6rem, 5vw, 3.4rem);
  width: auto;
  border-radius: 8px;
  background: #1c4454;
}

.login-logo {
  display: block;
  width: min(280px, 100%);
  height: auto;
  margin: 0 auto 1rem;
  border-radius: 12px;
  background: #1c4454;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.nav-links a, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 0.55rem 1rem;
  font: inherit;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
}

.nav-links a:hover, .btn:hover {
  transform: translateY(-1px);
  background: var(--surface-strong);
  border-color: rgba(47, 214, 164, 0.5);
  color: var(--text);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #1aa87c);
  border-color: transparent;
  color: #042018;
  font-weight: 650;
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent-2), #e85b3a);
  border-color: transparent;
  color: #2a0d05;
  font-weight: 650;
}

.btn-ghost { background: transparent; }
.btn-danger { background: rgba(255, 107, 122, 0.18); border-color: rgba(255, 107, 122, 0.45); color: #ffd6db; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  padding: 1.25rem;
  animation: rise 0.65s ease both;
}

.panel + .panel { margin-top: 1rem; }

.hero-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.stat {
  padding: 1rem;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--border);
}

.stat strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.8rem;
  margin-top: 0.25rem;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 650;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
}

.muted { color: var(--muted); }
.lead { color: var(--muted); margin: 0 0 1rem; line-height: 1.5; }

.flash-wrap { display: grid; gap: 0.5rem; margin-bottom: 1rem; }
.flash {
  padding: 0.8rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  animation: rise 0.4s ease both;
}
.flash.success { background: rgba(61, 255, 181, 0.12); border-color: rgba(61, 255, 181, 0.35); }
.flash.error { background: rgba(255, 107, 122, 0.14); border-color: rgba(255, 107, 122, 0.4); }
.flash.warning { background: rgba(255, 200, 87, 0.14); border-color: rgba(255, 200, 87, 0.4); }

.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.9rem;
}

.device-card {
  display: block;
  padding: 1.1rem;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  color: inherit;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
  animation: rise 0.7s ease both;
}

.device-card:hover {
  transform: translateY(-3px) scale(1.01);
  border-color: rgba(47, 214, 164, 0.55);
  background: rgba(47, 214, 164, 0.08);
  color: inherit;
}

.device-card h3 { margin-bottom: 0.2rem; }
.meta { font-size: 0.92rem; color: var(--muted); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 0 currentColor;
  animation: pulse 1.8s ease infinite;
}

.badge.online { color: var(--ok); background: rgba(61, 255, 181, 0.12); }
.badge.offline { color: #ff9aa5; background: rgba(255, 107, 122, 0.12); }
.badge.offline::before { animation: none; opacity: 0.7; }

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  text-align: left;
  padding: 0.75rem 0.6rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  vertical-align: middle;
}
th { color: var(--muted); font-weight: 600; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; }

.slot-table {
  font-size: 0.99rem;
}
.slot-table th,
.slot-table td {
  padding: 0.31rem 0.5rem;
  line-height: 1.2;
}
.slot-table th {
  font-size: 0.79rem;
  padding-bottom: 0.38rem;
}
.slot-table td.actions {
  gap: 0.33rem;
  margin-top: 0;
  flex-wrap: nowrap;
}
.slot-table .select-col {
  width: 8.5rem;
  white-space: nowrap;
}
.slot-select {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
}
.slot-select input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--accent);
  cursor: pointer;
}
.slot-table tr:has(.slot-check:checked) td {
  background: rgba(47, 214, 164, 0.12);
}
.slot-submit-bar {
  margin-top: 0.85rem;
  align-items: center;
}
.btn-compact {
  padding: 0.24rem 0.6rem;
  font-size: 0.86rem;
  border-radius: 999px;
  line-height: 1.15;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
}
.tabs a {
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  border: 1px solid transparent;
  color: var(--muted);
}
.tabs a.active {
  color: var(--text);
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.08);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.7rem;
  margin-bottom: 1rem;
}
.status-item {
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.8rem;
}
.status-item label {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}

.form-grid {
  display: grid;
  gap: 0.85rem;
}
.form-row {
  display: grid;
  gap: 0.35rem;
}
.form-row.inline {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}
label { color: var(--muted); font-size: 0.9rem; }
input[type="text"],
input[type="password"],
input[type="number"],
input[type="url"],
select,
textarea {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  padding: 0.7rem 0.85rem;
  font: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(47, 214, 164, 0.45);
  border-color: transparent;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.45rem;
}
.check-grid label {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  color: var(--text);
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login-card {
  width: min(420px, 100%);
  padding: 2rem;
  animation: rise 0.7s ease both, glow 4s ease-in-out infinite alternate;
}
.login-card h1 {
  font-size: clamp(2rem, 5vw, 2.6rem);
  margin-bottom: 0.25rem;
}
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }

.search-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  min-width: min(420px, 100%);
}
.search-bar input[type="search"] {
  flex: 1 1 220px;
  min-width: 180px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  padding: 0.7rem 0.85rem;
  font: inherit;
}
.search-bar input[type="search"]:focus {
  outline: 2px solid rgba(47, 214, 164, 0.45);
  border-color: transparent;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.register-inline {
  margin: 1.25rem 0 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.register-actions { display: flex; flex-direction: column; justify-content: flex-end; }
.table-meta { margin: 0 0 0.65rem; font-size: 0.92rem; }
.data-table tbody tr:hover td {
  background: rgba(47, 214, 164, 0.06);
}
.data-table td.actions {
  white-space: nowrap;
}
.inventory-table input[type="text"] {
  width: 100%;
}
.inventory-table tr.slot-empty td {
  opacity: 0.78;
}
.inventory-table code {
  font-size: 0.85em;
  color: var(--accent-3);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(61, 255, 181, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(61, 255, 181, 0); }
  100% { box-shadow: 0 0 0 0 rgba(61, 255, 181, 0); }
}
@keyframes glow {
  from { box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35); }
  to { box-shadow: 0 18px 60px rgba(47, 214, 164, 0.18); }
}

@media (max-width: 800px) {
  .hero-row, .stat-grid { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; }
}
