
:root{
  --bg:#050505;
  --surface:#151515;
  --surface-2:#1b1b1b;
  --text:#fff;
  --muted:#999;
  --line:#303030;
  --app-height:100dvh;
  --safe-top:env(safe-area-inset-top,0px);
  --safe-right:env(safe-area-inset-right,0px);
  --safe-bottom:env(safe-area-inset-bottom,0px);
  --safe-left:env(safe-area-inset-left,0px);
  --telegram-top-offset:0px;
  --telegram-bottom-offset:0px;
}

*{box-sizing:border-box}
html,body{
  width:100%;
  height:100%;
  margin:0;
  overflow:hidden;
  background:#050505;
  color:var(--text);
  font-family:-apple-system,BlinkMacSystemFont,"SF Pro Display","Segoe UI",sans-serif;
  -webkit-text-size-adjust:100%;
}
button,input{font:inherit}
button{color:inherit}

.app-shell{
  width:100%;
  max-width:none;
  height:var(--app-height);
  min-height:0;
  margin:0 auto;
  padding:
    max(var(--safe-top), var(--telegram-top-offset))
    max(12px,var(--safe-right))
    max(var(--safe-bottom), var(--telegram-bottom-offset))
    max(12px,var(--safe-left));
  display:grid;
  grid-template-rows:58px minmax(0,1fr) 66px;
  background:linear-gradient(180deg,#0b0b0b,#030303);
  overflow:hidden;
}

.topbar{
  position:relative;
  flex-shrink:0;
  height:58px;
  padding:0;
  display:grid;
  grid-template-columns:40px minmax(0,1fr) 40px;
  align-items:center;
  z-index:10;
  background:linear-gradient(180deg,#080808 80%,rgba(8,8,8,0));
}
.brand{
  justify-self:center;
  display:flex;
  align-items:center;
  gap:8px;
  font-size:18px;
  font-weight:800;
  transform: translateX(28px);
}
.brand-logo{width:30px;height:30px;border-radius:10px;display:grid;place-items:center;background:linear-gradient(145deg,#fff,#777);color:#050505;font-weight:900}
.icon-button{width:38px;height:38px;border:1px solid var(--line);border-radius:50%;background:#171717;display:grid;place-items:center;font-size:18px}
.icon-button:last-child{justify-self:end}

#appContent{
  min-height:0;
  min-width:0;
  overflow-y:auto;
  overflow-x:hidden;
  padding:8px 0 18px;
  -webkit-overflow-scrolling:touch;
  overscroll-behavior:contain;
  scrollbar-width:none;
}
#appContent::-webkit-scrollbar{display:none}

.app-page{display:none;animation:pageIn .2s ease}
.app-page.active{display:block}
@keyframes pageIn{from{opacity:.35;transform:translateY(6px)}to{opacity:1;transform:none}}

.status-card,.summary-card,.connect-card,.balance-card,.settings-card{
  background:linear-gradient(145deg,#1b1b1b,#111);
  border:1px solid rgba(255,255,255,.08);
  border-radius:20px;
  padding:16px;
}
.status-card .d-flex{align-items:flex-start!important}
.status-pill{display:inline-flex;align-items:center;gap:8px;font-size:12px;font-weight:800;background:#252525;border:1px solid #383838;padding:6px 10px;border-radius:999px}
.dot{width:7px;height:7px;border-radius:50%;background:#fff;box-shadow:0 0 10px #fff}
.plan-name{font-size:17px;font-weight:750}
.small-dark-button,.secondary-button{background:#242424;border:1px solid #3b3b3b;border-radius:14px;padding:9px 13px;font-weight:700}

.progress-ring{
  --size:140px;
  width:var(--size);height:var(--size);margin:0 auto;border-radius:50%;
  display:grid;place-items:center;
  background:conic-gradient(#fff calc(var(--progress)*1%),#333 0);
  position:relative;
}
.progress-ring:before{content:"";position:absolute;inset:11px;border-radius:50%;background:#171717}
.progress-ring-inner{position:relative;display:grid;text-align:center}
.progress-ring-inner strong{font-size:44px;line-height:1}
.progress-ring-inner span{color:var(--muted);margin-top:4px;font-size:12px;white-space:nowrap}

.muted{color:var(--muted);font-size:14px}
.divider{height:1px;background:var(--line);margin:18px 0}
.thin-progress{height:8px;border-radius:999px;background:#303030;overflow:hidden}
.thin-progress span{display:block;height:100%;background:#fff;border-radius:inherit}

.primary-button,.primary-small{
  border:0;background:#fff;color:#050505;font-weight:850;
  border-radius:17px;min-height:52px;padding:0 18px;font-size:16px;
}
.primary-small{min-height:44px;border-radius:14px;font-size:14px}

.quick-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
.quick-card{
  min-width:0;min-height:88px;padding:8px 4px;background:var(--surface-2);
  border:1px solid rgba(255,255,255,.06);border-radius:17px;
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:7px;
  font-weight:750;font-size:12px;
}
.quick-icon,.list-icon,.large-icon{width:40px;height:40px;flex:0 0 40px;border-radius:13px;background:#2b2b2b;display:grid;place-items:center;font-size:19px}

.list-card{
  width:100%;min-width:0;min-height:70px;padding:13px 14px;border-radius:18px;
  background:var(--surface-2);border:1px solid rgba(255,255,255,.06);
  display:flex;align-items:center;gap:12px;
}
.list-card .flex-grow-1{min-width:0}
.list-card small,.device-item small{display:block;color:var(--muted);margin-top:3px}

.bottom-nav{
  position:relative;
  width:100%;height:62px;margin:4px 0 0;padding:5px;
  border:1px solid #2d2d2d;border-radius:22px;background:rgba(12,12,12,.98);
  display:grid;grid-template-columns:repeat(4,minmax(0,1fr));z-index:30;
}
.nav-item{
  min-width:0;border:0;background:transparent;border-radius:17px;color:#8f8f8f;
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;font-size:10px;
}
.nav-item i{font-size:19px}
.nav-item span{max-width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
.nav-item.active{background:#fff;color:#050505;font-weight:800}

.page-heading{margin:12px 2px 14px}
.page-heading h1{font-size:27px;font-weight:850;margin:0 0 10px}
.page-heading p{font-size:17px;font-weight:750;margin:0 0 4px}
.page-heading span{color:var(--muted);font-size:13px;line-height:1.4}

.tariff-list{display:grid;gap:9px}
.tariff-card{
  min-width:0;min-height:82px;border-radius:18px;border:1px solid #383838;background:#171717;
  padding:12px;display:grid;grid-template-columns:26px minmax(0,1fr) auto;align-items:center;gap:8px;cursor:pointer;
}
.tariff-card.selected{border-color:#fff;box-shadow:0 0 0 1px #fff inset}
.tariff-card input{display:none}
.radio-ui{width:22px;height:22px;border-radius:50%;border:2px solid #555;display:grid;place-items:center}
.tariff-card.selected .radio-ui:after{content:"";width:10px;height:10px;border-radius:50%;background:#fff}
.tariff-main,.tariff-price{display:flex;flex-direction:column}
.tariff-main{min-width:0}
.tariff-main strong,.tariff-price strong{font-size:14px}
.tariff-main small,.tariff-price small{color:var(--muted);margin-top:4px;font-size:11px}
.tariff-price{text-align:right}
.tariff-price em{font-style:normal;font-size:11px;color:var(--muted)}

.copy-field{display:flex;align-items:center;gap:8px;background:#222;border:1px solid #333;border-radius:14px;padding:0 12px}
.copy-field input{flex:1;min-width:0;background:transparent;border:0;color:#ddd;padding:13px 0;outline:none}
.copy-field button{border:0;background:transparent;font-size:19px}

.counter-badge{background:#2d2d2d;border-radius:999px;padding:7px 10px;font-weight:800}
.device-item{display:grid;grid-template-columns:38px minmax(0,1fr) 34px;align-items:center;gap:10px;padding:12px 0;border-top:1px solid var(--line)}
.device-item>i{width:38px;height:38px;border-radius:12px;background:#0a0a0a;display:grid;place-items:center}
.device-item button{border:0;background:transparent;color:#aaa}

.profile-head{display:flex;align-items:center;gap:14px;margin-top:8px}
.profile-head h2{font-size:23px;margin:0 0 3px}
.avatar{width:58px;height:58px;flex:0 0 58px;border-radius:17px;background:linear-gradient(145deg,#fff,#777);color:#050505;display:grid;place-items:center;font-size:25px;font-weight:900}
.balance-value{font-size:34px}
.promo-row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px}
.promo-row input{min-width:0;background:#202020;border:1px solid #444;color:#fff;border-radius:13px;padding:12px}
.promo-row button{border:0;border-radius:13px;padding:0 14px;font-weight:800}
.setting-row{min-height:62px;display:flex;justify-content:space-between;align-items:center;border-bottom:1px solid var(--line)}
.setting-row:last-child{border-bottom:0}
.segmented{display:flex;background:#242424;padding:4px;border-radius:12px}
.segmented button{border:0;background:transparent;color:#999;padding:7px 11px;border-radius:9px}
.segmented button.active{background:#fff;color:#050505;font-weight:800}
.switch input{display:none}
.switch span{width:52px;height:30px;border-radius:999px;background:#3a3a3a;display:block;position:relative}
.switch span:before{content:"";position:absolute;width:24px;height:24px;border-radius:50%;background:#fff;top:3px;left:3px}
.switch input:checked+span{background:#fff}
.switch input:checked+span:before{left:25px;background:#050505}

.menu-link{width:100%;border:0;background:#181818;border-radius:15px;padding:15px;text-align:left;margin-bottom:10px}
.custom-modal,.custom-toast{background:#171717;color:#fff;border:1px solid #333}
.modal-content{border-radius:22px}
.toast-container{z-index:2000}
.modal{padding:8px!important}
.modal-dialog{width:100%;max-width:420px;margin:auto}
.modal-content{max-height:calc(var(--app-height) - 20px);overflow:hidden}
.modal-body{overflow-y:auto}

body.light-mode{--text:#111;--muted:#6c6c6c;--line:#ddd;background:#efefef}
body.light-mode .app-shell{background:#f4f4f4}
body.light-mode .topbar{background:linear-gradient(180deg,#f4f4f4 80%,rgba(244,244,244,0))}
body.light-mode .status-card,
body.light-mode .summary-card,
body.light-mode .connect-card,
body.light-mode .balance-card,
body.light-mode .settings-card,
body.light-mode .quick-card,
body.light-mode .list-card,
body.light-mode .tariff-card{background:#fff;color:#111;border-color:#ddd}
body.light-mode .bottom-nav{background:#fff}
body.light-mode .progress-ring:before{background:#fff}

@media(max-width:360px){
  .app-shell{padding-left:8px;padding-right:8px;grid-template-rows:54px minmax(0,1fr) 60px}
  .topbar{height:54px}
  .status-card,.summary-card,.connect-card,.balance-card,.settings-card{padding:13px}
  .progress-ring{--size:122px}
  .progress-ring-inner strong{font-size:38px}
  .quick-card{min-height:78px;font-size:11px}
  .bottom-nav{height:56px}
  .nav-item span{font-size:9px}
}


.legal-text{
  font-size:14px;
  line-height:1.55;
}
.legal-text h6{
  font-size:15px;
  font-weight:800;
  margin:18px 0 7px;
}
.legal-text h6:first-child{margin-top:0}
.legal-text p{margin:0 0 10px}


/* v31: Telegram Mini App navigation touch fix */
#appContent{position:relative;z-index:1;}
.bottom-nav{
  z-index:1000;
  pointer-events:auto;
  touch-action:manipulation;
  -webkit-transform:translateZ(0);
  transform:translateZ(0);
}
.nav-item{
  pointer-events:auto;
  touch-action:manipulation;
  cursor:pointer;
  -webkit-tap-highlight-color:transparent;
  user-select:none;
  -webkit-user-select:none;
}
.nav-item i,.nav-item span{pointer-events:none;}


.legal-date{
  color:var(--muted);
  font-size:12px;
  margin-bottom:16px!important;
}
.legal-text{
  font-size:14px;
  line-height:1.58;
}
.legal-text h6{
  margin:18px 0 7px;
  font-size:15px;
  font-weight:850;
}
.legal-text h6:first-of-type{margin-top:0}
.legal-text p{margin:0 0 10px}
#appModal .modal-dialog{height:min(92dvh,760px)}
#appModal .modal-content{height:100%}
#appModal .modal-body{
  overflow-y:auto;
  overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch;
}


.legal-link,
.legal-link:visited,
.legal-link:hover,
.legal-link:active{
  color:inherit;
  text-decoration:none;
}

.legal-menu-link,
.legal-menu-link:visited,
.legal-menu-link:hover,
.legal-menu-link:active{
  display:block;
  color:inherit;
  text-decoration:none;
}


/* v38: единый размер Mini App независимо от точки запуска */
html{
  width:100%;
  height:100%;
  min-height:100%;
}
body{
  width:100%;
  height:100%;
  min-height:100%;
}
.app-shell{
  width:100%;
  max-width:none;
  min-height:100%;
}

/* На широких экранах сохраняем удобную ширину содержимого,
   но не меняем размер самого приложения. */
@media (min-width: 700px){
  #appContent,
  .topbar,
  .bottom-nav{
    width:min(100%, 620px);
    margin-left:auto;
    margin-right:auto;
  }
}


/* v39 Platega */
.tariff-card.selected{
  box-shadow:0 0 0 1px #fff inset;
}
