:root {
  color-scheme: light;
  --bg: #00365c;
  --card: rgba(255, 255, 255, 0.92);
  --card2: rgba(232, 247, 250, 0.86);
  --text: #071827;
  --muted: #40566f;
  --line: rgba(15, 23, 42, 0.16);
  --blue: #0ea5e9;
  --green: #10b981;
  --red: #e11d48;
  --amber: #d97706;
  --purple: #7c3aed;
  --radius: 22px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html {
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
  overscroll-behavior-x: none;
}

body {
  margin: 0;
  width: 100%;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  touch-action: pan-y;
  min-height: 100dvh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 520px at 12% -10%, rgba(255, 255, 255, 0.30), transparent 60%),
    linear-gradient(180deg, #7edbd4 0%, #0b8495 52%, #00365c 100%),
    var(--bg);
  background-attachment: fixed;
}

svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.hidden { display: none !important; }
.eyebrow { margin: 0 0 6px; color: var(--blue); font-size: 12px; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
h1 { font-size: clamp(22px, 5.2vw, 30px); }
h2 { font-size: 17px; }
h3 { font-size: 14px; }
.muted, small { color: var(--muted); }

.card {
  border: 1px solid var(--line);
  background: linear-gradient(150deg, var(--card), var(--card2));
  border-radius: var(--radius);
  box-shadow: 0 18px 42px rgba(0, 49, 74, 0.22);
  backdrop-filter: blur(16px);
}

/* ================= LOGIN ================= */
.login {
  position: relative;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 18px;
  overflow: hidden;
  color: #f7f3eb;
  background: #101820;
}

.login::before {
  content: "";
  position: absolute;
  inset: 0;
  width: min(76vw, 460px);
  height: min(76vw, 460px);
  margin: auto;
  border: 1px solid rgba(197, 151, 96, 0.15);
  border-radius: 50%;
  box-shadow: 0 0 0 60px rgba(197, 151, 96, 0.035), 0 0 0 120px rgba(197, 151, 96, 0.025);
  pointer-events: none;
}

.login-pattern {
  position: absolute;
  inset: 0;
  opacity: 0.2;
  background-image: repeating-linear-gradient(118deg, transparent 0 42px, rgba(255, 255, 255, 0.05) 43px 44px);
  pointer-events: none;
}

.login::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 140px;
  height: 5px;
  margin: auto auto 0;
  background: #c59760;
  pointer-events: none;
}

.login-card {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  display: grid;
  gap: 15px;
  padding: 30px 24px 24px;
  border: 1px solid rgba(197, 151, 96, 0.42);
  border-radius: 6px;
  background: rgba(247, 243, 235, 0.97);
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.34);
}

.login-card::before {
  content: "EST. 2026  •  GESTAO ONLINE";
  justify-self: center;
  margin: -10px 0 2px;
  padding: 7px 12px;
  border: 0;
  border-radius: 999px;
  color: #89623a;
  background: transparent;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.login-brand { text-align: center; display: grid; gap: 4px; margin-bottom: 8px; }
.login-brand h1 { color: #101820; font-family: Georgia, "Times New Roman", serif; font-size: clamp(31px, 8vw, 40px); font-weight: 500; letter-spacing: 0.08em; }
.login-brand h1 span { display: block; margin-top: 2px; color: #89623a; font-family: Inter, ui-sans-serif, system-ui, sans-serif; font-size: 0.31em; font-weight: 800; letter-spacing: 0.48em; transform: translateX(0.24em); }
.login-brand .eyebrow { color: #89623a; font-size: 10px; letter-spacing: 0.28em; }
.login-sub { max-width: 300px; margin: 4px auto 0; color: var(--muted); font-size: 14px; line-height: 1.45; }

.login-secure { margin: -4px 0 0; color: #64717b; font-size: 11px; text-align: center; }
.login-secure span { display: inline-block; width: 6px; height: 6px; margin-right: 5px; border-radius: 50%; background: #54806a; vertical-align: 1px; }

label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 0.02em; }

input, select {
  width: 100%;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 16px;
  padding: 14px 15px;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.84);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}
input:focus, select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18); }

.btn-primary {
  border: 0;
  border-radius: 17px;
  padding: 16px;
  font: inherit;
  font-weight: 900;
  color: #ffffff;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.18), transparent 40%),
    linear-gradient(120deg, #0284c7, #0f766e 52%, #14b8a6);
  box-shadow: 0 18px 34px rgba(14, 116, 144, 0.34);
  cursor: pointer;
  margin-top: 4px;
}
.btn-primary:active { transform: translateY(1px); }

.btn-perigo {
  border: 1px solid rgba(251, 113, 133, 0.4);
  border-radius: 14px;
  padding: 12px;
  font: inherit; font-weight: 800;
  color: var(--red);
  background: rgba(251, 113, 133, 0.10);
  cursor: pointer;
  margin-top: 14px;
}

.erro { min-height: 18px; margin: 0; color: var(--red); font-weight: 700; font-size: 13px; }

/* ================= APP / CASCA ================= */
.app {
  width: min(480px, 100%);
  max-width: 100vw;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 0 max(14px, env(safe-area-inset-left)) 0 max(14px, env(safe-area-inset-right));
  overflow-x: hidden;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: calc(8px + env(safe-area-inset-top)) 0 0;
  padding: 14px 14px 15px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #f2fffb;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 46%),
    linear-gradient(155deg, #0f766e 0%, #0d5f5a 45%, #0b4a52 100%);
  box-shadow:
    0 16px 34px rgba(6, 58, 60, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.38),
    inset 0 -12px 24px rgba(0, 40, 46, 0.22);
  backdrop-filter: blur(10px);
}
.topbar-titulo { min-width: 0; }
.topbar-titulo .eyebrow {
  margin: 0 0 3px;
  color: #a7f3e4;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-shadow: 0 1px 2px rgba(3, 45, 48, 0.4);
}
.topbar-titulo .topbar-marca { color: #a7f3e4; }
.topbar-titulo h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #ffffff; }
.topbar-acoes { display: flex; gap: 8px; flex: 0 0 auto; }

.icon-btn {
  width: 44px; height: 44px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 13px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
  cursor: pointer;
}
.icon-btn:active { background: rgba(255, 255, 255, 0.32); }

/* ================= SYNC STATUS ================= */
.sync-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  margin-right: 8px;
}
.sync-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber);
  transition: background 0.3s, box-shadow 0.3s;
}
.sync-dot.ok { background: var(--green); box-shadow: 0 0 8px var(--green); }
.sync-dot.error { background: var(--red); box-shadow: 0 0 8px var(--red); }
.sync-dot.syncing { background: var(--blue); box-shadow: 0 0 8px var(--blue); animation: pulse 1.5s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.sync-text {
  font-size: 11px; font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
  white-space: nowrap;
}
.sync-btn {
  width: 32px; height: 32px;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 10px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.sync-btn:active { background: rgba(255, 255, 255, 0.24); }
.sync-btn svg { width: 18px; height: 18px; }
.sync-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.periodo {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 22px minmax(0, 1fr);
  gap: 8px;
  align-items: end;
  min-width: 0;
  overflow: hidden;
  padding: 14px 14px 16px;
  margin-bottom: 16px;
  border-color: rgba(255, 255, 255, 0.78);
  box-shadow: 0 14px 34px rgba(0, 72, 92, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.84);
}
.periodo label { min-width: 0; }
.date-field { position: relative; }
.date-field .date-value {
  display: block;
  min-width: 0;
  width: 100%;
  overflow: hidden;
  padding: 12px 28px 12px 8px;
  border: 1px solid rgba(82, 120, 140, 0.25);
  border-radius: 15px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.75), 0 3px 9px rgba(12, 69, 88, 0.07);
  text-align: center;
  font-size: clamp(12px, 3.35vw, 15px);
  font-weight: 850;
  letter-spacing: -0.025em;
  white-space: nowrap;
}
.date-field .date-value::after {
  content: "⌄";
  position: absolute;
  right: 10px;
  color: #347087;
  font-size: 18px;
  line-height: 1;
}
.date-field input[type="date"] {
  position: absolute;
  inset: 21px 0 0;
  z-index: 2;
  width: 100%;
  height: 45px;
  min-width: 0;
  opacity: 0.01;
  cursor: pointer;
}
.date-field:focus-within .date-value {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.16), inset 0 1px 1px rgba(255, 255, 255, 0.75);
}
.periodo-seta {
  display: block;
  width: 22px;
  height: 22px;
  color: #256078;
  margin-bottom: 12px;
  justify-self: center;
}

.page { flex: 1; padding-bottom: 8px; }

/* --------- GRADE DE ICONES --------- */
.grade-modulos {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.modulo {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.94), rgba(222, 244, 249, 0.90));
  box-shadow: 0 14px 34px rgba(0, 49, 74, 0.26);
  padding: 16px 12px 14px;
  display: grid;
  justify-items: center;
  gap: 8px;
  text-align: center;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  min-height: 104px;
  align-content: center;
}
.modulo:active { transform: scale(0.97); }
.modulo-icone { width: 40px; height: 40px; padding: 8px; border-radius: 12px; }
.modulo span { font-size: 12.5px; font-weight: 900; line-height: 1.25; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.44); }

.c-blue { color: #0284c7; background: rgba(14, 165, 233, 0.20); }
.c-green { color: #059669; background: rgba(16, 185, 129, 0.20); }
.c-purple { color: #7c3aed; background: rgba(124, 58, 237, 0.18); }
.c-amber { color: #d97706; background: rgba(245, 158, 11, 0.22); }
.c-red { color: #e11d48; background: rgba(225, 29, 72, 0.18); }

/* --------- VOLTAR --------- */
.voltar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 800;
  font-size: 13px;
  padding: 4px 2px 12px;
  cursor: pointer;
}
.voltar svg { width: 18px; height: 18px; }

/* --------- CONTEUDO --------- */
.bloco { padding: 16px; margin-bottom: 12px; }
.bloco-titulo { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.bloco-titulo small { font-size: 12px; }

.subtabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  padding: 2px 1px 12px;
  margin-bottom: 2px;
  scrollbar-width: none;
}
.subtabs::-webkit-scrollbar { display: none; }
.subtab {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 13px;
  color: var(--tab-color, var(--muted));
  background: rgba(255, 255, 255, 0.58);
  font: inherit;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}
.subtab-vendas { --tab-color: #0369a1; --tab-bg: linear-gradient(120deg, #7dd3fc, #38bdf8); }
.subtab-pagamentos { --tab-color: #047857; --tab-bg: linear-gradient(120deg, #6ee7b7, #22d3ee); }
.subtab-operadores { --tab-color: #6d28d9; --tab-bg: linear-gradient(120deg, #c4b5fd, #818cf8); }
.subtab-produtos { --tab-color: #b45309; --tab-bg: linear-gradient(120deg, #fcd34d, #fb923c); }
.subtab-sangrias { --tab-color: #be123c; --tab-bg: linear-gradient(120deg, #fda4af, #fb7185); }
.estoque-tab-negativo { --tab-color: #be123c; --tab-bg: linear-gradient(120deg, #fda4af, #fb7185); --tab-shadow: rgba(251, 113, 133, 0.22); }
.estoque-tab-zerado { --tab-color: #b45309; --tab-bg: linear-gradient(120deg, #fcd34d, #fb923c); --tab-shadow: rgba(251, 191, 36, 0.22); }
.estoque-tab-baixo { --tab-color: #6d28d9; --tab-bg: linear-gradient(120deg, #c4b5fd, #818cf8); --tab-shadow: rgba(167, 139, 250, 0.22); }
.estoque-tab-ok { --tab-color: #047857; --tab-bg: linear-gradient(120deg, #6ee7b7, #22d3ee); --tab-shadow: rgba(52, 211, 153, 0.22); }
.subtab small { margin-left: 4px; color: currentColor; opacity: 0.72; }
.subtab.ativa {
  color: #04121f;
  border-color: transparent;
  background: var(--tab-bg, linear-gradient(120deg, #7dd3fc, #34d399));
  box-shadow: 0 10px 24px var(--tab-shadow, rgba(56, 189, 248, 0.18));
}
.subtab-vendas { --tab-shadow: rgba(56, 189, 248, 0.22); }
.subtab-pagamentos { --tab-shadow: rgba(52, 211, 153, 0.22); }
.subtab-operadores { --tab-shadow: rgba(167, 139, 250, 0.22); }
.subtab-produtos { --tab-shadow: rgba(251, 191, 36, 0.22); }
.subtab-sangrias { --tab-shadow: rgba(251, 113, 133, 0.22); }
.tab-panel .bloco { margin-bottom: 0; }

.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.kpi { min-width: 0; padding: 14px; position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--blue); }
.kpi span { display: block; color: var(--muted); font-weight: 800; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.07em; }
.kpi strong {
  display: block;
  max-width: 100%;
  margin: 8px 0 4px;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: clamp(18px, 4.6vw, 24px);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.06em;
  line-height: 1.05;
}
.kpi small { font-size: 11px; }
.k-blue::before { background: var(--blue); }
.k-green::before { background: var(--green); }
.k-red::before { background: var(--red); }
.k-amber::before { background: var(--amber); }
.k-purple::before { background: var(--purple); }

.bars { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(52px, 1fr); gap: 8px; align-items: end; min-height: 190px; overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; padding-top: 6px; }
.bar { display: grid; gap: 6px; align-items: end; justify-items: center; }
.bar strong { color: #0369a1; font-size: 9.5px; line-height: 1; max-width: 52px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-fill { min-height: 5px; width: 100%; max-width: 30px; border-radius: 999px 999px 6px 6px; background: linear-gradient(180deg, #7dd3fc, #2563eb); }
.bar label { font-size: 10px; color: var(--muted); white-space: nowrap; }

.ranking, .list { display: grid; gap: 8px; }
.rank, .item { display: grid; gap: 6px; padding: 11px; border-radius: 14px; background: rgba(255, 255, 255, 0.54); border: 1px solid var(--line); }
.rank-line { display: flex; justify-content: space-between; gap: 10px; font-weight: 800; font-size: 13.5px; }
.meter { height: 7px; overflow: hidden; border-radius: 999px; background: rgba(148, 163, 184, 0.16); }
.meter span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--green), var(--blue)); }
.item { grid-template-columns: 1fr auto; align-items: center; font-size: 13.5px; }
.item small { font-size: 11px; }

.pizza-wrap { display: grid; gap: 16px; justify-items: center; }
.pizza {
  width: min(230px, 72vw);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  box-shadow: 0 18px 44px rgba(2, 6, 23, 0.42);
}
.pizza-centro {
  width: 54%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.90);
  text-align: center;
  padding: 8px;
}
.pizza-centro strong { font-size: 17px; }
.pizza-centro span { color: var(--muted); font-size: 10px; font-weight: 900; line-height: 1.15; text-transform: uppercase; }
.pizza-legenda { width: 100%; display: grid; gap: 7px; }
.pizza-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.54);
  font-size: 12.5px;
  transition: transform 0.12s, border-color 0.12s, background 0.12s;
}
.pizza-item.ativa { border-color: rgba(14, 165, 233, 0.56); background: rgba(224, 242, 254, 0.78); transform: translateX(2px); }
.pizza-cor { width: 10px; height: 10px; border-radius: 50%; }
.pizza-nome { font-weight: 900; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pizza-item strong { font-size: 12.5px; }
.pizza-item small { color: var(--muted); font-weight: 900; }

.estoque-lista { display: grid; gap: 9px; }
.estoque-busca { margin-bottom: 12px; }
.estoque-busca input {
  border-color: rgba(251, 191, 36, 0.28);
  background: rgba(255, 255, 255, 0.68);
}
.estoque-busca input::placeholder { color: rgba(100, 116, 139, 0.72); }
.caixa-filtro { margin-bottom: 12px; }
.financeiro-busca, .produto-busca { margin-bottom: 10px; }
.financeiro-busca input, .produto-busca input {
  border-color: rgba(56, 189, 248, 0.24);
  background: rgba(255, 255, 255, 0.68);
}
.financeiro-cards { display: grid; gap: 10px; }
.financeiro-card {
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid #38bdf8;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.58);
}
.financeiro-card.status-vencido { border-left-color: #e11d48; }
.financeiro-card.status-recebido, .financeiro-card.status-pago { border-left-color: #10b981; }
.financeiro-card.status-aberto { border-left-color: #f59e0b; }
.financeiro-card-topo {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}
.financeiro-card-topo strong {
  min-width: 0;
  color: #047857;
  font-size: 13px;
  line-height: 1.25;
}
.financeiro-card-topo span {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 999px;
  color: #0f172a;
  background: rgba(125, 211, 252, 0.42);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}
.financeiro-card-linha {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}
.financeiro-card-linha b { color: var(--text); font-weight: 800; text-align: right; }
.financeiro-card-valores {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.financeiro-card-valores div {
  min-width: 0;
  padding: 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.58);
}
.financeiro-card small { display: block; color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.financeiro-card-valores b {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
  color: #b45309;
  font-size: 12.5px;
  line-height: 1.12;
}
.financeiro-card-valores div:nth-child(2) b { color: #e11d48; }
.financeiro-card p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.35; }
.financeiro-lista .table {
  width: max-content;
  min-width: 760px;
  table-layout: auto;
}
.financeiro-lista .table th,
.financeiro-lista .table td {
  width: auto;
  min-width: 104px;
  overflow: visible;
  text-overflow: clip;
}
.financeiro-lista .table th:first-child,
.financeiro-lista .table td:first-child {
  min-width: 210px;
  max-width: 260px;
  white-space: normal;
  line-height: 1.25;
}
.financeiro-lista .table th:nth-child(2),
.financeiro-lista .table td:nth-child(2) { min-width: 96px; }
.financeiro-lista .table th:nth-child(6),
.financeiro-lista .table td:nth-child(6) { min-width: 110px; }
.comissao-config { margin-bottom: 12px; }
.comissao-cards { display: grid; gap: 10px; }
.comissao-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid #10b981;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.58);
}
.comissao-card-topo {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}
.comissao-card-topo strong {
  min-width: 0;
  color: #047857;
  font-size: 13px;
  line-height: 1.25;
}
.comissao-card-topo span {
  flex: 0 0 auto;
  color: #b45309;
  font-size: 13px;
  font-weight: 950;
}
.comissao-card p {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.3;
}
.comissao-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.comissao-card-meta small {
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.58);
  font-size: 10.5px;
  font-weight: 850;
}
.status-filtros {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 10px;
  scrollbar-width: none;
}
.status-filtros::-webkit-scrollbar { display: none; }
.status-filtros button {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 11px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.58);
  font: inherit;
  font-size: 11.5px;
  font-weight: 900;
}
.status-filtros button.ativa {
  color: #04121f;
  border-color: transparent;
  background: linear-gradient(120deg, #7dd3fc, #34d399);
}
.paginacao {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}
.paginacao button {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 10px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.58);
  font: inherit;
  font-size: 12px;
  font-weight: 900;
}
.paginacao button:disabled { opacity: 0.38; }
.paginacao span { color: var(--muted); text-align: center; font-size: 12px; font-weight: 800; }
.estoque-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--estoque-cor, var(--blue));
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.54);
}
.estoque-item strong { display: block; font-size: 13px; line-height: 1.25; }
.estoque-item span { display: block; margin-top: 5px; color: var(--estoque-cor, var(--muted)); font-size: 11px; font-weight: 900; text-transform: uppercase; }
.estoque-item small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.estoque-saldo { display: grid; justify-items: end; gap: 3px; min-width: 72px; }
.estoque-saldo b { color: var(--estoque-cor, var(--text)); font-size: 18px; font-variant-numeric: tabular-nums; }
.estoque-saldo em { color: var(--muted); font-size: 10px; font-style: normal; font-weight: 900; text-transform: uppercase; }
.estoque-negativo { --estoque-cor: #fb7185; }
.estoque-zerado { --estoque-cor: #fbbf24; }
.estoque-baixo { --estoque-cor: #a78bfa; }
.estoque-ok { --estoque-cor: #34d399; }

.table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 13px; }
.table th, .table td { padding: 9px 6px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th:first-child, .table td:first-child { width: auto; text-align: left; overflow: hidden; text-overflow: ellipsis; }
.table th:not(:first-child), .table td:not(:first-child) { width: 86px; }
.table th.td-col-qtd, .table td.td-col-qtd { width: 64px; }
.table th.td-col-custo, .table td.td-col-custo { width: 74px; }
.table th.td-col-margem, .table td.td-col-margem { width: 74px; }
.table th { color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; }
.table td.num { font-variant-numeric: tabular-nums; font-weight: 700; }
.table td.td-data { color: #0369a1; font-weight: 800; }
.table td.td-operador { color: #047857; font-weight: 900; }
.table td.td-valor { color: #b45309; font-weight: 950; }
.table td.td-obs { color: #be123c; }
.table-wrap { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }

@media (max-width: 420px) {
  .kpis { gap: 8px; }
  .kpi { padding: 13px 12px; }
  .kpi span { font-size: 9.5px; letter-spacing: 0.04em; }
  .kpi strong { font-size: clamp(17px, 6vw, 22px); }
  .table { font-size: 12px; }
  .table th, .table td { padding: 8px 5px; }
  .table th:not(:first-child), .table td:not(:first-child) { width: 78px; }
  .table th.td-col-qtd, .table td.td-col-qtd { width: 56px; }
  .table th.td-col-custo, .table td.td-col-custo { width: 66px; }
  .table th.td-col-margem, .table td.td-col-margem { width: 58px; }
}

.vazio { padding: 18px 4px; text-align: center; color: var(--muted); font-size: 13px; }

.carregando { opacity: 0.55; transition: opacity 0.15s; }

.perfil { padding: 26px 20px; text-align: center; display: grid; gap: 4px; justify-items: center; }
.perfil-avatar {
  width: 72px; height: 72px;
  display: grid; place-items: center;
  border-radius: 24px;
  font-size: 24px; font-weight: 900; color: #04121f;
  background: linear-gradient(135deg, #7dd3fc, #a78bfa);
  margin-bottom: 10px;
}

/* --------- BARRA INFERIOR (fixa, rolavel no eixo) --------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: stretch;
  gap: 4px;
  margin-top: 0;
  padding: 8px max(8px, env(safe-area-inset-left)) calc(8px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-right));
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(239, 246, 255, 0.94));
  backdrop-filter: blur(14px);
  box-shadow: 0 -10px 28px rgba(12, 69, 88, 0.16);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
.tabbar::-webkit-scrollbar { display: none; }
.tabbar .tab {
  flex: 1 0 76px;
  min-width: 76px;
  min-height: 46px;
}
.tab {
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 3px;
  padding: 7px 2px;
  border-radius: 14px;
  cursor: pointer;
}
.tab svg { width: 21px; height: 21px; }
.tab span { font-size: 10px; font-weight: 700; }
.tab.ativa { color: var(--blue); background: rgba(56, 189, 248, 0.12); }

/* Reserva espaco para a barra fixa nao cobrir o conteudo. */
.app { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

@media (min-width: 520px) {
  .grade-modulos { grid-template-columns: repeat(3, 1fr); }
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .tabbar .tab { flex: 1 0 0; min-width: 0; }
}
