/* ══════════════════════════════════════
   BT-STOCK MOBILE CSS
   Only applies on screens ≤ 768px
   Does NOT modify any desktop styles
   ══════════════════════════════════════ */

/* ── Hide/Show logic ── */
@media (max-width: 768px) {
  #appMain.mob-hidden { display: none !important; }
  #appMobile { display: flex !important; }
}
@media (min-width: 769px) {
  #appMobile { display: none !important; }
}

/* ── Mobile Shell ── */
#appMobile {
  display: none;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
  font-family: 'Be Vietnam Pro', sans-serif;
}

/* ── Mobile Header ── */
.m-header {
  background: linear-gradient(135deg, #001f4d 0%, var(--navy) 60%, var(--navy2) 100%);
  color: #fff;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 2px 12px rgba(0,0,0,.25);
}
.m-header-logo { width: 34px; height: 34px; object-fit: contain; border-radius: 8px; }
.m-header-title { font-size: 14px; font-weight: 700; flex: 1; }
.m-header-sub { font-size: 10px; opacity: .6; }
.m-header-user {
  font-size: 11px; background: rgba(255,255,255,.12); padding: 4px 10px;
  border-radius: 8px; font-weight: 600; max-width: 120px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}

/* ── Mobile Content ── */
.m-content {
  flex: 1;
  padding: 12px 10px 80px 10px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Bottom Nav ── */
.m-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  display: flex;
  border-top: 1px solid var(--wave);
  box-shadow: 0 -2px 12px rgba(0,0,0,.08);
  z-index: 200;
  padding: 2px 0 max(2px, env(safe-area-inset-bottom));
}
.m-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 0;
  gap: 2px;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 10px;
  font-weight: 500;
  color: var(--mu);
  cursor: pointer;
  transition: .2s;
  position: relative;
}
.m-nav-item .m-nav-ico { font-size: 20px; line-height: 1; }
.m-nav-item.active { color: var(--navy); font-weight: 700; }
.m-nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 25%;
  right: 25%;
  height: 3px;
  background: var(--sea);
  border-radius: 0 0 3px 3px;
}

/* ── Cards ── */
.m-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 12px rgba(0,51,117,.08);
  margin-bottom: 10px;
  overflow: hidden;
}
.m-card-hdr {
  background: linear-gradient(135deg, var(--navy), var(--navy2));
  color: #fff;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.m-card-body { padding: 12px 14px; }

/* ── Stat Cards (mobile dashboard) ── */
.m-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.m-stat {
  background: #fff;
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0,51,117,.08);
  border-top: 3px solid var(--sea);
}
.m-stat-val { font-size: 18px; font-weight: 800; color: var(--navy); }
.m-stat-lbl { font-size: 10px; color: var(--mu); font-weight: 600; text-transform: uppercase; margin-top: 2px; }
.m-stat.c2 { border-top-color: var(--ok); }
.m-stat.c3 { border-top-color: var(--gold); }
.m-stat.c4 { border-top-color: var(--danger); }
.m-stat.c5 { border-top-color: #9C27B0; }

/* ── Phieu card in data list ── */
.m-phieu-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,51,117,.07);
  margin-bottom: 8px;
  overflow: hidden;
  border: 1.5px solid var(--navy);
}
.m-phieu-card-body { padding: 10px 12px; }
.m-phieu-num {
  font-size: 13px; font-weight: 700; color: var(--navy);
  display: flex; align-items: center; gap: 6px; margin-bottom: 4px;
}
.m-phieu-num .m-badge {
  background: var(--sea); color: #fff; font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 6px;
}
.m-phieu-meta { font-size: 11.5px; color: var(--mu); margin-bottom: 6px; }
.m-phieu-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--foam);
  padding-top: 6px;
}
.m-phieu-total { font-size: 14px; font-weight: 700; color: var(--navy); }
.m-phieu-kg { font-size: 12px; color: var(--sea); font-weight: 600; }
.m-phieu-actions { display: flex; gap: 2px; }
.m-phieu-actions button {
  background: none; border: none; font-size: 16px; padding: 4px 6px;
  cursor: pointer; border-radius: 6px; transition: .15s;
}
.m-phieu-actions button:hover { background: var(--foam); }

/* ── Full-screen Modal ── */
.m-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: mFadeIn .2s;
}
.m-modal {
  background: var(--bg);
  width: 100%;
  max-height: 95vh;
  border-radius: 16px 16px 0 0;
  display: flex;
  flex-direction: column;
  animation: mSlideUp .3s;
  overflow: hidden;
}
.m-modal-hdr {
  background: linear-gradient(135deg, var(--navy), var(--navy2));
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.m-modal-hdr h3 { font-size: 15px; font-weight: 700; margin: 0; }
.m-modal-close {
  background: rgba(255,255,255,.15); border: none; color: #fff;
  width: 32px; height: 32px; border-radius: 50%; font-size: 18px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.m-modal-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 14px 20px;
}
.m-modal-footer {
  padding: 10px 14px max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--wave);
  background: #fff;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

@keyframes mFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes mSlideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ── Mobile Form Fields ── */
.m-field { margin-bottom: 10px; }
.m-field label {
  display: block; font-size: 11px; font-weight: 600; color: var(--mu);
  text-transform: uppercase; letter-spacing: .3px; margin-bottom: 4px;
}
.m-field label span { color: var(--danger); }
.m-field input, .m-field select {
  width: 100%;
  border: 1.5px solid var(--wave);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--txt);
  background: #fff;
  outline: none;
  transition: .2s;
}
.m-field input:focus, .m-field select:focus {
  border-color: var(--sea);
  box-shadow: 0 0 0 3px rgba(30,109,181,.1);
}
.m-field-row { display: flex; gap: 8px; }
.m-field-row .m-field { flex: 1; }

/* ── Item Card (for form rows) ── */
.m-item-card {
  background: #fff;
  border: 1.5px solid var(--wave);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  position: relative;
}
.m-item-card-num {
  position: absolute; top: -8px; left: 10px;
  background: var(--navy); color: #fff; font-size: 10px; font-weight: 700;
  padding: 2px 8px; border-radius: 10px;
}
.m-item-card-name { font-size: 13px; font-weight: 700; color: var(--navy); margin-top: 4px; }
.m-item-card-details {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 4px; margin-top: 6px; font-size: 12px;
}
.m-item-card-details .m-detail-item { text-align: center; }
.m-item-card-details .m-detail-label { font-size: 10px; color: var(--mu); font-weight: 600; }
.m-item-card-details .m-detail-val { font-weight: 700; color: var(--txt); }
.m-item-card-actions {
  display: flex; gap: 4px; justify-content: flex-end; margin-top: 6px;
  border-top: 1px solid var(--foam); padding-top: 6px;
}
.m-item-card-total { font-size: 13px; font-weight: 700; color: var(--sea); flex: 1; }

/* ── Buttons ── */
.m-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border: none; border-radius: 10px;
  font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: .2s; flex: 1;
}
.m-btn-primary {
  background: linear-gradient(135deg, var(--sea), var(--navy2));
  color: #fff; box-shadow: 0 3px 12px rgba(30,109,181,.3);
}
.m-btn-primary:active { transform: scale(.97); }
.m-btn-outline {
  background: #fff; color: var(--navy); border: 1.5px solid var(--wave);
}
.m-btn-danger {
  background: linear-gradient(135deg, #c0392b, #e67e22);
  color: #fff;
}
.m-btn-sm { padding: 6px 12px; font-size: 12px; flex: none; border-radius: 8px; }
.m-btn-add {
  width: 100%; padding: 10px; border: 2px dashed var(--wave);
  background: var(--foam); border-radius: 10px; font-family: inherit;
  font-size: 13px; font-weight: 600; color: var(--navy);
  cursor: pointer; margin-top: 4px; transition: .2s;
}
.m-btn-add:active { background: #dce8f8; }

/* ── Filter bar ── */
.m-filter {
  background: #fff; border-radius: 10px; padding: 10px;
  box-shadow: 0 2px 10px rgba(0,51,117,.07);
  margin-bottom: 10px;
}
.m-filter-row { display: flex; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; }
.m-filter-row:last-child { margin-bottom: 0; }
.m-filter input, .m-filter select {
  flex: 1; min-width: 0; border: 1.5px solid var(--wave); border-radius: 8px;
  padding: 8px 10px; font-size: 13px; font-family: inherit;
  color: var(--txt); background: #fafcff; outline: none;
}

/* ── Section header ── */
.m-sec-hdr { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.m-sec-hdr h2 { font-size: 15px; font-weight: 700; color: var(--navy); margin: 0; }
.m-sec-line { flex: 1; height: 2px; background: linear-gradient(to right, var(--wave), transparent); }

/* ── Sub tabs ── */
.m-sub-tabs { display: flex; gap: 4px; margin-bottom: 10px; overflow-x: auto; }
.m-sub-tab {
  padding: 6px 12px; border: 1.5px solid var(--wave); background: #fff;
  border-radius: 8px; font-family: inherit; font-size: 12px; font-weight: 500;
  cursor: pointer; color: var(--mu); transition: .2s; white-space: nowrap; flex-shrink: 0;
}
.m-sub-tab.active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ── Menu Sheet ── */
.m-menu-sheet {
  position: fixed; inset: 0; z-index: 600;
  background: rgba(0,0,0,.5); display: none;
  animation: mFadeIn .2s;
}
.m-menu-sheet.open { display: block; }
.m-menu-panel {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: #fff; border-radius: 16px 16px 0 0;
  padding: 6px 0 max(10px, env(safe-area-inset-bottom));
  animation: mSlideUp .3s;
}
.m-menu-handle {
  width: 40px; height: 4px; background: var(--wave); border-radius: 2px;
  margin: 6px auto 10px;
}
.m-menu-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; font-size: 14px; font-weight: 500;
  color: var(--txt); cursor: pointer; transition: .15s;
  border: none; background: none; width: 100%; font-family: inherit;
  text-align: left;
}
.m-menu-item:active { background: var(--foam); }
.m-menu-item .m-menu-ico { font-size: 18px; }
.m-menu-divider { height: 1px; background: var(--foam); margin: 4px 16px; }

/* ── Tồn kho card ── */
.m-ton-group {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,51,117,.07);
  margin-bottom: 10px;
  overflow: hidden;
}
.m-ton-group-hdr {
  background: linear-gradient(135deg, var(--navy), var(--navy2));
  color: #fff; padding: 10px 14px;
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700;
}
.m-ton-item {
  padding: 8px 14px;
  border-bottom: 1px solid var(--foam);
  display: flex;
  align-items: center;
  gap: 8px;
}
.m-ton-item:last-child { border-bottom: none; }
.m-ton-size { font-size: 12px; font-weight: 600; color: var(--sea); min-width: 50px; }
.m-ton-vals { flex: 1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; text-align: center; font-size: 11px; }
.m-ton-vals .m-tv-label { font-size: 9px; color: var(--mu); font-weight: 600; text-transform: uppercase; }
.m-ton-vals .m-tv-val { font-weight: 700; font-size: 13px; }
.m-tv-nhap { color: var(--ok); }
.m-tv-xuat { color: var(--danger); }
.m-tv-ton { color: var(--navy); }

/* ── Recent list (dashboard) ── */
.m-recent-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-bottom: 1px solid var(--foam);
}
.m-recent-item:last-child { border-bottom: none; }
.m-ri-badge {
  background: var(--sea); color: #fff; font-size: 10px; font-weight: 700;
  padding: 3px 7px; border-radius: 6px; white-space: nowrap; flex-shrink: 0;
}
.m-ri-info { flex: 1; min-width: 0; }
.m-ri-info b { font-size: 12px; color: var(--navy); display: block;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-ri-info small { font-size: 10.5px; color: var(--mu); }
.m-ri-amount { font-size: 12px; font-weight: 700; color: var(--navy); white-space: nowrap; }

/* ── Empty state ── */
.m-empty {
  text-align: center; padding: 30px; color: var(--mu);
  font-size: 13px;
}

/* ── Summary / Total bar ── */
.m-total-bar {
  background: var(--navy); color: #fff; padding: 10px 14px;
  border-radius: 10px; display: flex; justify-content: space-between;
  font-weight: 700; font-size: 13px; margin-bottom: 10px;
}

/* ── Desktop toggle banner ── */
.m-desktop-banner {
  text-align: center; padding: 8px; font-size: 11px; color: var(--mu);
}
.m-desktop-banner a {
  color: var(--sea); font-weight: 600; text-decoration: underline; cursor: pointer;
}

/* ── Accordion (Tổng hợp) ── */
.m-accordion { 
  margin-bottom: 8px; 
  border-radius: 10px;
  border: 1.5px solid var(--navy);
  overflow: hidden;
}
.m-accordion-hdr {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; background: #fff; border-radius: 9px;
  box-shadow: none; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--navy);
  border: none; width: 100%; font-family: inherit; text-align: left;
}
.m-accordion-hdr .m-acc-arrow { margin-left: auto; transition: .2s; font-size: 14px; }
.m-accordion-hdr.open .m-acc-arrow { transform: rotate(180deg); }
.m-accordion-hdr.open { border-radius: 9px 9px 0 0; border-bottom: 1px solid var(--foam); }
.m-accordion-body {
  display: none; padding: 8px 12px; background: #fff;
  border-radius: 0 0 9px 9px;
}
.m-accordion-body.open { display: block; }

/* ── Phieu detail modal ── */
.m-detail-row {
  display: flex; justify-content: space-between; padding: 6px 0;
  border-bottom: 1px solid var(--foam); font-size: 13px;
}
.m-detail-row:last-child { border-bottom: none; }
.m-detail-row .m-dl { color: var(--mu); font-weight: 500; }
.m-detail-row .m-dv { font-weight: 600; color: var(--txt); }

/* ── NK/XK item card for mobile ── */
.m-kho-item {
  background: #fff; border: 1.5px solid var(--wave);
  border-radius: 10px; padding: 10px 12px; margin-bottom: 8px;
}
.m-kho-item-hdr {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 700; color: var(--navy);
  margin-bottom: 6px;
}
.m-kho-item-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 6px; font-size: 11.5px; text-align: center;
}
.m-kho-item-grid .m-kg-label { font-size: 9.5px; color: var(--mu); font-weight: 600; }
.m-kho-item-grid .m-kg-val { font-weight: 700; color: var(--txt); }
