/* =============================================================
   RABBS — painel administrativo. Mobile-first: bottom nav e
   cards no celular; sidebar e tabelas a partir de 1024px.
   ============================================================= */

:root {
    --color-bg: #0b1220;
    --color-surface: #141f36;
    --color-surface-2: #1a2743;
    --color-border: #263553;

    --color-primary: #2f6dff;
    --color-primary-dark: #1f52cc;
    --color-accent: #23d5a0;
    --color-whatsapp: #25d366;

    --color-text: #eef3ff;
    --color-text-muted: #9fadc7;
    --color-danger: #ff6b6b;
    --color-warning: #ffb547;

    --radius: 14px;
    --radius-sm: 10px;
    --tap: 44px;
    --bottom-nav-h: 62px;
    --sidebar-w: 240px;

    --space-xs: .5rem;
    --space-sm: .875rem;
    --space-md: 1.25rem;
    --space-lg: 2rem;

    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --shadow: 0 12px 32px rgba(3, 8, 20, .45);
}

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

body {
    margin: 0;
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.55;
    color: var(--color-text);
    background: var(--color-bg);
    overflow-x: hidden;
}

img, svg { max-width: 100%; height: auto; display: block; }
a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 var(--space-xs); letter-spacing: -.01em; }
p { margin: 0 0 var(--space-sm); }
ul, ol { margin: 0; padding: 0; list-style: none; }
dl, dd { margin: 0; }

:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 2px; border-radius: 4px; }

.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ------------------------------------------------------------- Botões */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    min-height: var(--tap);
    padding: .6rem 1.1rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font: inherit;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: background-color .18s ease, border-color .18s ease;
}
.btn:hover { text-decoration: none; }

.btn--primary { background: var(--color-primary); color: #fff; }
.btn--primary:hover { background: var(--color-primary-dark); }

.btn--ghost { background: transparent; color: var(--color-text); border-color: var(--color-border); }
.btn--ghost:hover { border-color: var(--color-accent); color: var(--color-accent); }

.btn--danger { background: transparent; color: var(--color-danger); border-color: var(--color-danger); }
.btn--danger:hover { background: rgba(255, 107, 107, .12); }
.btn--danger-text { color: var(--color-danger); }

.btn--whatsapp { background: var(--color-whatsapp); color: #04210f; }
.btn--whatsapp:hover { background: #1fbb59; }

/* No celular todo alvo de toque respeita 44px; a densidade menor só entra no
   desktop, onde existe mouse (ver media query >=1024px). */
.btn--sm { min-height: var(--tap); padding: .35rem .75rem; font-size: .875rem; }
.btn--lg { min-height: 52px; font-size: 1.0625rem; }
.btn--block { width: 100%; }

/* --------------------------------------------------------------- Login */

.auth-body {
    display: grid;
    place-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: var(--space-md);
    background:
        radial-gradient(900px 400px at 50% -5%, rgba(47, 109, 255, .3), transparent 70%),
        var(--color-bg);
}

.auth { width: 100%; max-width: 400px; }

.auth__card {
    padding: var(--space-lg) var(--space-md);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.auth__logo {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: var(--space-md);
    color: var(--color-accent);
    font-weight: 800;
    font-size: 1.25rem;
}
.auth__logo:hover { text-decoration: none; }

.auth__title { font-size: 1.5rem; }
.auth__subtitle { color: var(--color-text-muted); font-size: .9375rem; margin-bottom: var(--space-md); }
.auth__back { margin-top: var(--space-md); text-align: center; font-size: .9375rem; }
/* Só aparece quando o navegador oferece instalação (o JS remove o hidden). */
.auth__install { margin-top: var(--space-md); }
.auth__install[hidden] { display: none; }

/* ---------------------------------------------------------- Layout base */

.admin-body {
    padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
}

.sidebar { display: none; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    min-height: 56px;
    padding: var(--space-xs) var(--space-md);
    background: rgba(11, 18, 32, .95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--color-border);
}
.topbar__title { margin: 0; font-size: 1.125rem; }
/* No celular a criação é o FAB; este botão só aparece quando o FAB some. */
.topbar__action { display: none; }

.admin-content {
    padding: var(--space-md);
    /* Folga extra no fim para o botão flutuante não cobrir o último registro. */
    padding-bottom: calc(var(--space-md) + 72px);
    max-width: 1200px;
    margin-inline: auto;
}

/* --------------------------------------------------------------- Flash */

.flash {
    margin: 0 0 var(--space-sm);
    padding: .75rem 1rem;
    border-radius: var(--radius-sm);
    border-left: 4px solid;
    font-weight: 500;
    font-size: .9375rem;
}
.flash--success { background: rgba(35, 213, 160, .12); border-color: var(--color-accent); }
.flash--error { background: rgba(255, 107, 107, .12); border-color: var(--color-danger); }

/* ---------------------------------------------------------- Bottom nav */

.bottom-nav {
    position: fixed;
    inset: auto 0 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
}

.bottom-nav__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: var(--tap);
    padding: 0;
    background: none;
    border: none;
    color: var(--color-text-muted);
    font: inherit;
    font-size: .6875rem;
    font-weight: 600;
    cursor: pointer;
}
.bottom-nav__item:hover { text-decoration: none; color: var(--color-text); }
.bottom-nav__item.is-active { color: var(--color-accent); }

/* --------------------------------------------------- Bottom sheet "Mais" */

/* overflow:hidden contém o translateY(100%) do painel durante a abertura. */
.more-sheet { position: fixed; inset: 0; z-index: 60; overflow: hidden; }
.more-sheet[hidden] { display: none; }

.more-sheet__backdrop { position: absolute; inset: 0; background: rgba(3, 8, 20, .6); }

.more-sheet__panel {
    position: absolute;
    inset: auto 0 0;
    padding: var(--space-sm) var(--space-md) calc(var(--space-lg) + env(safe-area-inset-bottom, 0px));
    background: var(--color-surface);
    border-radius: var(--radius) var(--radius) 0 0;
    border-top: 1px solid var(--color-border);
    animation: sheet-up .2s ease;
}

@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }

.more-sheet__grip {
    display: block;
    width: 40px; height: 4px;
    margin: 0 auto var(--space-sm);
    background: var(--color-border);
    border-radius: 2px;
}

.more-sheet__link {
    display: flex;
    align-items: center;
    gap: .75rem;
    width: 100%;
    min-height: var(--tap);
    padding: .6rem 0;
    background: none;
    border: none;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
    font: inherit;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}
.more-sheet__link:hover { text-decoration: none; color: var(--color-accent); }
.more-sheet__link--danger { color: var(--color-danger); border-bottom: none; }

/* -------------------------------------------------------------- Stats */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-xs);
    margin-bottom: var(--space-md);
}

.stat {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    padding: var(--space-sm);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-border);
    border-radius: var(--radius-sm);
}
.stat__label { color: var(--color-text-muted); font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
/* nowrap: um valor monetário nunca deve quebrar em "R$" / "1.500,00". */
.stat__value { font-size: 1.0625rem; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; }
.stat__link { font-size: .8125rem; margin-top: .15rem; }

.stat--income, .stat--positive { border-left-color: var(--color-accent); }
.stat--income .stat__value, .stat--positive .stat__value { color: var(--color-accent); }
.stat--expense, .stat--negative { border-left-color: var(--color-danger); }
.stat--expense .stat__value, .stat--negative .stat__value { color: var(--color-danger); }
.stat--pending { border-left-color: var(--color-primary); }
.stat--overdue { border-left-color: var(--color-warning); }
.stat--overdue .stat__value { color: var(--color-warning); }
.stat--leads { border-left-color: var(--color-primary); }

/* -------------------------------------------------------------- Painéis */

.panel {
    margin-bottom: var(--space-md);
    padding: var(--space-md);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-xs);
    margin-bottom: var(--space-sm);
}
.panel__title { font-size: 1.0625rem; margin: 0; }
.panel__action { font-size: .875rem; font-weight: 600; }
.panel__hint { color: var(--color-text-muted); font-size: .875rem; }
.panel__footer { margin-top: var(--space-sm); }

.empty {
    padding: var(--space-md);
    color: var(--color-text-muted);
    text-align: center;
    background: var(--color-surface);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-sm);
}

.result-count { color: var(--color-text-muted); font-size: .875rem; }

/* --------------------------------------------------------- Listas/cards */

.record-list { display: flex; flex-direction: column; }

.record {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-xs) var(--space-sm);
    padding: .7rem 0;
    border-bottom: 1px solid var(--color-border);
}
.record:last-child { border-bottom: none; }
.record__main { display: flex; flex-direction: column; min-width: 0; }
.record__title { font-weight: 600; font-size: .9375rem; overflow-wrap: anywhere; }
.record__meta { color: var(--color-text-muted); font-size: .8125rem; }

/* No celular o campo editável ocupa a linha inteira: espremido entre dois
   botões ele fica com ~130px e trunca o nome da categoria. */
.record__inline-form { display: flex; gap: .35rem; align-items: center; flex: 1 1 100%; min-width: 0; }
.record__inline-form .field__input { flex: 1; min-width: 0; }
/* Ação destrutiva sozinha na 2ª linha: alinhada à direita, sob o "Salvar". */
.record > form:last-child:not(.record__inline-form) { margin-left: auto; }

.card-list { display: grid; gap: var(--space-xs); }

.data-card {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: start;
    gap: .35rem var(--space-sm);
    padding: var(--space-sm);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}
/* O badge ocupa a coluna estreita da 1ª linha; sem isto ele é auto-posicionado
   na coluna 1fr de uma linha nova e vira uma barra de largura total. */
.data-card > .badge { grid-column: 2; grid-row: 1; justify-self: end; }
.data-card__link { display: flex; flex-direction: column; min-width: 0; color: inherit; }
.data-card__link:hover { text-decoration: none; color: var(--color-accent); }
.data-card__title { font-weight: 700; font-size: .9375rem; overflow-wrap: anywhere; }
.data-card__subtitle { color: var(--color-text-muted); font-size: .8125rem; }
.data-card__body { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .35rem var(--space-sm); }
.data-card__meta { color: var(--color-text-muted); font-size: .8125rem; }
.data-card__amount { font-weight: 700; }
.data-card__message {
    grid-column: 1 / -1;
    margin: .25rem 0 0;
    padding: .5rem .7rem;
    background: var(--color-surface-2);
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    font-size: .875rem;
}
.data-card__actions {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem;
    margin-top: .35rem;
}
/* Botões nunca encolhem; o formulário de status ganha a própria linha para o
   select não colapsar até virar só a setinha. */
.data-card__actions > * { flex: 0 0 auto; }
.data-card__actions .record__inline-form { flex: 1 1 100%; }

.amount { font-weight: 700; white-space: nowrap; }
.amount--in { color: var(--color-accent); }
.amount--out { color: var(--color-danger); }

/* -------------------------------------------------------------- Badges */

.badge {
    display: inline-flex;
    align-items: center;
    padding: .2rem .6rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 700;
    white-space: nowrap;
}
.badge--active, .badge--paid, .badge--lead-won,
.badge--rec-active { background: rgba(35, 213, 160, .16); color: var(--color-accent); }
.badge--pending, .badge--lead-contacted { background: rgba(47, 109, 255, .18); color: #8db0ff; }
.badge--overdue, .badge--lead-new,
.badge--rec-paused { background: rgba(255, 181, 71, .16); color: var(--color-warning); }
/* Parcial: recebido em parte, ainda com saldo — nem pago, nem intocado. */
.badge--partial { background: rgba(167, 139, 250, .18); color: #c4b5fd; }
.badge--canceled, .badge--inactive, .badge--lead-lost,
.badge--rec-ended { background: rgba(159, 173, 199, .14); color: var(--color-text-muted); }

/* ------------------------------------------------------ Fluxo de caixa */

.flow--current { border-color: var(--color-primary); }

.flow__bars { flex-direction: column; gap: .35rem; width: 100%; }

.flow__row { display: grid; grid-template-columns: 62px 1fr auto; align-items: center; gap: .5rem; }
.flow__legend { color: var(--color-text-muted); font-size: .75rem; }
.flow__value { font-size: .8125rem; font-weight: 600; white-space: nowrap; }

.flow__track {
    display: flex;
    height: 10px;
    background: var(--color-bg);
    border-radius: 999px;
    overflow: hidden;
}
.flow__bar { display: block; height: 100%; }
.flow__bar--received { background: var(--color-accent); }
/* Previsto: hachurado, para distinguir do que já entrou de fato. */
.flow__bar--expected {
    background: repeating-linear-gradient(
        45deg,
        rgba(35, 213, 160, .45),
        rgba(35, 213, 160, .45) 4px,
        rgba(35, 213, 160, .18) 4px,
        rgba(35, 213, 160, .18) 8px
    );
}
.flow__bar--expense { background: var(--color-danger); }
/* A pagar: previsto de saída, hachurado como o previsto de entrada. */
.flow__bar--due {
    background: repeating-linear-gradient(
        45deg,
        rgba(255, 107, 107, .5),
        rgba(255, 107, 107, .5) 4px,
        rgba(255, 107, 107, .2) 4px,
        rgba(255, 107, 107, .2) 8px
    );
}

.text-positive { color: var(--color-accent); }
.text-danger { color: var(--color-danger); }

.table tbody tr.is-current { background: rgba(47, 109, 255, .1); }
.table tfoot th, .table tfoot td {
    padding: .7rem var(--space-sm);
    border-top: 2px solid var(--color-border);
    font-weight: 700;
}

/* Barra de progresso do recebimento parcial */
.progress {
    height: 8px;
    margin-top: var(--space-sm);
    background: var(--color-bg);
    border-radius: 999px;
    overflow: hidden;
}
.progress__bar { display: block; height: 100%; background: var(--color-accent); border-radius: 999px; }

/* --------------------------------------------------------------- Abas */

.tabs {
    display: flex;
    gap: .25rem;
    margin-bottom: var(--space-md);
    overflow-x: auto;
    border-bottom: 1px solid var(--color-border);
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tabs__item {
    display: inline-flex;
    align-items: center;
    min-height: var(--tap);
    padding: 0 var(--space-sm);
    border-bottom: 2px solid transparent;
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: .9375rem;
    white-space: nowrap;
}
.tabs__item:hover { text-decoration: none; color: var(--color-text); }
.tabs__item.is-active { color: var(--color-accent); border-bottom-color: var(--color-accent); }

/* ------------------------------------------------------- Detalhamentos */

.detail-list { display: grid; gap: .7rem; }
.detail-list > div { display: flex; justify-content: space-between; gap: var(--space-sm); }
/* O rótulo cede espaço; o valor é que precisa caber inteiro. */
.detail-list dt { color: var(--color-text-muted); font-size: .875rem; flex: 1 1 auto; min-width: 0; }
.detail-list dd { flex: 0 1 auto; text-align: right; font-weight: 600; overflow-wrap: break-word; }
.detail-list__amount { font-size: 1.125rem; color: var(--color-accent); }
.detail-list__wide { flex-direction: column; }
.detail-list__wide dd { text-align: left; font-weight: 400; }

/* ------------------------------------------------------------ Formulários */

.form { margin: 0; }
.form--stacked .field { margin-bottom: var(--space-md); }
.form--inline { display: flex; flex-wrap: wrap; gap: var(--space-xs); align-items: flex-end; }
.form--inline .field { flex: 1 1 160px; margin: 0; }

.field { margin-bottom: var(--space-md); }
.field__label { display: block; margin-bottom: .3rem; font-size: .875rem; font-weight: 600; }

.field__input {
    width: 100%;
    min-height: var(--tap);
    padding: .6rem .8rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font: inherit;
    /* 16px evita o zoom automático do iOS ao focar o campo */
    font-size: 1rem;
}
.field__input:focus { border-color: var(--color-primary); }
.field__input--textarea { min-height: 96px; resize: vertical; }
.field__input[type="file"] { padding: .55rem; }

.field__hint { display: block; margin-top: .25rem; color: var(--color-text-muted); font-size: .8125rem; }
.field__error { display: block; margin-top: .25rem; color: var(--color-danger); font-size: .8125rem; }

.form__actions { display: grid; gap: var(--space-xs); }

.toggle-group { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem; }
.toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: var(--tap);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
}
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle.is-active { border-color: var(--color-primary); background: rgba(47, 109, 255, .16); }
.toggle:has(input:focus-visible) { outline: 3px solid var(--color-accent); outline-offset: 2px; }

fieldset { margin: 0 0 var(--space-md); padding: 0; border: none; }
legend { padding: 0; }

/* Escolhas de rádio empilhadas, com alvo de toque inteiro clicável. */
.choice {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    min-height: var(--tap);
    padding: .6rem .75rem;
    margin-bottom: .35rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: .9375rem;
    cursor: pointer;
}
.choice:hover { border-color: var(--color-primary); }
.choice input { margin: .2rem 0 0; flex-shrink: 0; accent-color: var(--color-primary); }
.choice:has(input:checked) { border-color: var(--color-primary); background: rgba(47, 109, 255, .12); }
.choice:has(input:focus-visible) { outline: 3px solid var(--color-accent); outline-offset: 2px; }

/* ------------------------------------------------------------- Filtros */

.filters { margin-bottom: var(--space-md); }
.filters__row { display: grid; gap: var(--space-xs); margin-bottom: var(--space-xs); }
.filters__more { margin-bottom: var(--space-xs); }
.filters__more summary {
    display: flex;
    align-items: center;
    min-height: var(--tap);
    color: var(--color-text-muted);
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
}

.month-picker { display: grid; grid-template-columns: 2fr 1fr; gap: var(--space-xs); margin-bottom: var(--space-md); }

/* -------------------------------------------------------------- Tabelas */

/* A tabela existe apenas no desktop; no mobile os dados vêm em cards. */
.table-wrap { display: none; }

/* ------------------------------------------------------------- Perigo */

.danger-zone {
    margin-top: var(--space-lg);
    padding: var(--space-md);
    background: rgba(255, 107, 107, .06);
    border: 1px solid rgba(255, 107, 107, .3);
    border-radius: var(--radius);
    display: grid;
    gap: var(--space-xs);
}
.danger-zone__title { font-size: 1rem; color: var(--color-danger); }
.danger-zone__text { color: var(--color-text-muted); font-size: .875rem; margin: 0; }

/* ---------------------------------------------------------------- FAB */

.fab {
    position: fixed;
    right: var(--space-md);
    bottom: calc(var(--bottom-nav-h) + var(--space-md) + env(safe-area-inset-bottom, 0px));
    z-index: 25;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    box-shadow: var(--shadow);
}
.fab:hover { background: var(--color-primary-dark); text-decoration: none; }

/* ============================================== Tablet — >= 768px */

@media (min-width: 768px) {
    .stat-grid { grid-template-columns: repeat(3, 1fr); gap: var(--space-sm); }
    .stat-grid--compact { grid-template-columns: repeat(3, 1fr); }
    .stat__value { font-size: 1.25rem; }

    .record__inline-form { flex: 1 1 auto; }
    .data-card__actions .record__inline-form { flex: 0 1 auto; }

    /* Campos de filtro param de crescer: esticados até 1440px ficam absurdos. */
    .filters__row { grid-template-columns: repeat(auto-fit, minmax(180px, 260px)); }
    .filters .btn--block { width: auto; min-width: 200px; }
    .month-picker { grid-template-columns: 240px 120px; }
    .form__actions { grid-template-columns: 1fr auto; }
    .form__actions .btn--block { width: auto; min-width: 160px; }
    .admin-content { padding: var(--space-lg) var(--space-md); }
    .detail-list { grid-template-columns: repeat(2, 1fr); gap: var(--space-sm) var(--space-lg); }
    .detail-list__wide { grid-column: 1 / -1; }
}

/* ============================================= Desktop — >= 1024px */

@media (min-width: 1024px) {
    .admin-body { padding-bottom: 0; padding-left: var(--sidebar-w); }
    .admin-content { padding-bottom: var(--space-lg); }

    /* No desktop a criação sai do FAB e vai para o botão da topbar. */
    .bottom-nav, .more-sheet, .fab { display: none; }
    .topbar__action { display: inline-flex; }
    .btn--sm { min-height: 36px; }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 40;
        display: flex;
        flex-direction: column;
        width: var(--sidebar-w);
        padding: var(--space-md);
        background: var(--color-surface);
        border-right: 1px solid var(--color-border);
    }

    .sidebar__logo {
        display: flex;
        align-items: center;
        gap: .5rem;
        margin-bottom: var(--space-lg);
        color: var(--color-accent);
        font-weight: 800;
        font-size: 1.25rem;
    }
    .sidebar__logo:hover { text-decoration: none; }

    .sidebar__nav { display: flex; flex-direction: column; gap: .15rem; }
    .sidebar__link {
        display: flex;
        align-items: center;
        gap: .65rem;
        min-height: var(--tap);
        padding: 0 .7rem;
        border-radius: var(--radius-sm);
        color: var(--color-text-muted);
        font-weight: 600;
        font-size: .9375rem;
    }
    .sidebar__link:hover { text-decoration: none; background: var(--color-surface-2); color: var(--color-text); }
    .sidebar__link.is-active { background: rgba(47, 109, 255, .18); color: var(--color-accent); }

    .sidebar__logout { margin-top: auto; }

    .topbar { padding: var(--space-sm) var(--space-lg); }
    .topbar__title { font-size: 1.375rem; }
    .admin-content { padding: var(--space-lg); }

    .stat-grid--compact { grid-template-columns: repeat(3, 1fr); }
}

/* ============================================ Desktop largo — >= 1200px */

/* A tabela só substitui os cards quando sobra largura real: entre 1024 e 1199
   a sidebar come 240px e as colunas ficam espremidas a ponto de cortar ações. */
@media (min-width: 1200px) {
    /* Só somem os cards que TÊM uma tabela para substituí-los. O padrão é
       permanecer visível: esquecer o modificador duplica informação, enquanto
       o contrário faria a tela inteira desaparecer no desktop. */
    .card-list--mobile-only { display: none; }
    .table-wrap {
        display: block;
        overflow-x: auto;
        background: var(--color-surface);
        border: 1px solid var(--color-border);
        border-radius: var(--radius);
        /* Ancora os .sr-only das células: sem isto eles se posicionam contra o
           viewport e esticam a página quando a tabela é mais larga que a tela. */
        position: relative;
    }

    .table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
    .table th, .table td { padding: .7rem var(--space-sm); text-align: left; }
    .table thead th {
        color: var(--color-text-muted);
        font-size: .75rem;
        text-transform: uppercase;
        letter-spacing: .06em;
        border-bottom: 1px solid var(--color-border);
        white-space: nowrap;
    }
    .table tbody tr { border-bottom: 1px solid var(--color-border); }
    .table tbody tr:last-child { border-bottom: none; }
    .table tbody tr:hover { background: var(--color-surface-2); }
    .table th[scope="row"] { font-weight: 600; }
    /* Textos longos quebram; valores, datas e ações nunca. */
    .table td, .table th[scope="row"] { overflow-wrap: anywhere; }
    .table__right { text-align: right; white-space: nowrap; }
    .table__actions { text-align: right; white-space: nowrap; }
}

/* ============================================ Telas grandes — >= 1400px */

@media (min-width: 1400px) {
    /* Só aqui cabem os 6 indicadores lado a lado sem quebrar "R$ 3.150,00". */
    .stat-grid { grid-template-columns: repeat(6, 1fr); }
}

/* ------------------------------------------------------- Acessibilidade */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}
