/* ==========================================================================
   Videira (base Empório ERP) — Design System
   Tokens, componentes e tema dos plugins legados (DataTables / Select2).
   As views usam Tailwind (CDN) para layout; tudo que é identidade mora aqui.
   ========================================================================== */

:root {
    --canvas: #F4F6F4;
    --surface: #FFFFFF;
    --surface-2: #F9FAF9;
    --field: #FFFFFF;
    --line: #E3E7E3;
    --line-strong: #CDD3CD;
    --ink: #121A16;
    --ink-2: #47524C;
    --ink-3: #78837D;

    --brand: #1D4E5F;
    --brand-hover: #163F4D;
    --brand-ink: #FFFFFF;
    --brand-soft: #E7F0F2;

    --in: #17804F;
    --in-hover: #116A41;
    --in-soft: #E5F3EB;
    --out: #B23A2A;
    --out-hover: #962F21;
    --out-soft: #F9EAE7;
    --warn: #A86A0B;
    --warn-soft: #FBF1DE;
    --gold: #C8941B;

    --tape: #121A16;
    --tape-ink: #F3F5F3;
    --tape-gold: #D9A62E;

    --radius: 14px;
    --radius-sm: 10px;
    --shadow-1: 0 1px 0 rgba(18, 26, 22, .03), 0 1px 3px rgba(18, 26, 22, .05);
    --shadow-2: 0 10px 30px -12px rgba(18, 26, 22, .18), 0 2px 6px rgba(18, 26, 22, .05);
    --ring: 0 0 0 3px rgba(29, 78, 95, .18);

    --font-display: 'Bricolage Grotesque', 'Geist', system-ui, sans-serif;
    --font-body: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-mono: 'Geist Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace;

    --ease: cubic-bezier(.2, .8, .2, 1);
    color-scheme: light;
}

.dark {
    --canvas: #0D1311;
    --surface: #141B18;
    --surface-2: #18201D;
    --field: #0F1614;
    --line: #232D29;
    --line-strong: #33403B;
    --ink: #E8EDEA;
    --ink-2: #AEB8B3;
    --ink-3: #7A8580;

    --brand: #7DB7C8;
    --brand-hover: #95C6D4;
    --brand-ink: #0D1311;
    --brand-soft: rgba(125, 183, 200, .12);

    --in: #4CC488;
    --in-hover: #66D29C;
    --in-soft: rgba(76, 196, 136, .12);
    --out: #F08372;
    --out-hover: #F49B8D;
    --out-soft: rgba(240, 131, 114, .12);
    --warn: #E5B04E;
    --warn-soft: rgba(229, 176, 78, .12);
    --gold: #E2B44A;

    --tape: #E8EDEA;
    --tape-ink: #0D1311;
    --tape-gold: #8A5F08;

    --shadow-1: 0 1px 0 rgba(0, 0, 0, .2);
    --shadow-2: 0 18px 40px -16px rgba(0, 0, 0, .6);
    --ring: 0 0 0 3px rgba(125, 183, 200, .25);
    color-scheme: dark;
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */
html { -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
body {
    font-family: var(--font-body);
    background: var(--canvas);
    color: var(--ink);
    font-feature-settings: 'ss01', 'cv11';
    -webkit-font-smoothing: antialiased;
}
.font-display { font-family: var(--font-display); font-optical-sizing: auto; letter-spacing: -0.02em; }
.num, .font-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
::selection { background: rgba(200, 148, 27, .28); }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); background-clip: content-box; border: 3px solid transparent; }

/* Dinheiro: centavos discretos, sempre tabular */
.money { font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; letter-spacing: -0.02em; }
.money .cur { font-size: .78em; opacity: .55; margin-right: .2em; font-weight: 500; }
.money .c { opacity: .55; font-size: .86em; }
.money.in { color: var(--in); }
.money.out { color: var(--out); }

/* --------------------------------------------------------------------------
   Campos de formulário (baixa especificidade: utilitários Tailwind vencem)
   -------------------------------------------------------------------------- */
main input:where([type=text], [type=number], [type=date], [type=email], [type=password], [type=search], [type=tel], [type=url], :not([type])),
main select, main textarea,
.auth input:where([type=text], [type=password]) {
    min-height: 2.6rem;
    padding: .55rem .8rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background-color: var(--field);
    color: var(--ink);
    font-size: .9rem;
    line-height: 1.3;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background-color .15s;
}
main select {
    appearance: none;
    padding-right: 2.2rem;
    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='%2378837D' stroke-width='2' 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 .7rem center;
}
main input:where([type=number]) { font-family: var(--font-mono); font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
main input[type=number]::-webkit-inner-spin-button, main input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
main input:where([type=date]) { font-family: var(--font-mono); font-size: .85rem; }
main input:hover, main select:hover, main textarea:hover { border-color: var(--ink-3); }
main input:focus, main select:focus, main textarea:focus,
.auth input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: var(--ring);
}
main input[readonly] { background-color: var(--surface-2); color: var(--ink-2); cursor: default; }
main input[readonly]:hover { border-color: var(--line-strong); }
.dark main input:where([type=date])::-webkit-calendar-picker-indicator { filter: invert(.8); }

main input[type=checkbox], main input[type=radio] {
    width: 1.05rem; height: 1.05rem;
    accent-color: var(--brand);
    cursor: pointer;
}

/* --------------------------------------------------------------------------
   Shell: sidebar, topbar, área principal
   -------------------------------------------------------------------------- */
.app-sidebar {
    width: 252px;
    background: var(--surface);
    border-right: 1px solid var(--line);
}
.brand-mark {
    width: 34px; height: 34px; border-radius: 10px;
    display: grid; place-items: center;
    background: var(--brand); color: var(--brand-ink);
    font-family: var(--font-display); font-weight: 700; font-size: 1.05rem;
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .18);
}
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; letter-spacing: -0.03em; color: var(--ink); }
.brand-sub { font-size: .68rem; color: var(--ink-3); letter-spacing: .08em; text-transform: uppercase; }

.nav-group { font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .09em; color: var(--ink-3); padding: 0 .75rem; margin: 1.4rem 0 .4rem; }
.nav-link {
    position: relative;
    display: flex; align-items: center; gap: .7rem;
    padding: .5rem .75rem; border-radius: 9px;
    font-size: .875rem; font-weight: 500; color: var(--ink-2);
    transition: background-color .15s, color .15s;
}
.nav-link svg { width: 17px; height: 17px; opacity: .75; flex-shrink: 0; }
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link.is-active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav-link.is-active svg { opacity: 1; }
.nav-link.is-active::before {
    content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
    border-radius: 0 3px 3px 0; background: var(--brand);
}
.nav-link .dot-in, .nav-link .dot-out { width: 6px; height: 6px; border-radius: 99px; margin-left: auto; }
.nav-link .dot-in { background: var(--in); }
.nav-link .dot-out { background: var(--out); }

.app-topbar {
    height: 60px;
    background: color-mix(in srgb, var(--canvas) 82%, transparent);
    backdrop-filter: saturate(1.4) blur(10px);
    -webkit-backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--line);
}
.today-chip {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .35rem .7rem; border-radius: 99px;
    border: 1px solid var(--line); background: var(--surface);
    font-size: .78rem; color: var(--ink-2);
}
.today-chip b { font-family: var(--font-mono); font-weight: 500; color: var(--ink); }

.icon-btn {
    width: 38px; height: 38px; display: grid; place-items: center;
    border-radius: 10px; color: var(--ink-2);
    transition: background-color .15s, color .15s;
}
.icon-btn:hover { background: var(--surface); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }

/* Drawer mobile */
@media (max-width: 767px) {
    .app-sidebar {
        position: fixed; inset: 0 auto 0 0; z-index: 60;
        transform: translateX(-100%); transition: transform .28s var(--ease);
        display: flex !important;
    }
    body.nav-open .app-sidebar { transform: none; box-shadow: var(--shadow-2); }
    .nav-scrim { position: fixed; inset: 0; background: rgba(13, 19, 17, .45); z-index: 55; opacity: 0; pointer-events: none; transition: opacity .2s; }
    body.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
}

/* Barra de progresso de navegação AJAX */
.nav-progress {
    position: fixed; top: 0; left: 0; height: 2px; width: 0; z-index: 100;
    background: var(--gold);
    box-shadow: 0 0 10px rgba(200, 148, 27, .6);
    opacity: 0; transition: width .4s var(--ease), opacity .3s;
}
.nav-progress.is-loading { opacity: 1; }
#app-view { transition: opacity .18s var(--ease); }
#app-view.is-leaving { opacity: .45; pointer-events: none; }
#app-view.is-entering { animation: view-in .32s var(--ease); }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* --------------------------------------------------------------------------
   Cabeçalho de página
   -------------------------------------------------------------------------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem 1.5rem; margin-bottom: 1.75rem; }
.crumbs { display: flex; align-items: center; gap: .4rem; font-size: .75rem; color: var(--ink-3); margin-bottom: .45rem; }
.crumbs a:hover { color: var(--brand); }
.crumbs svg { width: 12px; height: 12px; opacity: .6; }
.page-title { font-family: var(--font-display); font-size: clamp(1.6rem, 1.2rem + 1.2vw, 2.15rem); font-weight: 650; letter-spacing: -0.035em; line-height: 1.05; color: var(--ink); }
.page-title .tag { font-family: var(--font-body); font-size: .7rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; vertical-align: middle; margin-left: .6rem; padding: .25rem .55rem; border-radius: 99px; position: relative; top: -.35em; }
.tag-in { background: var(--in-soft); color: var(--in); }
.tag-out { background: var(--out-soft); color: var(--out); }
.page-sub { margin-top: .4rem; font-size: .9rem; color: var(--ink-2); max-width: 60ch; }
.page-actions { display: flex; flex-wrap: wrap; gap: .6rem; }

/* --------------------------------------------------------------------------
   Cartões
   -------------------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.card-title { font-size: .9rem; font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: .55rem; }
.card-title svg { width: 16px; height: 16px; color: var(--ink-3); }
.card-hint { font-size: .78rem; color: var(--ink-3); }
.card-body { padding: 1.25rem; }
.card-foot { padding: 1rem 1.25rem; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }

/* Faixa de filtros */
.filter-bar { display: grid; gap: .9rem; align-items: end; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); padding: 1.1rem 1.25rem; }
.filter-bar .btn { width: 100%; }

/* Campo */
.field { display: flex; flex-direction: column; gap: .4rem; min-width: 0; }
.field > label, .label { font-size: .76rem; font-weight: 600; color: var(--ink-2); letter-spacing: .01em; }
.field .req { color: var(--out); margin-left: 2px; }
.field .help { font-size: .74rem; color: var(--ink-3); }
.control { position: relative; }
.control > .control-icon {
    position: absolute; left: .75rem; top: 50%; transform: translateY(-50%);
    width: 16px; height: 16px; color: var(--ink-3); pointer-events: none;
}
.control > .control-prefix {
    position: absolute; left: .8rem; top: 50%; transform: translateY(-50%);
    font-family: var(--font-mono); font-size: .78rem; color: var(--ink-3); pointer-events: none;
}
main .control > .control-icon ~ input, main .control > .control-icon ~ select,
main .control > .control-prefix ~ input { padding-left: 2.35rem; width: 100%; }
main .field select, main .field input:not([type=checkbox]):not([type=radio]), main .field textarea { width: 100%; }

.form-grid { display: grid; gap: 1.1rem 1.25rem; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.form-section + .form-section { border-top: 1px solid var(--line); }
.form-section { padding: 1.4rem 1.25rem; display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 220px) minmax(0, 1fr); }
.form-section > header h3 { font-size: .9rem; font-weight: 600; color: var(--ink); }
.form-section > header p { font-size: .8rem; color: var(--ink-3); margin-top: .25rem; line-height: 1.45; }
@media (max-width: 860px) { .form-section { grid-template-columns: 1fr; } }
.form-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: .6rem; padding: 1rem 1.25rem; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }

/* Segmentado (Sim/Não) */
.segmented { justify-self: start; width: max-content; max-width: 100%; display: inline-flex; padding: 3px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--line); }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; }
.segmented span { display: block; padding: .4rem 1rem; border-radius: 8px; font-size: .82rem; font-weight: 500; color: var(--ink-2); cursor: pointer; transition: all .15s; }
.segmented input:checked + span { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); font-weight: 600; }
.segmented input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 1px; }

/* --------------------------------------------------------------------------
   Botões
   -------------------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    min-height: 2.6rem; padding: 0 1rem; border-radius: var(--radius-sm);
    font-size: .875rem; font-weight: 600; letter-spacing: -0.005em;
    border: 1px solid transparent; white-space: nowrap; cursor: pointer;
    transition: background-color .15s, border-color .15s, color .15s, transform .1s, box-shadow .15s;
}
.btn svg { width: 16px; height: 16px; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.is-busy { opacity: .6; cursor: progress; }
.btn-primary { background: var(--brand); color: var(--brand-ink); box-shadow: inset 0 -1px 0 rgba(0,0,0,.2); }
.btn-primary:hover { background: var(--brand-hover); }
.btn-in { background: var(--in); color: #fff; box-shadow: inset 0 -1px 0 rgba(0,0,0,.2); }
.btn-in:hover { background: var(--in-hover); }
.btn-out { background: var(--out); color: #fff; box-shadow: inset 0 -1px 0 rgba(0,0,0,.2); }
.btn-out:hover { background: var(--out-hover); }
.dark .btn-in, .dark .btn-out { color: #0D1311; }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { border-color: var(--ink-3); background: var(--surface-2); }
.btn-quiet { background: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: var(--surface-2); color: var(--ink); }
.btn-sm { min-height: 2.1rem; padding: 0 .75rem; font-size: .8rem; border-radius: 8px; }
.btn-icon { width: 2.1rem; min-height: 2.1rem; padding: 0; border-radius: 8px; color: var(--ink-3); background: transparent; }
.btn-icon:hover { background: var(--surface-2); color: var(--ink); }
.btn-icon.danger:hover { background: var(--out-soft); color: var(--out); }
.btn .spin { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
kbd { font-family: var(--font-mono); font-size: .7rem; padding: .05rem .35rem; border-radius: 5px; border: 1px solid var(--line-strong); color: var(--ink-3); background: var(--surface-2); }

/* --------------------------------------------------------------------------
   Livro-razão (tabela principal)
   -------------------------------------------------------------------------- */
.ledger-wrap { overflow-x: auto; }
.ledger { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .875rem; }
.ledger thead th {
    position: sticky; top: 0; z-index: 1;
    background: var(--surface-2);
    font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3);
    text-align: left; padding: .7rem 1rem; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.ledger tbody td { padding: .8rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; color: var(--ink-2); }
.ledger tbody tr:last-child td { border-bottom: 0; }
.ledger tbody tr { transition: background-color .12s; }
.ledger tbody tr:hover { background: var(--surface-2); }
.ledger tbody tr.is-selected { background: var(--brand-soft); }
.ledger tbody tr.is-selected td:first-child { box-shadow: inset 3px 0 0 var(--gold); }
.ledger .t-right { text-align: right; }
.ledger .t-center { text-align: center; }
.ledger .t-check { width: 44px; padding-right: 0; }
.ledger .who { color: var(--ink); font-weight: 500; }
.ledger .sub { font-size: .75rem; color: var(--ink-3); margin-top: 2px; }
.ledger .id { font-family: var(--font-mono); font-size: .72rem; color: var(--ink-3); }
.ledger .date { font-family: var(--font-mono); font-size: .8rem; color: var(--ink-2); white-space: nowrap; }
.ledger .row-actions { display: flex; gap: 2px; justify-content: flex-end; opacity: .55; transition: opacity .15s; }
.ledger tr:hover .row-actions, .ledger tr:focus-within .row-actions { opacity: 1; }
.ledger tfoot td { padding: .85rem 1rem; background: var(--surface-2); border-top: 1px solid var(--line); font-weight: 600; color: var(--ink); }
.ledger tr.is-removing { animation: row-out .35s var(--ease) forwards; }
@keyframes row-out { to { opacity: 0; transform: translateX(12px); } }
.ledger input.cell { min-height: 2.2rem; padding: .35rem .6rem; text-align: right; width: 6.6rem; }
.settle .ledger .who { white-space: nowrap; }
.settle .ledger td, .settle .ledger th { padding-left: .75rem; padding-right: .75rem; }

/* Chips de status */
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .18rem .55rem; border-radius: 99px; font-size: .72rem; font-weight: 600; white-space: nowrap; }
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 99px; background: currentColor; }
.chip-late { background: var(--out-soft); color: var(--out); }
.chip-today { background: var(--warn-soft); color: var(--warn); }
.chip-open { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.chip-paid { background: var(--in-soft); color: var(--in); }
.pill { font-family: var(--font-mono); font-size: .72rem; padding: .12rem .45rem; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); }

/* Resumo do período (acima da tabela) */
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); border-bottom: 1px solid var(--line); }
.summary > div { padding: 1rem 1.25rem; }
.summary > div + div { border-left: 1px solid var(--line); }
.summary dt { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.summary dd { margin-top: .3rem; font-size: 1.25rem; font-weight: 500; color: var(--ink); }
@media (max-width: 640px) { .summary > div + div { border-left: 0; border-top: 1px solid var(--line); } }

/* Busca rápida */
.quick-search { position: relative; flex: 0 1 380px; min-width: 220px; }
.quick-search svg { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--ink-3); pointer-events: none; }
main .quick-search input { padding-left: 2.1rem; padding-right: 2.2rem; min-height: 2.2rem; width: 100%; font-size: .83rem; }
.quick-search kbd { position: absolute; right: .55rem; top: 50%; transform: translateY(-50%); }

/* Estado vazio */
.empty { text-align: center; padding: 3.5rem 1.5rem; }
.empty .empty-icon { width: 48px; height: 48px; margin: 0 auto 1rem; border-radius: 14px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-3); }
.empty .empty-icon svg { width: 22px; height: 22px; }
.empty h4 { font-weight: 600; color: var(--ink); font-size: .95rem; }
.empty p { color: var(--ink-3); font-size: .85rem; margin-top: .3rem; max-width: 42ch; margin-inline: auto; }

/* --------------------------------------------------------------------------
   Assinatura: a "fita de caixa"
   Barra escura que sobe quando há títulos marcados e soma ao vivo.
   -------------------------------------------------------------------------- */
.tape {
    position: sticky; bottom: 1rem; z-index: 30;
    margin-top: 1rem;
    display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
    padding: .7rem .75rem .7rem 1.25rem;
    border-radius: 16px;
    background: var(--tape); color: var(--tape-ink);
    box-shadow: 0 20px 40px -18px rgba(13, 19, 17, .55);
    transform: translateY(140%); opacity: 0; pointer-events: none;
    transition: transform .38s var(--ease), opacity .25s;
}
.tape.is-open { transform: none; opacity: 1; pointer-events: auto; }
.tape::before {
    content: ''; position: absolute; left: 0; right: 0; top: 0; height: 6px;
    border-radius: 16px 16px 0 0;
    background: radial-gradient(circle at 5px -1px, transparent 4px, var(--gold) 4.5px) 0 0 / 10px 6px repeat-x;
    opacity: .9;
}
.tape-count { display: flex; align-items: baseline; gap: .45rem; font-size: .82rem; opacity: .75; }
.tape-count b { font-family: var(--font-mono); font-size: 1.05rem; font-weight: 600; opacity: 1; color: var(--tape-gold); }
.tape-sep { width: 1px; align-self: stretch; background: currentColor; opacity: .15; }
.tape-total { display: flex; flex-direction: column; line-height: 1.1; }
.tape-total small { font-size: .66rem; text-transform: uppercase; letter-spacing: .1em; opacity: .6; }
.tape-total .money { font-size: 1.35rem; font-weight: 600; }
.tape-actions { margin-left: auto; display: flex; gap: .5rem; }
.tape .btn-quiet { color: var(--tape-ink); opacity: .75; }
.tape .btn-quiet:hover { background: rgba(255,255,255,.08); opacity: 1; }
.dark .tape .btn-quiet:hover { background: rgba(0,0,0,.06); }
.tape .btn-gold { background: var(--gold); color: #1A1406; }
.tape .btn-gold:hover { filter: brightness(1.06); }
.tape-bump { animation: bump .3s var(--ease); }
@keyframes bump { 40% { transform: scale(1.06); } }

/* Painel de baixa (tela receber/pagar) */
.settle { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
@media (max-width: 1100px) { .settle { grid-template-columns: 1fr; } }
.receipt { position: sticky; top: 1rem; }
.receipt .card-body { display: grid; gap: 1rem; }
.receipt-line { display: flex; justify-content: space-between; align-items: baseline; font-size: .85rem; color: var(--ink-2); }
.receipt-line .money { color: var(--ink); }
.receipt-total { border-top: 1px dashed var(--line-strong); padding-top: 1rem; display: flex; justify-content: space-between; align-items: baseline; }
.receipt-total span { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.receipt-total .money { font-size: 1.75rem; font-weight: 600; }
.receipt .fee { font-size: .76rem; color: var(--warn); background: var(--warn-soft); padding: .5rem .7rem; border-radius: 8px; display: none; }
.receipt .fee.is-visible { display: block; }

/* --------------------------------------------------------------------------
   Painel inicial
   -------------------------------------------------------------------------- */
.day-hero { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 2fr); gap: 1.25rem; margin-bottom: 1.25rem; }
@media (max-width: 1024px) { .day-hero { grid-template-columns: 1fr; } }
.day-card { padding: 1.5rem; display: flex; flex-direction: column; justify-content: space-between; gap: 1.5rem; background: var(--tape); color: var(--tape-ink); border-color: transparent; position: relative; overflow: hidden; }
.day-card .weekday { font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; opacity: .6; }
.day-card .daynum { font-family: var(--font-display); font-size: 5rem; font-weight: 700; line-height: .85; letter-spacing: -0.05em; }
.day-card .month { font-family: var(--font-display); font-size: 1.3rem; font-weight: 500; opacity: .85; }
.day-card .net small { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; opacity: .55; margin-bottom: .2rem; }
.day-card .net > .money { font-size: 1.7rem; font-weight: 600; }
.day-card .net > .money.pos { color: var(--tape-gold); }
.day-card::after { content: ''; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%; border: 22px solid var(--tape-gold); opacity: .14; }

.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
@media (max-width: 640px) { .stat-grid { grid-template-columns: 1fr; } }
.stat { padding: 1.15rem 1.25rem; display: flex; flex-direction: column; gap: .35rem; transition: border-color .15s, transform .15s; }
a.stat:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.stat .stat-label { display: flex; align-items: center; gap: .45rem; font-size: .78rem; font-weight: 600; color: var(--ink-2); }
.stat .stat-label i, .stat .stat-label svg { width: 15px; height: 15px; }
.stat > .money { font-size: 1.6rem; font-weight: 500; color: var(--ink); }
.stat .stat-meta { font-size: .76rem; color: var(--ink-3); }
.stat.is-in .stat-label svg { color: var(--in); }
.stat.is-out .stat-label svg { color: var(--out); }
.stat.is-alert { border-color: color-mix(in srgb, var(--out) 35%, var(--line)); }
.stat.is-alert > .money { color: var(--out); }

.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-top: .5rem; }
.bars .bar { flex: 1; display: flex; align-items: flex-end; gap: 1px; height: 100%; position: relative; border-radius: 4px; }
.bars .bar:hover { background: var(--surface-2); }
.bars .bar i { display: block; flex: 1; border-radius: 3px 3px 1px 1px; min-height: 1px; }
.bars .bar .b-in { background: var(--in); opacity: .85; }
.bars .bar .b-out { background: var(--out); opacity: .75; }
.bars .bar.is-today::after { content: ''; position: absolute; left: 50%; bottom: -8px; width: 4px; height: 4px; border-radius: 50%; background: var(--gold); transform: translateX(-50%); }
.bars-legend { display: flex; gap: 1rem; font-size: .74rem; color: var(--ink-3); }
.bars-legend span::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: .35rem; vertical-align: 0; }
.bars-legend .l-in::before { background: var(--in); }
.bars-legend .l-out::before { background: var(--out); }

.agenda li { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: .9rem; align-items: center; padding: .75rem 1.25rem; border-bottom: 1px solid var(--line); }
.agenda li:last-child { border-bottom: 0; }
.agenda .when { font-family: var(--font-mono); font-size: .75rem; color: var(--ink-3); line-height: 1.2; }
.agenda .when b { display: block; font-size: 1.05rem; color: var(--ink); font-weight: 600; }
.agenda .who { font-size: .86rem; color: var(--ink); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agenda .what { font-size: .74rem; color: var(--ink-3); }

/* --------------------------------------------------------------------------
   Toasts e diálogo de confirmação
   -------------------------------------------------------------------------- */
.toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 90; display: flex; flex-direction: column; gap: .5rem; max-width: min(380px, calc(100vw - 2rem)); }
.toast {
    display: flex; align-items: flex-start; gap: .7rem;
    padding: .8rem .9rem; border-radius: 12px;
    background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-2);
    font-size: .85rem; color: var(--ink);
    animation: toast-in .3s var(--ease);
}
.toast svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.toast.ok svg { color: var(--in); }
.toast.err svg { color: var(--out); }
.toast.info svg { color: var(--brand); }
.toast button { margin-left: auto; color: var(--ink-3); }
.toast.is-leaving { animation: toast-out .25s var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }

dialog.confirm {
    border: 0; padding: 0; border-radius: 16px; width: min(420px, calc(100vw - 2rem));
    background: var(--surface); color: var(--ink); box-shadow: var(--shadow-2);
}
dialog.confirm::backdrop { background: rgba(13, 19, 17, .5); backdrop-filter: blur(2px); }
dialog.confirm[open] { animation: toast-in .25s var(--ease); }
dialog.confirm .c-body { padding: 1.4rem 1.4rem 1rem; display: flex; gap: 1rem; }
dialog.confirm .c-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--out-soft); color: var(--out); flex-shrink: 0; }
dialog.confirm h3 { font-weight: 600; font-size: 1rem; }
dialog.confirm p { color: var(--ink-2); font-size: .87rem; margin-top: .3rem; line-height: 1.5; }
dialog.confirm .c-actions { display: flex; justify-content: flex-end; gap: .5rem; padding: .9rem 1.4rem; background: var(--surface-2); border-top: 1px solid var(--line); }

/* Alertas vindos dos models PHP ("alert alert-success") */
.alert { padding: .8rem 1rem; border-radius: 10px; font-size: .86rem; border: 1px solid var(--line); background: var(--surface); margin-bottom: .5rem; }
.alert-success { background: var(--in-soft); color: var(--in); border-color: transparent; }
.alert-danger { background: var(--out-soft); color: var(--out); border-color: transparent; }

/* --------------------------------------------------------------------------
   DataTables (cadastros) — tema único
   -------------------------------------------------------------------------- */
.dataTables_wrapper { font-size: .85rem; color: var(--ink-2); }
.dataTables_wrapper .row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin: 0 0 .75rem; }
.dataTables_wrapper .row > div { flex: 1 1 auto; padding: 0; max-width: none; }
.dataTables_wrapper .dataTables_length label, .dataTables_wrapper .dataTables_filter label { display: inline-flex; align-items: center; gap: .5rem; font-weight: 500; color: var(--ink-3); }
.dataTables_wrapper .dataTables_filter { text-align: right; }
.dataTables_wrapper .dataTables_length select { min-height: 2.1rem; padding: .25rem 2rem .25rem .6rem; width: auto; }
.dataTables_wrapper .dataTables_filter input { min-height: 2.1rem; width: 220px; }
.dataTables_wrapper .dataTables_info { padding-top: 1rem; color: var(--ink-3); font-size: .8rem; }
.dataTables_wrapper .dataTables_paginate { padding-top: 1rem; }
.dataTables_wrapper .pagination { display: flex; gap: 4px; justify-content: flex-end; list-style: none; padding: 0; margin: 0; }
.dataTables_wrapper .page-link, .dataTables_wrapper .paginate_button {
    display: inline-flex; min-width: 2rem; height: 2rem; padding: 0 .6rem; align-items: center; justify-content: center;
    border-radius: 8px; border: 1px solid transparent; color: var(--ink-2); font-size: .8rem; font-weight: 500; background: transparent; cursor: pointer;
}
.dataTables_wrapper .page-item.active .page-link, .dataTables_wrapper .paginate_button.current { background: var(--brand); color: var(--brand-ink); }
.dataTables_wrapper .page-item:not(.active):not(.disabled) .page-link:hover { background: var(--surface-2); border-color: var(--line); color: var(--ink); }
.dataTables_wrapper .page-item.disabled .page-link { opacity: .4; cursor: default; }
table.dataTable { border-collapse: separate !important; border-spacing: 0; width: 100% !important; }
table.dataTable thead th { position: relative; cursor: pointer; }
table.dataTable thead .sorting::after, table.dataTable thead .sorting_asc::after, table.dataTable thead .sorting_desc::after { position: absolute; right: .5rem; opacity: .35; font-size: .7rem; }
table.dataTable thead .sorting::after { content: '↕'; }
table.dataTable thead .sorting_asc::after { content: '↑'; opacity: .9; }
table.dataTable thead .sorting_desc::after { content: '↓'; opacity: .9; }
table.dataTable thead .sorting::before, table.dataTable thead .sorting_asc::before, table.dataTable thead .sorting_desc::before { display: none; }
table.dataTable td.dataTables_empty { text-align: center; padding: 2.5rem 1rem; color: var(--ink-3); }

/* --------------------------------------------------------------------------
   Select2 — integrado aos campos
   -------------------------------------------------------------------------- */
.select2-container { width: 100% !important; font-size: .9rem; }
.select2-container--default .select2-selection--single {
    height: 2.6rem; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--field);
    display: flex; align-items: center;
}
.select2-container--default .select2-selection--single .select2-selection__rendered { color: var(--ink); line-height: 1.3; padding-left: .8rem; padding-right: 2rem; }
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 100%; right: .5rem; }
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single { border-color: var(--brand); box-shadow: var(--ring); }
.select2-dropdown { background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow-2); overflow: hidden; color: var(--ink); }
.select2-container--default .select2-search--dropdown .select2-search__field { border: 1px solid var(--line-strong); border-radius: 8px; background: var(--field); color: var(--ink); padding: .4rem .6rem; }
.select2-container--default .select2-results__option { padding: .45rem .8rem; font-size: .86rem; }
.select2-container--default .select2-results__option--highlighted[aria-selected] { background: var(--brand); color: var(--brand-ink); }
.select2-container--default .select2-results__option[aria-selected=true] { background: var(--brand-soft); color: var(--brand); }

/* --------------------------------------------------------------------------
   Login
   -------------------------------------------------------------------------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); background: var(--canvas); }
@media (max-width: 900px) { .auth { grid-template-columns: 1fr; } .auth-side { display: none !important; } }
.auth-side { background: var(--tape); color: var(--tape-ink); padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-side h2 { font-family: var(--font-display); font-size: clamp(2.2rem, 1.5rem + 2.5vw, 3.6rem); font-weight: 650; letter-spacing: -0.045em; line-height: 1; max-width: 12ch; }
.auth-side h2 em { font-style: normal; color: var(--tape-gold); }
.auth-side p { opacity: .65; max-width: 36ch; margin-top: 1rem; font-size: .95rem; line-height: 1.55; }
.auth-tape { font-family: var(--font-mono); font-size: .8rem; display: grid; gap: .55rem; max-width: 340px; opacity: .85; }
.auth-tape div { display: flex; justify-content: space-between; border-bottom: 1px dashed rgba(127,127,127,.35); padding-bottom: .45rem; }
.auth-tape div:last-child { border: 0; color: var(--tape-gold); font-weight: 600; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 2rem 1.25rem; }
.auth-form form { width: 100%; max-width: 380px; display: grid; gap: 1.1rem; }
.auth input { width: 100%; padding-left: 2.4rem !important; }

/* --------------------------------------------------------------------------
   Ponte para as telas de cadastro escritas só com utilitários Tailwind:
   título e tabelas herdam a identidade sem reescrever cada view.
   -------------------------------------------------------------------------- */
#app-view h1.text-2xl { font-family: var(--font-display); font-size: clamp(1.6rem, 1.2rem + 1.2vw, 2.15rem); font-weight: 650; letter-spacing: -0.035em; line-height: 1.05; }
#app-view .rounded-xl { border-radius: var(--radius); }
#app-view table.dataTable thead th { font-size: .68rem; letter-spacing: .08em; }
#app-view table.dataTable tbody td { font-size: .86rem; }

/* Movimento reduzido */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* Impressão */
@media print {
    .app-sidebar, .app-topbar, .tape, .toasts, .page-actions { display: none !important; }
    body { background: #fff; }
    .card { box-shadow: none; }
}

/* ==========================================================================
   Videira — complementos ao design system do Empório
   ========================================================================== */

/* Séries de gráficos (paleta categórica validada p/ daltonismo: azul, laranja, água) */
:root { --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; }
.dark { --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; }

/* Menu: grupos recolhíveis (um por menu do sistema) e subtítulos (submenus) */
.nav-sect > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; user-select: none; }
.nav-sect > summary::-webkit-details-marker { display: none; }
.nav-sect > summary svg { width: 13px; height: 13px; transition: transform .2s var(--ease); }
.nav-sect:not([open]) > summary svg { transform: rotate(-90deg); }
.nav-sect > summary:hover { color: var(--ink); }
.nav-sub { font-size: .7rem; color: var(--ink-3); padding: 0 .75rem; margin: .7rem 0 .2rem; opacity: .8; }
.nav-link.is-pending { opacity: .62; }
.nav-link .soon { margin-left: auto; font-size: .6rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; padding: .1rem .35rem; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-3); white-space: nowrap; }

/* Avatar com iniciais */
.avatar { width: 34px; height: 34px; border-radius: 99px; display: grid; place-items: center; flex-shrink: 0; font-size: .75rem; font-weight: 600; background: var(--brand-soft); color: var(--brand); }
.avatar.lg { width: 44px; height: 44px; font-size: .9rem; }

/* Cabeçalho da célula */
.cel-meta { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; font-size: .82rem; color: var(--ink-2); margin-top: .6rem; }
.cel-meta span { display: inline-flex; align-items: center; gap: .4rem; }
.cel-meta svg { width: 14px; height: 14px; color: var(--ink-3); }

/* Grade de ações (atalhos de uma célula) */
.action-grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.action-tile { display: flex; gap: .75rem; align-items: flex-start; padding: .95rem 1rem; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); transition: border-color .15s, transform .15s var(--ease); }
.action-tile:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.action-tile .ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex-shrink: 0; }
.action-tile .ico svg { width: 17px; height: 17px; }
.action-tile b { display: block; font-size: .86rem; font-weight: 600; color: var(--ink); }
.action-tile small { display: block; font-size: .74rem; color: var(--ink-3); margin-top: 2px; line-height: 1.35; }
.action-tile.primary { background: var(--brand); border-color: var(--brand); }
.action-tile.primary .ico { background: rgba(255, 255, 255, .14); color: var(--brand-ink); }
.action-tile.primary b, .action-tile.primary small { color: var(--brand-ink); }
.action-tile.primary small { opacity: .75; }

/* Liderança (4 papéis) */
.roles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.roles > div { padding: 1rem 1.25rem; display: flex; gap: .75rem; align-items: center; min-width: 0; border-top: 1px solid var(--line); margin-top: -1px; }
.roles dt { font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.roles dd { font-size: .88rem; font-weight: 500; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roles dd.vazio { color: var(--ink-3); font-weight: 400; }

/* Chamada: uma linha por membro com Presente/Ausente */
.roll > li { display: flex; align-items: center; gap: .85rem; padding: .7rem 1.25rem; border-bottom: 1px solid var(--line); }
.roll > li:last-child { border-bottom: 0; }
.roll .who { flex: 1; min-width: 0; font-size: .88rem; font-weight: 500; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roll .segmented span { padding: .35rem .8rem; font-size: .8rem; }
.segmented input[value=p]:checked + span { background: var(--in-soft); color: var(--in); box-shadow: none; }
.segmented input[value=a]:checked + span { background: var(--out-soft); color: var(--out); box-shadow: none; }
.tally { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .82rem; color: var(--ink-2); align-items: center; }
.tally b { font-family: var(--font-mono); font-size: 1rem; color: var(--ink); margin-right: .25rem; }

/* Situação na chamada */
.chip-p { background: var(--in-soft); color: var(--in); }
.chip-a { background: var(--out-soft); color: var(--out); }

/* Passos do diário (chamada → visitantes → relato) */
.steps { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1.25rem; counter-reset: passo; list-style: none; padding: 0; }
.steps li { counter-increment: passo; display: inline-flex; align-items: center; gap: .5rem; padding: .35rem .8rem .35rem .4rem; border-radius: 99px; font-size: .78rem; color: var(--ink-3); border: 1px solid var(--line); background: var(--surface); }
.steps li::before { content: counter(passo); width: 20px; height: 20px; border-radius: 99px; display: grid; place-items: center; font-size: .7rem; font-weight: 600; background: var(--surface-2); }
.steps li.is-done { color: var(--in); }
.steps li.is-done::before { content: "\2713"; background: var(--in-soft); }
.steps li.is-current { color: var(--ink); border-color: var(--brand); font-weight: 600; }
.steps li.is-current::before { background: var(--brand); color: var(--brand-ink); }

/* Barras horizontais (painel: composição e posição eclesiástica) */
.hbars { display: grid; gap: .85rem; }
.hbar { display: grid; grid-template-columns: minmax(0, 9.5rem) minmax(0, 1fr) 3.4rem; gap: .75rem; align-items: center; font-size: .84rem; }
.hbar .lbl { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .trk { height: 10px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.hbar .trk i { display: block; height: 100%; border-radius: 0 4px 4px 0; background: var(--brand); min-width: 2px; }
.hbar .val { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; color: var(--ink); line-height: 1.15; }
.hbar .val small { display: block; font-size: .68rem; color: var(--ink-3); }

/* Texto longo do diário */
.prose-box { font-size: .9rem; line-height: 1.6; color: var(--ink); white-space: pre-line; }
.prose-box.is-empty { color: var(--ink-3); font-style: italic; }

/* Gráfico de linhas (App.lineChart) */
.lc { position: relative; }
.lc-legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .76rem; color: var(--ink-2); margin-bottom: .5rem; }
.lc-legend span { display: inline-flex; align-items: center; gap: .4rem; }
.lc-legend i, .lc-tip i { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }
.lc svg { display: block; overflow: visible; }
.lc .lc-grid { stroke: var(--line); stroke-width: 1; }
.lc .lc-base { stroke: var(--line-strong); stroke-width: 1; }
.lc .lc-tick { fill: var(--ink-3); font-size: 11px; font-family: var(--font-mono); }
.lc .lc-label { fill: var(--ink-2); font-size: 11px; font-weight: 500; }
.lc .lc-rule { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 3; }
.lc-tip { position: absolute; top: 1.6rem; pointer-events: none; min-width: 150px; padding: .55rem .7rem; border-radius: 10px; background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow-2); font-size: .76rem; color: var(--ink); z-index: 5; }
.lc-tip b { display: block; font-family: var(--font-mono); font-weight: 600; margin-bottom: .3rem; }
.lc-tip div { display: flex; align-items: center; gap: .45rem; }
.lc-tip em { margin-left: auto; font-style: normal; font-family: var(--font-mono); font-weight: 600; }
.lc-empty { font-size: .85rem; color: var(--ink-3); padding: 2rem 0; text-align: center; }

/* Tabela "ledger" em telas pequenas: rolagem horizontal sem quebrar a página */
.ledger-wrap { -webkit-overflow-scrolling: touch; }

/* Segmentado com links (alternar Analítico / Sintético) */
.seg-links a span { display: block; padding: .4rem 1rem; border-radius: 8px; font-size: .82rem; font-weight: 500; color: var(--ink-2); }
.seg-links a:hover span { color: var(--ink); }
.seg-links a.is-on span { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* Celular: tabelas rolam na horizontal em vez de quebrar nomes palavra por palavra */
@media (max-width: 640px) {
    .ledger-wrap .ledger { min-width: 620px; }
    .ledger .who { white-space: nowrap; }
    .quick-search kbd { display: none; }
    .quick-search { flex-basis: 100%; }
}

/* Colunas secundárias somem no celular; o resumo aparece sob a coluna principal */
.show-sm { display: none; }
@media (max-width: 640px) {
    .hide-sm { display: none; }
    .show-sm { display: block; }
    .ledger-wrap .ledger.ledger-compact { min-width: 0; }
    .ledger.ledger-compact .who { white-space: normal; }
    .ledger.ledger-compact td, .ledger.ledger-compact th { padding-left: .8rem; padding-right: .8rem; }
}

/* Lista de duas colunas (nome + valor): saldo das contas */
.agenda.agenda-2 li { grid-template-columns: minmax(0, 1fr) auto; }
.agenda li.is-total { background: var(--surface-2); }

/* Demonstrativo: tipos zerados discretos e barra proporcional ao maior valor */
.ledger tr.is-zero td, .ledger tr.is-zero .who { color: var(--ink-3); font-weight: 400; }
.demo-bar { display: block; height: 4px; margin-top: .4rem; border-radius: 2px; background: var(--surface-2); max-width: 16rem; overflow: hidden; }
.demo-bar i { display: block; height: 100%; border-radius: 0 2px 2px 0; }
.demo-bar.in i { background: var(--in); }
.demo-bar.out i { background: var(--out); }

/* Financeiro analítico: níveis Entradas/Saídas → tipo → lançamento */
.ledger.analitico tbody tr.lvl-1 td { background: var(--brand-soft); color: var(--ink); font-weight: 650; border-top: 1px solid var(--line); }
.ledger.analitico tbody tr.lvl-2 td { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.ledger.analitico tbody tr:not(.lvl-1):not(.lvl-2) td:first-child { padding-left: 1.6rem; }

@media print {
    .no-print, .quick-search { display: none !important; }
    .demo-bar { display: none; }
}

/* Pessoas: faixa de abas do cadastro (rola na horizontal no celular) */
.tabs { display: flex; gap: .25rem; overflow-x: auto; padding: 3px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); scrollbar-width: thin; }
.tabs a { display: inline-flex; align-items: center; gap: .4rem; padding: .45rem .8rem; border-radius: 9px; font-size: .82rem; font-weight: 500; color: var(--ink-2); white-space: nowrap; }
.tabs a svg { width: 15px; height: 15px; }
.tabs a:hover { color: var(--ink); }
.tabs a.is-on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-1); }
.tab-n { font-family: var(--font-mono); font-size: .68rem; padding: 0 .35rem; border-radius: 6px; background: var(--brand-soft); color: var(--brand); }

/* Foto da pessoa */
.avatar-foto { width: 52px; height: 52px; border-radius: 99px; object-fit: cover; flex-shrink: 0; border: 1px solid var(--line); }
.foto-grande { width: 100%; max-width: 220px; aspect-ratio: 1; object-fit: cover; border-radius: 14px; border: 1px solid var(--line); }

/* Checkbox com rótulo; papel travado (o usuário não pode alterar) */
.check { display: inline-flex; align-items: center; gap: .55rem; font-size: .86rem; color: var(--ink); cursor: pointer; min-height: 2.2rem; }
.check input { width: 17px; height: 17px; accent-color: var(--brand); }
.check.is-locked { color: var(--ink-3); cursor: default; }
.check.is-locked svg { width: 14px; height: 14px; }

/* Consolidação: 12 semanas marcáveis */
.weeks { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: .35rem; }
@media (max-width: 640px) { .weeks { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.week { position: relative; }
.week input { position: absolute; opacity: 0; inset: 0; }
.week span { display: grid; place-items: center; height: 2.4rem; border-radius: 9px; border: 1px solid var(--line-strong); font-family: var(--font-mono); font-size: .85rem; color: var(--ink-2); cursor: pointer; transition: all .15s; }
.week input:checked + span { background: var(--in-soft); border-color: var(--in); color: var(--in); font-weight: 600; }
.week input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 1px; }
.file-input { width: 100%; max-width: 100%; min-width: 0; font-size: .82rem; color: var(--ink-2); }
.file-input::file-selector-button { font: inherit; font-weight: 600; margin-right: .6rem; padding: .45rem .8rem; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; }

/* Sufixo dentro do campo (ex.: "h" de horas) */
.control > .control-suffix { position: absolute; right: .8rem; top: 50%; transform: translateY(-50%); font-size: .82rem; color: var(--ink-3); pointer-events: none; }
main .control > input:has(+ .control-suffix) { padding-right: 2rem; width: 100%; }

/* Permissões / papéis em grade de checkboxes */
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .25rem 1rem; }
.perm-grid.perm-inline { display: flex; flex-wrap: wrap; gap: 0 .9rem; }
.perm-inline .check { font-size: .78rem; min-height: 1.8rem; }

/* Menus do sistema: cabeçalho editável, submenus e programas */
.menu-head { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.menu-head input[type=text] { min-height: 2.1rem; font-size: .86rem; }
.menu-head .menu-nome { flex: 1 1 14rem; font-weight: 600; }
.menu-head .menu-icone { width: 8rem; font-family: var(--font-mono); font-size: .78rem; }
.sub-box { border: 1px solid var(--line); border-radius: 12px; padding: .75rem; display: grid; gap: .6rem; background: var(--surface-2); }
.prog-list { display: grid; gap: .4rem; }
.prog-row { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.prog-row select { min-height: 2.1rem; font-size: .8rem; flex: 1 1 16rem; }
.prog-novo { border-top: 1px dashed var(--line-strong); padding-top: .6rem; }

/* Campos dentro de tabela (programas) */
.cell-in { width: 100%; min-height: 2rem; font-size: .84rem; padding: .3rem .5rem; }
.cell-in + .cell-in { margin-top: .3rem; }
.cell-in.mono { font-family: var(--font-mono); font-size: .76rem; color: var(--ink-2); }
.prog-row select[name=target] { flex: 0 0 8.5rem; width: 8.5rem; }
