/* Painel das Lojas — uma coluna, barra de separadores em baixo no telemóvel, em cima no PC */
:root {
  --bg: #EEF1F0; --surface: #FFFFFF; --sunk: #E3E8E6; --ink: #15201C; --muted: #5B6863; --line: #D5DCD9;
  --accent: #2443C4; --accent-ink: #FFFFFF; --accent-soft: #E3E8FB;
  --gain: #11804F; --gain-soft: #DDF1E6; --loss: #BC3A26; --loss-soft: #F8E1DC; --warn: #9A6200; --warn-soft: #FBEFD6;
  --font-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-body: "Instrument Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-data: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --radius: 14px; --nav-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1312; --surface: #161D1B; --sunk: #1E2724; --ink: #E6EEEA; --muted: #92A19B; --line: #2A3532;
    --accent: #8199FF; --accent-ink: #0E1312; --accent-soft: #222C4D;
    --gain: #45C98D; --gain-soft: #17322A; --loss: #FF7E66; --loss-soft: #3A1F1A; --warn: #F2B544; --warn-soft: #3A2E14;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.45;
  padding-top: env(safe-area-inset-top, 0px); -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
a { color: var(--accent); }

.arranque { min-height: 60vh; display: grid; place-items: center; color: var(--muted); }
.app { max-width: 920px; margin: 0 auto; padding-inline: 16px;
  padding-block: 14px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom, 0px)); }

/* topo */
.topo { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.topo h1 { font-family: var(--font-display); font-weight: 700; font-size: 1.45rem; letter-spacing: -0.02em; margin: 0; }
.sync { display: inline-flex; align-items: center; gap: 6px; font-size: 0.76rem; color: var(--muted); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 10px; background: var(--surface); cursor: pointer; }
.sync i { width: 7px; height: 7px; border-radius: 50%; background: var(--gain); display: inline-block; }
.sync.off i { background: var(--warn); } .sync.err i { background: var(--loss); }

/* separadores */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); }
.tabs a { height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 0.72rem; font-weight: 600; color: var(--muted); text-decoration: none; }
.tabs svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a[aria-current="page"] { color: var(--accent); }
@media (min-width: 760px) {
  .app { padding-block: 22px 48px; }
  .tabs { position: sticky; top: env(safe-area-inset-top, 0px); bottom: auto; display: flex; gap: 4px; border: 1px solid var(--line);
    border-radius: 999px; padding: 4px; margin-bottom: 20px; width: fit-content; }
  .tabs a { height: 38px; flex-direction: row; gap: 7px; padding-inline: 16px; border-radius: 999px; font-size: 0.86rem; }
  .tabs svg { width: 18px; height: 18px; }
  .tabs a[aria-current="page"] { background: var(--accent-soft); }
}

.view { display: grid; gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.panel > h2, .sec-h h2 { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em; margin: 0 0 12px; }
.sec-h { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.label { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: 0.82rem; }
.num { font-family: var(--font-data); font-variant-numeric: tabular-nums; }
.gain { color: var(--gain); } .loss { color: var(--loss); }

/* filtros */
.filters { display: grid; gap: 10px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 14px; font-size: 0.86rem;
  font-weight: 500; cursor: pointer; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); margin-right: 6px; vertical-align: 1px; }
.chip .dot.on { background: var(--gain); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.seg button { border: 0; background: var(--sunk); border-radius: 8px; padding: 6px 12px; font-size: 0.84rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.seg select { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 5px 8px; font-size: 0.84rem; }

/* números grandes */
.hero { display: grid; gap: 4px; }
.big { font-family: var(--font-display); font-weight: 700; font-size: clamp(2.2rem, 9vw, 3.1rem); letter-spacing: -0.03em; line-height: 1;
  font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.hero .sub { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.88rem; color: var(--muted); margin-top: 6px; }
.pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 2px 9px; font-size: 0.78rem; font-weight: 600; background: var(--sunk); }
.pill.gain { background: var(--gain-soft); } .pill.loss { background: var(--loss-soft); } .pill.warn { background: var(--warn-soft); color: var(--warn); }

.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; }
@media (min-width: 620px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } .kpis.k4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi { background: var(--surface); padding: 12px 14px; display: grid; gap: 4px; min-width: 0; align-content: start; }
.kpi .v { font-family: var(--font-data); font-variant-numeric: tabular-nums; font-size: 1.1rem; font-weight: 500; overflow-wrap: anywhere; }
.kpi .h { font-size: 0.76rem; color: var(--muted); }

/* gráfico */
.chart svg { display: block; width: 100%; height: 190px; }
.readout { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 0.84rem; margin-top: 8px; min-height: 1.4em; }

/* tabelas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
th { text-align: right; font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 600;
  padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { text-align: right; padding: 9px 8px; border-bottom: 1px solid var(--line); font-family: var(--font-data); font-variant-numeric: tabular-nums; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; font-family: var(--font-body); padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
tr:last-child td { border-bottom: 0; }

/* formulários */
.form { display: grid; gap: 14px; }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 420px) { .row3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.field { display: grid; gap: 5px; min-width: 0; align-content: start; }
.field > label { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 10px;
  padding: 11px 12px; font-size: 1rem; min-width: 0; }
.field input.money { font-family: var(--font-data); font-variant-numeric: tabular-nums; }
.field textarea { min-height: 70px; resize: vertical; }
.hint { font-size: 0.74rem; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }
.check input { width: 18px; height: 18px; }
.group-title { font-family: var(--font-display); font-weight: 700; font-size: 0.95rem; margin: 4px 0 -4px; }
.result { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; background: var(--sunk); border-radius: 12px; padding: 12px; }
.result div { display: grid; gap: 2px; min-width: 0; }
.result .v { font-family: var(--font-data); font-variant-numeric: tabular-nums; font-weight: 500; font-size: 1.02rem; overflow-wrap: anywhere; }
.breakdown { font-size: 0.8rem; color: var(--muted); line-height: 1.6; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn { border: 0; border-radius: 10px; padding: 11px 18px; font-weight: 600; cursor: pointer; background: var(--sunk); text-decoration: none; color: var(--ink); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.grow { flex: 1 1 180px; }
.btn.danger { background: var(--loss-soft); color: var(--loss); }
.btn.ghost { background: none; border: 1px solid var(--line); }
.btn.sm { padding: 6px 12px; font-size: 0.84rem; border-radius: 8px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.note { display: flex; gap: 8px; align-items: flex-start; font-size: 0.85rem; border-radius: 10px; padding: 9px 12px; background: var(--accent-soft); }
.note.warn { background: var(--warn-soft); } .note.err { background: var(--loss-soft); }

/* listas */
.month-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 6px 0 2px; }
.month-h h3 { font-family: var(--font-display); font-weight: 700; font-size: 1rem; margin: 0; text-transform: capitalize; }
.list { display: grid; }
.item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 11px 0; border: 0;
  border-bottom: 1px solid var(--line); background: none; text-align: left; width: 100%; color: inherit; }
button.item, a.item { cursor: pointer; text-decoration: none; }
.item:last-child { border-bottom: 0; }
.item.day { grid-template-columns: 52px minmax(0, 1fr) auto; gap: 12px; }
.item .d { font-family: var(--font-data); font-size: 0.8rem; color: var(--muted); line-height: 1.2; }
.item .d b { display: block; font-family: var(--font-display); font-size: 1.15rem; color: var(--ink); font-weight: 700; }
.item .mid { min-width: 0; display: grid; gap: 2px; }
.item .t { font-weight: 600; font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .s { font-size: 0.78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .p { text-align: right; font-family: var(--font-data); font-variant-numeric: tabular-nums; font-size: 0.95rem; }
.item .p small { display: block; font-size: 0.74rem; color: var(--muted); font-family: var(--font-body); }
.status { font-size: 0.72rem; font-weight: 600; border-radius: 999px; padding: 2px 8px; background: var(--sunk); color: var(--muted); }
.status.ativa, .status.feito { background: var(--gain-soft); color: var(--gain); }
.status.pendente, .status.pausada { background: var(--warn-soft); color: var(--warn); }

.menu { display: grid; }
.menu a { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line);
  color: inherit; text-decoration: none; font-weight: 600; }
.menu a:last-child { border-bottom: 0; }
.menu a span { font-weight: 400; color: var(--muted); font-size: 0.84rem; }

.empty { text-align: center; padding: 26px 12px; color: var(--muted); display: grid; gap: 10px; justify-items: center; }
.empty strong { color: var(--ink); font-family: var(--font-display); font-size: 1.05rem; }

.auth { max-width: 420px; margin: 8vh auto 0; padding-inline: 16px; display: grid; gap: 16px; }
.auth h1 { font-family: var(--font-display); font-size: 1.8rem; letter-spacing: -0.02em; margin: 0; }

.back { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 0.9rem; }

.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 0.88rem; z-index: 30;
  max-width: calc(100vw - 32px); text-align: center; }
@media (min-width: 760px) { .toast { bottom: 24px; } }
@media (prefers-reduced-motion: no-preference) { .toast { animation: rise .2s ease-out; } @keyframes rise { from { transform: translate(-50%, 8px); opacity: 0; } } }

.cartao-link { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; text-decoration: none; color: inherit; }
.cartao-link .cl-txt { display: grid; gap: 4px; min-width: 0; }
