:root{
  --bg:#F6F8FC;
  --card:#FFFFFF;
  --text:#0F172A;
  --muted:#64748B;

  --brand1:#2E5BFF;
  --brand2:#2BB7FF;
  --radius:22px;

  /* ✅ ความสูงเมนูโดยประมาณ (ใช้กันทับเนื้อหา) */
  --bottomNavH: 92px;
}

/* reset */
*{ box-sizing:border-box; }
html{ height:100%; }
body{
  min-height:100%;
  margin:0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans Thai", "Noto Sans", sans-serif;

  overflow-x: hidden;

  /* ✅ กันเมนูบัง (เผื่อ safe-area) */
  padding-bottom: calc(var(--bottomNavH) + env(safe-area-inset-bottom));
}

/* ✅ กัน fixed เพี้ยนเพราะ parent มี transform (จำกัดให้เท่าที่จำเป็น) */
.container,
.container-fluid,
.container-app,
main,
#app,
.wrapper{
  transform: none !important;
}

/* ✅ ไม่ไปยุ่ง svg ทั้งระบบมากเกินไป */
svg{ max-width:none; }

/* container app (mobile-first) */
.container-app{
  max-width: 520px;
  margin: 0 auto;
  padding: 0 14px;
}

/* Appbar */
.appbar{
  position: sticky;
  top: 0;
  z-index: 2000;
  background: rgba(246,248,252,.86);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(15,23,42,.06);
}
.appbar .wrap{
  height: 56px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 0 14px;
  max-width: 520px;
  margin: 0 auto;
}
.appbar .title{ font-weight: 900; letter-spacing:-.02em; }
.pill{
  border-radius: 999px;
  padding: .45rem .75rem;
  border: 1px solid rgba(15,23,42,.08);
  background:#fff;
  font-weight: 800;
  color: var(--muted);
  font-size: .85rem;
  text-decoration:none;
}

/* HERO */
.hero{
  border-radius: 0 0 26px 26px;
  background: linear-gradient(135deg, var(--brand1), var(--brand2));
  color:#fff;
  padding: 18px 14px;
}
.hero .inner{
  max-width: 520px;
  margin: 0 auto;
  display:flex;
  gap: 14px;
  align-items:center;
}
.hero h2{
  font-size: 22px;
  font-weight: 1000;
  letter-spacing: -.02em;
  margin: 0 0 8px 0;
}
.hero p{
  margin:0;
  opacity: .92;
  line-height: 1.35;
}

/* ✅ ล็อก SVG ใน hero ไม่ให้โดนยืด */
.hero .mascot{
  flex: 0 0 auto;
  width: 130px;
}
.hero .mascot svg{
  display:block;
  width: 130px !important;
  height: 160px !important;
}

/* Card */
.card-soft{
  background: var(--card);
  border: 1px solid rgba(15,23,42,.06);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(2,6,23,.06);
}

/* Section spacing */
.section{ padding: 14px 0; }

/* Inputs */
.form-control, .form-select{
  border-radius: 16px;
  padding: .8rem 1rem;
  border: 1px solid rgba(15,23,42,.10);
}
.form-control:focus,.form-select:focus{
  outline: none;
  box-shadow: 0 0 0 .25rem rgba(46,91,255,.18);
  border-color: rgba(46,91,255,.35);
}

/* Big primary button */
.btn-primary-big{
  width: 100%;
  border:0;
  border-radius: 22px;
  padding: 16px 18px;
  background: linear-gradient(135deg, #243BDA, #2E5BFF);
  color:#fff;
  font-weight: 1000;
  font-size: 1.05rem;
  box-shadow: 0 16px 30px rgba(46,91,255,.28);
}
.btn-primary-big:hover{ filter: brightness(.98); color:#fff; }

/* ✅ Bottom nav: ตรึงขอบล่างจอจริงแบบนิ่ง
   - ไม่ใช้ bottom: env(...) (เพราะ padding เมนูเองอยู่แล้ว)
   - ไม่ใส่ will-change กัน “แกว่ง” */
.bottom-nav{
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;

  z-index: 9999 !important;
  width: 100% !important;

  background: rgba(255,255,255,.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(0,0,0,.08);

  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  transform: none !important;
  pointer-events: auto;
}

.bottom-nav .wrap{
  max-width: 520px;
  margin: 0 auto;
  display:flex;
  justify-content:space-between;
  gap: 10px;
}

.navitem{
  flex:1;
  text-decoration:none;
  color: var(--muted);
  display:flex;
  flex-direction:column;
  align-items:center;
  gap: 4px;
  padding: 8px 6px;
  border-radius: 16px;
  border: 1px solid transparent;
  font-weight: 900;
  font-size: .78rem;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.navitem svg{ width: 22px; height: 22px; }

.navitem.active{
  background: rgba(46,91,255,.08);
  border-color: rgba(46,91,255,.14);
  color: #2E5BFF;
}

/* Offcanvas clickable */
.offcanvas{
  z-index: 20050 !important;
  pointer-events: auto !important;
}
.offcanvas *{ pointer-events: auto !important; }

.offcanvas-backdrop{
  z-index: 20040 !important;
  pointer-events: auto !important;
}
.offcanvas-backdrop.show{ opacity: .45; }

/* navbar */
.navbar{
  z-index: 20000 !important;
  pointer-events: auto !important;
}

/* date range pills */
.date-range{
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  flex-wrap: wrap;
  line-height: 1.15;
}
.date-range .d{
  font-weight: 700;
  white-space: nowrap;
}
.date-range .sep{
  opacity: .55;
  font-weight: 700;
}
.date-range .s{
  font-size: .85rem;
  opacity: .75;
  white-space: nowrap;
  border: 1px solid rgba(15,23,42,.10);
  padding: .1rem .45rem;
  border-radius: 999px;
  background: #fff;
}

/* MOBILE APP-LIKE DASHBOARD */
@media (max-width: 576px) {
  h3.mb-3{
    margin-bottom: .5rem !important;
    font-size: 1.15rem;
  }

  .card.mb-3 .card-body{
    padding: .75rem .9rem !important;
  }
  .card.mb-3 svg{
    width: 46px !important;
    height: 46px !important;
  }
  .card.mb-3 .fw-bold{ font-size: .95rem !important; }
  .card.mb-3 .text-muted{ font-size: .8rem !important; }

  .row.g-3{
    --bs-gutter-y: .6rem;
    --bs-gutter-x: .6rem;
  }

  .row.g-3 > div{
    flex: 0 0 100%;
    max-width: 100%;
  }

  .row.g-3 .card{ border-radius: 16px; }
  .row.g-3 .card-body{ padding: .7rem .9rem !important; }
  .row.g-3 hr{ margin: .4rem 0 !important; }
  .row.g-3 .fw-semibold{ font-size: .9rem; }
  .row.g-3 .small{ font-size: .75rem; }
  .row.g-3 .fw-bold{ font-size: 1rem; }

  .badge{
    font-size: .65rem;
    padding: .25em .45em;
  }
}
