/*
 * W2Briks — visual limpo, tema claro e escuro.
 * As cores vivem em variáveis: o tema é escolhido por <html data-theme="light|dark">.
 * Sem data-theme (tela de login) segue o tema do aparelho.
 */

:root {
    color-scheme: light;

    --bg: #f3f4f6;
    --surface: #ffffff;
    --surface-2: #f3f4f6;
    --surface-3: #e8eaee;
    --track: #e3e6eb;
    --line: #e5e7eb;
    --line-strong: #cdd2da;

    --text: #0f172a;
    --text-2: #334155;
    --muted: #566274;

    --accent: #137536;
    --accent-hover: #0e5e2a;
    --accent-ink: #ffffff;
    --accent-soft: #e6f4ea;

    --pos: #137536;
    --neg: #b91c1c;
    --warn: #a04806;
    --info: #1d4ed8;
    --neg-soft: #fdecec;
    --warn-soft: #fdf1dc;
    --info-soft: #e8effd;

    /* Séries dos gráficos, validadas contra a superfície de cada tema (ver README). */
    --series-1: #16955c;
    --series-2: #2a78d6;
    --series-3: #d9531e;

    --shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.04);
    --shadow-pop: 0 12px 32px rgba(15, 23, 42, 0.16);

    --radius: 16px;
    --radius-sm: 12px;
    --pad: 24px;
    --gap: 16px;
    --sidebar-w: 248px;
    --tabbar-h: 64px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="dark"] {
    color-scheme: dark;

    --bg: #0d0f13;
    --surface: #171a20;
    --surface-2: #1e222a;
    --surface-3: #272c36;
    --track: #2a303b;
    --line: #262b34;
    --line-strong: #38404d;

    --text: #f4f6f8;
    --text-2: #d3d8df;
    --muted: #9ba5b3;

    --accent: #3ddc84;
    --accent-hover: #5ee69a;
    --accent-ink: #06170d;
    --accent-soft: rgba(61, 220, 132, 0.14);

    --pos: #4ade80;
    --neg: #ff8a80;
    --warn: #fbbf24;
    --info: #8ab4ff;
    --neg-soft: rgba(255, 138, 128, 0.14);
    --warn-soft: rgba(251, 191, 36, 0.14);
    --info-soft: rgba(138, 180, 255, 0.14);

    --series-1: #1fae6d;
    --series-2: #3987e5;
    --series-3: #d95926;

    --shadow: none;
    --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.55);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        color-scheme: dark;

        --bg: #0d0f13;
        --surface: #171a20;
        --surface-2: #1e222a;
        --surface-3: #272c36;
        --track: #2a303b;
        --line: #262b34;
        --line-strong: #38404d;

        --text: #f4f6f8;
        --text-2: #d3d8df;
        --muted: #9ba5b3;

        --accent: #3ddc84;
        --accent-hover: #5ee69a;
        --accent-ink: #06170d;
        --accent-soft: rgba(61, 220, 132, 0.14);

        --pos: #4ade80;
        --neg: #ff8a80;
        --warn: #fbbf24;
        --info: #8ab4ff;
        --neg-soft: rgba(255, 138, 128, 0.14);
        --warn-soft: rgba(251, 191, 36, 0.14);
        --info-soft: rgba(138, 180, 255, 0.14);

        --series-1: #1fae6d;
        --series-2: #3987e5;
        --series-3: #d95926;

        --shadow: none;
        --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.55);
    }
}

body.compact {
    --pad: 16px;
    --gap: 12px;
    --radius: 12px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 var(--font);
    -webkit-font-smoothing: antialiased;
    min-height: 100dvh;
}

h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }
[hidden] { display: none !important; }

:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
    outline-offset: 2px;
    border-radius: 8px;
}

.skip {
    position: absolute; left: -9999px; top: 8px;
    background: var(--accent); color: var(--accent-ink);
    padding: 8px 14px; border-radius: 8px; z-index: 100;
}
.skip:focus { left: 8px; }

.muted { color: var(--muted); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.zero { color: var(--text-2); }
.nowrap { white-space: nowrap; }
.sr-only {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
@media (max-width: 959px) { .desk-only { display: none !important; } }

/* ---------- Ocultar valores (privacidade) ---------- */
body.hide-values .money,
body.hide-values .chart { filter: blur(7px); transition: filter 0.15s; }
body.hide-values .money:hover,
body.hide-values .money:focus,
body.hide-values .chart:hover { filter: none; }

/* ---------- Estrutura ---------- */
.main { padding: 20px 16px calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom)); }
.page { max-width: 1180px; margin: 0 auto; }
.page.wide { max-width: 1400px; }

.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between;
    padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }
.brand .icon { color: var(--accent); }

.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: grid; grid-template-columns: repeat(5, 1fr);
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface);
    border-top: 1px solid var(--line);
}
.tabbar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    height: var(--tabbar-h); font-size: 12px; font-weight: 500; color: var(--muted);
}
.tabbar a[aria-current="page"] { color: var(--accent); font-weight: 600; }
.tabbar a.primary { color: var(--text-2); }
.tabbar a.primary .fab {
    display: grid; place-items: center; width: 48px; height: 48px; margin-top: -20px;
    border-radius: 16px; background: var(--accent); color: var(--accent-ink);
    box-shadow: 0 6px 16px rgba(19, 117, 54, 0.35);
}

.sidebar { display: none; }

@media (min-width: 960px) {
    .topbar, .tabbar { display: none; }

    .sidebar {
        position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
        display: flex; flex-direction: column; gap: 28px; padding: 24px 16px 20px;
        background: var(--surface); border-right: 1px solid var(--line);
    }
    .sidebar .brand { padding: 0 10px; font-size: 20px; }

    .side-nav { display: grid; gap: 4px; }
    .side-nav a {
        display: flex; align-items: center; gap: 12px; padding: 12px 14px;
        border-radius: var(--radius-sm); color: var(--text-2); font-weight: 500;
    }
    .side-nav a:hover { background: var(--surface-2); color: var(--text); }
    .side-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

    .side-foot { margin-top: auto; display: grid; gap: 10px; }
    .side-user {
        display: flex; align-items: center; justify-content: space-between; gap: 8px;
        padding: 6px 4px 0 10px; font-size: 14px; color: var(--muted);
    }
    .side-user strong { display: block; color: var(--text); font-weight: 600; font-size: 15px; }

    .main { margin-left: var(--sidebar-w); padding: 36px 44px 72px; }
}

/* ---------- Cabeçalho de página ---------- */
.page-head {
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
    gap: 12px 16px; margin: 0 0 20px;
}
.page-head h1 { font-size: clamp(26px, 4.5vw, 32px); font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 15px; margin-bottom: 8px; font-weight: 500; }
.back:hover { color: var(--text); }

/* ---------- Botões ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 10px 18px;
    border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
    background: var(--surface); color: var(--text);
    font-weight: 600; font-size: 15px; cursor: pointer; white-space: nowrap;
    transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; color: var(--neg); border-color: var(--neg); }
.btn.danger:hover { background: var(--neg-soft); }
.btn.sm { min-height: 36px; padding: 6px 14px; font-size: 14px; }
.btn.block { width: 100%; }
.icon-btn {
    display: inline-grid; place-items: center; width: 44px; height: 44px;
    border-radius: 12px; border: 0; background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
form.inline { display: inline; margin: 0; }

/* Botão de tema: mostra a lua no tema claro e o sol no escuro. */
.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) .theme-toggle .sun { display: block; }
    :root:not([data-theme]) .theme-toggle .moon { display: none; }
}

/* ---------- Cards e blocos ---------- */
.card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: var(--pad); box-shadow: var(--shadow);
}
.card > .card-title {
    font-size: 17px; font-weight: 700; margin-bottom: 14px;
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.card-title a { font-size: 15px; font-weight: 600; color: var(--accent); }
.label { font-size: 14px; font-weight: 500; color: var(--muted); }

.stack { display: grid; gap: var(--gap); }
.stack > *, .cols-2 > *, .charts-grid > *, .form-layout > *, .kpis > * { min-width: 0; }
.cols-2 { display: grid; gap: var(--gap); grid-template-columns: 1fr; }
@media (min-width: 860px) {
    .cols-2 { grid-template-columns: 1fr 1fr; }
    .cols-2.wide-left { grid-template-columns: 1.15fr 1fr; }
}

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.section-head h2 { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.section-head a { font-size: 15px; font-weight: 600; color: var(--accent); }
.count {
    display: inline-block; min-width: 26px; padding: 1px 9px; border-radius: 99px;
    background: var(--surface-3); color: var(--text-2); font-size: 14px; font-weight: 600; text-align: center;
}

/* ---------- Números grandes (KPIs) ---------- */
.kpis { display: grid; gap: var(--gap); grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 900px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpis.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpis.three .kpi:last-child { grid-column: 1 / -1; }
@media (min-width: 900px) {
    .kpis.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .kpis.three .kpi:last-child { grid-column: auto; }
}

.kpi { padding: 20px; }
.kpi .label { display: block; }
.kpi .value { font-size: clamp(24px, 3.4vw, 32px); font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; margin-top: 8px; }
.kpi .sub { margin-top: 6px; color: var(--muted); font-size: 15px; }

/* Celular: cada número vira uma linha (rótulo à esquerda, valor à direita), sem estourar a tela. */
@media (max-width: 519px) {
    .kpis, .kpis.three { grid-template-columns: minmax(0, 1fr); gap: 10px; }
    .kpis.three .kpi:last-child { grid-column: auto; }
    .kpi {
        display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; align-items: center;
        padding: 14px 16px;
    }
    .kpi .label { grid-column: 1; grid-row: 1; }
    .kpi .sub { grid-column: 1; grid-row: 2; margin-top: 2px; font-size: 14px; }
    .kpi .value { grid-column: 2; grid-row: 1 / span 2; margin: 0; font-size: 24px; text-align: right; }
    .kpi .goal-mini { grid-column: 1 / -1; grid-row: 3; margin-top: 10px; }
}

/* ---------- Meta de lucro (barra dentro do cartão de lucro) ---------- */
.goal-mini { margin-top: 14px; display: grid; gap: 8px; font-size: 14px; color: var(--muted); }
.goal-mini strong { color: var(--accent); font-weight: 700; }
.goal-mini progress.bar { height: 8px; }
.goal-link { color: var(--accent); font-weight: 600; }
progress.bar {
    -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 12px;
    border: 0; border-radius: 99px; background: var(--track); overflow: hidden;
}
progress.bar::-webkit-progress-bar { background: var(--track); border-radius: 99px; }
progress.bar::-webkit-progress-value { background: var(--accent); border-radius: 99px; }
progress.bar::-moz-progress-bar { background: var(--accent); border-radius: 99px; }

/* ---------- Listas (estoque, vendas) ---------- */
.list { display: grid; }
.list-row {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 14px;
    padding: 14px 0; border-top: 1px solid var(--line);
}
.list > .list-row:first-child { border-top: 0; }
a.list-row:hover .who strong { color: var(--accent); }
.list-row .who { min-width: 0; }
.list-row .who strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-weight: 600; overflow-wrap: anywhere; }
.list-row .who small { color: var(--muted); font-size: 14px; }
.list-row .amt { text-align: right; font-weight: 700; white-space: nowrap; }
.list-row .amt small { display: block; font-weight: 500; font-size: 14px; color: var(--muted); }
.stock-row { grid-template-columns: minmax(0, 1fr) auto auto; }

.age {
    display: inline-block; padding: 3px 12px; border-radius: 99px;
    background: var(--surface-3); color: var(--text-2); font-size: 14px; font-weight: 600; white-space: nowrap;
}
.age.warn { background: var(--warn-soft); color: var(--warn); }
.age.old { background: var(--neg-soft); color: var(--neg); }

/* ---------- Pares nome / valor ---------- */
.rows { display: grid; }
.row {
    display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
    padding: 12px 0; border-top: 1px solid var(--line);
}
.rows > .row:first-child { border-top: 0; padding-top: 0; }
.row dt, .row .k { color: var(--text-2); }
.row dd, .row .v { margin: 0; font-weight: 600; text-align: right; }
.row.total .k { color: var(--text); font-weight: 700; }
.row.total .v { font-size: 20px; font-weight: 700; }
.row .note { display: block; color: var(--muted); font-weight: 400; font-size: 14px; }
.rows.tight .row { padding: 9px 0; }
.compare-title { margin: 28px 0 12px; }
.divider { height: 1px; background: var(--line-strong); margin: 8px 0; }

.compare-result {
    display: flex; justify-content: space-between; align-items: baseline;
    margin-top: 10px; padding: 14px 16px; background: var(--surface-2); border-radius: var(--radius-sm);
}
.compare-result .k { font-weight: 600; }
.compare-result .v { font-size: 20px; font-weight: 700; }
.disclaimer { margin-top: 12px; font-size: 14px; color: var(--muted); }

/* A conta do lucro: recebido − custo = bruto − custos = líquido */
.bridge { display: grid; }
.bridge .line {
    display: grid; grid-template-columns: 24px 1fr auto; gap: 12px; align-items: baseline;
    padding: 14px 0; border-top: 1px solid var(--line);
}
.bridge .line:first-child { border-top: 0; padding-top: 0; }
.bridge .sym { color: var(--muted); font-weight: 700; text-align: center; font-size: 18px; }
.bridge .name { color: var(--text-2); }
.bridge .name small { display: block; margin-top: 2px; color: var(--muted); font-size: 14px; }
.bridge .amount { font-weight: 700; text-align: right; white-space: nowrap; }
.bridge .line.result { border-top: 1px solid var(--line-strong); }
.bridge .line.result .name { color: var(--text); font-weight: 700; }
.bridge .line.result .sym { color: var(--accent); }
.bridge .line.total { margin-top: 8px; padding: 18px 16px; background: var(--surface-2); border: 0; border-radius: var(--radius-sm); }
.bridge .line.total .amount { font-size: 24px; letter-spacing: -0.02em; }

/* ---------- Selos e filtros ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px; border-radius: 99px;
    font-size: 14px; font-weight: 600; background: var(--surface-3); color: var(--text-2);
}
.badge.sold { background: var(--accent-soft); color: var(--pos); }
.badge.in_stock { background: var(--info-soft); color: var(--info); }
.badge.cancelled { background: var(--surface-3); color: var(--muted); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
    display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 16px; border-radius: 99px;
    border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-2);
    font-size: 15px; font-weight: 500; white-space: nowrap;
}
.chip:hover { background: var(--surface-2); }
.chip .count { min-width: 0; padding: 0 8px; background: transparent; color: var(--muted); font-weight: 600; }
.chip[aria-current="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip[aria-current="true"] .count { color: inherit; opacity: 0.85; }

.segmented { display: inline-flex; padding: 4px; gap: 2px; background: var(--surface-3); border-radius: 12px; }
.segmented a { white-space: nowrap; padding: 8px 16px; border-radius: 9px; font-size: 15px; font-weight: 500; color: var(--text-2); }
.segmented a[aria-current="page"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }

/* ---------- Formulários ---------- */
.form { display: grid; gap: var(--gap); }
.form-layout { display: grid; gap: var(--gap); }
@media (min-width: 1000px) {
    .form-layout { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
    .preview { position: sticky; top: 24px; }
}

.fields { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 640px) {
    .fields.two { grid-template-columns: 1fr 1fr; }
    .fields.three { grid-template-columns: repeat(3, 1fr); }
    .fields .span-2 { grid-column: span 2; }
}
.field { display: grid; gap: 6px; align-content: start; min-width: 0; }
.field > label, .field > .lbl { font-size: 15px; font-weight: 600; color: var(--text); }
.field .hint { font-size: 14px; color: var(--muted); }
.field .err { font-size: 14px; color: var(--neg); font-weight: 500; }
.field.has-error .input { border-color: var(--neg); }

.input {
    width: 100%; min-width: 0; min-height: 48px; padding: 11px 14px;
    background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.input:hover { border-color: var(--muted); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { min-height: 88px; resize: vertical; }
select.input {
    -webkit-appearance: none; appearance: none; padding-right: 40px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23788396' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center;
}

.money-input { position: relative; }
.money-input .prefix {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    color: var(--muted); font-size: 15px; pointer-events: none;
}
.money-input .input { padding-left: 46px; }

.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.check .t { font-weight: 600; }
.check .d { color: var(--muted); font-size: 14px; }

.radio-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.radio-cards.two-cols { grid-template-columns: repeat(2, 1fr); }
.radio-cards label {
    display: flex; align-items: center; justify-content: center; gap: 8px; text-align: center;
    padding: 11px 8px; min-height: 48px;
    border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
    font-weight: 600; color: var(--text-2); background: var(--surface); cursor: pointer;
}
.radio-cards label:hover { background: var(--surface-2); }
.radio-cards input { position: absolute; opacity: 0; pointer-events: none; }
.radio-cards label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.radio-cards label:has(input:focus-visible) { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }

.section-title { font-size: 18px; font-weight: 700; margin-bottom: 14px; letter-spacing: -0.01em; }
.section-sub { color: var(--muted); font-size: 15px; margin: -8px 0 14px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

details.collapse > summary { list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; cursor: pointer; }
details.collapse > summary::-webkit-details-marker { display: none; }
details.collapse > summary .chev { color: var(--muted); transition: transform 0.15s; }
details.collapse[open] > summary .chev { transform: rotate(180deg); }
details.collapse .collapse-body { margin-top: 16px; }

/* ---------- Avisos ---------- */
.flash {
    display: flex; align-items: center; gap: 10px; padding: 14px 18px; margin-bottom: 16px;
    border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--line-strong); font-weight: 500;
}
.flash.success { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.flash.error { background: var(--neg-soft); border-color: var(--neg); color: var(--neg); }
.alert-error {
    margin-bottom: 16px; padding: 14px 18px; border-radius: var(--radius-sm);
    border: 1px solid var(--neg); background: var(--neg-soft); color: var(--neg); font-weight: 500;
}

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left; font-size: 14px; font-weight: 600; color: var(--muted);
    padding: 14px 16px; border-bottom: 1px solid var(--line-strong); white-space: nowrap;
}
.table td { padding: 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .product { font-weight: 600; display: block; }
.table .product:hover { color: var(--accent); }
.table .cat { color: var(--muted); font-size: 14px; }
body.compact .table td { padding: 10px 16px; }

/* Tabela no computador, cards no celular. */
.list-cards { display: grid; gap: 12px; grid-template-columns: 1fr; }
.table-wrap.desktop { display: none; }
@media (min-width: 900px) {
    .table-wrap.desktop { display: block; }
    .list-cards { display: none; }
}

.op-card { display: grid; gap: 12px; padding: 18px; }
.op-card:hover { border-color: var(--line-strong); }
.op-card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.op-card-head .name { font-weight: 700; font-size: 17px; }
.op-card-head .meta { color: var(--muted); font-size: 14px; margin-top: 2px; }
.op-card-profit { text-align: right; font-weight: 700; font-size: 18px; white-space: nowrap; }
.op-card-profit small { display: block; font-size: 14px; font-weight: 600; }
.op-card-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.op-card-grid .k { color: var(--muted); font-size: 14px; }
.op-card-grid .v { font-weight: 600; }

.filters { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; align-items: end; margin-bottom: 16px; }
.filters .field.grow { grid-column: 1 / -1; }
@media (min-width: 800px) {
    .filters { grid-template-columns: minmax(180px, 1.4fr) 1fr 1fr auto; }
    .filters .field.grow { grid-column: auto; }
}

/* ---------- Linha do tempo ---------- */
.timeline { display: grid; gap: 28px; }
.tl-month h2 { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; font-size: 18px; font-weight: 700; margin-bottom: 12px; }
.tl-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.tl-item { position: relative; display: grid; grid-template-columns: 22px 1fr; gap: 10px; }
.tl-item::before { content: ""; position: absolute; left: 4.5px; top: 24px; bottom: -14px; width: 2px; background: var(--line); }
.tl-item:last-child::before { display: none; }
.dot { width: 11px; height: 11px; border-radius: 50%; margin-top: 9px; background: var(--muted); box-shadow: 0 0 0 4px var(--bg); position: relative; z-index: 1; }
.dot.pos { background: var(--pos); }
.dot.neg { background: var(--neg); }
.tl-card { display: block; padding: 16px 18px; }
.tl-card:hover { border-color: var(--line-strong); }
.tl-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.tl-head .name { font-weight: 700; }
.tl-head .profit { font-weight: 700; white-space: nowrap; }
.tl-meta { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 6px; color: var(--muted); }
.tl-meta b { color: var(--text-2); font-weight: 600; }

/* ---------- Gráficos ---------- */
.charts-grid { display: grid; gap: var(--gap); grid-template-columns: 1fr; }
@media (min-width: 1000px) { .charts-grid { grid-template-columns: 1fr 1fr; } }
.charts-group { margin: 28px 0 12px; font-size: 20px; font-weight: 700; }
.charts-group:first-of-type { margin-top: 0; }
.chart-card .chart-sub { color: var(--muted); font-size: 15px; margin: -8px 0 14px; }

.chart { width: 100%; }
.chart-plot { outline-offset: 6px; }
.chart-canvas { position: relative; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--muted); font-size: 12px; font-family: var(--font); }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .zero-line { stroke: var(--line-strong); stroke-width: 1; }
.chart .series-line { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .series-area { stroke: none; opacity: 0.12; }
.chart .end-dot { stroke: var(--surface); stroke-width: 2; }
.chart .crosshair { stroke: var(--line-strong); stroke-width: 1; }
.chart .bar { transition: opacity 0.12s; }
.chart .bar.dim { opacity: 0.5; }
.chart .value-label { fill: var(--text); font-size: 13px; font-weight: 600; }
.chart .cat-label { fill: var(--text-2); font-size: 14px; }
.chart .hit { fill: transparent; }

.chart-tip {
    position: absolute; z-index: 5; pointer-events: none; min-width: 160px; max-width: 280px;
    padding: 10px 14px; background: var(--surface); border: 1px solid var(--line-strong);
    border-radius: 12px; box-shadow: var(--shadow-pop); font-size: 14px; opacity: 0; transition: opacity 0.1s;
}
.chart-tip.on { opacity: 1; }
.chart-tip .tip-title { color: var(--muted); margin-bottom: 6px; }
.chart-tip .tip-row { display: flex; align-items: center; gap: 12px; justify-content: space-between; margin-top: 3px; }
.chart-tip .tip-key { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); }
.chart-tip .tip-key i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; }
.chart-tip .tip-val { color: var(--text); font-weight: 700; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 10px; font-size: 15px; color: var(--text-2); }
.legend .key { display: inline-flex; align-items: center; gap: 8px; }
.legend .key i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; }
.legend .key.sw i { height: 11px; width: 11px; border-radius: 3px; }

details.data-table { margin-top: 14px; }
details.data-table summary { cursor: pointer; font-size: 15px; color: var(--muted); font-weight: 500; }
details.data-table summary:hover { color: var(--text); }
details.data-table .table-wrap { margin-top: 10px; max-height: 260px; overflow: auto; }

.empty {
    text-align: center; padding: 48px 20px; color: var(--muted);
    border: 2px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface);
}
.empty h2 { color: var(--text); font-size: 20px; margin-bottom: 6px; }
.empty .btn { margin-top: 18px; }

/* ---------- Menu "Mais" (celular) ---------- */
.menu-list { display: grid; padding: 4px 20px; }
.menu-list a, .menu-list button {
    display: flex; align-items: center; gap: 14px; width: 100%; padding: 16px 0;
    background: none; border: 0; border-top: 1px solid var(--line); cursor: pointer; text-align: left; font-weight: 500;
}
.menu-list > :first-child { border-top: 0; }
.menu-list .icon { color: var(--muted); }
.menu-list .go { margin-left: auto; color: var(--muted); }

/* ---------- Login ---------- */
.auth-shell { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 28px; text-align: center; }
.auth-brand .mark {
    display: grid; place-items: center; width: 60px; height: 60px; border-radius: 18px;
    background: var(--surface); border: 1px solid var(--line-strong); color: var(--accent);
}
.auth-brand h1 { font-size: 28px; letter-spacing: -0.02em; }
.auth-brand p { color: var(--muted); }

.settings-section { scroll-margin-top: 20px; }
.notes { white-space: normal; color: var(--text-2); }
.notes + .notes { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
code, .code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.9em; background: var(--surface-3); padding: 2px 6px; border-radius: 6px;
}
.code-block {
    text-align: left; white-space: pre-wrap; margin: 16px 0 0; padding: 12px;
    font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    background: var(--surface-2); border-radius: 10px; overflow-x: auto;
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

@media print {
    .sidebar, .topbar, .tabbar, .page-actions, .btn { display: none !important; }
    .main { margin: 0; padding: 0; }
}

/* ---------- Trocas e Briks ---------- */
.movement-type { margin-bottom: 16px; }
.card-link { margin: 12px 0 0; font-size: 15px; }
.card-link a { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-weight: 600; }
.notice { margin: 0; padding: 12px 16px; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--text); }
.op-card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
a.badge:hover { color: var(--accent); }
.page-actions .segmented + .btn { margin-left: 4px; }

.out-list { display: grid; gap: 8px; }
.out-item {
    display: grid; gap: 12px; align-items: center; padding: 12px 14px;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.out-item.on { border-color: var(--accent); background: var(--accent-soft); }
.out-item.has-error { border-color: var(--neg); }
.out-item .field label { font-size: 14px; }
.out-item .err { font-size: 14px; color: var(--neg); font-weight: 500; }
@media (min-width: 720px) {
    .out-item { grid-template-columns: 1fr 200px; }
}
.in-row { padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.in-row:last-child { border-bottom: 0; padding-bottom: 0; }
.in-row [data-remove-in] { margin-top: 8px; }
.cash-amount { margin-top: 16px; }
.preview h3.label { margin: 8px 0 4px; }

.brik-steps { list-style: none; margin: 0; padding: 0; display: grid; }
.brik-step { position: relative; padding: 14px 0 14px 22px; border-top: 1px solid var(--line); }
.brik-step:first-child { border-top: 0; padding-top: 0; }
.brik-step::before {
    content: ""; position: absolute; left: 0; top: 20px; width: 10px; height: 10px; border-radius: 50%;
    background: var(--series-2);
}
.brik-step:first-child::before { top: 6px; }
.brik-step.trade::before { background: var(--warn); }
.brik-step.sale::before { background: var(--series-1); }
.brik-step.stock::before { background: var(--muted); }
.brik-step p { margin: 4px 0; }
.brik-step .step-head { display: flex; justify-content: space-between; gap: 12px; }
.brik-step .step-kind { font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-2); }
.brik-step .step-total { margin-top: 8px; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); display: flex; justify-content: space-between; gap: 12px; }
.story { display: grid; gap: 6px; }
.story p { margin: 0; line-height: 1.45; }
.story p:last-child { font-weight: 600; }
.origin { margin: 12px 0 0; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); }
.origin .story p:last-child { font-weight: 500; }
.chain { margin: 0; line-height: 1.6; font-size: 16px; }
.chain strong { white-space: nowrap; }
.trade-link { display: flex; align-items: center; gap: 4px; color: var(--text-2); }
.trade-link .icon { flex: none; color: var(--muted); }
