:root {
  color-scheme: dark;
  --bg: #061016;
  --bg-strong: #0e2530;
  --panel: rgba(14, 33, 42, 0.82);
  --panel-strong: rgba(17, 48, 59, 0.96);
  --border: rgba(183, 226, 219, 0.12);
  --text: #f1fbf6;
  --muted: #b8d1d3;
  --accent: #ffb44d;
  --accent-strong: #ffd28e;
  --teal: #69d6c3;
  --ok: #88e0a2;
  --warn: #ffbf6e;
  --danger: #ff8f87;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
  --radius: 30px;
  --radius-sm: 20px;
  --font-display: "Avenir Next", "Trebuchet MS", sans-serif;
  --font-body: "Iowan Old Style", "Palatino Linotype", serif;
}

* {
  box-sizing: border-box;
}

html::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: calc(env(safe-area-inset-top, 0px) + 1.25rem);
  background:
    radial-gradient(circle at top left, rgba(255, 180, 77, 0.14), transparent 30%),
    radial-gradient(circle at top right, rgba(105, 214, 195, 0.16), transparent 28%),
    linear-gradient(180deg, #123847 0%, #123847 72%, rgba(18, 56, 71, 0) 100%);
  pointer-events: none;
  z-index: 0;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background-color: #123847;
  background:
    radial-gradient(circle at top left, rgba(255, 180, 77, 0.14), transparent 30%),
    radial-gradient(circle at top right, rgba(105, 214, 195, 0.16), transparent 28%),
    linear-gradient(180deg, #123847 0%, var(--bg) 46%, #04080d 100%);
  color: var(--text);
}

body {
  position: relative;
  font-family: var(--font-body);
}

body::before,
body::after {
  content: "";
  position: fixed;
  border-radius: 999px;
  filter: blur(40px);
  pointer-events: none;
  opacity: 0.6;
}

body::before {
  width: 14rem;
  height: 14rem;
  left: -4rem;
  bottom: 6rem;
  background: rgba(255, 180, 77, 0.12);
}

body::after {
  width: 16rem;
  height: 16rem;
  right: -5rem;
  top: 5rem;
  background: rgba(105, 214, 195, 0.12);
}

button,
input,
a {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  padding: 1rem 1rem 1rem;
  isolation: isolate;
}

.app-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(circle at top left, rgba(255, 180, 77, 0.14), transparent 30%),
    radial-gradient(circle at top right, rgba(105, 214, 195, 0.16), transparent 28%),
    linear-gradient(180deg, #123847 0%, var(--bg) 46%, #04080d 100%);
}

.topbar,
.main-content {
  max-width: 1260px;
  margin: 0 auto;
}

.site-footer {
  max-width: 1260px;
  margin: 1.5rem auto 0;
  padding: 0 0.2rem 0.4rem;
  text-align: center;
}

.site-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.topbar.is-hidden {
  display: none;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding-top: max(0.35rem, env(safe-area-inset-top, 0px));
  margin-bottom: 1.2rem;
}

.topbar-actions,
.topbar-nav,
.button-row,
.tab-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.brand-mark {
  width: 3.25rem;
  height: 3.25rem;
  flex: 0 0 auto;
}

.brand:focus-visible {
  outline: 2px solid rgba(255, 210, 142, 0.45);
  outline-offset: 0.35rem;
  border-radius: 1rem;
}

.topbar-actions {
  align-items: center;
  justify-content: flex-end;
}

.topbar-nav {
  padding: 0.35rem;
  border-radius: 999px;
  background: rgba(11, 30, 38, 0.45);
  border: 1px solid rgba(183, 226, 219, 0.08);
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.72rem 1rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-weight: 700;
  white-space: nowrap;
  transition:
    transform 180ms ease,
    background 180ms ease,
    color 180ms ease;
}

.user-pill[data-active="true"] {
  background: rgba(255, 180, 77, 0.18);
  color: var(--accent-strong);
}

.user-pill-icon {
  display: inline-grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 999px;
  background: rgba(255, 180, 77, 0.16);
  color: var(--accent);
}

.user-pill-svg {
  width: 1.25rem;
  height: 1.25rem;
  display: block;
  fill: currentColor;
}

.eyebrow {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

h1,
h2,
h3,
strong {
  margin: 0;
  font-family: var(--font-display);
}

h1 {
  max-width: none;
  font-size: clamp(1.5rem, 2.2vw, 2rem);
  line-height: 1;
}

h2 {
  font-size: clamp(1.8rem, 3vw, 2.7rem);
  line-height: 1.06;
}

h3 {
  font-size: 1.35rem;
  line-height: 1.15;
}

p,
li,
span,
label,
input,
button {
  font-size: 1.03rem;
  line-height: 1.6;
}

.panel,
.card,
.hero-card,
.device-card,
.empty-state,
.add-sensor-card {
  backdrop-filter: blur(18px);
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.panel {
  padding: clamp(1.25rem, 2vw, 1.8rem);
  border-radius: calc(var(--radius) + 4px);
}

.panel.view.flat-view {
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
}

.hero-card {
  padding: clamp(1.4rem, 3vw, 2.2rem);
  border-radius: var(--radius);
}

.card,
.device-card,
.empty-state,
.add-sensor-card {
  padding: 1.35rem;
  border-radius: var(--radius-sm);
}

.view {
  animation: rise 320ms ease;
}

.stack,
.compact-stack,
.landing-grid,
.hero-grid,
.grid.two-up,
.device-grid,
.metrics-grid {
  display: grid;
  gap: 1rem;
}

.compact-stack {
  gap: 0.75rem;
}

.landing-grid,
.hero-grid,
.grid.two-up {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

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

.auth-shell {
  display: grid;
  justify-items: center;
  gap: 1.5rem;
  margin: 0 auto;
  width: min(100%, 26rem);
}

.main-content.landing-mode {
  min-height: calc(100vh - 5rem);
  display: grid;
  place-items: center;
}

.main-content.landing-mode + .site-footer {
  margin-top: 0.5rem;
}

.main-content.landing-mode .panel.view {
  width: 100%;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
}

.landing-brand {
  justify-items: center;
  text-align: center;
}

.landing-glass {
  width: 100%;
  padding: 2rem 1.4rem 1.5rem;
  border-radius: calc(var(--radius) + 4px);
  background: rgba(12, 27, 35, 0.56);
  border: 1px solid rgba(183, 226, 219, 0.12);
  backdrop-filter: blur(24px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.24);
}

.landing-brand-mark {
  width: 5.5rem;
  height: 5.5rem;
}

.landing-title {
  font-size: clamp(2.1rem, 5vw, 3rem);
}

.auth-form {
  width: 100%;
}

.landing-actions {
  justify-items: center;
  text-align: center;
}

.text-button {
  padding: 0;
  background: transparent;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.steps,
.helper-list {
  display: grid;
  gap: 0.75rem;
  margin: 0;
  padding-left: 1.35rem;
}

.steps li::marker {
  color: var(--accent);
  font-family: var(--font-display);
  font-weight: 700;
}

.muted {
  color: var(--muted);
}

.status-summary {
  margin-top: -0.2rem;
}

.split-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.overview-status {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.overview-status-icon {
  width: 0.95rem;
  height: 0.95rem;
  fill: var(--accent-strong);
  flex: 0 0 auto;
}

.field {
  display: grid;
  gap: 0.45rem;
}

input {
  width: 100%;
  min-height: 3.25rem;
  padding: 0.85rem 1rem;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(8, 19, 25, 0.65);
  color: var(--text);
}

input:focus {
  outline: 2px solid rgba(255, 210, 142, 0.45);
  outline-offset: 2px;
}

.primary-button,
.secondary-button,
.ghost-button,
.tab-button {
  min-height: 3rem;
  padding: 0.82rem 1.2rem;
  border-radius: 999px;
  transition:
    transform 180ms ease,
    background 180ms ease,
    opacity 180ms ease;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.tab-button:hover {
  transform: translateY(-1px);
}

.primary-button {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #13202a;
  font-weight: 800;
}

.secondary-button {
  background: rgba(105, 214, 195, 0.16);
  color: var(--text);
  border: 1px solid rgba(105, 214, 195, 0.2);
}

.ghost-button,
.tab-button {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.nav-overview-button,
.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-icon-svg {
  width: 1rem;
  height: 1rem;
  fill: currentColor;
}

.tab-button.active,
.ghost-button[data-active="true"] {
  background: rgba(255, 180, 77, 0.18);
  color: var(--accent-strong);
}

.full-width {
  width: 100%;
}

.account-logout-button {
  margin-top: 0;
  min-height: 2.65rem;
  padding: 0.65rem 0.95rem;
}

.account-hero-main {
  gap: 0.35rem;
}

.account-hero-head {
  align-items: center;
  margin-top: -0.1rem;
}

.account-hero-email {
  margin-top: -0.1rem;
}

.inline-feedback {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 18px;
  border: 1px solid transparent;
}

.global-message {
  background: rgba(255, 255, 255, 0.06);
}

.global-message.success {
  background: rgba(136, 224, 162, 0.12);
  border-color: rgba(136, 224, 162, 0.24);
}

.global-message.error {
  background: rgba(255, 143, 135, 0.14);
  border-color: rgba(255, 143, 135, 0.3);
}

.global-message.warn {
  background: rgba(255, 191, 110, 0.14);
  border-color: rgba(255, 191, 110, 0.26);
}

.availability {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0.15rem 0.75rem;
  border-radius: 999px;
  font-size: 0.92rem;
}

.availability.online {
  background: rgba(136, 224, 162, 0.14);
  color: var(--ok);
}

.availability.offline {
  background: rgba(255, 143, 135, 0.16);
  color: var(--danger);
}

.availability-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  flex: 0 0 auto;
}

.availability-dot-icon {
  width: 1.1rem;
  height: 1.1rem;
  fill: currentColor;
}

.availability-dot.online {
  background: rgba(136, 224, 162, 0.18);
  color: var(--ok);
}

.availability-dot.offline {
  background: rgba(255, 143, 135, 0.18);
  color: var(--danger);
}

.metric {
  display: grid;
  gap: 0.35rem;
  padding: 0.9rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
}

.metric-icon-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.metric-icon-wrap-side {
  display: none;
}

.metric-label {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  color: rgba(246, 250, 252, 0.92);
  font-weight: 700;
  font-size: 0.9rem;
}

.metric-icon {
  width: 1.35rem;
  height: 1.35rem;
  fill: var(--accent-strong);
  display: block;
}

.metric-copy {
  display: grid;
  gap: 0.28rem;
}

.metric strong {
  display: block;
}

.sensor-meta {
  font-size: 0.82rem;
  line-height: 1.35;
}

.sensor-device-id {
  margin-top: 0.2rem;
}

.sensor-footer {
  margin-top: 0.85rem;
}

.claim-code-card {
  display: grid;
  gap: 0.5rem;
  padding: 1rem;
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(255, 180, 77, 0.16), rgba(105, 214, 195, 0.16));
  border: 1px solid rgba(255, 210, 142, 0.18);
}

.claim-code {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3rem);
  letter-spacing: 0.12em;
}

.add-sensor-card {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0.55rem;
  min-height: 17rem;
  width: 100%;
  text-align: center;
  background: rgba(17, 48, 59, 0.72);
  border: 1px solid rgba(183, 226, 219, 0.14);
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background 180ms ease;
}

.add-sensor-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 180, 77, 0.26);
  background: rgba(20, 54, 66, 0.78);
}

.add-sensor-plus {
  font-family: var(--font-display);
  font-size: clamp(3rem, 7vw, 4.75rem);
  line-height: 1;
  color: var(--accent);
}

.add-sensor-label {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--text);
}

.sensor-admin-list {
  display: grid;
  gap: 0.65rem;
  margin-top: 1rem;
}

.sensor-admin-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.8rem 0.95rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.sensor-admin-main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.sensor-admin-name {
  white-space: nowrap;
  flex: 0 0 auto;
}

.sensor-admin-device-id,
.sensor-admin-detail {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sensor-admin-device-id {
  max-width: 12rem;
}

.sensor-admin-detail {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
}

.sensor-admin-actions {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex: 0 0 auto;
}

.danger-button {
  background: rgba(255, 143, 135, 0.14);
  color: var(--danger);
  border: 1px solid rgba(255, 143, 135, 0.24);
}

.icon-button {
  min-height: 2.5rem;
  width: 2.5rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-button-svg {
  width: 1.05rem;
  height: 1.05rem;
  fill: currentColor;
}

.empty-state {
  display: grid;
  place-items: center;
  text-align: center;
  min-height: 14rem;
}

.empty-dashboard-title {
  margin-bottom: 1rem;
}

.dashboard-count-title {
  margin-bottom: 1rem;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 960px) {
  .landing-grid,
  .hero-grid,
  .grid.two-up,
  .device-grid,
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .sensor-admin-item {
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.75rem 0.85rem;
  }

  .sensor-admin-main {
    flex-wrap: wrap;
    row-gap: 0.35rem;
  }

  .sensor-admin-device-id,
  .sensor-admin-detail {
    min-width: 0;
    flex: 1 1 100%;
    max-width: 100%;
  }

  .sensor-admin-actions {
    margin-left: auto;
  }

  .topbar {
    gap: 0.8rem;
    padding-top: max(0.9rem, calc(env(safe-area-inset-top, 0px) + 0.55rem));
  }

  .topbar-actions {
    flex-wrap: nowrap;
    gap: 0.55rem;
  }

  .topbar-nav {
    flex-wrap: nowrap;
  }

  .device-card {
    padding: 0.9rem;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
    margin: 0.65rem 0;
  }

  .metric {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: stretch;
    gap: 0.55rem;
    padding: 0.62rem 0.68rem;
    min-height: 4.8rem;
  }

  .metric-icon-wrap-side {
    display: inline-flex;
    align-self: stretch;
    width: 2.2rem;
  }

  .metric-icon-wrap-inline {
    display: none;
  }

  .metric-copy {
    align-self: center;
  }

  .metric-label {
    display: block;
    font-size: 0.78rem;
  }

  .metric-icon {
    width: 1.6rem;
    height: 1.6rem;
  }

  .sensor-meta {
    font-size: 0.72rem;
  }

  .availability-dot {
    width: 2.15rem;
    height: 2.15rem;
  }

  .availability-dot-icon {
    width: 1rem;
    height: 1rem;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 1rem 0.8rem 0.8rem;
  }

  .main-content.landing-mode {
    min-height: calc(100vh - 4.6rem);
  }

  .topbar {
    gap: 0.65rem;
    padding-top: max(1rem, calc(env(safe-area-inset-top, 0px) + 0.7rem));
  }

  .brand {
    gap: 0.6rem;
  }

  .brand-mark {
    width: 2.6rem;
    height: 2.6rem;
  }

  .topbar-actions {
    gap: 0.45rem;
    min-width: 0;
  }

  .topbar-nav {
    width: auto;
    padding: 0.25rem;
  }

  .topbar-nav button {
    flex: 0 1 auto;
    min-height: 2.65rem;
    padding: 0.7rem 0.9rem;
    font-size: 0.95rem;
  }

  h1 {
    max-width: none;
    font-size: 1.5rem;
  }

  .sensor-admin-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
  }

  .sensor-admin-main {
    display: grid;
    gap: 0.3rem;
  }

  .sensor-admin-name,
  .sensor-admin-device-id,
  .sensor-admin-detail {
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
  }

  .sensor-admin-actions {
    align-self: start;
    margin-left: 0;
  }
}
