
/* =========================================================
   V560 - MOBILE QUOTE FIX USING REAL DOM CLASSES
   Applies only <= 820px.
   Desktop/A4/print untouched.
   ========================================================= */

@media screen and (max-width:820px){

  /* ===== PAGE / PAPER ===== */
  body:has(.v379-public-quote-page),
  body:has(.v372-preview-page){
    margin:0!important;
    padding:0!important;
    background:#eef2ef!important;
    overflow-x:hidden!important;
  }

  .v379-public-quote-page,
  .v372-preview-page{
    width:100%!important;
    min-width:0!important;
    max-width:100%!important;
    margin:0!important;
    padding:0!important;
    background:#eef2ef!important;
    overflow-x:hidden!important;
  }

  .v379-public-quote-page .v372-paper,
  .v372-preview-page .v372-paper,
  .v379-public-quote-page .v379-a4-paper,
  .v372-preview-page .v379-a4-paper{
    width:100%!important;
    min-width:0!important;
    max-width:100%!important;
    min-height:0!important;
    margin:0!important;
    padding:14px 12px 22px!important;
    box-sizing:border-box!important;
    border:0!important;
    border-radius:0!important;
    box-shadow:none!important;
    background:#fff!important;
    overflow:visible!important;
  }

  /* ===== TOP TOOLBAR ===== */
  .v373-public-toolbar,
  .v372-preview-actions{
    position:sticky!important;
    top:0!important;
    z-index:100!important;
    width:100%!important;
    display:flex!important;
    align-items:center!important;
    justify-content:space-between!important;
    gap:8px!important;
    padding:9px 10px!important;
    box-sizing:border-box!important;
    background:rgba(255,255,255,.97)!important;
    border-bottom:1px solid #dce5df!important;
    box-shadow:0 4px 14px rgba(15,23,42,.07)!important;
    backdrop-filter:blur(10px)!important;
  }

  .v373-public-toolbar > div:first-child,
  .v372-preview-actions > div:first-child{
    min-width:0!important;
  }

  .v373-public-toolbar > div:first-child span,
  .v372-preview-actions > div:first-child span{
    display:block!important;
    font-size:9px!important;
    font-weight:800!important;
    letter-spacing:.08em!important;
    color:#6a776f!important;
  }

  .v373-public-toolbar > div:first-child strong,
  .v372-preview-actions > div:first-child strong{
    display:block!important;
    margin-top:2px!important;
    font-size:12px!important;
    line-height:1.25!important;
    color:#0a5f3a!important;
    white-space:nowrap!important;
    overflow:hidden!important;
    text-overflow:ellipsis!important;
  }

  .v377-public-actions,
  .v372-preview-actions > div:last-child{
    display:flex!important;
    gap:6px!important;
    flex:0 0 auto!important;
  }

  .v373-public-toolbar button,
  .v372-preview-actions button{
    min-height:38px!important;
    padding:0 10px!important;
    border-radius:8px!important;
    font-size:10px!important;
    font-weight:800!important;
    white-space:nowrap!important;
  }

  /* ===== HEADER ===== */
  .v372-header{
    display:grid!important;
    grid-template-columns:1fr!important;
    gap:12px!important;
    margin:0!important;
    padding:0 0 13px!important;
    border-bottom:2px solid #0b6b42!important;
  }

  .v372-company{
    display:flex!important;
    align-items:flex-start!important;
    gap:10px!important;
    min-width:0!important;
  }

  .v372-company > img,
  .v372-logo-fallback{
    flex:0 0 auto!important;
    width:62px!important;
    max-width:62px!important;
    height:auto!important;
    object-fit:contain!important;
  }

  .v372-company > div{
    min-width:0!important;
    flex:1!important;
  }

  .v372-company h2{
    margin:0 0 5px!important;
    font-size:16px!important;
    line-height:1.25!important;
    color:#153d2a!important;
  }

  .v372-company p{
    margin:2px 0!important;
    font-size:12px!important;
    line-height:1.4!important;
    color:#4f5f56!important;
    word-break:break-word!important;
  }

  .v372-title,
  .v520-title{
    width:100%!important;
    min-width:0!important;
    text-align:center!important;
  }

  .v372-title h1,
  .v520-title h1{
    margin:0 0 8px!important;
    font-size:26px!important;
    line-height:1!important;
    color:#0b6740!important;
    letter-spacing:.03em!important;
  }

  .v520-quote-meta{
    display:grid!important;
    grid-template-columns:1fr!important;
    gap:5px!important;
    padding:9px 10px!important;
    border:1px solid #dce5df!important;
    border-radius:9px!important;
    background:#f8fbf9!important;
  }

  .v520-meta-row{
    display:flex!important;
    justify-content:space-between!important;
    align-items:flex-start!important;
    gap:12px!important;
    font-size:12px!important;
    line-height:1.35!important;
  }

  .v520-meta-row span{
    color:#66756d!important;
    font-weight:700!important;
  }

  .v520-meta-row strong,
  .v520-meta-row b{
    color:#173d2a!important;
    text-align:right!important;
    word-break:break-word!important;
  }

  /* ===== CUSTOMER INFO ===== */
  .v372-info{
    display:block!important;
    margin:12px 0!important;
    padding:0!important;
  }

  .v372-info > div{
    width:100%!important;
    min-width:0!important;
    padding:11px 12px!important;
    box-sizing:border-box!important;
    border:1px solid #dce5df!important;
    border-radius:10px!important;
    background:#fbfcfb!important;
  }

  .v372-info h3{
    margin:0 0 8px!important;
    font-size:13px!important;
    line-height:1.25!important;
    color:#0b6540!important;
    letter-spacing:.03em!important;
  }

  .v519-customer-stack{
    display:grid!important;
    gap:6px!important;
  }

  .v519-customer-stack p{
    display:grid!important;
    grid-template-columns:minmax(118px,40%) minmax(0,1fr)!important;
    align-items:start!important;
    gap:8px!important;
    margin:0!important;
    font-size:12.5px!important;
    line-height:1.4!important;
  }

  .v519-customer-stack p b{
    color:#506158!important;
  }

  .v519-customer-stack p span{
    min-width:0!important;
    color:#172b20!important;
    font-weight:600!important;
    word-break:break-word!important;
    white-space:normal!important;
  }

  /* ===== REAL PRODUCT TABLE -> CARDS ===== */
  .v372-table-wrap{
    width:100%!important;
    max-width:100%!important;
    overflow:visible!important;
    margin:0!important;
    padding:0!important;
  }

  .v372-table{
    display:block!important;
    width:100%!important;
    max-width:100%!important;
    border:0!important;
    border-collapse:separate!important;
    background:transparent!important;
  }

  .v372-table thead{
    display:none!important;
  }

  .v372-table tbody{
    display:grid!important;
    width:100%!important;
    gap:10px!important;
  }

  .v372-table tbody tr{
    display:grid!important;
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
    width:100%!important;
    padding:11px 12px!important;
    box-sizing:border-box!important;
    gap:7px 12px!important;
    border:1px solid #dce5df!important;
    border-radius:11px!important;
    background:#fff!important;
    box-shadow:0 3px 12px rgba(15,23,42,.045)!important;
  }

  .v372-table tbody td{
    display:flex!important;
    align-items:flex-start!important;
    justify-content:space-between!important;
    gap:7px!important;
    min-width:0!important;
    width:auto!important;
    padding:0!important;
    border:0!important;
    background:transparent!important;
    font-size:12.5px!important;
    line-height:1.35!important;
    text-align:right!important;
    white-space:normal!important;
    word-break:break-word!important;
  }

  .v372-table tbody td::before{
    content:"";
    flex:0 0 auto!important;
    color:#758078!important;
    font-size:9.5px!important;
    font-weight:900!important;
    letter-spacing:.045em!important;
    text-align:left!important;
  }

  .v372-table tbody td:nth-child(1)::before{content:"STT"}
  .v372-table tbody td:nth-child(2)::before{content:"MÃ HÀNG"}
  .v372-table tbody td:nth-child(3)::before{content:"SẢN PHẨM"}
  .v372-table tbody td:nth-child(4)::before{content:"ĐVT"}
  .v372-table tbody td:nth-child(5)::before{content:"SỐ LƯỢNG"}
  .v372-table tbody td:nth-child(6)::before{content:"ĐƠN GIÁ"}
  .v372-table tbody td:nth-child(7)::before{content:"THUẾ"}
  .v372-table tbody td:nth-child(8)::before{content:"THÀNH TIỀN"}

  .v372-table tbody td:nth-child(3){
    grid-column:1/-1!important;
    order:-2!important;
    justify-content:flex-start!important;
    padding-bottom:6px!important;
    border-bottom:1px dashed #e2e8e4!important;
    text-align:left!important;
    color:#123d29!important;
    font-size:14px!important;
    font-weight:900!important;
  }

  .v372-table tbody td:nth-child(3)::before{
    margin-right:5px!important;
    color:#0b6540!important;
  }

  .v372-table tbody td:nth-child(8){
    grid-column:1/-1!important;
    padding-top:7px!important;
    border-top:1px solid #edf1ef!important;
    color:#075f3a!important;
    font-size:13.5px!important;
    font-weight:900!important;
  }

  .v372-table tbody tr:has(td.empty){
    display:block!important;
  }

  .v372-table td.empty{
    display:block!important;
    text-align:center!important;
    padding:16px!important;
  }

  /* ===== SUMMARY ===== */
  .v372-summary{
    display:grid!important;
    grid-template-columns:1fr!important;
    gap:10px!important;
    margin:12px 0!important;
  }

  .v372-thankyou,
  .v520-thankyou{
    display:flex!important;
    align-items:flex-start!important;
    gap:9px!important;
    padding:11px 12px!important;
    border:1px solid #e3e9e5!important;
    border-radius:10px!important;
    background:#fafcfb!important;
  }

  .v520-thankyou-copy strong{
    display:block!important;
    margin-bottom:3px!important;
    font-size:12.5px!important;
    line-height:1.35!important;
    color:#193f2c!important;
  }

  .v520-thankyou-copy p{
    margin:0!important;
    font-size:12px!important;
    line-height:1.45!important;
    color:#627068!important;
  }

  .v372-total{
    width:100%!important;
    max-width:100%!important;
    margin:0!important;
    padding:11px 12px!important;
    box-sizing:border-box!important;
    border:1px solid #d8e4dd!important;
    border-radius:10px!important;
    background:linear-gradient(135deg,#f7fbf9,#fff)!important;
  }

  .v372-total > div{
    display:flex!important;
    align-items:center!important;
    justify-content:space-between!important;
    gap:12px!important;
    padding:5px 0!important;
    font-size:12.5px!important;
    line-height:1.35!important;
  }

  .v372-total > div span{
    color:#59685f!important;
    font-weight:800!important;
  }

  .v372-total > div b{
    color:#173d2a!important;
    font-size:13px!important;
  }

  .v372-total .grand{
    margin-top:4px!important;
    padding-top:9px!important;
    border-top:1px solid #dce5df!important;
  }

  .v372-total .grand span,
  .v372-total .grand b{
    color:#075f3a!important;
    font-size:15px!important;
    font-weight:900!important;
  }

  /* ===== FOOTER: PAYMENT + CONFIRMATION ===== */
  .v372-footer,
  .v519-footer{
    display:grid!important;
    grid-template-columns:1fr!important;
    gap:10px!important;
    margin:0!important;
    padding:0!important;
  }

  .v519-card{
    width:100%!important;
    min-width:0!important;
    min-height:0!important;
    margin:0!important;
    padding:11px 12px!important;
    box-sizing:border-box!important;
    border:1px solid #dce5df!important;
    border-radius:10px!important;
    background:#fff!important;
  }

  .v519-card h4{
    margin:0 0 8px!important;
    font-size:13px!important;
    line-height:1.25!important;
    color:#0b6540!important;
  }

  .v519-bank-grid{
    display:grid!important;
    grid-template-columns:minmax(110px,38%) minmax(0,1fr)!important;
    gap:6px 10px!important;
    font-size:12px!important;
    line-height:1.4!important;
  }

  .v519-bank-grid > *{
    min-width:0!important;
    word-break:break-word!important;
  }

  .v519-sign-grid{
    display:grid!important;
    grid-template-columns:1fr 1fr!important;
    gap:8px!important;
    min-height:0!important;
  }

  .v519-sign-col{
    min-width:0!important;
    min-height:0!important;
    padding:7px 5px!important;
    text-align:center!important;
    overflow:visible!important;
  }

  .v519-sign-col > strong{
    font-size:11px!important;
    line-height:1.25!important;
    color:#173d2a!important;
  }

  .v519-sign-col > small{
    display:block!important;
    margin-top:3px!important;
    font-size:9.5px!important;
    line-height:1.25!important;
    color:#768179!important;
  }

  .v519-sign-space,
  .v524-sign-space,
  .v533-stamped-signature{
    min-height:78px!important;
    height:78px!important;
    margin-top:4px!important;
    overflow:visible!important;
  }

  .v524-quote-signature{
    max-width:112px!important;
    max-height:70px!important;
  }

  .v533-company-stamp{
    max-width:86px!important;
    max-height:86px!important;
  }

  .v519-sign-line{
    margin:2px auto 4px!important;
  }

  .v519-signer-name{
    margin:0!important;
    font-size:11px!important;
    line-height:1.3!important;
    font-weight:800!important;
    white-space:normal!important;
    word-break:break-word!important;
  }

  .v519-sign-col em{
    display:block!important;
    margin-top:3px!important;
    font-size:9.5px!important;
    line-height:1.2!important;
  }

  /* ===== CONTACT FOOTER ===== */
  .v374-contact-strip{
    display:grid!important;
    grid-template-columns:1fr!important;
    gap:3px!important;
    margin-top:10px!important;
    padding:9px 10px!important;
    border-radius:9px!important;
    font-size:11px!important;
    line-height:1.35!important;
    text-align:center!important;
    white-space:normal!important;
  }

  /* ===== MOBILE BOTTOM ACTIONS ===== */
  .v377-mobile-actions{
    position:sticky!important;
    bottom:0!important;
    z-index:110!important;
    display:grid!important;
    grid-template-columns:1fr 1fr!important;
    gap:8px!important;
    padding:9px 10px calc(9px + env(safe-area-inset-bottom))!important;
    background:rgba(255,255,255,.97)!important;
    border-top:1px solid #dce5df!important;
    box-shadow:0 -5px 16px rgba(15,23,42,.08)!important;
    backdrop-filter:blur(10px)!important;
  }

  .v377-mobile-actions button{
    min-height:44px!important;
    border-radius:9px!important;
    font-size:12px!important;
    font-weight:900!important;
  }

  /* hide desktop public toolbar action buttons if mobile sticky buttons are present */
  .v379-public-quote-page .v377-public-actions{
    display:none!important;
  }

  /* watermark must never block mobile readability */
  .v390-config-logo-watermark{
    opacity:.025!important;
    max-width:65vw!important;
    pointer-events:none!important;
  }
}

@media screen and (max-width:430px){
  .v519-customer-stack p{
    grid-template-columns:1fr!important;
    gap:2px!important;
  }

  .v372-table tbody tr{
    grid-template-columns:1fr!important;
  }

  .v372-table tbody td{
    grid-column:1/-1!important;
  }

  .v519-bank-grid{
    grid-template-columns:1fr!important;
    gap:2px!important;
  }

  .v519-sign-grid{
    grid-template-columns:1fr!important;
    gap:10px!important;
  }
}

/* IMPORTANT: print/A4 remains untouched */
@media print{
  .v372-table{
    display:table!important;
  }
  .v372-table thead{
    display:table-header-group!important;
  }
  .v372-table tbody{
    display:table-row-group!important;
  }
  .v372-table tbody tr{
    display:table-row!important;
  }
  .v372-table tbody td{
    display:table-cell!important;
  }
  .v372-table tbody td::before{
    content:none!important;
    display:none!important;
  }
}
