:root {
  --ink: #071d33;
  --muted: #6d7d91;
  --line: #d9e3ed;
  --panel: #ffffff;
  --blue: #075985;
  --cyan: #0ea5e9;
  --green: #10b981;
  --red: #ef4444;
  --amber: #f59e0b;
  font-family: "Segoe UI", Tahoma, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top right, rgba(14, 165, 233, 0.2), transparent 32rem),
    linear-gradient(135deg, #f8fbff, #eef5fa);
  color: var(--ink);
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 20px;
  background: linear-gradient(180deg, #071d33, #0a2b48);
  color: white;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: linear-gradient(135deg, #0ea5e9, #14b8a6);
  color: white;
  font-weight: 900;
  letter-spacing: -1px;
  box-shadow: 0 16px 40px rgba(14, 165, 233, 0.28);
}

.brand span {
  display: block;
  color: #9cc7df;
  font-size: 12px;
  margin-top: 2px;
}

nav {
  display: grid;
  gap: 8px;
}

nav a,
.sidebar button {
  color: #cfe7f7;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 12px 14px;
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

nav a.active,
nav a:hover,
.sidebar button:hover {
  background: rgba(14, 165, 233, 0.14);
  border-color: rgba(125, 211, 252, 0.24);
  color: white;
}

.sidebar form {
  margin-top: auto;
}

.content {
  padding: 28px;
  display: grid;
  gap: 22px;
}

.topbar {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 24px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  box-shadow: 0 20px 60px rgba(7, 29, 51, 0.08);
}

.topbar p {
  margin: 0 0 6px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 48px);
  letter-spacing: -0.04em;
}

h2 {
  font-size: 20px;
  margin-bottom: 14px;
}

#collectorStatus {
  padding: 9px 12px;
  border-radius: 999px;
  background: #e8f7ee;
  color: #047857;
  font-weight: 800;
  font-size: 13px;
  white-space: nowrap;
}

.cards,
.device-grid,
.report-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.card,
.device,
.panel {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 18px 45px rgba(7, 29, 51, 0.07);
}

.card {
  padding: 18px;
}

.card small,
.device small {
  display: block;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
  font-weight: 800;
}

.card strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.panel {
  padding: 20px;
}

.table-wrap {
  overflow: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 860px;
  font-size: 13px;
}

th {
  text-align: left;
  background: #f2f6fb;
  color: #51657c;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid #e8eef5;
}

td strong {
  display: block;
}

.blocked-row {
  background: #fff1f2;
}

.blocked-row td {
  border-bottom-color: #fecdd3;
}

.activity-status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  margin-right: 8px;
  font-size: 12px;
  font-weight: 900;
}

.activity-status.observed {
  background: #e0f2fe;
  color: #075985;
}

.activity-status.blocked {
  background: #fee2e2;
  color: #b91c1c;
}

.device {
  padding: 16px;
  min-height: 128px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 800;
  border-radius: 999px;
  padding: 6px 9px;
  margin-bottom: 12px;
}

td .status {
  margin-bottom: 0;
}

.up {
  background: #dcfce7;
  color: #047857;
}

.down {
  background: #fee2e2;
  color: #b91c1c;
}

.pending {
  background: #fef3c7;
  color: #92400e;
}

.device h3 {
  margin: 0 0 6px;
}

.device h4 {
  margin: 0 0 8px;
  font-size: 16px;
}

.device-group {
  display: grid;
  gap: 12px;
}

.device-groups {
  display: grid;
  gap: 22px;
}

.device-group + .device-group {
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.device-group > h3 {
  margin: 0;
  font-size: 16px;
}

.device p {
  margin: 5px 0;
  color: var(--muted);
  font-size: 13px;
}

pre {
  white-space: pre-wrap;
  color: #153047;
  background: #f4f8fb;
  padding: 16px;
  border-radius: 16px;
  overflow: auto;
}

.section-note {
  margin: -6px 0 18px;
  color: var(--muted);
}

.endpoint-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 16px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #f8fbff;
}

.endpoint-form label,
.user-access-form label {
  margin: 0;
  color: #31465c;
  font-size: 13px;
}

.endpoint-form .wide {
  grid-column: span 2;
}

.checkbox-label {
  display: flex;
  gap: 10px;
  align-items: center;
}

.checkbox-label input {
  width: auto;
  margin: 0;
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: end;
}

.form-actions button[type="button"],
.small-btn {
  background: white;
  color: var(--blue);
  border: 1px solid var(--line);
}

.small-btn {
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 12px;
}

.small-btn.danger {
  color: #b91c1c;
}

.actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.user-access-form {
  display: grid;
  gap: 18px;
  padding: 16px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #f8fbff;
}

.user-fields {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.access-manager {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  padding: 16px;
  border: 1px solid #dce8f3;
  border-radius: 18px;
  background: white;
}

.access-manager h3,
.access-block h4 {
  margin: 0;
}

.quick-actions {
  display: flex;
  gap: 8px;
  align-items: start;
}

.access-options {
  grid-column: 1 / -1;
  display: grid;
  gap: 16px;
}

.access-block {
  display: grid;
  gap: 10px;
}

.access-check-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.device-access-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.access-check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 0;
  padding: 12px;
  border: 1px solid #dce8f3;
  border-radius: 14px;
  background: #f8fbff;
  cursor: pointer;
}

.access-check:hover {
  border-color: rgba(14, 165, 233, 0.45);
  background: #f1f9fe;
}

.access-check input {
  width: auto;
  margin: 3px 0 0;
}

.access-check span {
  display: grid;
  gap: 3px;
}

.access-check small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card {
  width: min(430px, 100%);
  padding: 32px;
  border-radius: 28px;
  background: white;
  border: 1px solid var(--line);
  box-shadow: 0 24px 70px rgba(7, 29, 51, 0.14);
}

.login-card h1 {
  margin: 18px 0 8px;
}

.login-card p {
  color: var(--muted);
}

label {
  display: block;
  font-weight: 700;
  margin: 14px 0;
}

input {
  width: 100%;
  margin-top: 6px;
  border: 1px solid #cfdbe7;
  border-radius: 14px;
  padding: 13px 14px;
  font: inherit;
}

select {
  width: 100%;
  margin-top: 6px;
  border: 1px solid #cfdbe7;
  border-radius: 14px;
  padding: 13px 14px;
  font: inherit;
  background: white;
  color: var(--ink);
}

.activity-groups {
  display: grid;
  gap: 16px;
}

.activity-device {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fbfdff;
  overflow: hidden;
}

.activity-device.blocked {
  border-color: #fecdd3;
  box-shadow: inset 4px 0 0 #ef4444;
}

.activity-device header {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 18px;
  align-items: start;
  padding: 16px;
  background: linear-gradient(135deg, #ffffff, #f4f8fb);
  border-bottom: 1px solid #e8eef5;
}

.activity-device h3 {
  margin: 0 0 5px;
  font-size: 18px;
}

.activity-device p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.activity-summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 8px;
}

.activity-summary span,
.service-tags span {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  background: #edf5fb;
  color: #153047;
  font-size: 12px;
  font-weight: 800;
}

.activity-summary .danger-text {
  background: #fee2e2;
  color: #b91c1c;
}

.service-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px 0;
}

.nested-table {
  padding: 12px 16px 16px;
}

.nested-table table {
  min-width: 760px;
  background: white;
  border: 1px solid #e8eef5;
  border-radius: 14px;
  overflow: hidden;
}

.nested-table th:first-child,
.nested-table td:first-child {
  width: 38%;
}

button {
  border: 0;
  border-radius: 14px;
  background: var(--blue);
  color: white;
  padding: 13px 16px;
  font-weight: 800;
  cursor: pointer;
}

.login-card button {
  width: 100%;
}

.error {
  background: #fee2e2;
  color: #991b1b;
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 700;
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
  }

  .cards,
  .device-grid,
  .report-grid,
  .endpoint-form,
  .user-fields,
  .access-check-grid,
  .device-access-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .endpoint-form .wide {
    grid-column: span 2;
  }
}

@media (max-width: 620px) {
  .content {
    padding: 16px;
  }

  .topbar {
    display: grid;
  }

  .cards,
  .device-grid,
  .report-grid,
  .endpoint-form,
  .user-fields,
  .access-check-grid,
  .device-access-grid {
    grid-template-columns: 1fr;
  }

  .endpoint-form .wide {
    grid-column: auto;
  }

  .access-manager {
    grid-template-columns: 1fr;
  }
}

.starlink-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.starlink-card {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
  box-shadow: 0 18px 45px rgba(7, 29, 51, 0.07);
}

.starlink-card small {
  display: block;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
  font-weight: 800;
}

.starlink-card strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.starlink-card .speed {
  font-size: 42px;
  font-weight: 800;
  color: var(--ink);
}

.starlink-card.main {
  border-color: #0ea5e9;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.05), rgba(16, 185, 129, 0.05));
}

.starlink-card.main small {
  color: #0ea5e9;
}

.backup-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.backup-card {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
  box-shadow: 0 18px 45px rgba(7, 29, 51, 0.07);
}

.backup-card small {
  display: block;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
  font-weight: 800;
}

.backup-card strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.backup-card .speed {
  font-size: 42px;
  font-weight: 800;
  color: var(--ink);
}

.backup-card.main {
  border-color: #f59e0b;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.05), rgba(239, 68, 68, 0.05));
}

.backup-card.main small {
  color: #f59e0b;
}

.speedtest-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.speedtest-card {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
  box-shadow: 0 18px 45px rgba(7, 29, 51, 0.07);
}

.speedtest-card small {
  display: block;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
  font-weight: 800;
}

.speedtest-card strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.speedtest-card .speed {
  font-size: 42px;
  font-weight: 800;
  color: var(--ink);
}

.speedtest-card.main {
  border-color: #10b981;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.05), rgba(5, 150, 105, 0.05));
}

.speedtest-card.main small {
  color: #10b981;
}

.speedtest-chart {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 16px;
  box-shadow: 0 18px 45px rgba(7, 29, 51, 0.07);
}

.speedtest-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 120px;
}

.speedtest-bar-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  height: 100%;
}

.speedtest-bar {
  width: 100%;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  transition: height 0.3s ease;
}

.speedtest-bar-dl {
  background: #10b981;
}

.speedtest-bar-ul {
  background: #f59e0b;
}
