@media (max-width: 900px) {
  body {
    overflow-x: hidden;
  }

  .layout {
    display: block;
    min-height: 100vh;
    padding: 0 16px calc(96px + env(safe-area-inset-bottom));
  }

  #sidebar {
    display: none;
  }

  .app {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    padding: calc(20px + env(safe-area-inset-top)) 0 0;
    box-sizing: border-box;
  }

  #page {
    animation: mobilePageIn .28s cubic-bezier(.2,.9,.25,1) both;
  }

  .top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
  }

  .top .muted {
    font-size: 12px;
    letter-spacing: .08em;
    text-transform: uppercase;
  }

  h1 {
    font-size: 34px;
    line-height: 1;
    margin-top: 8px;
    letter-spacing: -1px;
  }

  .icon-button {
    width: 52px;
    height: 52px;
    border-radius: 18px;
  }

  .dashboard {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .left-column,
  .right-column {
    display: contents;
  }

  .hero-card,
  .section {
    border-radius: 26px;
    padding: 24px 20px;
    animation: mobileCardIn .32s cubic-bezier(.2,.9,.25,1) both;
    transform-origin: center top;
  }

  .hero-card {
    min-height: 255px;
    order: 1;
    animation-delay: .02s;
  }

  .right-column .section:nth-child(1) {
    order: 2;
    animation-delay: .08s;
  }

  .right-column .section:nth-child(2) {
    order: 3;
    animation-delay: .14s;
  }

  .network-section {
    order: 4;
    animation-delay: .20s;
    margin-bottom: 8px;
  }

  .status-row,
  .section-head,
  .device-row {
    gap: 14px;
  }

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

  .section-head h3 {
    font-size: 24px;
    line-height: 1.1;
  }

  .section-head .text-button {
    flex-shrink: 0;
    min-height: 38px;
    padding: 8px 14px;
    font-size: 14px;
    border-radius: 15px;
    white-space: nowrap;
  }

  .hero-card h2 {
    font-size: 26px;
  }

  .date strong {
    font-size: 17px;
  }

  .usage {
    margin: 26px 0;
  }

  .primary-button {
    height: 54px;
    border-radius: 18px;
    font-size: 15px;
  }

  .device-card {
    min-height: 88px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 18px;
    border-radius: 22px;
  }

  .device-card h4 {
    font-size: 18px;
  }

  .device-card p {
    font-size: 15px;
  }

  .small-button,
  .text-button {
    min-height: 42px;
    padding: 10px 16px;
    border-radius: 16px;
  }

  .device-card .small-button {
    flex-shrink: 0;
  }

  .actions {
    gap: 12px;
  }

  .actions button {
    min-height: 54px;
    padding: 16px 18px;
    border-radius: 18px;
  }

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

  .network-grid div {
    padding: 18px;
    border-radius: 20px;
  }

  .device-full-card,
  .tariff-card,
  .profile-main-card,
  .profile-subscription,
  .profile-actions {
    transform-origin: center top;
  }

  button,
  .nav-item,
  .bottom-nav button,
  .device-card,
  .device-full-card,
  .tariff-card {
    -webkit-tap-highlight-color: transparent;
  }

  button:active,
  .bottom-nav button:active,
  .device-card:active,
  .device-full-card:active,
  .tariff-card:active {
    transform: scale(.985);
  }

  .bottom-nav {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    z-index: 100;
    max-width: 520px;
    height: 78px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 10px;
    border-radius: 28px;
    background: rgba(18,18,20,.88);
    border: 1px solid rgba(255,255,255,.08);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    box-shadow: 0 20px 60px rgba(0,0,0,.45);
    transform: translateZ(0);
  }

  .bottom-nav button {
    position: relative;
    overflow: hidden;
    min-height: 48px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    border-radius: 18px;
    font-size: 12px;
    font-weight: 650;
    color: #9f9f9f;
    transition: .22s;
  }

  .bottom-nav button.active {
    background: #f4f4f4;
    color: #050505;
    transform: translateY(-2px);
    box-shadow: 0 8px 26px rgba(255,255,255,.16);
  }

  .bottom-nav button::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: rgba(255,255,255,.12);
    opacity: 0;
    transition: .18s;
  }

  .bottom-nav button:active::after {
    opacity: 1;
  }

  .nav-icon {
    font-size: 18px;
    line-height: 1;
  }

  #showAddDevice,
  #page .section-head .text-button[data-page="devices"] {
    width: 52px !important;
    height: 52px !important;
    min-width: 52px !important;
    min-height: 52px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 18px !important;
    font-size: 0 !important;
  }

  #showAddDevice::before,
  #page .section-head .text-button[data-page="devices"]::before {
    content: "";
    width: 24px;
    height: 24px;
    display: block;
    background-image: url("../assets/png/add.png");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 24px;
  }

  #homeDeviceKey {
    width: 54px !important;
    height: 54px !important;
    min-width: 54px !important;
    min-height: 54px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 18px !important;
    font-size: 0 !important;
  }

  #homeDeviceKey::before,
  .show-device-key::before,
  .show-device-qr::before,
  .show-device-delete::before {
    content: "";
    width: 24px;
    height: 24px;
    display: block;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 24px;
  }

  #homeDeviceKey::before,
  .show-device-key::before {
    background-image: url("../assets/png/key.png");
  }

  .show-device-qr::before {
    background-image: url("../assets/png/qr.png");
  }

  .show-device-delete::before {
    background-image: url("../assets/png/delete.png");
    filter: brightness(0) saturate(100%) invert(79%) sepia(26%) saturate(946%) hue-rotate(304deg) brightness(107%) contrast(104%);
  }

  .device-actions {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }

  .device-actions button {
    height: 56px;
    padding: 0 !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 18px;
    font-size: 0 !important;
  }

  .modal {
    padding: 14px;
    align-items: flex-end;
  }

  .modal-window {
    width: 100%;
    max-width: 520px;
    border-radius: 28px;
    padding: 26px 22px;
    animation: mobileModalIn .24s cubic-bezier(.2,.9,.25,1) both;
  }

  .payments-window {
    width: 100%;
  }

  .payment-item {
    padding: 16px;
  }

  .toast {
    left: 18px;
    right: 18px;
    top: auto;
    bottom: calc(92px + env(safe-area-inset-bottom));
    text-align: center;
  }

  .mobile-sheet {
    position: fixed;
    inset: 0;
    z-index: 1500;
    display: none;
    align-items: flex-end;
    padding: 16px;
    background: rgba(0,0,0,.58);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }

  .mobile-sheet.active {
    display: flex;
  }

  .mobile-sheet-window {
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    display: grid;
    gap: 10px;
    animation: sheetIn .24s cubic-bezier(.2,.9,.25,1) both;
  }

  .mobile-sheet-group {
    overflow: hidden;
    border-radius: 24px;
    background: rgba(28,28,30,.92);
    border: 1px solid rgba(255,255,255,.1);
  }

  .mobile-sheet button {
    width: 100%;
    min-height: 56px;
    border-radius: 0;
    border: none;
    background: transparent;
    color: var(--text);
    font-weight: 700;
    font-size: 16px;
  }

  .mobile-sheet button + button {
    border-top: 1px solid rgba(255,255,255,.08);
  }

  .mobile-sheet-cancel {
    border-radius: 22px !important;
    background: #f4f4f4 !important;
    color: #050505 !important;
  }

  @keyframes mobileCardIn {
    from {
      opacity: 0;
      transform: translateY(18px) scale(.985);
    }

    to {
      opacity: 1;
      transform: none;
    }
  }

  @keyframes mobilePageIn {
    from {
      opacity: 0;
      transform: translateY(12px);
    }

    to {
      opacity: 1;
      transform: none;
    }
  }

  @keyframes mobileModalIn {
    from {
      opacity: 0;
      transform: translateY(20px) scale(.97);
    }

    to {
      opacity: 1;
      transform: none;
    }
  }

  @keyframes sheetIn {
    from {
      opacity: 0;
      transform: translateY(22px) scale(.98);
    }

    to {
      opacity: 1;
      transform: none;
    }
  }
}
@media (max-width:900px){
  .right-column .section:nth-child(1) .section-head{
    margin-bottom:18px;
  }

  #page .section-head .text-button[data-page="devices"]{
    position:relative;
    top:-2px;
  }
}
.hero-card,
.section,
.device-card,
.device-full-card,
.tariff-card{
    transition:
        transform .18s ease,
        box-shadow .25s ease;
}

.hero-card:active,
.section:active,
.device-card:active,
.device-full-card:active,
.tariff-card:active{

    transform:
        scale(.985)
        translateY(1px);
}


/* ===== MOBILE PROFILE ===== */
@media (max-width:900px){

  .profile-page{
    display:grid;
    grid-template-columns:1fr;
    gap:18px;
  }

  .profile-main-card,
  .profile-subscription,
  .profile-actions{
    animation:mobileCardIn .32s cubic-bezier(.2,.9,.25,1) both;
  }

  .profile-main-card{
    order:1;
  }

  .profile-subscription{
    order:2;
    padding:26px 22px;
  }

  .profile-actions{
    order:3;
  }

  .profile-top{
    align-items:center;
    margin-bottom:26px;
  }

  .profile-avatar{
    width:64px;
    height:64px;
    border-radius:22px;
    font-size:24px;
  }

  .profile-top h3{
    font-size:22px;
  }

  .profile-top .muted{
    margin-top:4px;
  }

  .profile-top .status-badge{
    margin-left:auto;
    padding:8px 12px;
    font-size:12px;
  }

  .profile-info-grid{
    grid-template-columns:1fr 1fr;
    gap:12px;
  }

  .profile-info-grid div{
    padding:16px;
    border-radius:18px;
  }

  .profile-info-grid span{
    font-size:12px;
  }

  .profile-info-grid strong{
    font-size:16px;
  }

  .subscription-plan{
    margin-top:16px;
    font-size:34px;
    letter-spacing:2px;
  }

  .subscription-date strong{
    font-size:22px;
  }

  .profile-action-list{
    gap:0;
    overflow:hidden;
    border-radius:22px;
    background:rgba(255,255,255,.035);
    border:1px solid rgba(255,255,255,.06);
  }

  .profile-action-list button{
    min-height:58px;
    padding:0 18px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    border:none;
    border-radius:0;
    background:transparent;
    font-size:16px;
  }

  .profile-action-list button + button{
    border-top:1px solid rgba(255,255,255,.07);
  }

  .profile-action-list button::after{
    content:"›";
    color:var(--muted);
    font-size:24px;
    line-height:1;
  }

  .profile-action-list button:active{
    background:rgba(255,255,255,.05);
  }

}