:root {
  --bg: #030812;
  --bg-soft: #07111f;
  --panel: rgba(10, 22, 38, .84);
  --panel-strong: rgba(13, 28, 48, .94);
  --line: rgba(129, 173, 222, .16);
  --line-strong: rgba(30, 232, 185, .42);
  --text: #f4f8ff;
  --muted: #94a4b8;
  --soft: #c5d2e2;
  --mint: #18e7b2;
  --cyan: #16d4df;
  --blue: #2384ff;
  --red: #ff5f55;
  --yellow: #ffc857;
  --shadow: 0 28px 90px rgba(0, 0, 0, .44);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  min-width: 0;
}

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--text);
  background:
    radial-gradient(circle at 18% -8%, rgba(35, 132, 255, .18), transparent 32rem),
    radial-gradient(circle at 96% 2%, rgba(24, 231, 178, .12), transparent 28rem),
    linear-gradient(180deg, #04101d 0%, #020712 58%, #02050c 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  overflow-x: clip;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, .025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .025) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, .72), transparent 76%);
}

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

button,
input,
select,
textarea {
  font: inherit;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 18px;
  color: var(--text);
  background: rgba(10, 22, 38, .72);
  font-weight: 850;
  line-height: 1;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .035);
}

button:disabled {
  opacity: .48;
  cursor: not-allowed;
}

button svg,
.button svg,
.icon-button svg,
.top-nav svg,
.quick-actions svg,
.mobile-menu svg,
.mobile-bottom-nav svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

.primary {
  border: 0;
  color: #f7ffff;
  background: linear-gradient(135deg, #17dca7, #16bfd2 54%, #2274e8);
  box-shadow: 0 12px 28px rgba(11, 117, 210, .18);
}

.ghost {
  background: rgba(255, 255, 255, .045);
}

.danger-button {
  border-color: rgba(255, 95, 85, .46);
  color: #ffd7d3;
  background: rgba(255, 95, 85, .1);
}

.danger-button:hover {
  border-color: rgba(255, 95, 85, .72);
  background: rgba(255, 95, 85, .16);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--text);
  background: rgba(10, 22, 38, .72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .035);
}

.muted,
.muted-label,
.last-signal,
small {
  color: var(--muted);
}

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

h1 {
  margin-bottom: 12px;
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 10px;
  font-size: clamp(22px, 2.4vw, 30px);
  line-height: 1.12;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 4px;
  font-size: 17px;
  line-height: 1.22;
}

p {
  line-height: 1.5;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(129, 173, 222, .16);
  border-radius: 13px;
  padding: 13px 14px;
  color: var(--text);
  background: rgba(255, 255, 255, .055);
  outline: none;
}

select {
  color-scheme: dark;
}

select option,
select optgroup {
  color: #eef6ff;
  background: #091827;
}

select option:checked {
  color: #fff;
  background: #1e6bd2;
}

select option:disabled {
  color: #8290a5;
  background: #101927;
}

input::placeholder,
textarea::placeholder {
  color: rgba(197, 210, 226, .54);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 3px rgba(24, 231, 178, .1);
}

label {
  display: grid;
  gap: 8px;
  color: var(--soft);
  font-size: 13px;
  font-weight: 750;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}

.check {
  display: flex;
  align-items: center;
  gap: 9px;
}

.check input {
  width: auto;
}

.app-body {
  padding: 24px 24px 24px 244px;
}

.shell-header {
  position: fixed;
  inset: 24px auto 24px 24px;
  z-index: 20;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 22px;
  width: 196px;
  padding: 18px 14px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(5, 13, 24, .74);
  backdrop-filter: blur(22px);
  box-shadow: var(--shadow);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
}

.brand img {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 10px;
  object-fit: cover;
}

.brand b {
  display: block;
  color: #fff;
  font-size: 15px;
  line-height: 1;
  white-space: nowrap;
}

.brand b span {
  color: transparent;
  background: linear-gradient(135deg, var(--mint), var(--cyan), var(--blue));
  -webkit-background-clip: text;
  background-clip: text;
}

.brand small {
  display: block;
  max-width: 130px;
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-nav {
  display: grid;
  align-content: start;
  gap: 8px;
}

.top-nav a {
  display: grid;
  grid-template-columns: 20px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border-radius: 12px;
  padding: 0 10px;
  color: #c8d4e4;
  font-size: 13px;
  font-weight: 750;
}

.top-nav a:hover,
.top-nav a.active {
  color: #fff;
  background: rgba(129, 173, 222, .11);
}

.top-nav a.active svg {
  color: var(--mint);
}

.header-side {
  display: grid;
  gap: 10px;
}

.status-pill {
  display: block;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 10px;
  overflow: hidden;
  font-size: 11px;
  font-weight: 850;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-pill.ok {
  color: #8fffe0;
  background: rgba(24, 231, 178, .1);
}

.status-pill.warn {
  color: #ffe2a3;
  background: rgba(255, 200, 87, .1);
}

.header-side form,
.header-side button {
  width: 100%;
}

.container {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.mobile-title {
  display: none;
}

.mobile-menu,
.mobile-bottom-nav {
  display: none;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
  margin-bottom: 18px;
}

.control-card,
.panel,
.device-card,
.user-card,
.plan-card,
.table-wrap,
.notice {
  border: 1px solid var(--line);
  border-radius: 20px;
  background:
    linear-gradient(145deg, rgba(13, 29, 50, .9), rgba(5, 14, 25, .82)),
    rgba(9, 20, 35, .82);
  backdrop-filter: blur(16px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .035), 0 20px 70px rgba(0, 0, 0, .22);
}

.control-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  align-items: center;
  min-height: 196px;
  padding: 28px 30px;
  overflow: hidden;
}

.control-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 72% 50%, rgba(24, 231, 178, .18), transparent 20rem),
    linear-gradient(90deg, transparent, rgba(35, 132, 255, .08));
}

.control-card > * {
  position: relative;
  z-index: 1;
}

.muted-label {
  margin-bottom: 6px;
  font-weight: 800;
}

.open-state {
  margin: 0 0 26px;
  color: var(--mint);
  font-size: 26px;
  font-weight: 900;
}

.last-signal {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}

.open-form {
  display: grid;
  place-items: center;
}

.open-button {
  position: relative;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 4px;
  place-items: center;
  width: 98px;
  height: 98px;
  border: 1px solid rgba(24, 231, 178, .42);
  border-radius: 26px;
  padding: 0;
  color: #9effe6;
  background:
    radial-gradient(circle at 50% 42%, rgba(24, 231, 178, .18), transparent 56%),
    linear-gradient(145deg, rgba(15, 50, 57, .9), rgba(5, 18, 30, .96));
  box-shadow: 0 10px 34px rgba(0, 0, 0, .24), 0 0 22px rgba(24, 231, 178, .1), inset 0 1px 0 rgba(255, 255, 255, .05);
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.open-button:not(:disabled):hover {
  transform: translateY(-1px);
  border-color: rgba(24, 231, 178, .78);
  box-shadow: 0 14px 42px rgba(0, 0, 0, .28), 0 0 26px rgba(24, 231, 178, .16), inset 0 1px 0 rgba(255, 255, 255, .06);
}

.open-button:disabled {
  opacity: .56;
}

.open-button::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: inherit;
  background: radial-gradient(circle at 50% 38%, rgba(22, 95, 92, .34), rgba(5, 18, 30, .18));
}

.open-button span,
.open-button b {
  position: relative;
  z-index: 1;
}

.open-button span {
  display: grid;
  place-items: center;
}

.open-button svg {
  width: 27px;
  height: 27px;
  margin-bottom: 3px;
  stroke-width: 1.8;
}

.open-button b {
  font-size: 12px;
  line-height: 1;
}

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

.dashboard-grid > .stat-grid {
  grid-template-columns: 1fr;
}

.stat-grid article {
  display: grid;
  align-content: center;
  min-height: 116px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  background: rgba(10, 22, 38, .74);
}

.stat-grid span {
  color: var(--soft);
  font-size: 13px;
  font-weight: 800;
}

.stat-grid b {
  margin: 8px 0 4px;
  color: var(--mint);
  font-size: 40px;
  line-height: 1;
}

.stat-grid b.danger,
.danger {
  color: var(--red);
}

.online {
  color: var(--mint);
}

.stat-grid small {
  font-weight: 800;
}

.quick-actions {
  display: none;
}

.panel,
.notice {
  padding: 20px;
}

.notice {
  margin-bottom: 18px;
  border-color: rgba(255, 200, 87, .32);
  color: #ffe5ac;
  background: rgba(255, 200, 87, .1);
}

.section-head,
.page-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.page-title {
  margin-bottom: 18px;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--mint);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.soft-link {
  color: #9effe6;
  font-size: 13px;
  font-weight: 850;
}

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

.event-line {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 58px;
  border-bottom: 1px solid rgba(129, 173, 222, .1);
  padding: 10px 0;
}

.event-line:last-child {
  border-bottom: 0;
}

.event-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid currentColor;
  border-radius: 11px;
}

.event-line.ok .event-icon {
  color: var(--mint);
}

.event-line.bad .event-icon {
  color: var(--red);
}

.event-line b,
.event-line small {
  display: block;
}

.event-line time {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(3, 1fr);
  min-width: 320px;
  margin-bottom: 14px;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(10, 22, 38, .86);
}

.segmented span {
  padding: 12px 18px;
  color: var(--soft);
  text-align: center;
  font-weight: 800;
}

.segmented .active {
  color: #fff;
  background: rgba(24, 231, 178, .12);
  box-shadow: inset 0 -2px 0 var(--mint);
}

.user-list,
.device-grid,
.plan-grid {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.user-list {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.device-grid,
.plan-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.user-card {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  min-height: 86px;
  padding: 14px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  color: #08131f;
  background: linear-gradient(180deg, #fff, #aebccd);
  font-size: 22px;
  font-weight: 900;
}

.user-card h3,
.user-card p {
  margin: 0;
}

.user-card > .icon-button {
  grid-column: -2;
  justify-self: end;
}

.crown {
  color: var(--yellow);
}

.device-card {
  padding: 20px;
}

.device-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.device-actions form {
  margin: 0;
}

.device-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(129, 173, 222, .12);
}

.device-head h2,
.device-head p {
  margin: 0;
}

.switch {
  position: relative;
  width: 54px;
  height: 30px;
  min-height: 30px;
  border: 0;
  border-radius: 999px;
  padding: 0;
  background: rgba(255, 255, 255, .14);
}

.switch::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #dce7f4;
  transition: transform .18s ease;
}

.switch.on {
  background: linear-gradient(135deg, var(--mint), var(--cyan));
}

.switch.on::before {
  transform: translateX(24px);
}

dl {
  display: grid;
  grid-template-columns: minmax(120px, .8fr) minmax(0, 1fr);
  gap: 14px 20px;
  margin: 0;
}

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

dd {
  margin: 0;
  text-align: right;
  font-weight: 850;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  align-items: end;
}

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

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(129, 173, 222, .1);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--mint);
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.plan-card {
  padding: 22px;
}

.plan-card h2 small {
  margin-left: 4px;
  color: var(--muted);
  font-size: 15px;
}

.plan-card ul,
.prose ul {
  margin-bottom: 0;
  padding-left: 20px;
  color: var(--soft);
  line-height: 1.7;
}

.flash {
  margin-bottom: 16px;
  border: 1px solid rgba(35, 132, 255, .32);
  border-radius: 14px;
  padding: 12px 14px;
  color: #d9ecff;
  background: rgba(35, 132, 255, .13);
  font-weight: 800;
}

.flash.bad {
  border-color: rgba(255, 95, 85, .42);
  color: #ffd0cc;
  background: rgba(255, 95, 85, .12);
}

.login-body {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 22px;
  background:
    radial-gradient(circle at 50% -10%, rgba(35, 132, 255, .18), transparent 34rem),
    linear-gradient(180deg, #07111f, #020712);
}

.login-phone {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(390px, 100%);
  min-height: min(844px, calc(100dvh - 44px));
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 44px;
  padding: 22px 28px 32px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(4, 12, 23, .96), rgba(4, 12, 23, .78) 46%, rgba(3, 8, 18, .96)),
    #06101d;
  box-shadow: var(--shadow), inset 0 0 0 8px rgba(0, 0, 0, .22);
}

.phone-status {
  display: none;
  justify-content: space-between;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.login-logo {
  z-index: 1;
  width: 90px;
  height: 90px;
  margin: 48px auto 20px;
  border-radius: 24px;
  object-fit: cover;
}

.login-phone h1,
.login-copy,
.login-form {
  position: relative;
  z-index: 2;
}

.login-phone h1 {
  margin-bottom: 12px;
  text-align: center;
  font-size: 30px;
}

.login-copy {
  margin-bottom: 0;
  color: #dce8f4;
  text-align: center;
  font-weight: 700;
}

.login-scene {
  position: absolute;
  left: 0;
  right: 0;
  top: clamp(292px, 38dvh, 328px);
  height: clamp(210px, 29dvh, 270px);
  background:
    linear-gradient(90deg, rgba(4, 12, 23, .88), rgba(4, 12, 23, .08) 22%, rgba(4, 12, 23, .08) 78%, rgba(4, 12, 23, .88)),
    linear-gradient(180deg, rgba(4, 12, 23, .02), rgba(4, 12, 23, .2) 58%, rgba(4, 12, 23, .92) 100%),
    url("/public/gate-bg.png") center center / 100% auto no-repeat;
  opacity: .98;
  mask-image: linear-gradient(180deg, transparent 0%, #000 16%, #000 82%, transparent 100%);
}

.login-form {
  display: grid;
  gap: 12px;
  width: 100%;
  margin-top: auto;
}

.login-submit {
  min-height: 56px;
  border-radius: 12px;
  font-size: 16px;
}

@media (min-width: 861px) {
  .login-body {
    place-items: center;
    padding: 48px;
    background:
      radial-gradient(circle at 24% 12%, rgba(24, 231, 178, .12), transparent 32rem),
      radial-gradient(circle at 78% 8%, rgba(35, 132, 255, .18), transparent 36rem),
      linear-gradient(180deg, #07111f, #020712 72%, #02050c);
  }

  .login-phone {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 392px;
    grid-template-rows: auto auto auto 1fr;
    align-items: start;
    gap: 12px 58px;
    width: min(1120px, calc(100vw - 96px));
    min-height: min(680px, calc(100dvh - 96px));
    border-radius: 30px;
    padding: 56px;
    background:
      linear-gradient(105deg, rgba(6, 19, 34, .96), rgba(6, 19, 34, .86) 48%, rgba(4, 12, 23, .96) 100%),
      #06101d;
    box-shadow: 0 34px 120px rgba(0, 0, 0, .42), inset 0 1px 0 rgba(255, 255, 255, .055);
  }

  .phone-status {
    display: none;
  }

  .login-logo {
    grid-column: 1;
    width: 88px;
    height: 88px;
    margin: 0 0 24px;
  }

  .login-phone h1 {
    grid-column: 1;
    margin: 0;
    text-align: left;
    font-size: clamp(42px, 4vw, 58px);
    line-height: 1;
  }

  .login-copy {
    grid-column: 1;
    max-width: 460px;
    margin: 2px 0 0;
    color: #dce8f4;
    text-align: left;
    font-size: 22px;
    line-height: 1.42;
    font-weight: 800;
  }

  .login-scene {
    left: 0;
    right: auto;
    top: auto;
    bottom: 0;
    width: 66%;
    height: 390px;
    background:
      linear-gradient(90deg, rgba(4, 12, 23, .78), rgba(4, 12, 23, .08) 32%, rgba(4, 12, 23, .92) 100%),
      linear-gradient(180deg, rgba(4, 12, 23, 0), rgba(4, 12, 23, .2) 52%, rgba(4, 12, 23, .96) 100%),
      url("/public/gate-bg.png") center bottom / cover no-repeat;
    mask-image: linear-gradient(180deg, transparent 0%, #000 18%, #000 100%);
  }

  .login-form {
    grid-column: 2;
    grid-row: 1 / 5;
    align-self: center;
    margin: 0;
    border: 1px solid rgba(129, 173, 222, .18);
    border-radius: 22px;
    padding: 26px;
    background: rgba(6, 17, 30, .84);
    box-shadow: 0 24px 80px rgba(0, 0, 0, .28), inset 0 1px 0 rgba(255, 255, 255, .04);
    backdrop-filter: blur(18px);
  }
}

@media (max-width: 960px) {
  .app-body {
    padding: 78px 14px 20px;
  }

  .shell-header {
    inset: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: auto;
    min-height: 62px;
    border-width: 0 0 1px;
    border-radius: 0;
    padding: 10px 14px;
  }

  .top-nav {
    display: none;
  }

  .brand small,
  .status-pill {
    display: none;
  }

  .header-side {
    display: block;
  }

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

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

  .control-card {
    grid-template-columns: minmax(0, 1fr) 132px;
  }

  .open-button {
    width: 104px;
    height: 104px;
  }
}

@media (max-width: 640px) {
  body::before {
    display: none;
  }

  .app-body {
    padding: 14px 12px calc(92px + env(safe-area-inset-bottom));
  }

  .shell-header {
    display: none;
  }

  .brand img {
    width: 40px;
    height: 40px;
  }

  .brand b {
    font-size: 18px;
  }

  .header-side form {
    display: none;
  }

  .mobile-title {
    display: grid;
    grid-template-columns: 44px 1fr 44px;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    margin-bottom: 14px;
  }

  .mobile-menu {
    position: relative;
    z-index: 30;
    display: block;
    width: 44px;
    height: 44px;
  }

  .mobile-menu summary {
    list-style: none;
  }

  .mobile-menu summary::-webkit-details-marker {
    display: none;
  }

  .mobile-menu nav {
    position: absolute;
    top: 52px;
    left: 0;
    display: grid;
    gap: 6px;
    width: min(246px, calc(100vw - 24px));
    border: 1px solid rgba(129, 173, 222, .2);
    border-radius: 17px;
    padding: 8px;
    background: rgba(5, 13, 24, .96);
    box-shadow: 0 24px 70px rgba(0, 0, 0, .42);
    backdrop-filter: blur(18px);
  }

  .mobile-menu nav a,
  .mobile-menu nav button {
    display: grid;
    grid-template-columns: 22px 1fr;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 42px;
    border: 0;
    border-radius: 12px;
    padding: 0 10px;
    color: #dce8f4;
    background: transparent;
    font-size: 13px;
    font-weight: 850;
    text-align: left;
  }

  .mobile-menu nav a.active,
  .mobile-menu nav a:hover,
  .mobile-menu nav button:hover {
    color: #fff;
    background: rgba(129, 173, 222, .12);
  }

  .mobile-menu nav a.active svg {
    color: var(--mint);
  }

  .mobile-menu form {
    margin: 0;
  }

  .mobile-title h1 {
    margin: 0;
    text-align: center;
    font-size: 18px;
  }

  .mobile-title > svg {
    justify-self: center;
    color: #dce8f4;
    width: 22px;
    height: 22px;
  }

  .mobile-bottom-nav {
    position: fixed;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 10px;
    z-index: 25;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(54px, 1fr));
    gap: 4px;
    border: 1px solid rgba(129, 173, 222, .18);
    border-radius: 21px;
    padding: 7px;
    background: rgba(5, 13, 24, .9);
    box-shadow: 0 20px 60px rgba(0, 0, 0, .42);
    backdrop-filter: blur(18px);
  }

  .mobile-bottom-nav a {
    display: grid;
    place-items: center;
    gap: 4px;
    min-height: 52px;
    border-radius: 14px;
    color: #91a1b6;
    font-size: 10px;
    font-weight: 850;
    line-height: 1.05;
    text-align: center;
  }

  .mobile-bottom-nav a.active {
    color: #fff;
    background: rgba(24, 231, 178, .1);
  }

  .mobile-bottom-nav a.active svg {
    color: var(--mint);
  }

  .page-title {
    display: none;
  }

  .dashboard-grid {
    gap: 14px;
  }

  .control-card {
    grid-template-columns: 1fr;
    min-height: 226px;
    padding: 20px;
  }

  .control-card .open-form {
    margin-top: 14px;
  }

  .open-state {
    margin-bottom: 12px;
    font-size: 20px;
  }

  .open-button {
    width: 84px;
    height: 84px;
    border-radius: 23px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .24), 0 0 20px rgba(24, 231, 178, .1);
  }

  .open-button::before {
    inset: 8px;
  }

  .open-button svg {
    width: 24px;
    height: 24px;
    margin-bottom: 5px;
  }

  .open-button b {
    font-size: 12px;
  }

  .dashboard-grid > .stat-grid {
    display: none;
  }

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

  .quick-actions a {
    display: grid;
    place-items: center;
    min-height: 82px;
    border: 1px solid var(--line);
    border-radius: 15px;
    padding: 12px 8px;
    background: rgba(10, 22, 38, .82);
    color: #fff;
    font-size: 12px;
    font-weight: 850;
    line-height: 1.12;
    text-align: center;
  }

  .quick-actions a span {
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .quick-actions svg {
    width: 28px;
    height: 28px;
    margin-bottom: 6px;
    color: var(--mint);
  }

  .panel,
  .device-card,
  .user-card,
  .plan-card,
  .notice {
    border-radius: 16px;
    padding: 16px;
  }

  .section-head h2 {
    font-size: 18px;
  }

  .event-line {
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 12px;
  }

  .event-line time {
    grid-column: 2;
    margin-top: -6px;
  }

  .segmented {
    width: 100%;
    min-width: 0;
  }

  .user-list,
  .device-grid,
  .plan-grid {
    grid-template-columns: 1fr;
  }

  .user-card {
    grid-template-columns: 46px minmax(0, 1fr) auto;
  }

  .user-card form {
    display: none;
  }

  .device-head {
    align-items: center;
  }

  .device-actions {
    display: grid;
    justify-content: stretch;
  }

  .device-actions .danger-button {
    width: 100%;
  }

  dl {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
  }

  dd {
    max-width: 46vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

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

  table {
    min-width: 640px;
  }

  th,
  td {
    padding: 11px 12px;
    font-size: 13px;
  }

  .login-body {
    padding: 0;
  }

  .login-phone {
    width: 100%;
    min-height: 100dvh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: max(16px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  }

  .login-logo {
    width: 86px;
    height: 86px;
    margin-top: 38px;
  }

  .login-scene {
    top: clamp(278px, 37dvh, 318px);
    height: clamp(198px, 29dvh, 254px);
    background-size: 100% auto;
  }
}

@media (max-width: 390px) {
  .app-body {
    padding-left: 10px;
    padding-right: 10px;
  }

  .control-card {
    padding: 18px;
  }

  .login-phone {
    padding-left: 18px;
    padding-right: 18px;
  }

  .login-logo {
    margin-top: 30px;
  }

  .login-phone h1 {
    font-size: 28px;
  }

  .login-scene {
    top: 270px;
    height: 194px;
  }
}
