:root {
  --bg: #080d13;
  --panel: #111923;
  --panel-2: #172230;
  --text: #edf5f2;
  --muted: #8fa19d;
  --line: rgba(255, 255, 255, .08);
  --mint: #74f2bd;
  --aqua: #46c8ff;
  --danger: #ff6b7a;
  --shadow: 0 28px 70px rgba(0, 0, 0, .42);
}

* { box-sizing: border-box; }

html, body, #root {
  margin: 0;
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
  overscroll-behavior: none;
  background:
    radial-gradient(circle at 50% -10%, rgba(70, 200, 255, .22), transparent 32rem),
    radial-gradient(circle at 85% 20%, rgba(116, 242, 189, .13), transparent 22rem),
    var(--bg);
  color: var(--text);
  font-family: ui-rounded, "SF Pro Rounded", "Avenir Next", "Trebuchet MS", sans-serif;
}

body {
  display: flex;
  justify-content: center;
  padding: 0;
  touch-action: pan-y;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform .14s ease, filter .14s ease, background .14s ease, box-shadow .14s ease;
}

button.is-pressed,
.device-card.is-pressed,
.location-card.is-pressed,
.hero.is-pressed {
  transform: scale(.972);
  filter: brightness(.94);
}

.phone {
  width: min(430px, 100vw);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(28px + env(safe-area-inset-top, 0px)) 18px calc(108px + env(safe-area-inset-bottom, 0px));
  border: 0;
  border-radius: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .055), transparent 23%),
    linear-gradient(145deg, #0b1119, #0a0f15 54%, #101820);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.phone::before {
  content: "";
  position: absolute;
  inset: -90px -80px auto auto;
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(116, 242, 189, .18), transparent 68%);
  pointer-events: none;
}

.topbar, .brand, .status-row, .location-card, .sheet-head, .bottom-nav {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 14px;
  position: relative;
  z-index: 1;
}

.topbar-clean {
  justify-content: center;
  min-height: 70px;
}

.brand {
  gap: 13px;
  font-size: 20px;
}

.brand-mark {
  width: 50px;
  height: 52px;
  border-radius: 0;
  display: none;
  place-items: center;
  position: relative;
  overflow: hidden;
  background: transparent;
  box-shadow: none;
}

.brand-mark img {
  width: 100%;
  height: 170px;
  display: block;
  object-fit: contain;
  object-position: top center;
}

.brand-horizontal {
  width: 220px;
  height: 82px;
  display: block;
  overflow: hidden;
}

.brand-horizontal img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  transform: scale(2.65);
}

.home-tab .topbar-clean {
  min-height: min(31vh, 255px);
  align-items: flex-start;
  padding-top: 4px;
}

.home-tab .brand {
  justify-content: center;
}

.home-tab .brand-mark {
  display: grid;
  width: min(250px, 64vw);
  height: min(245px, 30vh);
  border-radius: 0;
  overflow: visible;
  background: transparent;
  box-shadow: none;
  transform: translateY(-46px);
}

.home-tab .brand-mark img {
  width: 100%;
  height: 100%;
}

.home-tab .brand-horizontal {
  display: none;
}

.icon-btn, .ghost-pill, .top-spacer {
  background: rgba(255, 255, 255, .07);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.icon-btn {
  width: 45px;
  height: 45px;
  display: grid;
  place-content: center;
  gap: 4px;
}

.icon-btn span {
  display: block;
  width: 17px;
  height: 2px;
  border-radius: 99px;
  background: var(--text);
}

.ghost-pill {
  padding: 12px 14px;
  color: var(--muted);
}

.top-spacer {
  width: 45px;
  height: 45px;
  opacity: 0;
}

.hero {
  margin-top: 0;
  padding: 34px 20px 22px;
  border-radius: 34px;
  background:
    radial-gradient(circle at 50% 18%, rgba(70, 200, 255, .16), transparent 170px),
    linear-gradient(180deg, rgba(255, 255, 255, .08), rgba(255, 255, 255, .025));
  border: 1px solid var(--line);
  text-align: center;
  position: relative;
}

.page {
  display: none;
  animation: page-in .18s ease both;
}

.page.active {
  display: block;
  max-height: calc(100vh - 186px);
  overflow-y: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.page.active::-webkit-scrollbar {
  display: none;
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.device-picker {
  width: 100%;
  min-height: 92px;
  padding: 14px 12px 10px;
  border-radius: 24px;
  background: transparent;
  text-align: center;
  transition: transform .14s ease, background .14s ease;
}

.device-picker:active {
  transform: scale(.985);
  background: rgba(255, 255, 255, .04);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

h1, h2 { margin: 0; }
h1 {
  font-size: clamp(28px, 8vw, 36px);
  letter-spacing: -.04em;
  overflow-wrap: anywhere;
  line-height: 1.08;
}
h1 span {
  color: var(--mint);
  font-size: 24px;
  vertical-align: 5px;
}
h2 { font-size: 24px; letter-spacing: -.03em; }

.status-row {
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
}

.active-status {
  width: max-content;
  margin-left: auto;
  margin-right: auto;
  padding: 8px 13px;
  border-radius: 999px;
  background: rgba(116, 242, 189, .09);
  color: var(--text);
}

.status-online .status-dot {
  background: var(--mint);
  box-shadow: 0 0 18px var(--mint);
}

.status-recent {
  background: rgba(255, 205, 88, .1);
}

.status-recent .status-dot {
  background: #ffd35c;
  box-shadow: 0 0 18px rgba(255, 211, 92, .8);
}

.status-idle {
  background: rgba(143, 161, 157, .1);
}

.status-idle .status-dot {
  background: var(--muted);
  box-shadow: none;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 18px var(--mint);
}

.stats-grid {
  display: grid;
  grid-template-columns: .76fr 1.24fr;
  gap: 10px;
  margin-top: 20px;
}

.stats-grid article {
  min-height: 76px;
  padding: 14px;
  border-radius: 22px;
  background: rgba(23, 34, 48, .74);
  border: 1px solid var(--line);
  text-align: left;
}

.stats-grid span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.stats-grid strong {
  display: block;
  font-size: 18px;
  letter-spacing: -.03em;
}

.location-card {
  width: 100%;
  justify-content: space-between;
  margin-top: 14px;
  padding: 20px;
  border-radius: 26px;
  background: var(--panel);
  border: 1px solid var(--line);
  text-align: left;
  transition: transform .16s ease, background .16s ease;
}

.location-card .eyebrow {
  margin-bottom: 8px;
}

.page-head {
  margin: 26px 0 14px;
}

.devices-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.device-counter {
  min-width: 56px;
  padding: 9px 12px;
  border-radius: 999px;
  background: rgba(116, 242, 189, .12);
  border: 1px solid rgba(116, 242, 189, .3);
  color: var(--mint);
  font-size: 14px;
  font-weight: 900;
  text-align: center;
}

.faq-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.faq-list article {
  padding: 16px;
  border-radius: 22px;
  background: rgba(17, 25, 35, .82);
  border: 1px solid var(--line);
}

.faq-list strong {
  display: block;
  margin-bottom: 8px;
  font-size: 16px;
}

.faq-list p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.add-note {
  margin-top: 12px;
  text-align: left;
}

.settings-tabs {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.settings-tabs button {
  width: 100%;
  min-height: 56px;
  padding: 14px 16px;
  border-radius: 20px;
  background: rgba(23, 34, 48, .74);
  border: 1px solid var(--line);
  color: var(--text);
  text-align: left;
  font-weight: 900;
}

.settings-tabs button.active {
  border-color: rgba(116, 242, 189, .46);
  background: linear-gradient(135deg, rgba(116, 242, 189, .16), rgba(70, 200, 255, .08));
}

.settings-faq-button {
  border-color: rgba(116, 242, 189, .46) !important;
  background: linear-gradient(135deg, rgba(116, 242, 189, .16), rgba(70, 200, 255, .08)) !important;
}

.settings-tabs button.disabled {
  opacity: .52;
  cursor: not-allowed;
}

.settings-tabs span {
  float: right;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

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

.back-settings {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: rgba(23, 34, 48, .74);
  border: 1px solid var(--line);
  color: var(--mint);
  font-size: 34px;
  line-height: 1;
  padding-bottom: 4px;
}

.location-card:active {
  transform: scale(.985);
  background: #15202c;
}

.route-badge {
  min-width: 98px;
  padding: 10px 14px;
  border-radius: 99px;
  color: #06120e;
  background: linear-gradient(135deg, var(--mint), var(--aqua));
  font-weight: 800;
  text-align: center;
}

.mini-card {
  margin-top: 14px;
  padding: 18px;
  border-radius: 30px;
  background: rgba(17, 25, 35, .82);
  border: 1px solid var(--line);
}

.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.action-grid button {
  min-height: 64px;
  border-radius: 20px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 800;
  transition: transform .14s ease, background .14s ease;
}

.action-grid button:active {
  transform: scale(.975);
  background: rgba(116, 242, 189, .14);
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(0, 0, 0, .54);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease;
}

.country-panel,
.device-panel,
.qr-panel,
.rename-panel,
.add-panel,
.menu-panel {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 11;
  width: min(430px, 100vw);
  padding: 10px 18px 22px;
  border-radius: 32px 32px 0 0;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 80% 0%, rgba(116, 242, 189, .13), transparent 16rem),
    rgba(13, 20, 29, .97);
  box-shadow: 0 -28px 60px rgba(0, 0, 0, .46);
  transform: translate(-50%, 105%);
  transition: transform .28s cubic-bezier(.2, .8, .2, 1);
  touch-action: pan-y;
  will-change: transform;
}

.dragging-sheet {
  transition: none !important;
}

body.country-open,
body.device-open,
body.qr-open,
body.rename-open,
body.add-open,
body.menu-open {
  overflow: hidden;
}

body.country-open .sheet-backdrop,
body.device-open .sheet-backdrop,
body.qr-open .sheet-backdrop,
body.rename-open .sheet-backdrop,
body.add-open .sheet-backdrop,
body.menu-open .sheet-backdrop {
  opacity: 1;
  pointer-events: auto;
}

body.country-open .country-panel,
body.device-open .device-panel,
body.qr-open .qr-panel,
body.rename-open .rename-panel,
body.add-open .add-panel,
body.menu-open .menu-panel {
  transform: translate(-50%, 0);
}

.grabber {
  width: 160px;
  height: 42px;
  margin: -8px auto -4px;
  border-radius: 99px;
  position: relative;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.grabber::before {
  content: "";
  position: absolute;
  left: 57px;
  right: 57px;
  top: 17px;
  height: 5px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .22);
}

.sheet-head {
  justify-content: space-between;
  margin-bottom: 14px;
}

.sheet-head span {
  color: var(--muted);
  font-size: 13px;
}

.country-list,
.device-list,
.menu-list {
  display: grid;
  gap: 10px;
}

.empty-card {
  padding: 16px;
  border-radius: 20px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  line-height: 1.45;
}

.menu-list button {
  width: 100%;
  padding: 16px;
  border-radius: 20px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  text-align: left;
  font-weight: 800;
}

.qr-box {
  width: min(260px, 86vw);
  margin: 12px auto 14px;
  padding: 16px;
  border-radius: 28px;
  background: #f6fbf8;
  box-shadow: 0 22px 50px rgba(0, 0, 0, .28);
}

.qr-box img {
  display: block;
  width: 100%;
  height: auto;
}

.sheet-note {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.45;
  text-align: center;
}

.download-btn {
  width: 100%;
  min-height: 56px;
  border-radius: 20px;
  color: #06120e;
  background: linear-gradient(135deg, var(--mint), var(--aqua));
  font-weight: 900;
  transition: transform .14s ease, filter .14s ease;
}

.download-btn:active {
  transform: scale(.975);
  filter: brightness(1.08);
}

.input-label {
  display: grid;
  gap: 9px;
  color: var(--muted);
  font-size: 13px;
}

.input-label input {
  width: 100%;
  padding: 17px 16px;
  border-radius: 20px;
  border: 1px solid var(--line);
  outline: none;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
}

.name-warning {
  min-height: 22px;
  margin: 0 0 12px;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.35;
  text-align: left;
}

.name-warning:empty {
  display: none;
}

.country,
.device-option {
  display: grid;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px;
  border-radius: 20px;
  text-align: left;
  background: var(--panel-2);
  border: 1px solid transparent;
  transition: transform .14s ease, background .14s ease, border-color .14s ease;
}

.country { grid-template-columns: 42px 1fr auto; }
.device-option {
  grid-template-columns: 1fr auto;
}

.device-option-main {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.device-delete {
  width: 38px;
  height: 38px;
  border-radius: 14px;
  background: rgba(255, 107, 122, .14);
  border: 1px solid rgba(255, 107, 122, .28);
  color: #ff334d;
  font-size: 31px;
  font-weight: 900;
  line-height: 1;
  display: grid;
  place-items: center;
  padding-bottom: 4px;
}

.device-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 24px;
  background: rgba(23, 34, 48, .74);
  border: 1px solid var(--line);
}

.device-card.active {
  border-color: rgba(116, 242, 189, .42);
  background: linear-gradient(135deg, rgba(116, 242, 189, .14), rgba(70, 200, 255, .07));
}

.device-pick {
  min-width: 0;
  padding: 6px;
  background: transparent;
  text-align: left;
}

.device-pick strong {
  display: block;
  margin-bottom: 5px;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.device-pick span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

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

.device-qr {
  height: 38px;
  min-width: 48px;
  padding: 0 11px;
  border-radius: 14px;
  color: #06120e;
  background: linear-gradient(135deg, var(--mint), var(--aqua));
  font-size: 13px;
  font-weight: 900;
}

.device-rename {
  width: 38px;
  height: 38px;
  border-radius: 14px;
  color: var(--text);
  background: rgba(237, 245, 242, .08);
  border: 1px solid var(--line);
  font-size: 18px;
  font-weight: 900;
  display: grid;
  place-items: center;
}

.confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0, 0, 0, .62);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}

.confirm-dialog {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 21;
  width: min(360px, calc(100% - 34px));
  padding: 22px;
  border-radius: 28px;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 85% 0%, rgba(255, 107, 122, .14), transparent 13rem),
    rgba(13, 20, 29, .98);
  box-shadow: 0 28px 70px rgba(0, 0, 0, .52);
  transform: translate(-50%, -46%) scale(.96);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}

body.confirm-open .confirm-backdrop {
  opacity: 1;
  pointer-events: auto;
}

body.confirm-open .confirm-dialog {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.confirm-dialog h2 {
  margin-bottom: 10px;
}

.confirm-text {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.45;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.confirm-actions button {
  min-height: 52px;
  border-radius: 18px;
  font-weight: 900;
}

.cancel-delete,
.confirm-actions [data-action="cancel-delete"] {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
}

.confirm-delete,
.confirm-actions [data-action="delete-confirm"] {
  background: linear-gradient(135deg, #ff6b7a, #ff334d);
  color: #20070b;
}

.device-delete:active {
  transform: scale(.96);
  background: rgba(255, 107, 122, .22);
}

.country:active,
.device-option:active { transform: scale(.985); }
.country.active,
.device-option.active {
  border-color: rgba(116, 242, 189, .44);
  background: linear-gradient(135deg, rgba(116, 242, 189, .16), rgba(70, 200, 255, .08));
}

.country span { font-size: 28px; }
.country strong,
.device-option strong { font-size: 17px; }
.country em,
.device-option span {
  color: var(--muted);
  font-style: normal;
  font-size: 13px;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 6;
  width: min(394px, calc(100vw - 36px));
  transform: translateX(-50%);
  padding: 8px;
  gap: 8px;
  border-radius: 22px;
  background: rgba(8, 13, 19, .78);
  border: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.bottom-nav button {
  flex: 1;
  min-width: 0;
  padding: 10px 4px 9px;
  border-radius: 16px;
  background: transparent;
  color: var(--muted);
  display: grid;
  gap: 3px;
  place-items: center;
  transition: transform .14s ease, background .14s ease;
}

.bottom-nav button:active {
  transform: scale(.96);
}

.bottom-nav span {
  display: none;
}

.bottom-nav svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .96;
}

.bottom-nav em {
  font-size: 11px;
  font-style: normal;
  line-height: 1.1;
}

.bottom-nav button.active {
  color: #06120e;
  background: var(--mint);
  font-weight: 800;
}

@media (max-width: 390px) {
  .phone {
    padding-top: 30px;
  }
  .country-panel,
  .device-panel,
  .qr-panel,
  .rename-panel,
  .add-panel,
  .menu-panel {
    width: 100%;
  }
}
