/*
Theme Name: MWM - Consulta de Preços
Theme URI: https://nolocal.com.br
Author: No Local Soluções Digitais
Description: Sistema de Consulta de Preços MWM
Version: 1.5.9
Requires at least: 6.0
Requires PHP: 8.0
Text Domain: mwm
*/

/* ═══════════════════════════════════════════════════════════
   TOKENS
═══════════════════════════════════════════════════════════ */
:root {
  --g:   #1a7c3e;
  --gd:  #155f30;
  /* Colors overridden at runtime by wp_head if configured in Settings */
  --gl:  #f0f9f4;
  --acc: #e74c3c;
  --bg:  #f0f2f5;
  --txt: #1a1a1a;
  --bdr: #e0e0e0;
  --rad: 10px;
  --sh:  0 1px 8px rgba(0,0,0,0.08);
  --nav: 60px;       /* bottom nav height */
  --bar: 52px;       /* topbar height     */
  --sw:  220px;      /* sidebar width     */
}

/* ═══════════════════════════════════════════════════════════
   RESET
═══════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; overflow-x: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg); color: var(--txt);
  font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--g); text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }

/* ═══════════════════════════════════════════════════════════
   LAYOUT  (desktop sidebar + main)
═══════════════════════════════════════════════════════════ */
#mwm-sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sw);
  background: var(--gd); color: #fff;
  display: flex; flex-direction: column;
  z-index: 200; overflow-y: auto;
  transition: transform .25s ease;
}
#mwm-sidebar .sidebar-logo {
  padding: 20px 18px 14px;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
}
#mwm-sidebar .sidebar-logo img  { max-height: 46px; margin: 0 auto; object-fit: contain; }
#mwm-sidebar .sidebar-logo span { font-size: 22px; font-weight: 800; letter-spacing: 2px; }
#mwm-sidebar nav { flex: 1; padding: 6px 0; }
#mwm-sidebar nav ul { list-style: none; }
#mwm-sidebar nav ul li a {
  display: flex; align-items: center; gap: 11px;
  padding: 13px 18px; color: rgba(255,255,255,.78);
  font-size: 14px; font-weight: 500;
  transition: background .15s, color .15s;
}
#mwm-sidebar nav ul li a:hover,
#mwm-sidebar nav ul li a.active {
  background: rgba(255,255,255,.14); color: #fff;
}
#mwm-sidebar nav ul li a .icon { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }
#mwm-sidebar .sidebar-footer {
  padding: 12px 18px; font-size: 12px;
  color: rgba(255,255,255,.5);
  border-top: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
}
#mwm-sidebar .sidebar-footer a { color: rgba(255,255,255,.45); }

#mwm-main { margin-left: var(--sw); min-height: 100vh; display: flex; flex-direction: column; }

/* ── TOPBAR ── */
#mwm-topbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--bar);
  background: #fff; border-bottom: 1px solid #e8e8e8;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
  display: flex; align-items: center;
  justify-content: space-between; padding: 0 20px;
}
#btn-menu-toggle {
  display: none; background: none; border: none;
  font-size: 20px; color: var(--txt); cursor: pointer;
  padding: 6px; margin-right: 6px;
  align-items: center; justify-content: center;
}
.topbar-title { font-size: 16px; font-weight: 600; }
.cart-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--g); color: #fff;
  border-radius: 50px; padding: 7px 14px;
  font-size: 13px; font-weight: 500; cursor: pointer;
  text-decoration: none; transition: background .15s;
}
.cart-badge:hover { background: var(--gd); color: #fff; }
.cart-badge .badge-count {
  background: var(--acc); color: #fff;
  border-radius: 50%; width: 19px; height: 19px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700;
}

#mwm-content { padding: 20px; flex: 1; max-width: 100%; overflow-x: hidden; }

/* ═══════════════════════════════════════════════════════════
   COMPONENTS
═══════════════════════════════════════════════════════════ */

/* ── Cards ── */
.mwm-card {
  background: #fff; border-radius: var(--rad);
  box-shadow: var(--sh); padding: 18px; margin-bottom: 16px;
}
.mwm-card-title {
  font-size: 14px; font-weight: 700; color: var(--gd);
  padding-bottom: 12px; margin-bottom: 14px;
  border-bottom: 2px solid var(--g);
  display: flex; align-items: center; gap: 8px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 8px;
  font-size: 14px; font-weight: 500; cursor: pointer;
  border: 1.5px solid transparent; white-space: nowrap;
  transition: all .15s; -webkit-appearance: none;
  text-decoration: none;
}
.btn-primary   { background: var(--g);   color: #fff; border-color: var(--g);   }
.btn-primary:hover { background: var(--gd); border-color: var(--gd); color: #fff; }
.btn-danger    { background: var(--acc); color: #fff; border-color: var(--acc); }
.btn-danger:hover  { background: #c0392b; color: #fff; }
.btn-outline   { background: #fff; border-color: var(--g); color: var(--g); }
.btn-outline:hover { background: var(--g); color: #fff; }
.btn-secondary { background: #6c757d; color: #fff; border-color: #6c757d; }
.btn-success   { background: #27ae60; color: #fff; border-color: #27ae60; }
.btn-warning   { background: #f39c12; color: #fff; border-color: #f39c12; }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 6px; }

/* ── Forms ── */
.mwm-form-group { margin-bottom: 14px; }
.mwm-form-group label { display: block; font-size: 12px; font-weight: 600; color: #555; margin-bottom: 5px; }
.mwm-form-group input,
.mwm-form-group select,
.mwm-form-group textarea {
  width: 100%; padding: 11px 13px;
  border: 1.5px solid var(--bdr); border-radius: 8px;
  font-size: 15px; background: #fff; color: var(--txt);
  -webkit-appearance: none; appearance: none;
  transition: border-color .15s;
}
.mwm-form-group input:focus,
.mwm-form-group select:focus,
.mwm-form-group textarea:focus {
  outline: none; border-color: var(--g);
  box-shadow: 0 0 0 3px rgba(26,124,62,.1);
}
.mwm-form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mwm-form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* Image upload */
.img-upload-wrap {
  border: 2px dashed var(--bdr); border-radius: 8px;
  padding: 14px; text-align: center; cursor: pointer;
  transition: border-color .2s;
}
.img-upload-wrap:hover { border-color: var(--g); }
.img-upload-wrap img { max-height: 80px; margin: 0 auto 8px; border-radius: 6px; }
.img-upload-wrap .img-hint { font-size: 12px; color: #888; }

/* ── Tables (desktop) ── */
.mwm-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 8px; border: 1px solid #eee; }
.mwm-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mwm-table th {
  background: var(--g); color: #fff; padding: 10px 12px;
  text-align: left; font-weight: 600; white-space: nowrap;
  cursor: pointer; user-select: none;
}
.mwm-table th:hover { background: var(--gd); }
.mwm-table td { padding: 10px 12px; border-bottom: 1px solid #f3f3f3; vertical-align: middle; }
.mwm-table tr:last-child td { border-bottom: none; }
.mwm-table tr:hover td { background: #f7fbf9; }
.mwm-table .actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Search bar ── */
.mwm-search-wrap { position: relative; margin-bottom: 16px; }
.mwm-search-wrap input {
  width: 100%; padding: 13px 16px 13px 44px;
  border: 2px solid var(--bdr); border-radius: 50px;
  font-size: 15px; background: #fff;
  transition: border-color .2s;
}
.mwm-search-wrap input:focus { border-color: var(--g); outline: none; box-shadow: 0 0 0 3px rgba(26,124,62,.1); }
.mwm-search-wrap .search-icon {
  position: absolute; left: 15px; top: 50%; transform: translateY(-50%);
  color: #aaa; font-size: 16px; pointer-events: none;
}
.mwm-autocomplete {
  position: fixed;
  background: #fff; border: 1px solid #e0e0e0; border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0,0,0,.14); z-index: 9000;
  max-height: 340px; overflow-y: auto;
}
.mwm-autocomplete .ac-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 15px; cursor: pointer;
  border-bottom: 1px solid #f5f5f5; transition: background .12s;
}
.mwm-autocomplete .ac-item:last-child { border-bottom: none; }
.mwm-autocomplete .ac-item:hover { background: var(--gl); }
.mwm-autocomplete .ac-item img { width: 42px; height: 42px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.mwm-autocomplete .ac-info .ac-name { font-weight: 600; font-size: 14px; }
.mwm-autocomplete .ac-info .ac-code { font-size: 12px; color: #888; margin-top: 2px; }
.mwm-autocomplete .ac-price { margin-left: auto; font-weight: 700; color: var(--g); font-size: 14px; white-space: nowrap; }

/* ── Pieces grid ── */
.mwm-pieces-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.mwm-piece-card {
  background: #fff; border-radius: 10px; border: 1px solid #eee;
  overflow: hidden; cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  transition: box-shadow .2s, transform .15s;
}
.mwm-piece-card:active { transform: scale(.97); }
.mwm-piece-card img { width: 100%; height: 120px; object-fit: cover; }
.mwm-piece-card .piece-card-body { padding: 10px 11px; }
.mwm-piece-card .piece-card-name { font-weight: 700; font-size: 12px; line-height: 1.3; margin-bottom: 2px; }
.mwm-piece-card .piece-card-code { font-size: 11px; color: #888; }
.mwm-piece-card .piece-card-price { font-weight: 800; color: var(--g); margin-top: 5px; font-size: 14px; }

/* ── Product detail ── */
.mwm-product-detail { display: flex; gap: 18px; align-items: flex-start; }
.mwm-product-detail > img { width: 140px; height: 140px; object-fit: cover; border-radius: 10px; flex-shrink: 0; }
.mwm-product-detail .product-info h2 { font-size: 17px; margin-bottom: 6px; }
.mwm-product-detail .product-price { font-size: 22px; font-weight: 800; color: var(--g); margin: 8px 0; }
.mwm-product-detail table { font-size: 13px; width: 100%; }
.mwm-product-detail table td { padding: 3px 0; vertical-align: top; }
.mwm-product-detail table td:first-child { color: #666; font-weight: 600; width: 85px; }

/* ── Cart items ── */
.mwm-cart-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 0; border-bottom: 1px solid #f3f3f3;
}
.mwm-cart-item:last-child { border-bottom: none; }
.mwm-cart-item > img { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.mwm-cart-item .item-info { flex: 1; min-width: 0; }
.mwm-cart-item .item-name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mwm-cart-item .item-code { font-size: 12px; color: #888; }
.mwm-cart-item .item-qty { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.mwm-cart-item .item-qty button {
  width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid var(--g); background: #fff; color: var(--g);
  font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s; flex-shrink: 0;
}
.mwm-cart-item .item-qty button:hover { background: var(--g); color: #fff; }
.mwm-cart-item .item-qty span { font-weight: 700; min-width: 24px; text-align: center; }
.mwm-cart-item .item-price { font-weight: 700; color: var(--g); font-size: 13px; flex-shrink: 0; white-space: nowrap; }
.mwm-cart-item .item-remove {
  width: 30px; height: 30px; border-radius: 50%;
  background: #fff2f2; color: var(--acc);
  border: 1.5px solid #ffd0cc; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; flex-shrink: 0; transition: all .15s;
}
.mwm-cart-item .item-remove:hover { background: var(--acc); color: #fff; }

.cart-total-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 0; border-top: 2px solid var(--g); margin-top: 8px;
}
.cart-total-bar .total-label { font-size: 14px; font-weight: 600; }
.cart-total-bar .total-value { font-size: 20px; font-weight: 800; color: var(--g); }
.cart-actions { display: flex; gap: 10px; margin-top: 12px; }

/* ── Badges ── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-pending  { background: #fff3cd; color: #856404; }
.badge-approved { background: #d1e7dd; color: #0f5132; }
.badge-cancelled{ background: #f8d7da; color: #842029; }

/* ── Alerts ── */
.mwm-alert { padding: 12px 15px; border-radius: 8px; margin-bottom: 12px; font-size: 14px; }
.mwm-alert-success { background: #d1e7dd; color: #0f5132; border-left: 4px solid #27ae60; }
.mwm-alert-error   { background: #f8d7da; color: #842029; border-left: 4px solid var(--acc); }
.mwm-alert-info    { background: #cfe2ff; color: #084298; border-left: 4px solid #0d6efd; }

/* ── Page header ── */
.mwm-page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 10px; flex-wrap: wrap;
}
.mwm-page-header h1 { font-size: 18px; font-weight: 700; color: var(--gd); display: flex; align-items: center; gap: 8px; }

/* ── Filters ── */
.mwm-filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: flex-end; }
.filter-group { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 140px; }
.filter-group label { font-size: 11px; font-weight: 700; color: #666; text-transform: uppercase; letter-spacing: 0.5px; }
.filter-group input,
.filter-group select { padding: 9px 12px; border: 1.5px solid #ddd; border-radius: 8px; font-size: 14px; width: 100%; background: #fff; height: 40px; }

/* ── Filter Row (Flexible) ── */
.mwm-filter-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  align-items: flex-end;
}
@media (max-width: 768px) {
  .mwm-filter-row {
    grid-template-columns: 1fr 1fr;
  }
}
@media (max-width: 480px) {
  .mwm-filter-row {
    grid-template-columns: 1fr;
  }
}

/* ── Calculadora ── */
.calc-header-fields {
  display: grid; grid-template-columns: repeat(4,1fr); gap: 8px;
  background: var(--g); border-radius: 10px; padding: 12px; margin-bottom: 16px;
}
.calc-header-fields .calc-field label { color: rgba(255,255,255,.8); font-size: 10px; font-weight: 700; display: block; margin-bottom: 3px; }
.calc-header-fields .calc-field input {
  background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.3);
  color: #fff; border-radius: 6px; padding: 7px 8px; width: 100%; font-size: 13px; font-weight: 700;
}
.calc-result-box {
  background: var(--gl); border: 2px solid var(--g);
  border-radius: 10px; padding: 14px 16px; margin: 14px 0;
}
.calc-result-box label { font-size: 11px; font-weight: 700; color: #555; }
.calc-result-box .result-value { font-size: 24px; font-weight: 800; color: var(--g); margin-top: 2px; }

/* ── Modal (bottom-sheet mobile, centered desktop) ── */
.mwm-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.52);
  z-index: 1000; display: flex; align-items: flex-end;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.mwm-modal-overlay.active { opacity: 1; pointer-events: all; }
.mwm-modal {
  background: #fff; width: 100%;
  max-height: 92dvh; overflow-y: auto;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -4px 30px rgba(0,0,0,.18);
  transform: translateY(100%); transition: transform .28s cubic-bezier(.32,1,.56,1);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.mwm-modal-overlay.active .mwm-modal { transform: translateY(0); }
.mwm-modal::before {
  content: ''; display: block;
  width: 36px; height: 4px; background: #ddd;
  border-radius: 2px; margin: 10px auto 2px;
}
.mwm-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; border-bottom: 1px solid #eee;
  position: sticky; top: 0; background: #fff; z-index: 2;
}
.mwm-modal-header h3 { font-size: 16px; font-weight: 700; }
.mwm-modal-close {
  background: #f0f0f0; border: none; border-radius: 50%;
  width: 30px; height: 30px; font-size: 15px; cursor: pointer;
  color: #555; display: flex; align-items: center; justify-content: center;
}
.mwm-modal-body { padding: 16px 18px; }
.mwm-modal-footer {
  display: flex; gap: 10px; padding: 12px 18px;
  border-top: 1px solid #eee;
  position: sticky; bottom: 0; background: #fff; z-index: 2;
}
.mwm-modal-footer .btn { flex: 1; }

/* ── Login ── */
.mwm-login-page {
  min-height: 100vh; background: var(--gd);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.mwm-login-box {
  background: #fff; border-radius: 16px;
  padding: 32px 24px; width: 100%; max-width: 380px;
  box-shadow: 0 8px 40px rgba(0,0,0,.3);
}
.mwm-login-box .login-logo { text-align: center; margin-bottom: 20px; }
.mwm-login-box .login-logo img { max-height: 64px; margin: 0 auto; }
.mwm-login-box .login-logo .login-title { font-size: 26px; font-weight: 800; color: var(--g); letter-spacing: 3px; }
.mwm-login-box h2 { text-align: center; color: #666; font-size: 14px; font-weight: 400; margin-bottom: 20px; }

/* ── Toast ── */
#mwm-toast { position: fixed; bottom: 80px; left: 16px; right: 16px; z-index: 9999; pointer-events: none; display: none; }

/* ── Order cards (pedidos mobile) ── */
.order-card { background:#fff; border-radius:12px; box-shadow:var(--sh); margin-bottom:12px; overflow:hidden; border:1px solid #eee; }
.order-card-header { display:flex; align-items:center; justify-content:space-between; padding:13px 15px 10px; border-bottom:1px solid #f5f5f5; gap:8px; }
.order-num { font-weight:800; font-size:16px; color:var(--gd); }
.order-card-body { padding:11px 15px; display:grid; grid-template-columns:1fr 1fr; gap:8px; font-size:13px; }
.order-field label { display:block; font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:.4px; color:#999; margin-bottom:2px; }
.order-field span { font-weight:600; color:#222; font-size:13px; }
.order-total span { font-size:17px; font-weight:800; color:var(--g); }
.order-card-actions { padding:10px 15px 13px; display:flex; gap:8px; }
.order-card-actions .btn { flex:1; font-size:12px; padding:9px 8px; }

/* ═══════════════════════════════════════════════════════════
   BOTTOM NAV
═══════════════════════════════════════════════════════════ */
#mwm-bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--nav);
  background: var(--gd);
  z-index: 300;
  border-top: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 -2px 14px rgba(0,0,0,.25);
}
#mwm-bottom-nav ul {
  list-style: none; display: flex; height: 100%; margin: 0; padding: 0; width: 100%;
}
#mwm-bottom-nav ul li { flex: 1; display: flex; }
#mwm-bottom-nav ul li a {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px; padding: 5px 2px 3px;
  color: rgba(255,255,255,.55) !important;
  text-decoration: none !important;
  position: relative; transition: color .15s;
}
#mwm-bottom-nav ul li a i {
  font-size: 19px !important;
  color: inherit !important;
  display: block; line-height: 1; flex-shrink: 0;
}
#mwm-bottom-nav ul li a .nav-label {
  display: block;
  font-size: 8px !important;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .3px;
  color: inherit !important;
  line-height: 1;
  white-space: nowrap;
}
#mwm-bottom-nav ul li a.active { color: #fff !important; }
#mwm-bottom-nav ul li a.active::before {
  content: ''; position: absolute;
  top: 0; left: 20%; right: 20%;
  height: 3px; background: #fff;
  border-radius: 0 0 3px 3px;
}
.cart-dot { position: relative; display: flex; align-items: center; justify-content: center; }
.cart-dot .badge-count {
  position: absolute; top: -5px; right: -8px;
  background: var(--acc); color: #fff;
  border-radius: 50%; width: 15px; height: 15px;
  font-size: 9px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--gd);
}

/* Mobile menu overlay */
#mobile-menu-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 190;
}
#mobile-menu-overlay.active { display: block; }

/* ═══════════════════════════════════════════════════════════
   DESKTOP  ≥ 769px
═══════════════════════════════════════════════════════════ */
@media (min-width: 769px) {
  #mwm-sidebar    { transform: none !important; }
  #btn-menu-toggle{ display: none !important; }
  #mwm-bottom-nav { display: none !important; }
  #mwm-main       { margin-left: var(--sw) !important; padding-bottom: 0 !important; }
  #mwm-toast      { bottom: 24px; left: auto; right: 24px; width: 280px; }

  /* Desktop modal — centered dialog */
  .mwm-modal-overlay { align-items: center; }
  .mwm-modal {
    max-width: 660px; border-radius: 14px; margin: 0 auto;
    transform: translateY(16px) scale(.98);
  }
  .mwm-modal-overlay.active .mwm-modal { transform: none; }
  .mwm-modal::before { display: none; }
  .mwm-modal-footer .btn { flex: 0 0 auto; }
}

/* ═══════════════════════════════════════════════════════════
   MOBILE  ≤ 768px
═══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* Layout */
  #mwm-sidebar {
    transform: translateX(-100%);
    width: 270px; bottom: var(--nav); z-index: 210;
  }
  #mwm-sidebar.open { transform: translateX(0); }
  #btn-menu-toggle  { display: flex; }
  #mwm-bottom-nav   { display: flex; }
  #mwm-main         { margin-left: 0 !important; padding-bottom: var(--nav); }
  #mwm-content      { padding: 12px; }
  #mwm-topbar       { padding: 0 12px; }
  #mwm-topbar .cart-badge .cart-text { display: none; }

  /* Typography */
  body { font-size: 14px; }
  .mwm-page-header h1 { font-size: 17px; }

  /* Forms → 1 column always */
  .mwm-form-row,
  .mwm-form-row-3   { grid-template-columns: 1fr !important; }

  /* Calculadora: 2 cols */
  .calc-header-fields { grid-template-columns: 1fr 1fr !important; }

  /* Tables → add horizontal scroll, smaller text */
  .mwm-table-wrap   { border-radius: 6px; }
  .mwm-table        { font-size: 12px; min-width: 500px; }
  .mwm-table th,
  .mwm-table td     { padding: 9px 10px; }
  .mwm-table .actions .btn { padding: 5px 8px; font-size: 11px; }

  /* Pieces grid: 2 equal cols */
  .mwm-pieces-grid  { grid-template-columns: 1fr 1fr !important; gap: 10px; }
  .mwm-piece-card img { height: 100px; }

  /* Product detail → stack */
  .mwm-product-detail { flex-direction: column; }
  .mwm-product-detail > img { width: 100%; height: 180px; }

  /* Cart items */
  .mwm-cart-item .item-price { font-size: 12px; }
  .cart-actions { flex-direction: column; }
  .cart-actions .btn { width: 100%; }

  /* Page header → stack */
  .mwm-page-header  { flex-direction: column; align-items: flex-start; }
  .mwm-page-header .btn { width: 100%; }

  /* Filters → column */
  .mwm-filters { flex-direction: column; }
  .mwm-filters .filter-group { width: 100%; min-width: unset; }

  /* Buttons in modal footer */
  .mwm-modal-footer { flex-direction: column; }
  .mwm-modal-footer .btn { width: 100%; }

  /* Toast */
  #mwm-toast { bottom: calc(var(--nav) + 10px); left: 12px; right: 12px; }

  /* Cards in relatorios / peças tables: keep table but scroll */
  .table-scroll-hint {
    font-size: 11px; color: #999; text-align: center;
    padding: 4px; display: block; margin-bottom: 6px;
  }
}

/* ═══════════════════════════════════════════════════════════
   EXTRA SMALL  ≤ 380px
═══════════════════════════════════════════════════════════ */
@media (max-width: 380px) {
  #mwm-content { padding: 10px; }
  .mwm-card    { padding: 14px 12px; }
  .btn         { font-size: 13px; padding: 9px 12px; }
  .mwm-pieces-grid { gap: 8px; }
  .mwm-piece-card img { height: 88px; }
}

/* ═══════════════════════════════════════════════════════════
   PWA / SAFE AREA
═══════════════════════════════════════════════════════════ */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  @media (max-width: 768px) {
    #mwm-bottom-nav {
      padding-bottom: env(safe-area-inset-bottom);
      height: calc(var(--nav) + env(safe-area-inset-bottom));
    }
    #mwm-main { padding-bottom: calc(var(--nav) + env(safe-area-inset-bottom)); }
  }
}
