@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700;800;900&display=swap");

/* =========================================================
   ADMIN THEME TOKENS
   (mantive nomes, só padronizei e agrupei)
========================================================= */
:root{
  --bg: #070707;
  --bg2: #0b0b0b;

  --panel: rgba(255,255,255,.04);
  --panel2: rgba(255,255,255,.06);

  --text: #fff;
  --muted: rgba(255,255,255,.70);
  --border: rgba(255,255,255,.10);

  --primary: #ff1a1a;
  --primary2: #cc0000;

  --radius: 18px;
  --radius-lg: 24px;

  --shadow: 0 20px 60px rgba(0,0,0,.55);
}

/* =========================================================
   RESET + BASE
========================================================= */
*{
  margin:0;
  padding:0;
  box-sizing:border-box;
  font-family:"Inter",system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
}

/* Anti-estouro global (removi duplicatas e deixei só o essencial) */
html, body{
  width:100%;
  max-width:100%;
  overflow-x:hidden;
}

img, svg, video, canvas{
  max-width:100%;
  height:auto;
}

body{
  min-height:100vh;
  color:var(--text);
  background:
    radial-gradient(1200px 600px at 15% 0%, rgba(255,0,0,.14), transparent 55%),
    radial-gradient(900px 520px at 85% 10%, rgba(255,0,0,.10), transparent 60%),
    var(--bg);
}

a{color:inherit;text-decoration:none;}
img{display:block;}
button{font:inherit;}
small{color:var(--muted);}

.muted{color:var(--muted);}
.sr-only{
  position:absolute;
  width:1px;height:1px;
  padding:0;margin:-1px;
  overflow:hidden;
  clip:rect(0,0,0,0);
  border:0;
}

/* =========================================================
   APP LAYOUT
========================================================= */
.admin{
  width:100%;
  min-height:100vh;
  display:grid;
  grid-template-columns: 280px 1fr;
}

.main{
  padding:18px;
  width:100%;
  min-width:0;
  overflow:hidden;
}

/* =========================================================
   SIDEBAR
   - suporte a .sidebar e #sidebarPanel (você tinha os dois)
========================================================= */
.sidebar,
#sidebarPanel{
  position:sticky;
  top:0;
  height:100vh;
  overflow:auto;
  -webkit-overflow-scrolling:touch;

  background: rgba(0,0,0,.70);
  backdrop-filter: blur(10px);
  border-right: 1px solid var(--border);
  padding:18px;

  /* necessário pro footer absolute */
  position: sticky;
}

.brand{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding: 10px 10px 14px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand h1{
  font-size:18px;
  font-weight:950;
  letter-spacing:.6px;
}
.brand h1 span{color:var(--primary);}
.brand small{display:block;margin-top:2px;font-size:12px;}

.sidebar-toggle{
  display:none;
  width:42px;height:42px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.04);
  color:#fff;
  cursor:pointer;
  transition:.16s;
}
.sidebar-toggle:hover{
  border-color: rgba(255,0,0,.30);
  background: rgba(255,0,0,.10);
}

/* Menu */
.nav{
  margin-top:14px;
  display:grid;
  gap:10px;
}
.nav a{
  display:flex;
  align-items:center;
  gap:10px;
  padding: 12px 12px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.03);
  font-weight:900;
  color: rgba(255,255,255,.88);
  transition:.18s;
}
.nav a:hover{
  border-color: rgba(255,0,0,.28);
  background: rgba(255,0,0,.10);
  transform: translateY(-1px);
}
.nav a.active{
  border-color: rgba(255,0,0,.35);
  background: rgba(255,0,0,.16);
  color:#fff;
}

/* Footer dentro da sidebar */
.sidebar-foot{
  position:absolute;
  left:18px; right:18px;
  bottom:18px;
  display:grid;
  gap:10px;
}
.userbox{
  padding:12px;
  border-radius:16px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.03);
}
.userbox strong{display:block;font-weight:950;}
.userbox small{display:block;margin-top:6px;font-size:12px;}

/* Backdrop do drawer (mobile) */
.sidebar-backdrop{
  position:fixed;
  inset:0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(6px);
  opacity:0;
  pointer-events:none;
  transition:.2s;
  z-index:9998;
}
.sidebar-backdrop.open{
  opacity:1;
  pointer-events:auto;
}

/* Mobile topbar (aparece só no mobile) */
.mobilebar{
  display:none;
  align-items:center;
  gap:12px;
  margin-bottom:12px;
  padding:12px;
  border-radius:18px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.03);
  backdrop-filter: blur(10px);
}
.micon{
  width:44px;height:44px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.04);
  color:#fff;
  cursor:pointer;
  transition:.16s;
}
.micon:hover{
  border-color: rgba(255,0,0,.30);
  background: rgba(255,0,0,.10);
  transform: translateY(-1px);
}
.mobilebar-title strong{display:block;font-weight:950;letter-spacing:.2px;}
.mobilebar-title small{display:block;margin-top:2px;}

/* =========================================================
   BUTTONS
========================================================= */
.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  height:44px;
  padding:0 14px;
  border-radius:999px;
  font-weight:950;
  border:1px solid transparent;
  cursor:pointer;
  transition:.18s;
  user-select:none;
}

.btn-primary{
  background: linear-gradient(145deg, var(--primary), var(--primary2));
  color:#fff;
  box-shadow: 0 0 40px rgba(255,0,0,.16);
}
.btn-primary:hover{
  transform: translateY(-1px);
  box-shadow: 0 0 70px rgba(255,0,0,.22);
}

.btn-ghost{
  background: rgba(255,255,255,.04);
  border:1px solid rgba(255,255,255,.12);
  color:#fff;
}
.btn-ghost:hover{
  border-color: rgba(255,0,0,.28);
  background: rgba(255,0,0,.10);
}

.btn-mini{
  height:34px;
  padding:0 10px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.04);
  color:#fff;
  font-weight:900;
  cursor:pointer;
  transition:.18s;
}
.btn-mini:hover{border-color: rgba(255,0,0,.28); background: rgba(255,0,0,.10);}
.btn-mini.ghost{opacity:.9;}
.btn-mini.ghost:hover{opacity:1;}

/* =========================================================
   TOPBAR
========================================================= */
.top{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:16px;

  padding:14px;
  border-radius:18px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.03);
  backdrop-filter: blur(10px);

  margin-bottom:14px;
  min-width:0;
}

.top h2{
  font-size:28px;
  font-weight:950;
  letter-spacing:.2px;
}
.top .muted{font-size:13px;font-weight:800;}

.top-actions{
  display:flex;
  gap:10px;
  align-items:center;
  min-width:0;
  flex-wrap:wrap; /* quebra bonito em telas menores */
}

/* Search */
.search{
  display:flex;
  align-items:center;
  gap:10px;

  height:46px;
  min-height:46px;
  padding: 0 14px;

  border-radius:14px; /* evita o “bolão” */
  background: rgba(255,255,255,.05);
  border:1px solid rgba(255,255,255,.10);

  width:100%;
  max-width:560px;
  min-width:220px;

  align-self:flex-start; /* impede esticar vertical */
}
.search input{
  border:none;
  outline:none;
  width:100%;
  height:100%;
  line-height:46px;
  background:transparent;
  font-weight:800;
  color:#fff;
}
.search input::placeholder{color:rgba(255,255,255,.55);}

/* Icon button */
.icon{
  width:44px;height:44px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.04);
  color:#fff;
  cursor:pointer;
  transition:.16s;
}
.icon:hover{
  border-color: rgba(255,0,0,.28);
  background: rgba(255,0,0,.10);
  transform: translateY(-1px);
}

/* =========================================================
   DASHBOARD GRID / CARDS
========================================================= */
.grid{
  margin-top:14px;
  display:grid;
  grid-template-columns: repeat(12, minmax(0,1fr));
  gap:14px;
}

.card{
  grid-column: span 4;
  padding:16px;
  border-radius:22px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.04);
  box-shadow: var(--shadow);
  min-width:0;
}
.card h3{font-size:13px;color:rgba(255,255,255,.75);font-weight:900;}
.card strong{
  display:block;
  margin-top:10px;
  font-size:28px;
  font-weight:950;
  color:#fff;
}
.card .hint{margin-top:10px;color:var(--muted);font-size:12px;font-weight:800;}

/* KPIs do dashboard novo (você tinha separado no final) */
.dash-kpis, .dash-grid { width:100%; }
.dash-kpis{
  display:grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap:14px;
  margin-top:14px;
}
.dash-grid{
  display:grid;
  grid-template-columns: 1.55fr .85fr;
  gap:14px;
  margin-top:14px;
  align-items:start;
}
.dash-grid .table,
.dash-grid .panel{ min-width:0; }

/* =========================================================
   TABLE
========================================================= */
.table{
  grid-column: span 12;
  border-radius:22px;
  overflow:hidden;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.03);
  min-width:0;
}

.table-head{
  padding:14px 16px;
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:12px;
  border-bottom:1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.25);
}
.table-head h3{font-weight:950;}
.table-head small{font-weight:800;}

.table-wrap{
  overflow:auto;
  min-width:0;
  -webkit-overflow-scrolling:touch;
}

.table table{
  width:100%;
  border-collapse:collapse;
  min-width:860px;
}

.table th, .table td{
  padding:12px 14px;
  text-align:left;
  border-bottom:1px solid rgba(255,255,255,.06);
  font-size:13px;
}

.table th{
  color: rgba(255,255,255,.70);
  font-weight:900;
  text-transform: uppercase;
  letter-spacing:.4px;
  background: rgba(0,0,0,.18);
}

.table td{color: rgba(255,255,255,.88); font-weight:800;}
.table tr:hover td{background: rgba(255,0,0,.06);}

.row-click{cursor:pointer;}
.actions{
  display:flex;
  gap:8px;
  justify-content:flex-end;
  align-items:center;
}

/* Dashboard: tabela “lastOrders” */
#lastOrders td, #lastOrders th{ white-space: nowrap; }
#lastOrders td:nth-child(2), #lastOrders th:nth-child(2){ white-space: normal; } /* cliente pode quebrar */
#lastOrders td:nth-child(4), #lastOrders th:nth-child(4){ white-space: nowrap; } /* status */

/* =========================================================
   BADGES
========================================================= */
.badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:6px 10px;
  border-radius:999px;
  font-weight:950;
  font-size:12px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.04);
  text-transform: lowercase;

  /* “não encolher” */
  white-space: nowrap;
  flex: 0 0 auto;
  min-width: fit-content;
}

.badge.ok{border-color: rgba(0,255,120,.25); background: rgba(0,255,120,.08);}
.badge.wait{border-color: rgba(255,220,0,.25); background: rgba(255,220,0,.08);}
.badge.bad{border-color: rgba(255,0,0,.25); background: rgba(255,0,0,.10);}
.badge.danger{border-color: rgba(255,0,0,.35); background: rgba(255,0,0,.18);}

/* Status list (se existir #statusList gerado por JS) */
#statusList{
  display:grid;
  gap:10px;
  min-width:0;
}
#statusList > div{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;

  min-width:0;
  padding:10px 12px;
  border-radius:16px;
  border:1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.20);
}
#statusList > div > :first-child{
  flex:1 1 auto;
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
#statusList > div > :last-child{
  flex:0 0 auto;
  white-space:nowrap;
  min-width:fit-content;
}

/* =========================================================
   ORDERS TOOLBAR
========================================================= */
.orders-toolbar{
  margin-top:14px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;

  padding:14px;
  border-radius:18px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.03);
}

.toolbar-left{display:flex;align-items:center;gap:14px;flex-wrap:wrap;}
.toolbar-right{display:flex;gap:10px;align-items:center;}

.pill{
  display:inline-flex;
  align-items:baseline;
  gap:10px;
  padding:10px 14px;
  border-radius:999px;
  background: rgba(255,0,0,.10);
  border:1px solid rgba(255,0,0,.22);
}
.pill strong{font-weight:950;font-size:18px;color:#fff;}
.pill span{color:rgba(255,255,255,.70);font-weight:800;font-size:12px;}

.filters{display:flex;gap:10px;flex-wrap:wrap;}
.filters select{
  height:42px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.35);
  color:#fff;
  padding:0 12px;
  font-weight:900;
  outline:none;
}
.filters select:focus{
  border-color: rgba(255,0,0,.30);
  box-shadow: 0 0 0 3px rgba(255,0,0,.10);
}

/* =========================================================
   MODAL
========================================================= */
.modal{
  position:fixed;
  inset:0;
  display:none;
  z-index:99999;
}
.modal.open{display:block;}

.modal-backdrop{
  position:absolute;
  inset:0;
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(8px);
}

.modal-card{
  position:relative;
  width:min(1100px, 92vw);
  margin:5vh auto;
  max-height:90vh;
  overflow:auto;

  border-radius:26px;
  border:1px solid rgba(255,255,255,.12);
  background:
    radial-gradient(900px 420px at 18% 12%, rgba(255,0,0,.14), transparent 60%),
    rgba(10,10,10,.96);

  box-shadow: 0 30px 90px rgba(0,0,0,.65);
}

.modal-head{
  padding:16px 18px;
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
  border-bottom:1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.20);
}
.modal-head h3{font-size:18px;font-weight:950;}
.modal-body{padding:16px 18px 18px;}

.modal-grid{
  display:grid;
  grid-template-columns: 1fr 1.2fr;
  gap:14px;
}

.panel{
  border-radius:22px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.03);
  padding:14px;
  box-shadow: 0 16px 40px rgba(0,0,0,.35);
  min-width:0;
}

.panel h4{
  font-size:14px;
  letter-spacing:.2px;
  text-transform:uppercase;
  color: rgba(255,255,255,.80);
  margin-bottom:10px;
}

.kv{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  padding:10px 0;
  border-bottom:1px solid rgba(255,255,255,.06);
}
.kv:last-child{border-bottom:none;}
.kv span{color: rgba(255,255,255,.65); font-weight:800; font-size:12px;}
.kv strong{font-weight:950; text-align:right; max-width:62%;}

.panel-actions{
  margin-top:12px;
  display:grid;
  grid-template-columns: 1fr auto auto;
  gap:10px;
  align-items:center;
}
.panel-actions select{
  height:44px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.35);
  color:#fff;
  padding:0 12px;
  font-weight:900;
  outline:none;
}
.panel-actions select:focus{
  border-color: rgba(255,0,0,.35);
  box-shadow:0 0 0 3px rgba(255,0,0,.12);
}

.items{
  display:grid;
  gap:10px;
  margin-top:10px;
  max-height:38vh;
  overflow:auto;
  padding-right:6px;
}
.items::-webkit-scrollbar{width:6px;}
.items::-webkit-scrollbar-thumb{
  background: rgba(255,0,0,.35);
  border-radius:999px;
}

.item{
  display:grid;
  grid-template-columns: 56px 1fr auto;
  gap:10px;
  align-items:center;
  padding:10px;
  border-radius:16px;
  border:1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.25);
  min-width:0;
}
.item-img{
  width:56px;height:56px;
  border-radius:14px;
  overflow:hidden;
  background: rgba(255,255,255,.04);
  border:1px solid rgba(255,255,255,.08);
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:22px;
}
.item-img img{width:100%;height:100%;object-fit:cover;}
.item-info{min-width:0;}
.item-info strong{display:block;font-weight:950;}
.item-info small{display:block;margin-top:4px;color:rgba(255,255,255,.70);font-weight:800;}
.item-total{font-weight:950;color:rgba(255,255,255,.92); white-space:nowrap;}

.divider{
  height:1px;
  background: rgba(255,255,255,.08);
  margin:12px 0;
}
.totals .kv.total strong{
  font-size:18px;
  color: var(--primary);
  text-shadow: 0 0 22px rgba(255,0,0,.35);
}

/* =========================================================
   PRODUCTS (FORM / PREVIEW)
========================================================= */
.products-toolbar{
  margin-top:14px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
}

.pinfo{display:flex;align-items:center;gap:12px;}
.pimgwrap{
  width:56px;height:56px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.25);
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
}
.pimg{width:100%;height:100%;object-fit:cover;}

.form-grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:14px;
}

.form-col{
  border-radius:18px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.03);
  padding:14px;
  min-width:0;
}

.label{
  display:block;
  margin-top:12px;
  font-weight:900;
  font-size:12px;
  color: rgba(255,255,255,.72);
}

.input, .textarea{
  width:100%;
  margin-top:8px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.25);
  color:#fff;
  padding:12px;
  font-weight:800;
  outline:none;
}
.textarea{resize:vertical;}
.input:focus, .textarea:focus{
  border-color: rgba(255,0,0,.30);
  box-shadow: 0 0 0 3px rgba(255,0,0,.10);
}

.upload-row{
  display:flex;
  align-items:center;
  gap:10px;
  margin-top:10px;
  flex-wrap:wrap;
}

.preview{margin-top:12px;}
.preview-box{
  width:100%;
  height:220px;
  border-radius:18px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.25);
  display:grid;
  place-items:center;
  overflow:hidden;
}
.preview-box img{
  width:100%;
  height:100%;
  object-fit: contain; /* melhor pra admin (não corta) */
  display:block;
}

.form-actions{
  margin-top:14px;
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

/* =========================================================
   MESSAGES (CHAT-LIKE)
   (tinha 3 versões repetidas — consolidei numa só)
========================================================= */
.messages-layout{
  display:grid;
  grid-template-columns: 360px 1fr;
  gap:16px;
  align-items:stretch;
  min-width:0;
}

.messages-list,
.messages-view{
  background: rgba(255,255,255,.04);
  border:1px solid rgba(255,255,255,.08);
  border-radius:16px;
  overflow:hidden;
  min-width:0;
}

.messages-head{
  padding:14px;
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  border-bottom:1px solid rgba(255,255,255,.08);
}

.msg-items{
  max-height: calc(100vh - 220px);
  overflow:auto;
  -webkit-overflow-scrolling:touch;
}

.msg-item{
  width:100%;
  text-align:left;
  padding:12px 14px;
  background:transparent;
  border:0;
  border-bottom:1px solid rgba(255,255,255,.06);
  cursor:pointer;
  transition: background .15s ease, transform .15s ease;
}
.msg-item strong, .msg-item span{color:#fff;}
.msg-item:hover{ background: rgba(255,255,255,.04); }
.msg-item.active{ background: rgba(255,255,255,.06); }
.msg-item.unread strong::after{
  content:" •";
  color:#6cf2c2;
  font-weight:900;
}

.msg-top{ display:flex; justify-content:space-between; gap:10px; }
.msg-sub{ font-size:.85rem; margin-top:2px; }
.msg-snippet{ margin-top:6px; opacity:.92; font-size:.92rem; }

.msg-empty{ padding:22px; }

.msg-card{
  border-radius:18px;
  padding:16px;
  background: rgba(255,255,255,.03);
  border:1px solid rgba(255,255,255,.08);
}

.msg-card-head{
  display:flex;
  gap:12px;
  align-items:flex-start;
  justify-content:space-between;
  padding-bottom:12px;
  border-bottom:1px solid rgba(255,255,255,.08);
  flex-wrap:wrap; /* mobile: ações descem sem esmagar texto */
}
.msg-card-head > :first-child{
  flex: 1 1 220px;
  min-width:0;
}

.msg-actions{
  flex:0 0 auto;
  display:flex;
  align-items:center;
  gap:10px;
  max-width:100%;
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
  white-space:nowrap;
  padding-bottom:2px;
}
.msg-actions::-webkit-scrollbar{ display:none; }

.msg-body{
  margin-top:14px;
  display:flex;
  flex-direction:column;
  gap:12px;
}

/* Bolha */
.bubble{
  background: rgba(0,0,0,.25);
  border:1px solid rgba(255,255,255,.08);
  border-radius:16px;
  padding:14px;
  min-height:220px;
  display:flex;
  flex-direction:column;
}
.bubble-label{
  font-size:12px;
  opacity:.75;
  margin-bottom:10px;
}
#vText{
  margin:0;
  font-size:15px;
  line-height:1.5;
  white-space:pre-wrap;
  word-break:break-word;
  flex:1;
}
.bubble.has-text{ background: rgba(0,0,0,.32); }

/* =========================================================
   IMAGENS (CLOUDINARY) - ADM
========================================================= */
.img-panel{
  display:grid;
  gap:14px;
  padding:14px;
}
.img-actions{
  display:flex;
  align-items:center;
  gap:12px;
  flex-wrap:wrap;
}
.img-preview{display:grid;gap:8px;}
.img-preview-box{
  width:100%;
  min-height:220px;
  border-radius:16px;
  border:1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.35);
  display:grid;
  place-items:center;
  overflow:hidden;
}
.img-preview-box img{
  width:100%;
  height:100%;
  object-fit:contain;
  display:block;
}

/* =========================================================
   RESPONSIVE
========================================================= */

/* Desktop médio */
@media (max-width: 1200px){
  .dash-kpis{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Sidebar vira drawer (mantive compatível com:
   - .sidebar.open (antigo)
   - body.sidebar-open #sidebarPanel (ui.js)
*/
@media (max-width: 1100px){
  .admin{ grid-template-columns: 1fr; }

  .mobilebar{display:flex;}
  #btnSidebar{display:none !important;} /* você tinha esse ajuste */

  .sidebar,
  #sidebarPanel{
    position:fixed;
    left:0; top:0; bottom:0;
    width:min(92vw, 360px);
    height:100vh;
    z-index:9999;

    transform: translateX(-110%);
    transition: transform .22s ease;

    box-shadow: 18px 0 60px rgba(0,0,0,.65);
  }

  /* abrir via classe */
  .sidebar.open,
  #sidebarPanel.open{
    transform: translateX(0);
  }

  /* abrir via body.sidebar-open */
  body.sidebar-open #sidebarPanel{
    transform: translateX(0);
  }

  .main{padding:14px;}

  .top{flex-wrap:wrap;}
  .top-actions .search{
    max-width:100%;
    width:100%;
    min-width:0;
  }

  .grid{gap:12px;}
  .card{grid-column: span 12;}
}

/* Tablet */
@media (max-width: 980px){
  .modal-grid{grid-template-columns: 1fr;}
  .panel-actions{grid-template-columns: 1fr;}
  .actions{justify-content:flex-start;}
  .table table{min-width:760px;}
  .dash-grid{ grid-template-columns: 1fr; }

  /* messages */
  .messages-layout{ grid-template-columns: 1fr; gap:12px; }
  .msg-items{ max-height: 360px; }

  /* top actions empilha melhor */
  .top-actions{
    flex-direction:column;
    align-items:stretch;
  }
  .top-actions select,
  .top-actions button,
  .top-actions .search{
    width:100%;
    min-width:0;
  }
}

/* Mobile */
@media (max-width: 700px){
  .msg-actions{
    flex-wrap:wrap;
    overflow-x:visible;
    white-space:normal;
  }
}

@media (max-width: 560px){
  .dash-kpis{ grid-template-columns: 1fr; }
}

@media (max-width: 520px){
  .modal-card{margin:3vh auto;}
  .orders-toolbar{padding:12px;}
  .item{grid-template-columns: 52px 1fr; grid-auto-rows:auto;}
  .item-total{grid-column: 2; justify-self:end;}
  .form-grid{grid-template-columns: 1fr;}
  .preview-box{height:200px;}
  .img-preview-box{ min-height:180px; }
}

/* EXTRA: telas bem pequenas */
@media (max-width: 420px){
  .btn, button, select, input{ max-width:100%; }
}

/* =========================================================
   LOGIN ADM (opcional, se você usa no mesmo CSS)
   - removi seletores perigosos tipo ".card" aqui
   - foquei nos nomes que você já usa no admin auth
========================================================= */
@media (max-width: 520px){
  .admin-auth-wrap{
    padding-left:14px;
    padding-right:14px;
  }
}
/* =========================================================
   FIX — Opções do Painel ADM “bagunçadas”
   (sidebar menu + top actions)
   Cole no FINAL do CSS
========================================================= */

/* 1) SIDEBAR: garante espaçamento e alinhamento dos itens */
.nav{
  gap: 10px;
}

.nav a{
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  white-space: nowrap;     /* não quebra o texto no desktop */
  overflow: hidden;
  text-overflow: ellipsis; /* se for grande, corta com ... */
}

/* se você usa ícones dentro do link (svg/img/i/span), trava tamanho */
.nav a svg,
.nav a img,
.nav a i,
.nav a .icon{
  flex: 0 0 auto;
}

/* 2) SIDEBAR FOOT: evita sobrepor o menu em telas menores
      (menu com scroll + footer fixo) */
.sidebar,
#sidebarPanel{
  padding-bottom: 120px; /* espaço pro footer não “comer” os links */
}

.sidebar-foot{
  position: fixed; /* fica estável quando a sidebar rolar */
  width: calc(min(92vw, 360px) - 36px);
  max-width: calc(280px - 36px);
}

/* desktop: footer acompanha sidebar normal */
@media (min-width: 1101px){
  .sidebar-foot{
    position: absolute;
    width: auto;
    max-width: none;
  }
}

/* 3) TOP ACTIONS: no desktop NÃO deixa ficar “coluna” */
.top-actions{
  flex-wrap: nowrap;      /* trava as opções lado a lado */
  align-items: center;
}

/* Search fica com largura controlada, sem empurrar tudo */
.top-actions .search{
  width: 340px;
  max-width: 340px;
  min-width: 260px;
}

/* 4) No mobile: aí sim empilha bonitinho */
@media (max-width: 980px){
  .top-actions{
    flex-wrap: wrap;
    flex-direction: column;
    align-items: stretch;
  }
  .top-actions .search{
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
}

/* 5) Se as opções do menu “quebram” no mobile, permite 2 linhas lá */
@media (max-width: 520px){
  .nav a{
    white-space: normal; /* no mobile pode quebrar em 2 linhas */
    line-height: 1.15;
  }
}
/* =========================================================
   SIDEBAR MENU (HTML usa .side-nav)
   Cole no FINAL do admin.css
========================================================= */

.sidebar .side-nav,
#sidebarPanel .side-nav{
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

/* Links com cara de botão (premium) */
.sidebar .side-nav a,
#sidebarPanel .side-nav a{
  display: flex;
  align-items: center;
  gap: 10px;

  width: 100%;
  padding: 12px 12px;

  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.03);

  font-weight: 900;
  color: rgba(255,255,255,.88);

  transition: transform .18s ease, background .18s ease, border-color .18s ease;
  white-space: nowrap;     /* evita quebrar no desktop */
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar .side-nav a:hover,
#sidebarPanel .side-nav a:hover{
  border-color: rgba(255,0,0,.28);
  background: rgba(255,0,0,.10);
  transform: translateY(-1px);
}

.sidebar .side-nav a.active,
#sidebarPanel .side-nav a.active{
  border-color: rgba(255,0,0,.35);
  background: rgba(255,0,0,.16);
  color: #fff;
}

/* Mobile: pode quebrar em 2 linhas pra não cortar */
@media (max-width: 520px){
  .sidebar .side-nav a,
  #sidebarPanel .side-nav a{
    white-space: normal;
    line-height: 1.15;
  }
}
