/* =========================================================
   CUEVA PRO — MOBILE FOUNDATION V1
   UI foundation only. No business logic is changed.
========================================================= */

:root{
  --cueva-page-max:760px;
  --cueva-page-pad:14px;
  --cueva-header-height:78px;
  --cueva-nav-height:76px;

  --cueva-radius-xs:10px;
  --cueva-radius-sm:14px;
  --cueva-radius-md:18px;
  --cueva-radius-lg:22px;
  --cueva-radius-xl:28px;

  --cueva-touch:46px;

  --cueva-bg:#f5f5f7;
  --cueva-card:#fff;
  --cueva-card-soft:rgba(255,255,255,.82);
  --cueva-text:#111;
  --cueva-muted:#85858a;
  --cueva-line:rgba(17,17,17,.075);
  --cueva-gold:#d4a62a;
  --cueva-gold-soft:rgba(212,166,42,.12);

  --cueva-shadow-card:0 8px 24px rgba(0,0,0,.045);
  --cueva-shadow-float:0 16px 42px rgba(0,0,0,.11);
}

html,
body{
  width:100%;
  max-width:100%;
  overflow-x:hidden;
  overscroll-behavior-x:none;
}

body{
  min-width:0;
  background:var(--cueva-bg);
}

body,
button,
input,
select,
textarea{
  -webkit-text-size-adjust:100%;
}

button,
a,
input,
select,
textarea{
  touch-action:manipulation;
}

button,
a{
  -webkit-tap-highlight-color:transparent;
}

input,
select,
textarea{
  max-width:100%;
  min-width:0;
}

img,
svg,
video,
canvas{
  max-width:100%;
}

.mobile-app{
  width:100%;
  max-width:var(--cueva-page-max);
  min-width:0;
  margin:0 auto;
  padding-bottom:
    calc(
      var(--cueva-nav-height) +
      20px +
      var(--safe-bottom)
    );
}

.mobile-header{
  position:sticky;
  top:0;
  z-index:500;
  min-height:
    calc(
      var(--cueva-header-height) +
      var(--safe-top)
    );
  padding:
    calc(11px + var(--safe-top))
    var(--cueva-page-pad)
    10px;
  gap:10px;
  border-bottom:1px solid var(--cueva-line);
  background:rgba(248,248,250,.92);
  box-shadow:0 4px 18px rgba(0,0,0,.025);
}

.header-copy{
  min-width:0;
  flex:1;
}

.header-copy>span{
  font-size:8px;
  letter-spacing:.14em;
}

.header-copy h1{
  max-width:100%;
  margin-top:3px;
  overflow:hidden;
  font-size:23px;
  line-height:1.08;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.header-copy p{
  max-width:100%;
  margin-top:3px;
  overflow:hidden;
  font-size:9px;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.header-actions{
  flex:0 0 auto;
  gap:7px;
}

.header-actions button{
  width:42px;
  height:42px;
  min-width:42px;
  border-radius:14px;
  box-shadow:none;
}

.page-content{
  display:block;
  width:100%;
  min-width:0;
  padding:
    12px
    var(--cueva-page-pad)
    20px;
  overflow-x:hidden;
}

.page-content>*{
  min-width:0;
  max-width:100%;
}

.page-content.loading{
  opacity:.6;
}

/* ---------- Shared mobile surface ---------- */

.page-card,
.hero-card,
.stat-card,
.quick-action,
.more-item{
  max-width:100%;
}

.page-card{
  padding:14px;
  border:1px solid var(--cueva-line);
  border-radius:var(--cueva-radius-lg);
  background:var(--cueva-card);
  box-shadow:var(--cueva-shadow-card);
  backdrop-filter:none;
  -webkit-backdrop-filter:none;
}

.page-card h2{
  font-size:18px;
}

.page-card p{
  font-size:11px;
}

.hero-card{
  padding:17px;
  border-radius:var(--cueva-radius-xl);
}

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

.hero-card p{
  max-width:100%;
  font-size:10px;
  line-height:1.5;
}

/* ---------- Shared grids ---------- */

.stat-grid,
.quick-grid{
  gap:8px;
}

.stat-card{
  min-height:112px;
  padding:13px;
  border:1px solid var(--cueva-line);
  border-radius:var(--cueva-radius-lg);
  background:var(--cueva-card);
  box-shadow:var(--cueva-shadow-card);
  backdrop-filter:none;
}

.stat-card span{
  margin-top:12px;
  font-size:9px;
}

.stat-card strong{
  font-size:21px;
}

.quick-action{
  min-height:88px;
  padding:13px;
  border-radius:var(--cueva-radius-lg);
}

.quick-action strong{
  margin-top:11px;
  font-size:12px;
}

.quick-action small{
  font-size:8px;
}

.more-list{
  gap:7px;
}

.more-item{
  min-height:64px;
  grid-template-columns:40px minmax(0,1fr) auto;
  gap:10px;
  padding:10px;
  border-radius:var(--cueva-radius-md);
}

.more-item>i:first-child{
  width:40px;
  height:40px;
  border-radius:12px;
}

/* ---------- Mobile controls ---------- */

.primary-btn{
  min-height:var(--cueva-touch);
  border-radius:14px;
  font-size:12px;
}

button{
  min-width:0;
}

button:active{
  transform:scale(.985);
}

/* ---------- Bottom navigation ---------- */

.bottom-nav{
  left:50%;
  right:auto;
  bottom:0;
  width:min(100%,var(--cueva-page-max));
  height:
    calc(
      var(--cueva-nav-height) +
      var(--safe-bottom)
    );
  grid-template-columns:repeat(5,minmax(0,1fr));
  padding:
    7px
    6px
    calc(6px + var(--safe-bottom));
  transform:translateX(-50%);
  border-top:1px solid var(--cueva-line);
  background:rgba(252,252,253,.94);
  box-shadow:0 -8px 24px rgba(0,0,0,.055);
}

.nav-item{
  min-width:0;
  min-height:54px;
  gap:4px;
  padding:4px 2px;
  border-radius:14px;
  font-size:8px;
  line-height:1;
}

.nav-item i{
  font-size:17px;
}

.nav-item span{
  max-width:100%;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.nav-item.active{
  background:var(--cueva-gold-soft);
  color:#111;
}

.live-nav.active{
  background:transparent;
}

.live-nav i{
  width:41px;
  height:41px;
  margin-top:-18px;
  border-radius:14px;
}

/* ---------- Sheets / popups ---------- */

.sheet{
  padding:0;
}

.sheet-backdrop{
  backdrop-filter:blur(4px);
  -webkit-backdrop-filter:blur(4px);
}

.sheet-card{
  width:100%;
  max-width:var(--cueva-page-max);
  max-height:88dvh;
  margin:0 auto;
  overflow-y:auto;
  overscroll-behavior:contain;
  padding:
    10px
    var(--cueva-page-pad)
    calc(18px + var(--safe-bottom));
  border-radius:25px 25px 0 0;
  background:#f8f8fa;
}

.sheet-action{
  min-height:50px;
  border-radius:15px;
}

/* ---------- Long text / tables / old page content safety ---------- */

.page-content table{
  max-width:100%;
}

.page-content .table-wrap,
.page-content .table-responsive,
.page-content .scroll-x,
.page-content [class*="table-container"]{
  max-width:100%;
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
}

.page-content pre,
.page-content code{
  max-width:100%;
  overflow-wrap:anywhere;
}

.page-content h1,
.page-content h2,
.page-content h3,
.page-content h4,
.page-content p,
.page-content span,
.page-content strong,
.page-content small{
  overflow-wrap:anywhere;
}

/* ---------- Network ---------- */

.network-banner{
  z-index:3000;
  padding:
    calc(7px + var(--safe-top))
    var(--cueva-page-pad)
    8px;
  font-size:9px;
}

/* ---------- Phone widths ---------- */

@media(max-width:430px){
  :root{
    --cueva-page-pad:11px;
  }

  .mobile-header{
    padding-left:11px;
    padding-right:11px;
  }

  .header-copy h1{
    font-size:21px;
  }

  .header-actions button{
    width:40px;
    height:40px;
    min-width:40px;
  }

  .page-content{
    padding-top:9px;
  }

  .hero-card{
    padding:15px;
    border-radius:22px;
  }

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

  .page-card{
    padding:12px;
    border-radius:18px;
  }

  .stat-grid,
  .quick-grid{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }

  .stat-card{
    min-height:104px;
    padding:11px;
  }

  .more-item{
    border-radius:16px;
  }
}

@media(max-width:350px){
  .stat-grid,
  .quick-grid{
    grid-template-columns:1fr;
  }

  .header-copy p{
    display:none;
  }

  .header-actions{
    gap:5px;
  }

  .header-actions button{
    width:38px;
    height:38px;
    min-width:38px;
  }

  .nav-item{
    font-size:7px;
  }
}

/* ---------- Tablet / desktop preview ---------- */

@media(min-width:761px){
  body{
    background:#ececef;
  }

  .mobile-app{
    min-height:100dvh;
    border-left:1px solid var(--cueva-line);
    border-right:1px solid var(--cueva-line);
    background:var(--cueva-bg);
    box-shadow:0 0 50px rgba(0,0,0,.06);
  }
}
