/* ═══════════════════════════════════════════
   MarketPro — Gestão Marketplace
   style.css
   ═══════════════════════════════════════════ */

/* ─── Tema DARK (padrão) ─── */
:root {
  --bg: #0f0f11;
  --bg2: #17171a;
  --bg3: #1e1e22;
  --border: #2a2a30;
  --border2: #363640;
  --text: #f0eff2;
  --text2: #8e8d99;
  --text3: #5a5966;
  --accent: #7c6aff;
  --accent2: #5548d9;
  --accent-glow: rgba(124,106,255,0.15);
  --green: #2ecc71;
  --green-bg: rgba(46,204,113,0.1);
  --yellow: #f0c040;
  --yellow-bg: rgba(240,192,64,0.1);
  --red: #e05c5c;
  --red-bg: rgba(224,92,92,0.1);
  --font: 'DM Sans', sans-serif;
  --mono: 'Space Mono', monospace;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

/* ─── Tema LIGHT ─── */
[data-theme="light"] {
  --bg: #f2f2f5;
  --bg2: #ffffff;
  --bg3: #e9e9ee;
  --border: #d8d8e0;
  --border2: #c4c4d0;
  --text: #1a1a2e;
  --text2: #4a4a60;
  --text3: #8888a0;
  --accent: #6c5ce7;
  --accent2: #4a3fc5;
  --accent-glow: rgba(108,92,231,0.12);
  --green: #16a34a;
  --green-bg: rgba(22,163,74,0.1);
  --yellow: #b45309;
  --yellow-bg: rgba(180,83,9,0.08);
  --red: #dc2626;
  --red-bg: rgba(220,38,38,0.08);
  --shadow: 0 4px 24px rgba(0,0,0,0.10);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  transition: background 0.25s ease, color 0.25s ease;
}

/* ─── Layout ─── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  position: sticky;
  top: 0;
  height: 100vh;
}

.logo {
  padding: 0 20px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.logo-mark {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -1px;
}
.logo-sub { font-size: 11px; color: var(--text3); letter-spacing: 0.08em; text-transform: uppercase; margin-top: 2px; }

.nav-section { padding: 0 12px; margin-bottom: 8px; }
.nav-label { font-size: 10px; color: var(--text3); letter-spacing: 0.1em; text-transform: uppercase; padding: 0 8px; margin-bottom: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text2);
  font-size: 13px;
  font-weight: 400;
  transition: all 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--accent-glow); color: var(--accent); font-weight: 500; }
.nav-icon { font-size: 16px; width: 18px; text-align: center; }

.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 99px;
  font-family: var(--mono);
}
.nav-badge.green { background: var(--green); }

.sidebar-footer {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text3);
}
.sidebar-footer span { display: block; }
.version { font-family: var(--mono); color: var(--accent); }

/* ─── Main ─── */
.main { flex: 1; overflow-x: hidden; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-title { font-size: 15px; font-weight: 500; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border2);
  background: var(--bg3);
  color: var(--text);
  transition: all 0.15s;
  font-family: var(--font);
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent2); border-color: var(--accent2); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-danger { border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red-bg); }

/* ─── Pages ─── */
.page { display: none; padding: 28px; animation: fadeIn 0.2s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ─── Stats ─── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 28px; }

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}
.stat-label { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 8px; }
.stat-value { font-family: var(--mono); font-size: 26px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-value.green { color: var(--green); }
.stat-value.red { color: var(--red); }
.stat-value.yellow { color: var(--yellow); }
.stat-sub { font-size: 11px; color: var(--text3); margin-top: 6px; }

/* ─── Table ─── */
.table-wrap {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.table-title { font-size: 14px; font-weight: 500; }
.table-actions { display: flex; gap: 8px; }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 12px;
  font-size: 13px;
  color: var(--text2);
  min-width: 220px;
}
.search-box input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 13px;
  font-family: var(--font);
  width: 100%;
}
.search-box input::placeholder { color: var(--text3); }

table { width: 100%; border-collapse: collapse; }
thead tr { border-bottom: 1px solid var(--border); }
th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
  font-weight: 500;
  white-space: nowrap;
}
td {
  padding: 12px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg3); }

.prod-name { font-weight: 500; color: var(--text); }
.prod-sku { font-family: var(--mono); font-size: 11px; color: var(--text3); margin-top: 2px; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 500;
}
.badge-ok { background: var(--green-bg); color: var(--green); }
.badge-low { background: var(--yellow-bg); color: var(--yellow); }
.badge-out { background: var(--red-bg); color: var(--red); }
.badge-cat { background: var(--accent-glow); color: var(--accent); }

.qty-cell { font-family: var(--mono); font-size: 13px; font-weight: 700; }
.price-cell { font-family: var(--mono); font-size: 13px; }

.action-btns { display: flex; gap: 6px; }

/* ─── Form ─── */
.form-wrap {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.form-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.form-header h2 { font-size: 15px; font-weight: 500; }
.form-body { padding: 24px; }

.form-section {
  margin-bottom: 28px;
}
.form-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.form-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.form-grid-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid-2 { grid-template-columns: repeat(2, 1fr); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-full { grid-column: 1 / -1; }

label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  display: flex;
  align-items: center;
  gap: 4px;
}
label .req { color: var(--accent); }
label .hint { font-size: 10px; color: var(--text3); font-weight: 400; margin-left: 4px; }

input[type="text"],
input[type="number"],
textarea,
select {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  color: var(--text);
  font-size: 13px;
  font-family: var(--font);
  transition: border-color 0.15s;
  outline: none;
  width: 100%;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
input[type="number"] { font-family: var(--mono); }
textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
select option { background: var(--bg3); color: var(--text); }

.input-prefix {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s;
}
.input-prefix:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.prefix-tag {
  padding: 9px 12px;
  background: var(--bg);
  color: var(--text3);
  font-size: 12px;
  font-family: var(--mono);
  border-right: 1px solid var(--border);
  white-space: nowrap;
  display: flex;
  align-items: center;
}
.input-prefix input {
  border: none;
  border-radius: 0;
  flex: 1;
}
.input-prefix input:focus { box-shadow: none; }

/* ─── Lucro Preview ─── */
.lucro-card {
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: sticky;
  top: 80px;
}
.lucro-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text3);
  margin-bottom: 16px;
}
.lucro-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.lucro-row:last-child { border-bottom: none; }
.lucro-row-label { color: var(--text2); }
.lucro-row-val { font-family: var(--mono); font-weight: 700; }
.lucro-row-val.neg { color: var(--red); }
.lucro-row-val.pos { color: var(--green); }
.lucro-row-val.neu { color: var(--text); }
.lucro-total {
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--border2);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.lucro-total-label { font-size: 13px; font-weight: 500; color: var(--text); }
.lucro-total-val { font-family: var(--mono); font-size: 22px; font-weight: 700; }

.form-layout { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }

/* ─── Alerta Estoque ─── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 13px;
}
.alert-warning { background: var(--yellow-bg); border: 1px solid rgba(240,192,64,0.3); color: var(--yellow); }
.alert-danger { background: var(--red-bg); border: 1px solid rgba(224,92,92,0.3); color: var(--red); }
.alert-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }

/* ─── Empty state ─── */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text3);
}
.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-title { font-size: 15px; color: var(--text2); margin-bottom: 6px; }
.empty-desc { font-size: 13px; }

/* ─── Toast ─── */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 1000;
  max-width: 320px;
}
#toast.show { transform: translateY(0); opacity: 1; }
#toast.success { border-color: var(--green); }
#toast.error { border-color: var(--red); }
.toast-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.toast-dot.green { background: var(--green); }
.toast-dot.red { background: var(--red); }

/* ─── Modal ─── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  animation: fadeIn 0.2s ease;
}
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 15px; font-weight: 500; }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ─── Estoque rapido ─── */
.estoque-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.estoque-item:last-child { border-bottom: none; }
.estoque-info { flex: 1; }
.estoque-nome { font-size: 13px; font-weight: 500; }
.estoque-sku { font-family: var(--mono); font-size: 11px; color: var(--text3); margin-top: 2px; }
.estoque-controls { display: flex; align-items: center; gap: 8px; }
.estoque-qty { font-family: var(--mono); font-size: 14px; font-weight: 700; min-width: 30px; text-align: center; }
.qty-btn {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border2);
  background: var(--bg3);
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.qty-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ─── Responsivo + Mobile ─── */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .form-layout { grid-template-columns: 1fr; }
  .form-grid-3 { grid-template-columns: repeat(2, 1fr); }
  .lucro-card { position: static; }
  #rel-graficos { grid-template-columns: 1fr !important; }
}

/* ════════════════════════════════════════════
   INTEGRAÇÕES — Cards dos Marketplaces
   ════════════════════════════════════════════ */
.mkt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.mkt-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color .2s, box-shadow .2s;
  position: relative;
  overflow: hidden;
}
.mkt-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--border);
  transition: background .25s;
}
.mkt-card.conectado::before {
  background: linear-gradient(90deg, #22c55e, #16a34a);
}
.mkt-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 20px rgba(var(--accent-rgb),.12);
}

.mkt-card-logo {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--bg);
}

.mkt-card-info {
  flex: 1;
  min-width: 0;
}
.mkt-card-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text1);
  margin-bottom: 6px;
}
.mkt-card-status {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.mkt-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--bg);
  color: var(--text3);
  width: fit-content;
}
.mkt-badge.conectado {
  background: rgba(34,197,94,.12);
  color: #16a34a;
}
.mkt-loja {
  font-size: 12px;
  color: var(--text2);
  font-weight: 500;
}
.mkt-expiry {
  font-size: 11px;
  color: var(--text3);
}

.mkt-card-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

/* ─── Log de Sincronização ────────────────── */
.sync-log-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text2);
}
.sync-log-item:last-child { border-bottom: none; }
.sync-log-icon { font-size: 14px; flex-shrink: 0; }
.sync-log-mkt  { font-weight: 600; color: var(--text1); min-width: 100px; }
.sync-log-tipo { color: var(--text3); min-width: 70px; }
.sync-log-det  { flex: 1; }
.sync-log-hora { color: var(--text3); flex-shrink: 0; }

@media (max-width: 600px) {
  .mkt-grid { grid-template-columns: 1fr; }
  .mkt-card { flex-direction: column; }
  .mkt-card-actions { flex-direction: row; width: 100%; }
}
/* ═══════════════════════════════════════════
   SISTEMA DE USUÁRIOS
   ═══════════════════════════════════════════ */

/* ─── Overlay de Login ───────────────────── */
#login-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #0a0a10 0%, #12101e 50%, #0d0d14 100%);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#login-overlay.open { display: flex; }

#login-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(124,106,255,0.25);
  border-radius: 20px;
  padding: 44px 40px;
  width: 100%;
  max-width: 420px;
  backdrop-filter: blur(24px);
  box-shadow: 0 32px 80px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.05) inset;
  animation: loginIn 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes loginIn {
  from { opacity:0; transform: translateY(24px) scale(0.96); }
  to   { opacity:1; transform: translateY(0)    scale(1); }
}
#login-card.shake {
  animation: shake 0.45s cubic-bezier(.36,.07,.19,.97);
}
@keyframes shake {
  10%,90% { transform: translateX(-3px); }
  20%,80% { transform: translateX(5px); }
  30%,50%,70% { transform: translateX(-5px); }
  40%,60%     { transform: translateX(5px); }
}

#login-logo { text-align: center; margin-bottom: 32px; }
#login-logo-mark {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -1px;
}
#login-logo-sub {
  font-size: 12px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-top: 4px;
}

#login-erro {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid rgba(224,92,92,0.3);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 20px;
  text-align: center;
}

#login-form .field label { color: var(--text2); font-size: 13px; }
#login-form input {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 14px;
  padding: 12px 14px;
}
#login-form input:focus {
  background: rgba(124,106,255,0.08);
  border-color: var(--accent);
}

#login-btn {
  width: 100%;
  padding: 13px;
  border-radius: var(--radius);
  border: none;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 20px rgba(124,106,255,0.35);
}
#login-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 28px rgba(124,106,255,0.45); }
#login-btn:active { transform: translateY(0); }
#login-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

#login-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text3);
  margin-top: 20px;
  line-height: 1.6;
}
#login-hint strong { color: var(--text2); }

/* Light theme login */
[data-theme="light"] #login-overlay {
  background: linear-gradient(135deg, #e8e8f5 0%, #f0eeff 50%, #e4e4f2 100%);
}
[data-theme="light"] #login-card {
  background: rgba(255,255,255,0.85);
  border-color: rgba(108,92,231,0.2);
  box-shadow: 0 32px 80px rgba(0,0,0,0.12);
}
[data-theme="light"] #login-form input { background: #f5f5f8; color: var(--text); }
[data-theme="light"] #login-btn { background: linear-gradient(135deg, #6c5ce7 0%, #4a3fc5 100%); }

/* ─── Sidebar: usuário logado ────────────── */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 0;
}
.sidebar-user-info {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
#sidebar-user-nome {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: 10px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ─── Avatar ─────────────────────────────── */
.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: var(--mono);
}

/* ─── Badges de role ─────────────────────── */
.badge-admin   { background: rgba(124,106,255,0.15); color: var(--accent); }
.badge-gerente { background: rgba(46,204,113,0.1);   color: var(--green); }

/* ─── Grid de permissões (modal) ─────────── */
.perm-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}
.perm-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--bg3);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 13px;
  color: var(--text2);
  user-select: none;
}
.perm-toggle:hover { border-color: var(--accent); color: var(--text); }
.perm-toggle input { display: none; }
.perm-check {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 2px solid var(--border2);
  flex-shrink: 0;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.perm-toggle input:checked ~ .perm-check {
  background: var(--accent);
  border-color: var(--accent);
}
.perm-toggle input:checked ~ .perm-check::after {
  content: '✓';
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}
.perm-toggle input:checked ~ .perm-label { color: var(--text); }
.perm-label { flex: 1; font-size: 12px; }

@media (max-width: 480px) {
  .perm-grid { grid-template-columns: 1fr; }
  #login-card { padding: 32px 24px; }
}
/* ── Bottom nav (mobile) ── */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  z-index: 50;
  padding: 0 4px;
  padding-bottom: env(safe-area-inset-bottom, 8px);
}
.mobile-nav-inner {
  display: flex;
  justify-content: space-around;
  align-items: stretch;
}
.mnav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  border: none;
  background: none;
  color: var(--text3);
  font-size: 9px;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  -webkit-tap-highlight-color: transparent;
}
.mnav-btn .mico { font-size: 20px; line-height: 1; }
.mnav-btn.active { color: var(--accent); }
.mnav-btn:active { opacity: 0.7; }

/* ── FAB ── */
.fab {
  display: none;
  position: fixed;
  bottom: 80px;
  right: 20px;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: #fff;
  font-size: 26px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(124,106,255,0.4);
  z-index: 60;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.fab:active { transform: scale(0.93); }

/* ── Pull-to-refresh indicator ── */
.ptr-bar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
  z-index: 200;
  animation: ptrAnim 0.8s ease infinite;
}
@keyframes ptrAnim {
  0%   { transform: scaleX(0); transform-origin: left; }
  50%  { transform: scaleX(1); transform-origin: left; }
  51%  { transform: scaleX(1); transform-origin: right; }
  100% { transform: scaleX(0); transform-origin: right; }
}

/* ── Swipe cards (mobile produto list) ── */
.swipe-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 10px;
  position: relative;
  overflow: hidden;
}
.swipe-card-title { font-size: 14px; font-weight: 500; margin-bottom: 4px; }
.swipe-card-meta  { font-size: 12px; color: var(--text3); margin-bottom: 10px; }
.swipe-card-row   { display: flex; justify-content: space-between; font-size: 13px; }
.swipe-card-actions { display: flex; gap: 8px; margin-top: 12px; }

/* ── Export drawer ── */
.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 150;
  align-items: flex-end;
}
.drawer-backdrop.open { display: flex; }
.drawer {
  background: var(--bg2);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  padding: 16px 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  animation: slideUp 0.25s cubic-bezier(0.34,1.1,0.64,1);
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.drawer-handle {
  width: 40px; height: 4px;
  background: var(--border2);
  border-radius: 2px;
  margin: 0 auto 16px;
}
.drawer-title { font-size: 15px; font-weight: 500; margin-bottom: 16px; }
.export-opt {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.export-opt:last-child { border-bottom: none; }
.export-opt:active { opacity: 0.7; }
.export-ico {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.export-opt-info { flex: 1; }
.export-opt-name  { font-size: 14px; font-weight: 500; }
.export-opt-desc  { font-size: 12px; color: var(--text3); margin-top: 2px; }

/* ── Barra progresso PWA ── */
.install-banner {
  display: none;
  background: var(--accent-glow);
  border-bottom: 1px solid var(--accent);
  padding: 10px 16px;
  font-size: 13px;
  align-items: center;
  gap: 10px;
}
.install-banner.show { display: flex; }

@media (max-width: 768px) {
  .page { padding: 14px 14px 90px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .form-grid-3, .form-grid-2 { grid-template-columns: 1fr; }
  .topbar { padding: 12px 16px; }
  .topbar-right .btn:not(.btn-primary) { display: none; }
  table { font-size: 12px; }
  th, td { padding: 8px 10px; }
  .table-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .table-actions { width: 100%; }
  .search-box { width: 100%; }
  .mobile-nav { display: block; }
  .fab { display: flex; }
  .action-btns { flex-direction: column; }
  /* Esconde tabelas no mobile, mostra cards */
  .desktop-only { display: none !important; }
  .mobile-only  { display: block !important; }
  /* Dois-colunas para stats em mobile */
  #rel-graficos { grid-template-columns: 1fr !important; }
}
