:root {
  --bg: #101216;
  --surface: #171b22;
  --surface-strong: #202632;
  --text: #f4f7fb;
  --muted: #aab4c0;
  --line: #303846;
  --primary: #54c7ec;
  --primary-ink: #06151d;
  --accent: #f2bd5c;
  --danger: #ff6b6b;
  --ok: #79d98f;
  --warn: #f2bd5c;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(145deg, rgba(16, 18, 22, 0.98), rgba(25, 29, 39, 0.96)),
    repeating-linear-gradient(90deg, rgba(84, 199, 236, 0.045) 0 1px, transparent 1px 48px),
    repeating-linear-gradient(0deg, rgba(242, 189, 92, 0.035) 0 1px, transparent 1px 54px);
}

a {
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 14px 24px;
  background: rgba(16, 18, 22, 0.88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

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

.brand {
  text-decoration: none;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: var(--primary-ink);
  background: var(--primary);
  font-size: 13px;
}

.topnav {
  justify-content: center;
}

.topnav a,
.text-link {
  color: var(--muted);
  text-decoration: none;
}

.topnav a:hover,
.text-link:hover {
  color: var(--text);
}

.page {
  width: min(1280px, calc(100% - 32px));
  margin: 24px auto 48px;
}

.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(30px, 4vw, 46px);
}

h2 {
  font-size: 20px;
}

.compact {
  margin-bottom: 0;
  color: var(--muted);
}

.summary-strip,
.device-grid,
.split-grid {
  display: grid;
  gap: 16px;
}

.summary-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
}

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

.split-grid {
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  margin-bottom: 18px;
}

.device-card,
.panel,
.auth-panel,
.form-panel,
.empty-panel,
.flash,
.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.02));
  box-shadow: var(--shadow);
}

.device-card,
.panel,
.auth-panel,
.form-panel,
.empty-panel {
  padding: 20px;
}

.card-head,
.card-actions,
.inline-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-head {
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-head h2 {
  margin-bottom: 4px;
}

.card-head p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.card-actions {
  margin-top: 16px;
}

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

.metric {
  padding: 12px;
  box-shadow: none;
  background: rgba(255, 255, 255, 0.035);
}

.metric span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  font-size: 15px;
  word-break: break-word;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.status-ok {
  color: #07160c;
  background: var(--ok);
}

.status-warn {
  color: #1d1403;
  background: var(--warn);
}

.status-muted {
  color: var(--muted);
  background: var(--surface-strong);
}

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 15px;
  border: 0;
  border-radius: 8px;
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.button.primary {
  color: var(--primary-ink);
  background: var(--primary);
}

.button.secondary,
.icon-button {
  color: var(--text);
  background: var(--surface-strong);
}

.button.danger {
  color: white;
  background: var(--danger);
}

.logout-form {
  margin: 0;
}

.auth-shell,
.form-shell {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 150px);
}

.auth-panel,
.form-panel {
  width: min(460px, 100%);
}

label {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #10141b;
  font: inherit;
}

textarea {
  resize: vertical;
}

.checkbox-inline {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  margin: 0;
  white-space: nowrap;
}

.checkbox-inline input {
  width: auto;
  min-height: auto;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

code,
.token-box {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.details-list {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px 16px;
  margin: 0 0 18px;
}

.details-list dt {
  color: var(--muted);
}

.details-list dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.flash {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
  padding: 14px 16px;
  box-shadow: none;
}

.flash-success {
  border-color: rgba(121, 217, 143, 0.5);
}

.flash-error {
  border-color: rgba(255, 107, 107, 0.55);
}

.token-box {
  overflow-x: auto;
  margin: 0;
  padding: 12px;
  border-radius: 8px;
  color: var(--accent);
  background: #0d1015;
}

.empty-panel {
  display: grid;
  gap: 12px;
  justify-items: start;
}

@media (max-width: 860px) {
  .topbar,
  .page-head {
    align-items: start;
  }

  .topbar {
    grid-template-columns: 1fr;
  }

  .topnav {
    justify-content: start;
    flex-wrap: wrap;
  }

  .summary-strip,
  .device-grid,
  .split-grid {
    grid-template-columns: 1fr;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .page-head,
  .inline-row {
    flex-direction: column;
  }

  .inline-row {
    align-items: stretch;
  }
}
