:root {
  color-scheme: light;
  --bg: #f4f7f5;
  --surface: #ffffff;
  --surface-2: #eef4ef;
  --ink: #1f2a2e;
  --muted: #6a7676;
  --line: #dfe7e2;
  --teal: #1a9b8f;
  --teal-2: #dff5f1;
  --green: #27a567;
  --green-2: #e4f6ec;
  --coral: #ef6a5b;
  --coral-2: #fff0ed;
  --amber: #c98413;
  --amber-2: #fff3d7;
  --violet: #7357d6;
  --violet-2: #eee9ff;
  --shadow: 0 24px 60px rgba(25, 47, 54, 0.14);
  --radius: 8px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 0%, rgba(26, 155, 143, 0.14), transparent 30%),
    radial-gradient(circle at 95% 12%, rgba(239, 106, 91, 0.12), transparent 26%),
    linear-gradient(160deg, #f7faf7, #edf3f1 55%, #f6f1ea);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  display: grid;
  min-height: 100vh;
  padding: 18px;
  place-items: center;
}

.app {
  display: flex;
  width: min(100%, 430px);
  height: min(920px, calc(100vh - 36px));
  min-height: 640px;
  overflow: hidden;
  flex-direction: column;
  border: 1px solid rgba(31, 42, 46, 0.08);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 12px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(20px);
}

.brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border-radius: 8px;
  background: #1f2a2e;
  color: #fff;
  font-weight: 800;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 20px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 14px;
  font-size: 22px;
  line-height: 1.2;
}

h3 {
  margin-bottom: 8px;
  font-size: 15px;
  line-height: 1.25;
}

.bot-link {
  display: inline-flex;
  max-width: 150px;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.screen {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 6px 18px 18px;
}

.screen::-webkit-scrollbar {
  width: 0;
}

.view {
  display: grid;
  gap: 14px;
  animation: fade-in 160ms ease-out;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

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

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.panel-pad {
  padding: 16px;
}

.status-panel {
  display: grid;
  min-height: 364px;
  align-content: space-between;
  gap: 16px;
  padding: 18px;
  border: 1px solid rgba(26, 155, 143, 0.18);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(223, 245, 241, 0.8), rgba(255, 255, 255, 0.94)),
    var(--surface);
}

.status-panel.is-connected {
  border-color: rgba(39, 165, 103, 0.28);
  background:
    linear-gradient(180deg, rgba(228, 246, 236, 0.94), rgba(255, 255, 255, 0.96)),
    var(--surface);
}

.status-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.status-title {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
}

.status-subtitle {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.pill {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.pill.green {
  background: var(--green-2);
  color: #12663c;
}

.pill.amber {
  background: var(--amber-2);
  color: #7a4b04;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.dot.green {
  background: var(--green);
}

.connect-zone {
  display: grid;
  place-items: center;
  gap: 12px;
  padding: 10px 0 4px;
}

.connect-button {
  position: relative;
  display: grid;
  width: 176px;
  height: 176px;
  place-items: center;
  border-radius: 50%;
  background: #1f2a2e;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 18px 36px rgba(31, 42, 46, 0.26);
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.connect-button:active {
  transform: scale(0.98);
}

.connect-button.is-connected {
  background: var(--green);
  box-shadow: 0 18px 36px rgba(39, 165, 103, 0.26);
}

.connect-button span {
  display: grid;
  gap: 4px;
  text-align: center;
}

.connect-button strong {
  font-size: 18px;
  line-height: 1.1;
}

.connect-button small {
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
}

.connect-ring {
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 50%;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.metric {
  min-width: 0;
  padding: 11px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
}

.metric-label {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.metric-value {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
}

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

.action-btn,
.secondary-btn,
.primary-btn,
.ghost-btn,
.row-btn,
.plan,
.faq-btn,
.device-row,
.location-row {
  cursor: pointer;
}

.action-btn {
  min-height: 54px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.action-btn strong {
  display: block;
  font-size: 13px;
  line-height: 1.2;
}

.action-btn span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--coral-2);
}

.banner strong {
  display: block;
  margin-bottom: 3px;
  font-size: 14px;
}

.banner p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.secondary-btn,
.primary-btn,
.ghost-btn {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border-radius: var(--radius);
  font-weight: 800;
  text-align: center;
}

.primary-btn {
  background: var(--teal);
  color: #fff;
}

.secondary-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.ghost-btn {
  background: transparent;
  color: var(--teal);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-title p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.search {
  width: 100%;
  height: 44px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  outline: none;
}

.search:focus,
textarea:focus,
input:focus {
  border-color: var(--teal);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius);
  background: var(--surface-2);
}

.segmented button {
  min-height: 36px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.segmented button.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 6px 14px rgba(31, 42, 46, 0.08);
}

.list {
  display: grid;
  gap: 8px;
}

.location-row,
.row-btn,
.device-row {
  display: flex;
  width: 100%;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.location-main,
.row-main,
.device-main {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.flag,
.icon-box {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-2);
  font-weight: 800;
}

.icon-box.teal {
  background: var(--teal-2);
  color: #0f7169;
}

.icon-box.violet {
  background: var(--violet-2);
  color: var(--violet);
}

.icon-box.amber {
  background: var(--amber-2);
  color: var(--amber);
}

.row-copy {
  min-width: 0;
}

.row-copy strong {
  display: block;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-copy span {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-meta {
  display: grid;
  flex: 0 0 auto;
  justify-items: end;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.row-meta strong {
  color: var(--ink);
  font-size: 13px;
}

.location-row.is-selected {
  border-color: rgba(26, 155, 143, 0.5);
  background: var(--teal-2);
}

.plans {
  display: grid;
  gap: 10px;
}

.plan {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  min-height: 76px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.plan.is-selected {
  border-color: rgba(26, 155, 143, 0.5);
  background: var(--teal-2);
}

.plan small {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  margin-top: 7px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--amber-2);
  color: #7a4b04;
  font-size: 11px;
  font-weight: 800;
}

.price {
  text-align: right;
}

.price strong {
  display: block;
  font-size: 18px;
}

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

.form-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.form-row input {
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
}

.progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.progress span {
  display: block;
  width: var(--value, 72%);
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
  transition: width 260ms ease;
}

.diagnostic {
  display: grid;
  gap: 12px;
}

.check-grid {
  display: grid;
  gap: 8px;
}

.check {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  padding: 9px 10px;
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 13px;
}

.check span:last-child {
  font-weight: 800;
}

.faq {
  display: grid;
  gap: 8px;
}

.faq-btn {
  display: block;
  width: 100%;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.faq-btn strong {
  display: block;
  font-size: 14px;
}

.faq-btn span {
  display: none;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.faq-btn.is-open span {
  display: block;
}

textarea {
  width: 100%;
  min-height: 92px;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
}

.profile-card {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
}

.avatar {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: 12px;
  background: #1f2a2e;
  color: #fff;
  font-size: 22px;
  font-weight: 900;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 50px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.switch-row:last-child {
  border-bottom: 0;
}

.switch-copy strong {
  display: block;
  font-size: 14px;
}

.switch-copy span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.switch {
  position: relative;
  width: 46px;
  height: 28px;
  flex: 0 0 46px;
  border-radius: 999px;
  background: #cfdad4;
  cursor: pointer;
  transition: background 160ms ease;
}

.switch::after {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(31, 42, 46, 0.22);
  content: "";
  transition: transform 160ms ease;
}

.switch.is-on {
  background: var(--teal);
}

.switch.is-on::after {
  transform: translateX(18px);
}

.tabbar {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  padding: 8px 10px calc(8px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
}

.tab {
  display: grid;
  min-width: 0;
  min-height: 54px;
  place-items: center;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
}

.tab-icon {
  display: grid;
  width: 24px;
  height: 22px;
  place-items: center;
  font-size: 17px;
  line-height: 1;
}

.tab.is-active {
  background: var(--teal-2);
  color: #0f7169;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 36px));
  padding: 13px 14px;
  border: 1px solid rgba(31, 42, 46, 0.08);
  border-radius: var(--radius);
  background: #1f2a2e;
  color: #fff;
  box-shadow: 0 16px 34px rgba(31, 42, 46, 0.24);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  place-items: end center;
  padding: 18px;
  background: rgba(31, 42, 46, 0.34);
}

.modal-root.is-open {
  display: grid;
}

.sheet {
  width: min(100%, 430px);
  max-height: min(640px, calc(100vh - 36px));
  overflow: auto;
  padding: 18px;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: sheet-up 180ms ease-out;
}

@keyframes sheet-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

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

.sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}

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

.small {
  font-size: 12px;
  line-height: 1.4;
}

@media (max-width: 520px) {
  body {
    overflow: hidden;
    background: var(--surface);
  }

  .app-shell {
    padding: 0;
  }

  .app {
    width: 100%;
    height: 100vh;
    min-height: 100vh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .topbar {
    padding-top: max(14px, env(safe-area-inset-top, 0px));
  }

  .connect-button {
    width: 164px;
    height: 164px;
  }
}

@media (max-width: 360px) {
  .topbar {
    padding-inline: 14px;
  }

  .screen {
    padding-inline: 14px;
  }

  .bot-link {
    max-width: 116px;
    font-size: 11px;
  }

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

  .quick-grid,
  .form-row,
  .sheet-actions {
    grid-template-columns: 1fr;
  }

  .tab {
    font-size: 10px;
  }
}
