:root {
  --bg: #0b1220;
  --bg-soft: #111827;
  --surface: #1f2937;
  --surface-2: #243044;
  --border: rgba(255, 255, 255, 0.08);
  --text: #f8fafc;
  --muted: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  line-height: 1.5;
}

a { color: #a5b4fc; text-decoration: none; }
a:hover { color: #c7d2fe; }

.layout-public {
  background:
    radial-gradient(circle at top left, rgba(99, 102, 241, 0.25), transparent 30%),
    radial-gradient(circle at bottom right, rgba(14, 165, 233, 0.15), transparent 25%),
    #0f172a;
}

.public-shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.topbar-brand, .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  display: grid;
  place-items: center;
  font-weight: 700;
  color: white;
  box-shadow: var(--shadow);
}

.brand-mark-lg { width: 56px; height: 56px; font-size: 1.1rem; }

.hero-card, .card, .panel, .kpi-card, .info-card, .device-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
}

.hero-card {
  padding: 28px;
  margin-bottom: 24px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  color: #a5b4fc;
  margin-bottom: 8px;
}

h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); margin-bottom: 8px; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1.05rem; margin-bottom: 6px; }
h4 { font-size: 0.95rem; margin-bottom: 10px; }

.lead, .muted { color: var(--muted); }
.lead { font-size: 1rem; max-width: 640px; }

.login-panel {
  min-height: 100vh;
  display: grid;
  place-items: center;
  gap: 24px;
  padding: 24px;
}

.login-brand { text-align: center; max-width: 420px; }
.login-brand p { color: var(--muted); margin-top: 8px; }

.card {
  width: min(420px, 100%);
  padding: 28px;
  box-shadow: var(--shadow);
}

.card-glass { background: rgba(15, 23, 42, 0.82); }

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: #cbd5e1;
}

input[type=text], input[type=password] {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.8);
  color: var(--text);
  font-size: 1rem;
}

input:focus {
  outline: 2px solid rgba(99, 102, 241, 0.45);
  border-color: rgba(99, 102, 241, 0.8);
}

.stack > * + * { margin-top: 14px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: 0.15s ease;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); color: white; }
.btn-secondary { background: rgba(255,255,255,0.08); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: rgba(255,255,255,0.12); color: var(--text); }
.btn-danger { background: rgba(239, 68, 68, 0.15); color: #fecaca; border: 1px solid rgba(239,68,68,0.25); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-block { width: 100%; }
.btn-small { padding: 8px 12px; font-size: 0.82rem; }

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 0.92rem;
}

.alert-error { background: rgba(239,68,68,0.15); color: #fecaca; border: 1px solid rgba(239,68,68,0.25); }
.alert-success { background: rgba(34,197,94,0.12); color: #bbf7d0; border: 1px solid rgba(34,197,94,0.25); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  border: 1px solid var(--border);
}

.pill-online { color: #86efac; background: rgba(34,197,94,0.12); }
.pill-offline { color: var(--muted); background: rgba(255,255,255,0.04); }

.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.device-card {
  padding: 22px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.device-card:hover { transform: translateY(-2px); border-color: rgba(99,102,241,0.35); }
.device-online { border-color: rgba(34,197,94,0.35); box-shadow: 0 0 0 1px rgba(34,197,94,0.08); }

.device-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.device-icon { font-size: 2rem; }

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #64748b;
}

.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(34,197,94,0.15);
}

.device-meta {
  font-size: 0.82rem;
  margin: 12px 0 16px;
  display: grid;
  gap: 4px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.info-card { padding: 22px; }

.steps, .bullets {
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.92rem;
}

.steps li + li, .bullets li + li { margin-top: 8px; }

.layout-admin { background: var(--bg); }

.admin-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand-title { font-weight: 700; }
.brand-sub { font-size: 0.78rem; color: var(--muted); }

.sidebar-nav { display: grid; gap: 8px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--muted);
  font-weight: 500;
}

.nav-item:hover, .nav-item.active {
  background: rgba(99,102,241,0.12);
  color: var(--text);
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.admin-chip {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  font-size: 0.85rem;
}

.admin-main {
  padding: 28px;
  overflow-x: auto;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  padding: 20px;
}

.kpi-accent {
  background: linear-gradient(135deg, rgba(99,102,241,0.25), rgba(14,165,233,0.12));
}

.kpi-label { color: var(--muted); font-size: 0.85rem; margin-bottom: 8px; }
.kpi-value { font-size: 1.8rem; font-weight: 700; }

.panel-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.panel {
  padding: 20px;
  margin-bottom: 18px;
}

.panel-wide { grid-column: span 1; }

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
}

.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th, .data-table td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.data-table th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table.compact td, .data-table.compact th { padding: 10px 8px; }

.cell-main { font-weight: 500; }
.cell-sub { color: var(--muted); font-size: 0.8rem; margin-top: 2px; }

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

.device-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.82rem;
}

.device-tag.online {
  border-color: rgba(34,197,94,0.35);
  background: rgba(34,197,94,0.08);
}

.device-tag:hover { border-color: rgba(99,102,241,0.45); color: white; }

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

.progress {
  width: 120px;
  height: 8px;
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #06b6d4);
}

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
}

.badge-admin {
  background: rgba(99,102,241,0.15);
  color: #c7d2fe;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.admin-device-grid {
  margin-bottom: 24px;
}
  color: var(--muted);
  padding: 24px 8px;
  text-align: center;
}

@media (max-width: 960px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); }
  .panel-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .page-header, .topbar { flex-direction: column; align-items: stretch; }
  .admin-main, .public-shell { padding-left: 14px; padding-right: 14px; }
}
