:root {
  --bg: #0c0e12;
  --card: #16181e;
  --card-2: #101216;
  --line: #262a33;
  --text: #f4f6f8;
  --muted: #8b93a1;
  --blue: #d6ee4a;
  --green: #d6ee4a;
  --purple: #a855f7;
  --red: #f43f5e;
  --radius: 22px;
  --font: "Segoe UI", system-ui, sans-serif;
  --primary-soft: #1c2410;
  --topbar-bg: rgba(7, 8, 10, 0.92);
  --bar-track: #22262e;
  --conv-bg: #0e1218;
}

html[data-theme="light"] {
  --bg: #f4f5f7;
  --card: #ffffff;
  --card-2: #eef1f6;
  --line: #d5dbe3;
  --text: #12161c;
  --muted: #5c6775;
  --blue: #2563eb;
  --green: #059669;
  --purple: #7c3aed;
  --red: #dc2626;
  --primary-soft: #e8f1ff;
  --topbar-bg: rgba(255, 255, 255, 0.94);
  --bar-track: #e2e8f0;
  --conv-bg: #eef2f7;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(900px 420px at 8% -10%, rgba(214, 238, 74, 0.08), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
}
body.dash-page { overflow-x: hidden; }
.hidden { display: none !important; }

#lockScreen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.lock-card {
  width: min(400px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 24px;
}
.lock-card h1 { margin: 0 0 8px; }
.lock-card p, .lock-card label { color: var(--muted); font-size: 0.9rem; }
.lock-card input, .lock-card select, .lock-card textarea,
.page input, .page select, .page textarea {
  font: inherit;
  color: var(--text);
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
}
.lock-card input { width: 100%; margin: 8px 0 12px; }
.lock-error { color: var(--red); min-height: 1.2em; }

.btn {
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
}
.btn.primary { border: 0; background: #d6ee4a; color: #142000; font-weight: 700; }
.btn { border: 0; border-radius: 999px; background: #22262f; color: #fff; padding: 0 14px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.topbar-brand { display: flex; flex-direction: column; min-width: 90px; color: inherit; text-decoration: none; }
.topbar-brand span { color: var(--muted); font-size: 0.75rem; }
a.mod {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.topbar-actions a.btn { text-decoration: none; }
.top-tabs { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
}
.tab.active { color: var(--text); border-color: var(--blue); background: var(--primary-soft); }
.topbar-actions { display: flex; gap: 8px; margin-left: auto; align-items: center; }
.theme-btn {
  min-width: 132px;
  font-size: 0.85rem;
}
.theme-btn-lock {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 40;
}
body.dash-page:has(#shell:not(.hidden)) .theme-btn-lock {
  display: none !important;
}
.page-title {
  margin: 22px 28px 0;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 700;
  letter-spacing: -0.045em;
}

.dash-top {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px 28px 0;
  flex-wrap: wrap;
}
.dash-brand {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: -0.04em;
  white-space: nowrap;
}
.dash-brand span { font-weight: 800; }
.dash-nav { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.dash-link {
  font: inherit;
  color: #c5cad3;
  background: transparent;
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  text-decoration: none;
}
.dash-link:hover,
.mod.active {
  background: #1c1f27;
  color: #fff;
  border: 0;
  box-shadow: none;
}
.dash-tools { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.dash-clock { color: #8b93a1; font-size: 0.8rem; }
.home-tool {
  font: inherit;
  border: 1px solid #2a2e38;
  background: #14171d;
  color: #fff;
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
}
.module-grid { display: none; }
.mod { min-height: 0; }

#shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
#shell > .page:not(.hidden) {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

body.dash-page #app.inv-embed {
  display: block;
  flex: 1;
  min-height: 0;
  background: transparent;
}
body.dash-page .inv-embed .sidebar {
  height: 100%;
  min-height: 0;
  overflow: auto;
  position: sticky;
  top: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  display: flex;
  flex-direction: column;
}
body.dash-page .inv-embed .account-list {
  flex: 1;
  overflow: auto;
  min-height: 0;
}
body.dash-page .inv-embed .main {
  padding: 0 4px 28px;
  min-width: 0;
}
body.dash-page .page.inv-page { padding-top: 12px; }

.page { padding: 18px 20px 40px; }
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.kpi-top { display: flex; justify-content: space-between; align-items: flex-start; }
.kpi .l { color: var(--muted); font-size: 0.8rem; }
.kpi .v { font-size: 1.45rem; font-weight: 700; margin-top: 6px; }
.kpi .hint { color: var(--muted); font-size: 0.75rem; margin-top: 4px; }
.kpi .v.in { color: var(--green); }
.kpi .v.out { color: var(--red); }
.caixa-table-wrap { overflow-x: auto; margin-top: 8px; }
.caixa-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.caixa-table th, .caixa-table td {
  text-align: right;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.caixa-table th:first-child, .caixa-table td:first-child { text-align: left; }
.caixa-table thead th { color: var(--muted); font-weight: 600; }
.caixa-table tbody tr.today { background: var(--primary-soft); }
.caixa-table tbody tr.future { opacity: 0.35; }
.caixa-table .tot { font-weight: 700; }
.caixa-table td.in { color: var(--green); }
.caixa-table td.out { color: var(--red); }
.period-row, .caixa-cats { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.period-row .btn.active { border: 0; background: #d6ee4a; color: #142000; }
.caixa-table tbody tr.today { background: rgba(214, 238, 74, 0.16); }
.caixa-cats .pill {
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  min-width: 120px;
}
.caixa-cats .pill span { display: block; color: var(--muted); font-size: 0.75rem; }
.caixa-cats .pill strong { font-size: 0.95rem; }
.kpi .ico {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--blue);
  font-size: 1.05rem;
}

.mid-grid {
  display: grid;
  grid-template-columns: 1.5fr 0.85fr 0.85fr;
  gap: 12px;
  margin-bottom: 14px;
}
.mid-grid.two { grid-template-columns: 1fr 1fr; }
.item .acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.item .acts .btn { min-height: 36px; font-size: 0.8rem; }
.bot-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.card h2 { margin: 0 0 12px; font-size: 0.95rem; font-weight: 600; }
.card-head { display: flex; justify-content: space-between; gap: 12px; }
.sub { color: var(--muted); font-size: 0.8rem; margin: 0 0 6px; }
.hero { font-size: 1.7rem; font-weight: 700; }
.chart { height: 220px; }
.chart svg { width: 100%; height: 100%; display: block; }

.funnel-row { margin-bottom: 12px; }
.funnel-row .meta { display: flex; justify-content: space-between; font-size: 0.85rem; margin-bottom: 4px; }
.bar { height: 8px; background: var(--bar-track); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 99px; }
.conv {
  margin-top: 14px;
  background: var(--conv-bg);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: 0.82rem;
}

.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.86rem;
  line-height: 1.4;
}
.item strong { display: block; }
.muted { color: var(--muted); }
.bad { border-color: #5c2430; }
.warn { border-color: #5c4a1d; }
.ok { color: var(--green); }
.err { color: var(--red); }
.wa-qr { max-width: 180px; margin-top: 8px; border-radius: 8px; }
.sources { margin-top: 14px; }
.src { margin-bottom: 10px; }
.kpi-mini { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.kpi-mini div { background: var(--card-2); border-radius: 10px; padding: 10px; }
.kpi-mini .v { font-size: 1.2rem; font-weight: 700; }

.row { display: flex; gap: 8px; align-items: end; margin-bottom: 12px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 160px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 0.78rem; color: var(--muted); }
input, select, textarea { width: 100%; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.preview {
  margin: 0;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  white-space: pre-wrap;
  font-size: 0.82rem;
  min-height: 320px;
  overflow: auto;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chips button, .chip {
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.8rem;
}
.chips.small button { font-size: 0.72rem; border-style: dashed; color: var(--muted); }
.chips button.active { border-color: var(--blue); }
.status { color: var(--green); font-size: 0.85rem; }

@media (max-width: 1100px) {
  .kpi-row, .mid-grid, .mid-grid.two, .bot-grid, .split { grid-template-columns: 1fr; }
  .topbar {
    flex-wrap: nowrap;
    gap: 8px;
    padding: 8px 12px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
  .topbar-brand { min-width: 0; flex: 1; }
  .topbar-brand span { display: none; }
  .topbar-actions { margin-left: 0; flex-shrink: 0; }
  .theme-btn {
    min-width: 0;
    font-size: 0.75rem;
    padding: 8px 10px;
    min-height: 38px;
  }
  .theme-btn-lock {
    top: max(10px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
    font-size: 0.75rem;
    min-width: 0;
    padding: 8px 10px;
  }
  .page-title { display: none; }
  .module-grid {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 6px;
    padding: 8px 12px 10px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .module-grid::-webkit-scrollbar { display: none; }
  .mod {
    flex: 0 0 auto;
    padding: 8px 12px;
    min-height: 40px;
    font-size: 0.8rem;
  }
  .page { padding: 10px 12px 28px; }
  #shell > .page:not(.hidden) { display: flex; }

  body.dash-page #app.inv-embed {
    display: block;
    flex: 1;
    min-height: 0;
    gap: 0;
  }
  body.dash-page .inv-embed .main {
    flex: 1;
    min-height: 0;
    padding: 0 0 24px;
  }
  body.dash-page .page.inv-page { padding: 0 12px 16px; }
  body.dash-page #app {
    padding-top: 0;
  }
  body.dash-page .mobile-bar {
    position: sticky;
    top: 0;
    left: auto;
    right: auto;
    z-index: 15;
    margin: 0 -12px 10px;
    border-radius: 0;
  }
  .row { flex-wrap: wrap; }
  .grow { min-width: 100%; }
  #lockScreen { padding: 72px 16px 24px; }
}

.sheet-wrap {
  overflow: auto;
  max-height: calc(100dvh - 280px);
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}
.sheet {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}
.sheet th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--card-2);
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
}
.sheet td {
  border-bottom: 1px solid var(--line);
  padding: 6px 8px;
  vertical-align: middle;
}
.sheet tbody tr:hover td { background: var(--card-2); }
.col-game { min-width: 220px; }
.col-price, .col-stock { width: 110px; }
.price-cell, .qty-cell { display: flex; flex-direction: column; gap: 2px; }
.price-cell input, .qty-cell input {
  width: 100%;
  font: inherit;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 8px;
}
.qty-cell input { text-align: right; }
.price-cell input:focus, .qty-cell input:focus {
  outline: none;
  border-color: var(--blue);
  background: var(--card-2);
}
.price-cell.saved input, .qty-cell.saved input { border-color: var(--green); }
.price-cell.error input, .qty-cell.error input { border-color: var(--red); }
.game-title { display: block; font-weight: 600; }
.game-handle { display: block; font-size: 0.75rem; color: var(--muted); }
.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 650;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
}
.badge.ps5 { background: #f3f6f8; color: #111; }
.badge.ps4 { background: #003087; color: #fff; border-color: #003087; }
.badge.xbox { background: #107c10; color: #fff; }
.badge.catalog { color: var(--green); }
.badge.queimao { color: #e11d48; }
.badge.promo { color: #d97706; }
.badge.gift { color: #7c3aed; }
.status { font-size: 0.7rem; color: var(--muted); min-height: 1em; }
.status.ok { color: var(--green); }
.status.err { color: var(--red); }
.compare { color: var(--muted); text-decoration: line-through; }
.link { color: var(--blue); text-decoration: none; font-size: 0.8rem; }
.toast { font-size: 0.82rem; color: var(--green); }
.toast.err { color: var(--red); }
html[data-theme="light"] .badge.ps5 { background: #e2e8f0; }
html[data-theme="light"] .dash-brand,
html[data-theme="light"] .page-title { color: #12161c; }
html[data-theme="light"] .dash-link { color: #3d4654; }
html[data-theme="light"] .dash-link:hover,
html[data-theme="light"] .mod.active { background: #eceff4; color: #12161c; }
html[data-theme="light"] .home-tool,
html[data-theme="light"] .btn { background: #eceff4; color: #12161c; }
html[data-theme="light"] .btn.primary,
html[data-theme="light"] .period-row .btn.active { background: #d6ee4a; color: #142000; }
