* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, Arial, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
}

a {
  color: #93c5fd;
  text-decoration: none;
}

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

button {
  cursor: pointer;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #1e293b;
  background: #020617;
  position: sticky;
  top: 0;
}

.brand {
  font-weight: 700;
  color: #f8fafc;
}

.navlinks {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.link-button {
  background: transparent;
  color: #93c5fd;
  border: 0;
  padding: 0;
}

.page {
  padding: 1.5rem;
}

.hero,
.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1.5rem;
}

.hero h1,
.detail-header h1,
.panel h1,
.panel h2 {
  margin-top: 0;
}

.hero-actions {
  text-align: right;
}

.stats-grid,
.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card,
.panel {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 12px;
  padding: 1rem;
}

.stat-card strong {
  display: block;
  font-size: 2rem;
}

.bulk-panel {
  margin-bottom: 1.5rem;
}

.bulk-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

.filters,
.stack {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.filter-hint {
  align-self: center;
}

.stack {
  flex-direction: column;
}

input,
select,
textarea,
button {
  padding: 0.65rem 0.8rem;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #0f172a;
  color: #e2e8f0;
}

button {
  background: #2563eb;
  border-color: #2563eb;
  color: white;
}

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

.device-table {
  width: 100%;
  border-collapse: collapse;
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 12px;
  overflow: hidden;
}

.device-table th,
.device-table td {
  padding: 0.85rem;
  border-bottom: 1px solid #1f2937;
  text-align: left;
  vertical-align: top;
}

.subtle {
  color: #94a3b8;
  font-size: 0.9rem;
}

.inline-name {
  border: 0;
  background: transparent;
  color: #f8fafc;
  padding: 0;
  font-weight: 700;
  text-align: left;
}

.status-dot {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  display: inline-block;
  margin-right: 0.35rem;
}

.online {
  background: #22c55e;
}

.offline {
  background: #ef4444;
}

.status-pill {
  padding: 0.5rem 0.8rem;
  border-radius: 999px;
  color: white;
}

.tag-list {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tag {
  display: inline-flex;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: #1d4ed8;
  color: white;
  border: 0;
}

.removable-tag {
  background: #334155;
}

.meta-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.75rem 1rem;
}

.meta-list dt {
  color: #94a3b8;
}

.timeline-scale {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  margin-bottom: 1rem;
  color: #94a3b8;
}

.timeline-scale span:nth-child(2) {
  text-align: center;
}

.timeline-scale span:nth-child(3) {
  text-align: right;
}

.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.timeline-row {
  display: grid;
  grid-template-columns: minmax(180px, 240px) 1fr;
  gap: 1rem;
  align-items: center;
}

.timeline-track {
  position: relative;
  height: 1.4rem;
  border-radius: 999px;
  background: #1f2937;
  overflow: hidden;
  border: 1px solid #334155;
}

.timeline-segment {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #16a34a, #22c55e);
}

.timeline-meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.35rem;
}

.wide {
  grid-column: 1 / -1;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.toggle-links {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.toggle-link {
  padding: 0.45rem 0.75rem;
  border: 1px solid #334155;
  border-radius: 999px;
  color: #cbd5e1;
}

.toggle-link.active {
  background: #1d4ed8;
  border-color: #1d4ed8;
  color: white;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.login-card {
  width: min(420px, calc(100vw - 2rem));
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 16px;
  padding: 1.5rem;
}

.error-box,
.form-status.error {
  color: #fecaca;
}

.form-status.success {
  color: #86efac;
}

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

  .hero,
  .detail-header,
  .topbar,
  .panel-heading {
    flex-direction: column;
    align-items: flex-start;
  }

  .timeline-row {
    grid-template-columns: 1fr;
  }

  .timeline-meta {
    flex-direction: column;
  }
}
