/* ============================================================
   appVND — Design System v5 (ZeroPaper style)
   ============================================================ */
:root {
  /* Sidebar */
  --sb-bg:      #1a2744;
  --sb-hover:   rgba(255,255,255,.07);
  --sb-active:  #2563eb;
  --sb-text:    rgba(255,255,255,.65);
  --sb-text-on: #ffffff;
  --sb-w:       220px;

  /* Brand */
  --blue:       #2563eb;
  --blue-dk:    #1d4ed8;
  --blue-lt:    #eff6ff;
  --blue-mid:   #93c5fd;
  --green:      #059669;
  --green-bg:   #ecfdf5;
  --red:        #dc2626;
  --red-bg:     #fef2f2;
  --amber:      #d97706;
  --amber-bg:   #fffbeb;
  --purple:     #7c3aed;

  /* Layout */
  --bg:         #f0f4f8;
  --card:       #ffffff;
  --border:     #e2e8f0;
  --text:       #0f172a;
  --sub:        #64748b;
  --topbar-h:   56px;
  --nav-h:      62px;
  --r:          14px;
  --r-sm:       10px;
  --sh:         0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
  --sh-md:      0 4px 6px rgba(0,0,0,.07), 0 10px 30px rgba(0,0,0,.08);

  /* Charts */
  --c1: #2563eb; --c2: #059669; --c3: #d97706;
  --c4: #dc2626; --c5: #7c3aed; --c6: #0891b2;
  --c7: #be185d; --c8: #65a30d; --c9: #ea580c; --c10: #6366f1;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--text); overscroll-behavior: none; }
.hidden { display: none !important; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }
a { text-decoration: none; color: inherit; }

/* ── LOGIN ─────────────────────────────────────────── */
#login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(145deg, #0f172a 0%, #1a2744 50%, #2563eb 100%);
  padding: 24px;
}
.login-box {
  background: var(--card); border-radius: 24px; padding: 44px 36px;
  width: 100%; max-width: 400px; box-shadow: 0 32px 64px rgba(0,0,0,.3);
}
.login-logo { display: flex; justify-content: center; margin-bottom: 24px; }
.login-logo svg { width: 68px; height: 68px; }
.login-box h1 { text-align: center; font-size: 1.8rem; font-weight: 800; letter-spacing: -.5px; color: var(--text); }
.login-box > p { text-align: center; color: var(--sub); font-size: .9rem; margin: 4px 0 32px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: .72rem; font-weight: 700; color: var(--sub); text-transform: uppercase; letter-spacing: .7px; }
.field input, .field select {
  padding: 13px 15px; border: 1.5px solid var(--border); border-radius: var(--r-sm);
  font-size: .97rem; outline: none; transition: border-color .2s, box-shadow .2s; background: var(--card);
}
.field input:focus, .field select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.btn-login {
  width: 100%; padding: 15px; background: var(--blue); color: #fff; border: none;
  border-radius: var(--r-sm); font-size: 1rem; font-weight: 700; margin-top: 8px;
  transition: background .2s, transform .1s; letter-spacing: .3px;
}
.btn-login:hover  { background: var(--blue-dk); }
.btn-login:active { transform: scale(.99); }
.login-erro { color: var(--red); font-size: .85rem; text-align: center; min-height: 20px; margin-top: 10px; }

.bio-divider {
  display: flex; align-items: center; gap: 12px; margin: 16px 0 0;
  color: var(--sub); font-size: .8rem;
}
.bio-divider::before, .bio-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

.btn-bio {
  width: 100%; padding: 13px; background: var(--bg); color: var(--text);
  border: 1.5px solid var(--border); border-radius: var(--r-sm);
  font-size: .95rem; font-weight: 600; margin-top: 10px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  transition: border-color .2s, background .2s;
}
.btn-bio:hover  { border-color: var(--blue); background: var(--blue-lt); color: var(--blue); }
.btn-bio:active { transform: scale(.99); }

/* ── APP SHELL ──────────────────────────────────────── */
#app-screen {
  display: flex; height: 100vh; overflow: hidden;
  position: relative;
}

/* ── SIDEBAR ─────────────────────────────────────────── */
.sidebar {
  width: var(--sb-w); flex-shrink: 0; background: var(--sb-bg);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}

.sb-logo {
  display: flex; align-items: center; gap: 12px; padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sb-logo svg { width: 36px; height: 36px; flex-shrink: 0; }
.sb-logo-text { font-size: 1.2rem; font-weight: 800; color: #fff; letter-spacing: -.3px; }
.sb-logo-sub  { font-size: .68rem; color: rgba(255,255,255,.45); font-weight: 500; letter-spacing: .3px; text-transform: uppercase; }

.sb-section { padding: 16px 10px 8px; }
.sb-section-label { font-size: .62rem; font-weight: 700; color: rgba(255,255,255,.3);
  text-transform: uppercase; letter-spacing: 1px; padding: 0 10px; margin-bottom: 4px; }

.snav-item {
  display: flex; align-items: center; gap: 11px; width: 100%; padding: 11px 14px;
  border: none; background: transparent; color: var(--sb-text);
  border-radius: 10px; font-size: .875rem; font-weight: 500; text-align: left;
  transition: background .15s, color .15s; margin-bottom: 2px;
}
.snav-item svg { width: 19px; height: 19px; flex-shrink: 0; stroke: currentColor; transition: none; }
.snav-item:hover { background: var(--sb-hover); color: var(--sb-text-on); }
.snav-item.on    { background: var(--sb-active); color: var(--sb-text-on); font-weight: 600; }

.sb-spacer { flex: 1; }

.sb-user {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sb-av {
  width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.15);
  color: #fff; font-size: .85rem; font-weight: 700; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0;
}
.sb-user-info { flex: 1; min-width: 0; }
.sb-user-name { font-size: .82rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-role { font-size: .7rem; color: rgba(255,255,255,.45); text-transform: capitalize; }
.sb-logout {
  width: 30px; height: 30px; border: none; background: rgba(255,255,255,.08); border-radius: 8px;
  color: rgba(255,255,255,.55); display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background .15s, color .15s;
}
.sb-logout:hover { background: rgba(220,38,38,.3); color: #fff; }
.sb-logout svg { width: 15px; height: 15px; }

/* Overlay for mobile sidebar */
.sb-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 99; backdrop-filter: blur(2px);
}

/* ── MAIN WRAP ───────────────────────────────────────── */
.main-wrap {
  flex: 1; display: flex; flex-direction: column;
  margin-left: var(--sb-w); overflow: hidden;
  min-width: 0;
}

/* ── TOPBAR ──────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h); background: var(--card); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 20px; flex-shrink: 0;
  box-shadow: 0 1px 0 var(--border);
}
.topbar-menu {
  width: 36px; height: 36px; border: none; background: transparent; border-radius: 8px;
  display: none; align-items: center; justify-content: center; color: var(--sub);
  transition: background .15s;
}
.topbar-menu:hover { background: var(--bg); }
.topbar-menu svg { width: 20px; height: 20px; }

.topbar-breadcrumb { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.topbar-app   { font-size: .82rem; color: var(--sub); font-weight: 500; display: none; }
.topbar-sep   { color: var(--border); font-size: .85rem; display: none; }
.topbar-title { font-size: 1.05rem; font-weight: 700; color: var(--text); white-space: nowrap; }

.topbar-right { display: flex; align-items: center; gap: 6px; }
.topbar-btn {
  width: 36px; height: 36px; border: none; background: transparent; border-radius: 8px;
  color: var(--sub); display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.topbar-btn:hover { background: var(--bg); color: var(--text); }
.topbar-btn svg { width: 18px; height: 18px; }
.topbar-chip {
  width: 34px; height: 34px; border-radius: 50%; background: var(--blue);
  color: #fff; font-size: .8rem; font-weight: 700; display: flex; align-items: center;
  justify-content: center; cursor: default; border: 2px solid rgba(37,99,235,.2);
}

/* ── MAIN CONTENT ────────────────────────────────────── */
#main {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; background: var(--bg);
}
.page {
  display: none; padding: 20px; min-height: 100%;
}
.page.active { display: flex; flex-direction: column; gap: 16px; }

/* ── MOBILE BOTTOM NAV (hidden on tablet+) ───────────── */
.nav-bar {
  height: var(--nav-h); background: var(--card); border-top: 1px solid var(--border);
  display: none; flex-shrink: 0;
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; border: none; background: transparent; color: var(--sub);
  font-size: .65rem; font-weight: 600; text-transform: uppercase; letter-spacing: .3px;
  transition: color .15s;
}
.nav-btn svg { width: 22px; height: 22px; }
.nav-btn.on { color: var(--blue); }

/* ── PAGE HEADER ─────────────────────────────────────── */
.page-hdr { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.page-hdr-title { font-size: 1.1rem; font-weight: 700; }
.page-hdr-sub   { font-size: .82rem; color: var(--sub); margin-top: 1px; }

/* ── CARDS ───────────────────────────────────────────── */
.card {
  background: var(--card); border-radius: var(--r); box-shadow: var(--sh); padding: 20px;
}
.card-label { font-size: .7rem; font-weight: 700; color: var(--sub); text-transform: uppercase; letter-spacing: .6px; }
.card-num   { font-size: 1.9rem; font-weight: 800; letter-spacing: -.5px; line-height: 1.1; margin: 6px 0 4px; }
.card-sub   { font-size: .78rem; color: var(--sub); }

.trend {
  display: inline-flex; align-items: center; gap: 3px; font-size: .78rem; font-weight: 700;
  padding: 3px 9px; border-radius: 99px; margin-top: 5px;
}
.trend.up   { background: var(--green-bg); color: var(--green); }
.trend.down { background: var(--red-bg);   color: var(--red); }
.trend.flat { background: #f1f5f9;          color: var(--sub); }

/* Hero card */
.card-hero {
  background: linear-gradient(135deg, #1a2744 0%, #2563eb 100%);
  color: #fff; border: none;
}
.card-hero .card-label { color: rgba(255,255,255,.65); }
.card-hero .card-num   { color: #fff; font-size: 2.2rem; }
.card-hero .card-sub   { color: rgba(255,255,255,.7); }
.card-hero .trend.up   { background: rgba(255,255,255,.18); color: #fff; }
.card-hero .trend.down { background: rgba(255,255,255,.12); color: #fca5a5; }
.card-hero .trend.flat { background: rgba(255,255,255,.1); color: rgba(255,255,255,.7); }

/* KPI accent cards */
.card-kpi { position: relative; overflow: hidden; }
.card-kpi-icon {
  position: absolute; right: 16px; top: 16px;
  width: 42px; height: 42px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; opacity: .15;
}
.card-kpi-icon svg { width: 24px; height: 24px; }
.card-kpi.kpi-blue  .card-kpi-icon { background: var(--blue); }
.card-kpi.kpi-green .card-kpi-icon { background: var(--green); }
.card-kpi.kpi-green .card-num { color: var(--green); }

/* Grid layouts */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

/* ── CHART ───────────────────────────────────────────── */
.chart-wrap { position: relative; height: 160px; }
.chart-wrap.tall   { height: 220px; }
.chart-wrap.donut  { height: 200px; }
.sec-title {
  font-size: .7rem; font-weight: 700; color: var(--sub);
  text-transform: uppercase; letter-spacing: .6px; margin-bottom: 12px;
  display: flex; align-items: center; gap: 6px;
}
.dash-meses-legend { display: flex; align-items: center; gap: 4px; font-size: .68rem; font-weight: 600; margin-left: auto; text-transform: none; letter-spacing: 0; }
.ml-dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; }

/* Donut + legend layout */
.donut-row { display: flex; align-items: center; gap: 20px; }
.donut-wrap { position: relative; width: 160px; height: 160px; flex-shrink: 0; }
.donut-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; pointer-events: none;
}
.donut-center-val  { font-size: 1.1rem; font-weight: 800; color: var(--text); }
.donut-center-lbl  { font-size: .65rem; color: var(--sub); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.donut-legend      { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.legend-item       { display: flex; align-items: center; gap: 8px; }
.legend-dot        { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.legend-name       { flex: 1; font-size: .8rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend-val        { font-size: .78rem; font-weight: 700; color: var(--sub); white-space: nowrap; }

/* ── PERIOD PILLS ────────────────────────────────────── */
.pills-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.pills { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.pills::-webkit-scrollbar { display: none; }
.pill {
  flex-shrink: 0; padding: 6px 14px; border: 1.5px solid var(--border); border-radius: 99px;
  font-size: .78rem; font-weight: 600; background: var(--card); color: var(--sub); white-space: nowrap;
  transition: all .15s;
}
.pill.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.pill:hover:not(.on) { border-color: var(--blue); color: var(--blue); }

/* ── SEARCH ──────────────────────────────────────────── */
.search-bar {
  display: flex; align-items: center; gap: 10px; background: var(--card);
  border-radius: var(--r); padding: 11px 15px; box-shadow: var(--sh);
  border: 1.5px solid transparent; transition: border-color .2s;
}
.search-bar:focus-within { border-color: var(--blue); }
.search-bar svg   { width: 17px; height: 17px; color: var(--sub); flex-shrink: 0; }
.search-bar input { flex: 1; border: none; outline: none; font-size: .93rem; background: transparent; color: var(--text); }

/* ── STATS ROW ───────────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.stat { background: var(--card); border-radius: var(--r-sm); padding: 14px; box-shadow: var(--sh); text-align: center; }
.stat-n { font-size: 1.25rem; font-weight: 800; color: var(--blue); }
.stat-l { font-size: .68rem; color: var(--sub); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; margin-top: 2px; }

/* ── VENDOR LIST ─────────────────────────────────────── */
.vend-list  { display: flex; flex-direction: column; }
.vend-item  { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.vend-item:last-child { border-bottom: none; }
.vend-rank  { width: 26px; height: 26px; border-radius: 8px; background: var(--blue-lt); color: var(--blue);
  font-size: .75rem; font-weight: 800; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.vend-rank.r1 { background: #fef3c7; color: #b45309; }
.vend-rank.r2 { background: #f1f5f9; color: #475569; }
.vend-rank.r3 { background: #fdf2f8; color: #9d174d; }
.vend-info  { flex: 1; min-width: 0; }
.vend-name  { font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vend-bar   { height: 3px; background: var(--border); border-radius: 3px; margin-top: 6px; }
.vend-fill  { height: 100%; background: var(--blue); border-radius: 3px; transition: width .6s ease; }
.vend-total { font-size: .85rem; font-weight: 700; color: var(--blue); flex-shrink: 0; }

/* ── SELECT ──────────────────────────────────────────── */
.sel-wrap {
  background: var(--card); border-radius: var(--r); box-shadow: var(--sh); padding: 4px 8px;
}
.sel-wrap select {
  width: 100%; padding: 10px 8px; border: none; outline: none; background: transparent;
  font-size: .9rem; color: var(--text); cursor: pointer;
}

/* ── ITEM LISTS ──────────────────────────────────────── */
.item-list  { display: flex; flex-direction: column; gap: 8px; }

.venda-card { background: var(--card); border-radius: var(--r); padding: 15px; box-shadow: var(--sh);
  border-left: 3px solid transparent; transition: border-color .15s, box-shadow .15s; }
.venda-card:hover { border-left-color: var(--blue); box-shadow: var(--sh-md); }
.venda-top  { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 6px; }
.venda-doc  { font-size: .75rem; font-weight: 700; color: var(--blue); background: var(--blue-lt);
  padding: 3px 8px; border-radius: 6px; }
.venda-date { font-size: .75rem; color: var(--sub); }
.venda-art  { font-size: .9rem; font-weight: 500; margin-bottom: 10px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.venda-bot  { display: flex; justify-content: space-between; align-items: center; }
.venda-vend { font-size: .73rem; color: var(--sub); background: var(--bg); padding: 3px 8px; border-radius: 6px; }
.venda-val  { font-size: 1.05rem; font-weight: 800; color: var(--green); }
.venda-qty  { font-size: .7rem; color: var(--sub); text-align: right; margin-top: 1px; }

.cli-card { background: var(--card); border-radius: var(--r); padding: 15px; box-shadow: var(--sh);
  display: flex; align-items: center; gap: 13px; transition: box-shadow .15s; }
.cli-card:hover { box-shadow: var(--sh-md); }
.cli-av   { width: 44px; height: 44px; border-radius: 50%; background: var(--blue-lt); color: var(--blue);
  font-size: 1.1rem; font-weight: 800; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.cli-info  { flex: 1; min-width: 0; }
.cli-name  { font-size: .92rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cli-nif   { font-size: .74rem; color: var(--sub); margin-top: 2px; }
.cli-email { font-size: .74rem; color: var(--blue); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── ANÁLISE ─────────────────────────────────────────── */
.ana-controls {
  background: var(--card); border-radius: var(--r); padding: 16px; box-shadow: var(--sh);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.ana-controls select {
  flex: 1; min-width: 100px; padding: 9px 11px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: .88rem; outline: none; background: var(--card);
  transition: border-color .2s;
}
.ana-controls select:focus { border-color: var(--blue); }
.ana-controls .vs   { font-weight: 800; color: var(--sub); font-size: .88rem; flex-shrink: 0; }
.btn-refresh {
  padding: 9px 16px; background: var(--blue); color: #fff; border: none;
  border-radius: 8px; font-size: .85rem; font-weight: 700; flex-shrink: 0;
  transition: background .15s;
}
.btn-refresh:hover { background: var(--blue-dk); }

.comp-head {
  display: grid; grid-template-columns: 1fr auto auto auto; gap: 8px;
  padding: 7px 12px; background: var(--bg); border-radius: 8px;
  font-size: .68rem; font-weight: 700; color: var(--sub); text-transform: uppercase; margin-bottom: 4px;
}
.comp-row {
  display: grid; grid-template-columns: 1fr auto auto auto; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--border); align-items: center;
}
.comp-row:last-child { border-bottom: none; }
.comp-nome { font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.comp-v    { font-size: .8rem; font-weight: 600; text-align: right; white-space: nowrap; }
.comp-v.dim { color: var(--sub); }
.comp-pct      { font-size: .78rem; font-weight: 800; text-align: right; min-width: 56px; color: var(--sub); }
.comp-pct.up   { color: var(--green); }
.comp-pct.down { color: var(--red); }

/* ── MODALS ──────────────────────────────────────────── */
.modal-bg  { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 200;
  display: flex; align-items: flex-end; justify-content: center; }
.modal-box { background: var(--card); border-radius: 20px 20px 0 0; padding: 24px 20px;
  width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; }
.modal-box h3 { font-size: 1.05rem; font-weight: 700; margin-bottom: 18px; }
.modal-acoes  { display: flex; gap: 10px; margin-top: 18px; }
.btn-sec  { flex: 1; padding: 12px; background: var(--bg); border: none; border-radius: 10px;
  font-size: .9rem; font-weight: 700; color: var(--text); }
.btn-prim { flex: 1; padding: 12px; background: var(--blue); border: none; border-radius: 10px;
  font-size: .9rem; font-weight: 700; color: #fff; }
.field-err { color: var(--red); font-size: .8rem; margin-top: 6px; min-height: 18px; }

/* ── ADMIN TABLE ─────────────────────────────────────── */
.admin-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.admin-row:last-child { border-bottom: none; }
.admin-row.inactive { opacity: .5; }
.admin-av  { width: 38px; height: 38px; border-radius: 50%; background: var(--blue-lt); color: var(--blue);
  font-size: .9rem; font-weight: 800; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.admin-info { flex: 1; min-width: 0; }
.admin-name { font-size: .88rem; font-weight: 600; }
.admin-meta { font-size: .73rem; color: var(--sub); margin-top: 2px; }
.badge-role { display: inline-block; padding: 1px 7px; border-radius: 99px; font-size: .66rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .4px; margin-left: 5px; }
.badge-role.admin   { background: var(--amber-bg); color: var(--amber); }
.badge-role.gerente { background: var(--blue-lt);  color: var(--blue); }
.badge-role.vendedor{ background: var(--green-bg); color: var(--green); }
.btn-toggle {
  padding: 5px 12px; border: none; border-radius: 8px; font-size: .73rem; font-weight: 700;
  cursor: pointer; flex-shrink: 0; transition: opacity .15s;
}
.btn-toggle.ativo    { background: var(--red-bg);   color: var(--red); }
.btn-toggle.inativo  { background: var(--green-bg); color: var(--green); }
.btn-novo {
  padding: 8px 16px; background: var(--blue); color: #fff; border: none;
  border-radius: 8px; font-size: .82rem; font-weight: 700;
}

/* ── LOADING ─────────────────────────────────────────── */
#loading {
  position: fixed; inset: 0; background: rgba(255,255,255,.8);
  z-index: 999; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(3px);
}
.spinner { width: 38px; height: 38px; border: 3px solid var(--border); border-top-color: var(--blue);
  border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── API ERROR ───────────────────────────────────────── */
.api-erro {
  background: var(--red-bg); border: 1.5px solid #fca5a5; border-radius: var(--r);
  padding: 20px; text-align: center; margin-bottom: 4px;
}
.api-erro-icon { font-size: 2rem; margin-bottom: 8px; }
.api-erro-msg  { font-size: .9rem; font-weight: 600; color: var(--red); line-height: 1.5; }
.api-erro-msg small { font-weight: 400; font-size: .8rem; color: #b91c1c; }
.api-erro-url  { font-size: .7rem; color: var(--sub); margin: 8px 0; word-break: break-all; }
.api-erro-btn  {
  margin-top: 8px; padding: 9px 20px; background: var(--red); color: #fff;
  border: none; border-radius: 9px; font-size: .85rem; font-weight: 700; cursor: pointer;
}
.api-erro-btn:hover { opacity: .88; }

/* ── EMPTY STATE ─────────────────────────────────────── */
.empty { text-align: center; padding: 48px 20px; color: var(--sub); font-size: .88rem; }
.empty-icon { font-size: 2.5rem; margin-bottom: 10px; }

/* ──────────────────────────────────────────────────────
   RESPONSIVE
   ────────────────────────────────────────────────────── */

/* Mobile: hide sidebar, show bottom nav */
@media (max-width: 767px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sb-overlay {
    display: block;
  }
  .sb-overlay.hidden {
    display: none !important;
  }
  .main-wrap {
    margin-left: 0;
  }
  .topbar-menu { display: flex; }
  .topbar-app, .topbar-sep { display: inline; }
  .nav-bar { display: flex; }
  .page { padding: 14px; padding-bottom: calc(var(--nav-h) + 14px); }
  .grid3 { grid-template-columns: 1fr 1fr; }
  .donut-row { flex-direction: column; align-items: flex-start; }
  .donut-wrap { width: 100%; height: 180px; }
  .donut-legend { width: 100%; }
  .card-num { font-size: 1.6rem; }
  .card-hero .card-num { font-size: 2rem; }
}

/* Tablet+ : sidebar always visible */
@media (min-width: 768px) {
  .nav-bar { display: none; }
  .topbar-menu { display: none; }
  .page { max-width: 960px; }
  .grid3 { grid-template-columns: repeat(3, 1fr); }
}

/* Wide desktop */
@media (min-width: 1280px) {
  :root { --sb-w: 240px; }
  .page { max-width: 1100px; }
  .donut-wrap { width: 180px; height: 180px; }
}
