/* ============================================================
   RESPONSIVE v3.0
   - تمام قواعد داخل @media screen
   - چاپ کاملاً جدا (print.css)
   - پشتیبانی از تبلت، موبایل، موبایل کوچک
============================================================ */

/* ---------- تبلت افقی (max 1024) ---------- */
@media screen and (max-width: 1024px){
  .toolbar-inner{gap:6px;padding:7px 12px}
  .btn{padding:7px 11px;font-size:13px}
  .tb-group + .tb-group{padding-inline-start:6px}
}

/* ---------- تبلت (max 900) ---------- */
@media screen and (max-width: 900px){
  .toolbar-inner{padding:6px 10px}
  .btn{padding:7px 10px;font-size:12.5px}
  .page{padding:12mm 9mm}
  .parties-grid{gap:10px}
  .party{padding:9px 12px}
}

/* ---------- موبایل بزرگ (max 700) ---------- */
@media screen and (max-width: 700px){

  /* ================= layout ================= */
  body{font-size:13px;padding-bottom:110px}

  .toolbar{
    position:fixed; bottom:0; top:auto; left:0; right:0;
    border-bottom:none; border-top:1px solid var(--line);
    box-shadow:0 -3px 16px rgba(20,30,60,.12);
  }
  .toolbar-inner{
    justify-content:center;
    padding:8px 6px calc(8px + env(safe-area-inset-bottom));
    gap:6px; flex-wrap:nowrap; overflow-x:auto;
    -webkit-overflow-scrolling:touch;
  }
  .tb-group{flex-shrink:0}
  .btn{padding:8px 10px}
  .btn .lbl{display:none}
  .btn .ico{font-size:17px}
  .tb-label span{display:none}
  .tb-label select{padding:6px 8px;font-size:12.5px}
  .tb-profile{display:none}

  .page-wrap{padding:12px 8px 110px}
  .page{width:100%;min-height:0;padding:14px 12px;border-radius:10px}
  body[data-paper="a5"] .page{width:100%;padding:14px 12px;font-size:13px}

  /* ================= سربرگ ================= */
  .invoice-head{
    grid-template-columns:1fr;
    grid-template-areas:"title" "logo" "qr";
    text-align:center;
    gap:12px;
    padding:14px 12px;
  }
  .head-title{grid-area:title}
  .head-title h1{font-size:17px;margin-bottom:8px}
  .title-row{justify-content:center}
  .meta{justify-content:center;gap:6px 10px}
  .meta-chip{padding:3px 9px 3px 3px}
  .w-date{width:105px}
  .w-serial{width:135px}

  .logo-box{grid-area:logo;justify-self:center;max-width:170px}
  .logo-box.empty{max-width:150px}

  .qr-box{grid-area:qr;justify-self:center}

  /* ================= فروشنده / خریدار ================= */
  .parties-grid{grid-template-columns:1fr;gap:8px}
  .party{padding:9px 12px}
  .party h2{font-size:12.5px;margin-bottom:6px}
  .grid{grid-template-columns:1fr;gap:2px}
  .fld > span{min-width:78px;font-size:11.5px}
  .fld .field{font-size:12.5px}

  /* ================= جدول اقلام به کارت ================= */
  .items-wrap{margin-bottom:12px}

  .items,
  .items tbody,
  .items tr,
  .items td{
    display:block;
    width:100%;
  }
  .items{
    border:none;
    border-radius:0;
    box-shadow:none;
    overflow:visible;
  }
  .items thead{display:none}

  .items tbody tr{
    border:1px solid var(--line);
    border-radius:12px;
    margin-bottom:10px;
    padding:12px 10px 8px;
    position:relative;
    background:#fcfdff!important;
    box-shadow:0 2px 8px rgba(20,30,60,.03);
  }
  .items tbody tr:nth-child(even) td{background:transparent!important}
  .items tbody tr:hover td{background:transparent!important}
  .items tbody tr:focus-within td{background:transparent!important}

  .items tbody td{
    padding:4px 0;
    background:transparent!important;
    display:flex;
    align-items:center;
    gap:8px;
    border:none;
    text-align:right;
  }
  .items tbody td::before{
    font-weight:700;
    color:var(--ink-soft);
    font-size:11px;
    min-width:78px;
    flex-shrink:0;
    content:"";
  }

  /* labelهای صریح */
  .items tbody td.col-sku::before   { content:"کد کالا"; }
  .items tbody td.col-desc::before  { content:"شرح"; }
  .items tbody td.col-qty::before   { content:"تعداد"; }
  .items tbody td.col-price::before { content:"مبلغ واحد"; }
  .items tbody td.col-total::before { content:"مبلغ کل"; }

  /* شماره ردیف */
  .items .row-num{
    position:absolute;
    top:8px; left:10px;
    width:auto;
    color:var(--brand);
    font-weight:800;
    font-size:11.5px;
    padding:0;
    display:block;
  }
  .items .row-num::before{
    content:"ردیف ";
    color:var(--ink-faint);
    font-weight:500;
    min-width:0;
  }

  /* دکمه حذف */
  .items .c-del{
    position:absolute;
    top:6px; right:8px;
    width:auto;
    padding:0;
    display:block;
  }
  .items .c-del::before{content:"";min-width:0}

  /* ================= جمع کل ================= */
  .summary{justify-content:stretch}
  .sum-box{width:100%;min-width:0}
  .sum-row{padding:8px 12px;font-size:12.5px;flex-wrap:wrap;gap:6px}
  .num-amt{width:130px;font-size:12.5px}
  .disc-wrap .num-amt{width:110px}
  .tax-wrap .num-amt{width:70px}

  /* ================= امضا ================= */
  .signs{grid-template-columns:1fr;gap:10px}
  .sign{min-height:110px}

  /* ================= راهنمای کیبورد ================= */
  .row-hint{font-size:10px;gap:6px;padding:6px 8px}
  .kbd-hint{font-size:10px}
  kbd{font-size:9.5px;padding:1px 5px}

  /* ================= Viewer ================= */
  .viewer-bar{padding:8px 10px;gap:8px}
  .viewer-info strong{font-size:12.5px}
  .viewer-info span{font-size:11px}
  .viewer-actions{gap:4px}
  .viewer-actions .btn{padding:7px 9px;font-size:12px}
  .viewer-body{padding:12px 8px 110px}

  /* ================= Modal ================= */
  .modal{max-width:100%;max-height:92vh;border-radius:14px}
  .modal-lg{max-width:100%}
  .modal-head{padding:12px 14px}
  .modal-body{padding:12px 14px}
  .modal-foot{padding:10px 14px;justify-content:stretch;flex-wrap:wrap;gap:6px}
  .modal-foot .btn{flex:1;justify-content:center;min-width:0}

  .modal-search{padding:10px 14px 0}
  .snap-filters{gap:6px}
  .snap-filters .mini-sel{flex:1;min-width:0}

  .snap-item{padding:9px 10px;gap:8px;flex-wrap:wrap}
  .snap-item-main{width:100%}
  .snap-item-title{font-size:12.5px}
  .snap-item-sub{font-size:11px}
  .snap-item-total{font-size:12px;width:100%;text-align:right}
  .snap-item-actions{width:100%;justify-content:flex-end;gap:6px;margin-top:2px}

  /* ================= گزارش ================= */
  .report-grid{grid-template-columns:1fr 1fr}
  .report-card{padding:10px}
  .report-card .rc-value{font-size:15px}
  .report-table{font-size:11.5px}
  .report-table th,.report-table td{padding:6px 5px}

  /* ================= تنظیمات ================= */
  .settings-section .fld{
    flex-direction:column;
    align-items:flex-start;
    gap:4px;
  }
  .settings-section .fld > span{
    min-width:0;
    font-size:11.5px;
  }
  .settings-section .fld > input,
  .settings-section .fld > select{
    width:100%;
  }

  /* ================= Profile rows ================= */
  .profile-row{padding:9px 10px;gap:8px;flex-wrap:wrap}
  .profile-row .pr-name{font-size:12.5px}
}

/* ---------- موبایل کوچک (max 380) ---------- */
@media screen and (max-width: 380px){
  .head-title h1{font-size:15px}
  .meta-chip{font-size:11px}
  .w-date{width:95px}
  .w-serial{width:120px}
  .num-amt{width:110px;font-size:12px}
  .report-grid{grid-template-columns:1fr}
  .btn{padding:7px 8px}
  .btn .ico{font-size:15px}
}