:root {
    --bg: #f5f0ea;
    --surface: #ffffff;
    --surface2: #faf6f1;
    --border: #e2d6c8;
    --text: #2c2419;
    --muted: #7a6b5c;
    --primary: #6b4423;
    --primary-hover: #4a2f18;
    --primary-light: #f0e4d4;
    --sidebar-bg: #3d2817;
    --sidebar-text: #faf6f1;
    --sidebar-muted: #c9a87c;
    --success: #5a7a3a;
    --warning: #b45309;
    --danger: #b91c1c;
    --info: #8b6914;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(61, 40, 23, 0.1), 0 4px 16px rgba(61, 40, 23, 0.08);
    --sidebar-width: 260px;
    font-family: 'DM Sans', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    text-transform: uppercase;
}

body.modal-open {
    overflow: hidden;
}

/* Senha e campos numéricos mantêm digitação normal */
input[type="password"],
input[type="number"],
input[data-mask="money"],
input[data-mask="date"],
.no-uppercase {
    text-transform: none;
}

input::placeholder,
textarea::placeholder {
    text-transform: uppercase;
}

input[type="password"]::placeholder {
    text-transform: none;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); text-decoration: underline; }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    flex: 0 0 var(--sidebar-width);
    width: var(--sidebar-width);
    min-width: 0;
    background: var(--sidebar-bg);
    border-right: none;
    display: flex;
    flex-direction: column;
    padding: 1.25rem;
    color: var(--sidebar-text);
    transition: flex-basis 0.25s ease, width 0.25s ease, padding 0.25s ease, opacity 0.2s ease;
    overflow: hidden;
}

.app-shell.sidebar-collapsed .sidebar {
    flex-basis: 0;
    width: 0;
    min-width: 0;
    padding-left: 0;
    padding-right: 0;
    opacity: 0;
    pointer-events: none;
    border: none;
}

.main-topbar {
    display: flex;
    align-items: center;
    min-height: 2.75rem;
    margin: 0 0 1.25rem;
    position: sticky;
    top: 0;
    z-index: 90;
    background: var(--bg);
    padding: 0.35rem 0;
}

.main-inner {
    min-width: 0;
}

.sidebar-toggle {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--sidebar-bg);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(61, 40, 23, 0.3);
    transition: background 0.15s ease, transform 0.15s ease;
}

.sidebar-toggle:hover {
    background: var(--primary-hover);
}

.sidebar-toggle-icon {
    display: block;
    width: 14px;
    height: 14px;
    border-left: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    margin-left: 3px;
    transition: transform 0.2s ease;
}

.app-shell.sidebar-collapsed .sidebar-toggle-icon {
    transform: rotate(-135deg);
    margin-left: -2px;
}

.sidebar-backdrop {
    display: none;
}

.brand-text {
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 0.2s ease;
    width: 100%;
}

.app-shell.sidebar-collapsed .brand-text,
.app-shell.sidebar-collapsed .nav,
.app-shell.sidebar-collapsed .sidebar-footer,
.app-shell.sidebar-collapsed .sidebar-user {
    opacity: 0;
}

.brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0;
    margin-bottom: 0;
    padding-bottom: 0.85rem;
    border-bottom: none;
}

.brand strong { color: #fff; }

.brand .brand-text {
    display: none;
}

.brand-logo {
    width: 148px;
    height: 148px;
    max-width: none;
    max-height: none;
    border-radius: 50%;
    object-fit: cover;
    object-position: center;
    background: transparent;
    padding: 0;
    flex-shrink: 0;
    border: 3px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.28);
}

.brand-icon,
.login-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    border-radius: 8px;
    background: #fff;
    flex-shrink: 0;
}

.login-icon {
    width: 64px;
    height: 64px;
    font-size: 2.25rem;
    margin: 0 auto 1rem;
}

.brand small { color: var(--sidebar-muted); display: block; font-size: .75rem; }

.nav { display: flex; flex-direction: column; gap: .25rem; flex: 1; }

.nav-section {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    margin-top: .75rem;
    padding-top: .75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.nav-section:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.nav-section-label {
    padding: 0 .85rem .35rem;
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.45);
}

.nav a {
    color: var(--sidebar-muted);
    padding: .65rem .85rem;
    border-radius: 8px;
    font-size: .9rem;
    text-decoration: none;
    transition: .15s;
}

.nav a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    text-decoration: none;
}

.nav a.active {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    text-decoration: none;
    border-left: 3px solid #93c5fd;
}

.sidebar-footer,
.sidebar-user {
    margin-top: 0;
    margin-bottom: 1.25rem;
    padding: 0.85rem 0 1.15rem;
    border-top: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.user-chip {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: .6rem;
    margin-bottom: .75rem;
    text-align: left;
}

.avatar {
    width: 36px; height: 36px;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600;
}

.user-chip strong { color: #fff; font-size: .9rem; }
.user-chip small { color: var(--sidebar-muted); display: block; font-size: .72rem; line-height: 1.35; }

.sidebar .btn-ghost {
    color: var(--sidebar-muted);
    border-color: rgba(255, 255, 255, 0.25);
    width: 100%;
}
.sidebar .btn-ghost:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.main {
    flex: 1;
    min-width: 0;
    padding: 1rem 1.5rem 1.5rem;
    overflow-x: hidden;
    background: var(--bg);
    position: relative;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h1 { font-size: 1.5rem; font-weight: 600; color: var(--primary); }
.page-header p { color: var(--muted); font-size: .9rem; margin-top: .25rem; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.25rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    box-shadow: var(--shadow);
}

.stat-card .label {
    display: block;
    width: 100%;
    color: var(--muted);
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    line-height: 1.3;
}

.stat-card .value {
    display: block;
    width: 100%;
    font-size: 1.05rem;
    font-weight: 700;
    margin-top: .4rem;
    color: var(--primary);
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.stat-card.warning .value { color: var(--warning); }
.stat-card.danger .value { color: var(--danger); }
.stat-card.success .value { color: var(--success); }

.section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
    margin: 0 0 1rem;
}

.section-title--muted {
    color: var(--muted);
    font-size: 0.92rem;
    margin-top: 1.5rem;
}

.atalhos-topo {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    margin: 0 0 1.15rem;
}

.kpi-section {
    margin-bottom: 1.75rem;
}

.kpi-section--resumo {
    margin-bottom: 1.75rem;
}

.stats-grid--dashboard {
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 1rem;
}

.stats-grid--relatorio {
    grid-template-columns: repeat(auto-fit, minmax(13.25rem, 1fr));
    gap: 0.65rem;
    margin-bottom: 1.15rem;
}

.stats-grid--relatorio .stat-card {
    padding: 0.75rem 0.85rem;
    min-width: 0;
    overflow: visible;
}

.stats-grid--relatorio .stat-card .label {
    font-size: 0.7rem;
    letter-spacing: 0.02em;
    white-space: normal;
    line-height: 1.25;
    overflow: visible;
}

.stats-grid--relatorio .stat-card .value {
    font-size: 1.05rem;
    margin-top: 0.3rem;
    overflow: visible;
    text-overflow: unset;
    white-space: nowrap;
}

.stats-grid--relatorio .stat-card .stat-hint {
    font-size: 0.68rem;
    margin-top: 0.2rem;
    line-height: 1.3;
    overflow: visible;
    white-space: normal;
}

.stat-card .stat-hint {
    display: block;
    margin-top: 0.4rem;
    font-size: 0.72rem;
    line-height: 1.35;
    color: var(--muted);
    font-weight: 400;
    letter-spacing: 0.03em;
}

.stat-card--primary {
    border-color: #93c5fd;
    background: linear-gradient(180deg, #f0f7ff 0%, #ffffff 100%);
}

.stat-card--primary .value {
    color: var(--primary);
}

.stat-card--uniform,
.stats-grid--dashboard .stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
}

.stat-card--uniform .value,
.stats-grid--dashboard .stat-card .value {
    color: var(--primary);
}

.stats-grid--dashboard .stat-card.warning .value,
.stats-grid--dashboard .stat-card.danger .value,
.stats-grid--dashboard .stat-card.success .value {
    color: var(--primary);
}

.obra-valores-title {
    margin-top: .25rem;
}

.section-desc {
    font-size: 0.85rem;
    color: var(--muted);
    margin: 0 0 1rem;
}


.stats-grid--kpi {
    margin-bottom: 0;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 1rem;
}

.charts-section {
    margin-bottom: 1.75rem;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.15rem 1.25rem;
    box-shadow: var(--shadow);
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.chart-card--active {
    border-color: #c7d9f0;
    box-shadow: 0 4px 20px rgba(61, 40, 23, 0.12);
}

.charts-grid--muted .chart-card {
    opacity: 0.72;
    background: var(--surface2);
}

.chart-card h3 {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.85rem;
    line-height: 1.35;
}

.chart-card--wide {
    grid-column: span 1;
}

.chart-card--full {
    grid-column: 1 / -1;
}

.chart-wrap {
    position: relative;
    height: 260px;
    width: 100%;
}

.chart-wrap--tall {
    height: 300px;
}

.chart-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 180px;
    text-align: center;
    padding: 1.5rem;
}

.chart-empty span {
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.5;
    max-width: 220px;
}

.charts-section--modern {
    margin-bottom: 1.75rem;
}

.charts-grid--modern {
    grid-template-columns: repeat(12, 1fr);
}

.charts-grid--modern .chart-card {
    grid-column: span 6;
}

.charts-grid--modern .chart-card--hero {
    grid-column: span 12;
}

.charts-grid--modern .chart-card--wide {
    grid-column: span 12;
}

.charts-row--donuts {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.charts-row--donuts .chart-card {
    grid-column: auto;
    min-width: 0;
}

.chart-wrap--donut {
    height: 280px;
}

.chart-card-head h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
    margin: 0;
}

.chart-card-head p {
    font-size: 0.8rem;
    color: var(--muted);
    margin: 0.25rem 0 0.75rem;
}

.chart-wrap--hero {
    height: 320px;
}

.chart-wrap--compact {
    height: 200px;
}

.stats-grid--compact {
    margin-bottom: 1.5rem;
}

.card-desc {
    font-size: 0.85rem;
    color: var(--muted);
    margin: -0.5rem 0 1rem;
}

.id-link,
.table-registros .id-link {
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
    white-space: nowrap;
}

.id-link:hover,
.table-registros .id-link:hover {
    text-decoration: underline;
    color: var(--primary-hover);
}

.cliente-cell {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 140px;
}

.cliente-cell-nome {
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
}

.cliente-cell-local {
    font-size: 0.72rem;
    color: var(--muted);
    line-height: 1.25;
}

.cliente-select-wrap {
    position: relative;
}

.cliente-select-input {
    width: 100%;
}

.cliente-select-dropdown {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% - 0.25rem);
    z-index: 120;
    max-height: 240px;
    overflow-y: auto;
    margin: 0;
    padding: 0.35rem 0;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.cliente-select-option {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.1rem;
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.88rem;
}

.cliente-select-option:hover,
.cliente-select-option:focus {
    background: var(--primary-light);
}

.cliente-select-option strong {
    color: var(--primary);
    font-size: 0.8rem;
}

.cliente-select-option span {
    color: var(--text);
}

.cliente-select-option small {
    color: var(--muted);
    font-size: 0.72rem;
}

.cnpj-busca-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.cnpj-busca-row input {
    flex: 1;
    min-width: 200px;
}

.col-datetime {
    white-space: nowrap;
    font-size: 0.85rem;
    color: var(--muted);
}

@media (min-width: 1100px) {
    .chart-card--wide {
        grid-column: span 2;
    }

    .charts-grid--modern .chart-card--wide {
        grid-column: span 12;
    }
}

@media (min-width: 900px) and (max-width: 1099px) {
    .charts-grid--modern .chart-card {
        grid-column: span 6;
    }
}

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: .4rem;
    padding: .55rem 1rem;
    border-radius: 8px;
    border: none;
    font-size: .9rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: .15s;
    font-family: inherit;
}

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

.btn-ghost {
    background: var(--surface);
    color: var(--muted);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--primary-light); color: var(--primary); text-decoration: none; border-color: #d4b896; }

.btn-whatsapp {
    background: #128c7e;
    color: #fff;
}
.btn-whatsapp:hover {
    background: #075e54;
    color: #fff;
    text-decoration: none;
}

.share-link-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
    margin: 0 0 1.15rem;
}

.share-link-box label {
    display: block;
    font-size: 0.75rem;
    color: var(--muted);
    margin-bottom: 0.4rem;
}

.share-link-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.share-link-row input {
    flex: 1 1 16rem;
    min-width: 0;
    text-transform: none;
}

.share-link-status {
    margin-top: 0.45rem;
    font-size: 0.8rem;
    color: var(--success);
}

.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: .35rem .7rem; font-size: .8rem; }

.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

th, td {
    padding: .65rem .75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    color: var(--muted);
    font-weight: 600;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    white-space: nowrap;
    background: var(--surface2);
}

tr:hover td { background: var(--primary-light); }

code {
    background: var(--primary-light);
    color: var(--primary);
    padding: .15rem .4rem;
    border-radius: 4px;
    font-size: .85em;
}

.badge {
    display: inline-block;
    padding: .2rem .55rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-success { background: #dcfce7; color: var(--success); }
.badge-warning { background: #fef3c7; color: var(--warning); }
.badge-danger  { background: #fee2e2; color: var(--danger); }
.badge-info    { background: #e0f2fe; color: var(--info); }
.badge-neutral { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }

/* Status do pedido — assinaturas */
.badge-status-completo {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

.badge-status-fazenda {
    background: #dbeafe;
    color: #1d4ed8;
    border: 1px solid #93c5fd;
}

.badge-status-cliente {
    background: #fef3c7;
    color: #b45309;
    border: 1px solid #fcd34d;
}

.block-muted {
    display: block;
    margin-top: 0.2rem;
    color: var(--muted);
    font-size: 0.78rem;
}

.status-pedido-hint {
    display: block;
    margin-top: 0.25rem;
    max-width: 11rem;
    font-size: 0.68rem;
    line-height: 1.35;
    text-transform: none;
    white-space: normal;
}

.col-status-pedido {
    white-space: normal;
    min-width: 7.5rem;
    vertical-align: middle;
}

.table-planilha .col-status-pedido .badge {
    white-space: nowrap;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.form-group { display: flex; flex-direction: column; gap: .35rem; }
.form-group.full { grid-column: 1 / -1; }

label { font-size: .8rem; color: var(--muted); font-weight: 500; }

input, select, textarea {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .55rem .75rem;
    color: var(--text);
    font-size: .9rem;
    font-family: inherit;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(107, 68, 35, 0.2);
}

textarea { min-height: 80px; resize: vertical; }

.form-actions {
    display: flex;
    gap: .75rem;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}

.page-header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.filters-card {
    padding: 1.1rem 1.25rem 1.2rem;
    margin-bottom: 1.25rem;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.75rem 0.85rem;
    align-items: end;
}

.filters-busca {
    grid-column: auto;
}

.filters-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    padding-bottom: 0.1rem;
}

.celula-sub {
    display: block;
    margin-top: 0.15rem;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 400;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    margin-bottom: 1rem;
    align-items: flex-end;
}

.filters .form-group { min-width: 160px; }

.alert {
    padding: .75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: .9rem;
}

.alert-success { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert-error   { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: linear-gradient(160deg, rgba(232, 240, 250, 0.92) 0%, rgba(248, 250, 252, 0.95) 50%, #ffffff 100%),
        url('../img/concreto_ci.png') center / cover no-repeat;
}

.login-brand {
    text-align: center;
    margin-bottom: 1.25rem;
}

.login-logo {
    width: 200px;
    height: 200px;
    max-width: 72vw;
    max-height: 72vw;
    border-radius: 50%;
    object-fit: cover;
    object-position: center;
    margin: 0 auto 0.5rem;
    display: block;
    box-shadow: 0 6px 24px rgba(61, 40, 23, 0.18);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 2rem;
    box-shadow: var(--shadow);
}

.login-card h1 {
    font-size: 1.35rem;
    margin-bottom: .35rem;
    color: var(--primary);
    text-align: center;
}
.login-card .subtitle {
    color: var(--muted);
    font-size: .9rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.actions-inline {
    display: inline-flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.28rem;
    align-items: center;
    justify-content: flex-start;
    vertical-align: middle;
}

.actions-inline > a,
.actions-inline > form,
.actions-inline > button {
    flex: 0 0 auto;
}

.actions-inline .btn {
    width: auto;
    flex-shrink: 0;
    justify-content: center;
    text-align: center;
}

.actions-inline form {
    display: inline-flex;
    flex: 0 0 auto;
    margin: 0;
}

.actions-inline .actions-form {
    display: inline-flex;
    flex: 0 0 auto;
    margin: 0;
}

.actions-inline .actions-form button {
    width: auto;
    flex-shrink: 0;
}

.btn-icon {
    padding: .38rem;
    min-width: 2rem;
    min-height: 2rem;
    line-height: 1;
    flex-shrink: 0;
}

.btn-icon .ico-acao {
    display: block;
    width: 1rem;
    height: 1rem;
}

.btn-icon.btn-primary .ico-acao {
    color: #fff;
}

.midia-info-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.midia-info-label {
    display: block;
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    margin-bottom: .25rem;
}

.midia-path {
    display: block;
    font-size: .82rem;
    word-break: break-all;
    color: var(--text);
    background: var(--bg);
    padding: .45rem .6rem;
    border-radius: 6px;
}

.midia-section .card-title {
    margin-bottom: 1rem;
}

.midia-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
}

.midia-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--bg);
}

.midia-thumb {
    display: block;
    aspect-ratio: 4 / 3;
    background: #eef2f6;
    overflow: hidden;
}

.midia-thumb img,
.midia-thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.midia-thumb--file {
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.midia-ext {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}

.midia-meta {
    padding: .65rem .75rem;
    display: flex;
    flex-direction: column;
    gap: .2rem;
}

.midia-nome {
    font-size: .82rem;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.midia-nome:hover {
    color: var(--primary);
    text-decoration: underline;
}

.midia-meta small {
    color: var(--muted);
    font-size: .72rem;
}

.mapas-section {
    margin-bottom: 1.75rem;
}

.section-desc {
    color: var(--muted);
    font-size: .88rem;
    margin: -.75rem 0 1.25rem;
}

.mapas-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

.mapa-card .card-title {
    margin-bottom: .5rem;
}

.mapa-card .card-desc {
    margin-bottom: .75rem;
}

.mapa-geo-br {
    min-height: 350px;
    width: 100%;
}

.mapa-empty {
    color: var(--muted);
    font-size: .85rem;
    padding: 1rem;
    margin: 0;
}

.mapa-painel-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.mapa-painel-stat {
    display: flex;
    flex-direction: column;
    gap: .2rem;
}

.mapa-painel-stat span {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    font-weight: 600;
}

.mapa-painel-stat strong {
    font-size: 1.35rem;
    color: var(--primary);
}

.mapa-ranking {
    list-style: none;
    margin: 0;
    padding: 0;
}

.mapa-ranking li {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: .55rem 0;
    border-bottom: 1px solid var(--border);
    font-size: .88rem;
}

@media (max-width: 900px) {
    .mapas-grid {
        grid-template-columns: 1fr;
    }

    .mapa-painel-grid {
        grid-template-columns: 1fr;
    }
}

.empty-state {
    text-align: center;
    padding: 2.5rem;
    color: var(--muted);
}

.perm-hint {
    color: var(--muted);
    font-size: .85rem;
    margin: .25rem 0 .75rem;
}

.perm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: .5rem;
}

.perm-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .55rem .75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface2);
    font-size: .875rem;
    color: var(--text);
    cursor: pointer;
}

.perm-item input { width: auto; margin: 0; }

.record-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 1.5rem;
    padding: .75rem 1rem;
    margin-bottom: 1rem;
    background: var(--primary-light);
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    font-size: .875rem;
    color: var(--text);
}

.field-hint {
    font-size: .75rem;
    color: var(--muted);
    margin-top: .2rem;
}

.calc-box {
    background: var(--surface2);
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 1rem;
}

.check-inline {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.88rem;
    font-weight: 500;
}

.parcelas-preview th,
.parcelas-preview td {
    font-size: 0.85rem;
}

.parcela-vencida td {
    background: #fef2f2;
}

.parcela-futura td {
    background: #f8fafc;
}

.calc-box-title {
    display: block;
    font-size: .8rem;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: .75rem;
}

.calc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
}

.calc-output {
    display: block;
    margin-top: .35rem;
    padding: .5rem .65rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-weight: 600;
    color: var(--primary);
    font-size: .95rem;
}

.record-meta-hint {
    margin: 0 0 1rem;
    padding: .6rem .85rem;
    background: var(--surface2);
    border-radius: 8px;
    font-size: .85rem;
    color: var(--muted);
    border-left: 3px solid var(--primary);
}

body.menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    left: 0;
    right: 0;
}

@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(288px, 88vw);
        max-width: 288px;
        flex: none;
        z-index: 1100;
        transform: translateX(-105%);
        opacity: 1;
        pointer-events: auto;
        padding: 1rem 1rem 1.25rem;
        padding-top: max(1rem, env(safe-area-inset-top));
        box-shadow: 4px 0 24px rgba(15, 23, 42, 0.2);
        transition: transform 0.25s ease;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    .app-shell:not(.sidebar-collapsed) .sidebar {
        transform: translateX(0);
    }

    .app-shell.sidebar-collapsed .sidebar {
        flex-basis: auto;
        width: min(288px, 88vw);
        min-width: 0;
        padding: 1rem;
        opacity: 1;
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1050;
        margin: 0;
        padding: 0;
        border: none;
        background: rgba(15, 23, 42, 0.45);
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .sidebar-backdrop[hidden] {
        display: none !important;
    }

    .main {
        width: 100%;
        padding: 0.75rem 1rem 1.25rem;
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }

    .main-topbar {
        margin-bottom: 1rem;
        padding-top: max(0.35rem, env(safe-area-inset-top));
    }

    .sidebar-toggle {
        width: 44px;
        height: 44px;
    }

    body.menu-open .main-topbar {
        position: fixed;
        top: max(0.35rem, env(safe-area-inset-top));
        left: max(1rem, env(safe-area-inset-left));
        z-index: 1200;
        margin-bottom: 0;
        padding: 0.35rem 0;
        background: transparent;
        pointer-events: auto;
    }

    .nav {
        flex-direction: column;
        flex-wrap: nowrap;
        gap: 0.15rem;
    }

    .nav a {
        padding: 0.85rem 1rem;
        font-size: 0.95rem;
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .page-header h1 {
        font-size: 1.25rem;
        line-height: 1.3;
        padding-right: 0;
    }

    .page-header .btn,
    .page-header .actions-inline {
        width: 100%;
    }

    .page-header .btn {
        justify-content: center;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .stats-grid--relatorio {
        grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
        gap: 0.55rem;
    }

    .stat-card .value {
        font-size: 0.95rem;
    }
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }

    .filters {
        flex-direction: column;
        align-items: stretch;
    }

    .filters .form-group {
        min-width: 0;
        width: 100%;
    }

    .filters .btn {
        width: 100%;
    }

    .filters-grid {
        grid-template-columns: 1fr 1fr;
    }

    .filters-busca,
    .filters-actions {
        grid-column: 1 / -1;
    }

    th, td {
        padding: 0.55rem 0.5rem;
        font-size: 0.8rem;
    }

    .table-planilha td.col-acoes {
        min-width: 8rem;
        padding-left: 0.35rem;
        padding-right: 0.35rem;
    }

    .table-planilha td.col-acoes .actions-inline {
        gap: 0.2rem;
    }

    .table-planilha td.col-acoes .btn-icon {
        padding: 0.3rem;
        min-width: 1.85rem;
        min-height: 1.85rem;
    }

    .table-planilha td.col-acoes .ico-acao {
        width: 0.9rem;
        height: 0.9rem;
    }

    .card {
        padding: 1rem;
    }

    .charts-grid,
    .charts-grid--modern {
        grid-template-columns: 1fr;
    }

    .charts-row--donuts {
        grid-template-columns: 1fr;
    }

    .charts-grid--modern .chart-card,
    .charts-grid--modern .chart-card--hero,
    .charts-grid--modern .chart-card--wide,
    .chart-card--wide,
    .chart-card--full {
        grid-column: span 1;
    }

    .chart-wrap,
    .chart-wrap--tall,
    .chart-wrap--hero {
        height: 240px;
    }

    .chart-wrap--compact {
        height: 180px;
    }

    .table-registros .col-datetime {
        font-size: 0.78rem;
    }

    .user-chip small {
        font-size: 0.68rem;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid--relatorio {
        grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
    }

    .page-header h1 {
        font-size: 1.15rem;
    }

    .filters-grid {
        grid-template-columns: 1fr;
    }
}

/* Aba RESUMO da planilha */
.resumo-planilha {
    padding: 0;
    overflow: hidden;
}

.table-resumo {
    width: 100%;
    border-collapse: collapse;
}

.table-resumo th,
.table-resumo td {
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.table-resumo th {
    background: var(--surface2);
    font-weight: 600;
    color: var(--muted);
    width: 28%;
}

.table-resumo .resumo-valor {
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--primary);
    width: 22%;
}

.table-resumo tr:last-child th,
.table-resumo tr:last-child td {
    border-bottom: none;
}

.table-meses {
    width: 100%;
    min-width: 1180px;
    border-collapse: collapse;
    table-layout: fixed;
}

.table-meses th,
.table-meses td {
    width: 7.2%;
    padding: 0.7rem 0.4rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    white-space: nowrap;
}

.table-meses th:last-child,
.table-meses td:last-child {
    border-right: none;
}

.table-meses th {
    background: var(--surface2);
    font-weight: 600;
    font-size: 0.68rem;
    color: var(--muted);
    letter-spacing: 0.02em;
}

.table-meses .mes-label,
.table-meses th.mes-label,
.table-meses td.mes-label {
    width: 110px;
    min-width: 110px;
    text-align: left;
    padding-left: 0.85rem;
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--surface2);
    color: var(--primary);
    font-weight: 700;
    font-size: 0.72rem;
}

.table-meses td.resumo-valor {
    font-weight: 700;
    font-size: 0.82rem;
    color: var(--primary);
}

.table-meses td.resumo-valor.valor-receita {
    color: var(--success);
}

.table-meses td.resumo-valor.valor-despesa {
    color: var(--danger);
}

.table-meses tbody tr:last-child td,
.table-meses tbody tr:last-child th {
    border-bottom: none;
}

.table-matriz {
    width: max(100%, 122rem);
    min-width: 122rem;
    border-collapse: collapse;
    font-size: 0.75rem;
    table-layout: fixed;
}

.table-matriz .col-tipo { width: 14rem; }
.table-matriz .col-mes { width: 7.25rem; }
.table-matriz .col-total { width: 8.25rem; }
.table-matriz .col-media { width: 8.25rem; }
.table-matriz .col-pct { width: 4.5rem; }

.table-matriz th,
.table-matriz td {
    padding: 0.42rem 0.4rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    white-space: nowrap;
    overflow: visible;
}

.table-matriz th:last-child,
.table-matriz td:last-child {
    border-right: none;
}

.table-matriz thead th {
    background: var(--surface2);
    font-weight: 600;
    font-size: 0.65rem;
    color: var(--muted);
    letter-spacing: 0.02em;
}

.table-matriz .th-sort a {
    color: inherit;
    text-decoration: none;
}

.table-matriz .th-sort a:hover,
.table-matriz .th-sort.is-sorted a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 800;
}

.table-matriz .matriz-tipo {
    position: sticky;
    left: 0;
    z-index: 2;
    min-width: 0;
    max-width: none;
    text-align: left;
    padding-left: 0.55rem;
    background: var(--surface);
    font-weight: 700;
    color: var(--text);
    white-space: normal;
    overflow: visible;
    overflow-wrap: anywhere;
    word-break: break-word;
    hyphens: auto;
    line-height: 1.3;
    vertical-align: middle;
}

.table-matriz thead .matriz-tipo {
    background: var(--surface2);
    z-index: 3;
}

.table-matriz .matriz-pct {
    font-weight: 700;
    color: var(--primary);
    min-width: 0;
    font-variant-numeric: tabular-nums;
}

.table-matriz .matriz-media,
.table-matriz .matriz-valor {
    font-weight: 700;
    min-width: 0;
    font-variant-numeric: tabular-nums;
    overflow: visible;
}

.table-matriz .matriz-zero {
    color: var(--muted) !important;
    font-weight: 400;
}

.table-matriz .matriz-grupo th {
    background: var(--primary-light);
    color: var(--primary);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    text-align: left;
}

.table-matriz .matriz-total th,
.table-matriz .matriz-total td {
    background: var(--surface2);
    font-weight: 700;
}

.table-matriz .matriz-titulo th {
    text-align: center;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    padding: 0.65rem 0.4rem;
    color: #fff;
}

.table-matriz .matriz-titulo .matriz-tipo {
    color: #fff;
}

.table-matriz .matriz-titulo--despesa th,
.table-matriz .matriz-titulo--despesa .matriz-tipo {
    background: #8a1c1c;
}

.table-matriz .matriz-titulo--receita th,
.table-matriz .matriz-titulo--receita .matriz-tipo {
    background: #3d5c28;
}

.table-matriz .matriz-titulo--saldo th,
.table-matriz .matriz-titulo--saldo .matriz-tipo {
    background: var(--primary);
}

.table-matriz .matriz-variacao th.matriz-tipo {
    white-space: normal;
    min-width: 150px;
    max-width: 200px;
    font-size: 0.68rem;
    line-height: 1.35;
    background: #fff8ee;
}

.table-matriz .matriz-variacao th.matriz-tipo small {
    display: block;
    margin-top: 0.25rem;
    font-weight: 400;
    color: var(--muted);
    text-transform: none;
    letter-spacing: 0;
}

.table-matriz .matriz-variacao td {
    background: #fff8ee;
    font-size: 0.7rem;
}

.table-matriz .matriz-saldo th,
.table-matriz .matriz-saldo td {
    background: #f0e4d4;
    font-weight: 800;
    font-size: 0.75rem;
    border-top: 3px solid var(--primary);
    border-bottom: 3px solid var(--primary);
}

.table-matriz .matriz-saldo th.matriz-tipo {
    background: #f0e4d4;
    color: var(--primary-hover);
}

.table-matriz tbody tr.matriz-saldo:hover td,
.table-matriz tbody tr.matriz-saldo:hover th.matriz-tipo {
    background: #e8d5bc;
}

.table-matriz tbody tr:hover td,
.table-matriz tbody tr:hover th.matriz-tipo {
    background: var(--primary-light);
}

.stat-card--link {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stat-card--link:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    text-decoration: none;
}

/* Tabelas estilo planilha Excel */
.table-planilha {
    font-size: 0.72rem;
    white-space: nowrap;
    border: 1px solid var(--border);
}

.table-planilha th,
.table-planilha td {
    border-right: 1px solid var(--border);
    padding: 0.45rem 0.5rem;
}

.table-planilha th:last-child,
.table-planilha td:last-child {
    border-right: none;
}

.table-planilha th {
    background: var(--primary-light);
    color: var(--primary-hover);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.th-sort {
    white-space: nowrap;
}

.th-sort a {
    color: inherit;
    text-decoration: none;
    display: inline-block;
}

.th-sort a:hover,
.th-sort.is-sorted a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 700;
}

.table-planilha .badge {
    font-size: 0.65rem;
    padding: 0.15rem 0.4rem;
}

.table-planilha .btn-sm:not(.btn-icon) {
    font-size: 0.68rem;
    padding: 0.25rem 0.5rem;
}

.table-planilha .btn-sm.btn-icon {
    padding: 0.38rem;
}

.table-planilha th.col-acoes,
.table-planilha td.col-acoes {
    width: 1%;
    min-width: 10.5rem;
    white-space: nowrap;
    vertical-align: middle;
    text-align: left;
}

.table-planilha td.col-acoes--wide {
    min-width: 12rem;
}

.table-planilha td.col-acoes .actions-inline {
    display: inline-flex;
    flex-wrap: nowrap;
}

/* Listas que ainda usam actions-inline direto na célula */
.table-planilha td.actions-inline:not(.col-acoes) {
    display: table-cell;
    width: 1%;
    min-width: 10.5rem;
    white-space: nowrap;
    vertical-align: middle;
}

.table-planilha td.actions-inline:not(.col-acoes) > a,
.table-planilha td.actions-inline:not(.col-acoes) > form,
.table-planilha td.actions-inline:not(.col-acoes) > button {
    display: inline-flex;
    vertical-align: middle;
    margin-right: 0.28rem;
}

.table-planilha td.actions-inline:not(.col-acoes) > *:last-child {
    margin-right: 0;
}

.page-header .actions-inline {
    display: flex;
    flex-wrap: wrap;
}

.col-id {
    width: 1%;
    text-align: center;
    white-space: nowrap;
}

.table-wrap--scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.col-obs {
    max-width: 140px;
    white-space: normal;
    font-size: 0.68rem;
    color: var(--muted);
}

.input-readonly {
    background: var(--surface2);
    color: var(--muted);
    cursor: default;
}

.status-dose.badge-danger {
    color: var(--danger);
    font-weight: 600;
}

.status-dose.badge-warning {
    color: var(--warning);
    font-weight: 600;
}

.status-dose.badge-success {
    color: var(--success);
    font-weight: 600;
}

.status-dose.badge-neutral {
    color: var(--muted);
    font-weight: 600;
}

.table-rebanho th {
    font-size: 0.64rem;
    letter-spacing: 0.03em;
}

@media (max-width: 900px) {
    .table-resumo th,
    .table-resumo td {
        display: block;
        width: 100%;
        padding: 0.5rem 1rem;
    }

    .table-resumo tr {
        display: grid;
        grid-template-columns: 1fr 1fr;
        border-bottom: 1px solid var(--border);
    }

    .table-resumo th {
        background: transparent;
        font-size: 0.75rem;
        padding-bottom: 0;
    }

    .table-resumo .resumo-valor {
        font-size: 1rem;
        padding-top: 0;
        padding-bottom: 0.75rem;
    }

    .table-meses th,
    .table-meses td {
        padding: 0.5rem 0.35rem;
        font-size: 0.62rem;
    }

    .table-meses td.resumo-valor {
        font-size: 0.75rem;
    }
}

/* Modal de confirmação / alerta */
.gado-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.gado-modal[hidden] {
    display: none !important;
}

.gado-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(44, 36, 25, 0.45);
}

.gado-modal-box {
    position: relative;
    width: min(100%, 420px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem 1.35rem 1.1rem;
    animation: gadoModalIn 0.18s ease-out;
}

@keyframes gadoModalIn {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.gado-modal-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.gado-modal-message {
    font-size: 0.9rem;
    color: var(--muted);
    line-height: 1.45;
    text-transform: none;
    margin-bottom: 1.1rem;
}

.gado-modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
}

.gado-modal-actions .btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.gado-modal-actions .btn-danger:hover {
    background: #991b1b;
    border-color: #991b1b;
    color: #fff;
}

.badge-receita { background: #dcfce7; color: var(--success); }
.badge-despesa { background: #fee2e2; color: var(--danger); }
.valor-receita { color: var(--success); font-weight: 700; white-space: nowrap; }
.valor-despesa { color: var(--danger); font-weight: 700; white-space: nowrap; }
.valor-saldo { color: var(--primary); font-weight: 700; white-space: nowrap; }
.crescimento-up { color: var(--success); font-weight: 700; }
.crescimento-down { color: var(--danger); font-weight: 700; }
.stat-delta { font-size: 0.72rem; margin-top: 0.25rem; font-weight: 600; }

.brand-fallback {
    width: 148px;
    height: 148px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #8b5a2b 0%, #3d2817 100%);
    color: #faf6f1;
    font-size: 2.4rem;
    font-weight: 700;
    border: 3px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.28);
    letter-spacing: 0.04em;
}

.login-fallback {
    width: 160px;
    height: 160px;
    font-size: 2.8rem;
    margin: 0 auto 0.75rem;
}

.mes-curto { display: none; }

.relatorio-detalhado {
    white-space: normal;
}

.relatorio-detalhado th,
.relatorio-detalhado td {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    hyphens: auto;
    line-height: 1.3;
    vertical-align: top;
}

.relatorio-detalhado .col-id,
.relatorio-detalhado .celula-data,
.relatorio-detalhado .celula-numero {
    white-space: nowrap;
    overflow-wrap: normal;
    word-break: normal;
    hyphens: none;
}

.relatorio-mes-titulo td {
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.03em;
    padding: 0.55rem 0.6rem;
}

.relatorio-parcela td {
    background: var(--surface2);
    color: var(--muted);
    font-size: 0.7rem;
}

.relatorio-mes-total td,
.relatorio-geral-total td {
    background: var(--primary-light);
    font-weight: 700;
    border-top: 2px solid var(--border);
}

.relatorio-geral-total td {
    background: #e8d5bc;
    border-top: 3px solid var(--primary);
}

.relatorio-print-header {
    display: none;
}

@media print {
    @page {
        margin: 7mm 6mm 6mm;
    }

    html, body {
        width: 100% !important;
        height: auto !important;
        background: #fff !important;
        text-transform: none;
        overflow: visible !important;
    }

    .sidebar,
    .sidebar-toggle,
    .sidebar-backdrop,
    .main-topbar,
    .no-print,
    .stats-grid,
    .page-header .actions-inline {
        display: none !important;
    }

    .app-shell {
        display: block;
        min-height: 0;
    }

    .main,
    .main-inner {
        padding: 0 !important;
        margin: 0 !important;
        background: #fff;
        overflow: visible !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .relatorio-print-header {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        gap: 8mm;
        border-bottom: 1.6pt solid #3d2817;
        padding: 0 0 2.2mm;
        margin: 0 0 3mm;
    }

    .relatorio-print-brand {
        display: flex;
        align-items: center;
        gap: 3mm;
        min-width: 0;
    }

    .relatorio-print-brand img {
        height: 11mm;
        width: auto;
        max-width: 28mm;
        object-fit: contain;
    }

    .relatorio-print-brand strong {
        display: block;
        font-size: 11pt;
        font-weight: 700;
        color: #3d2817;
        line-height: 1.15;
    }

    .relatorio-print-brand small {
        display: block;
        font-size: 7.5pt;
        color: #6b5344;
        letter-spacing: 0.04em;
    }

    .relatorio-print-meta {
        text-align: right;
    }

    .relatorio-print-meta h1 {
        margin: 0;
        font-size: 12pt;
        font-weight: 700;
        color: #3d2817;
        line-height: 1.2;
    }

    .relatorio-print-meta p {
        margin: 0.6mm 0 0;
        font-size: 8pt;
        color: #5a4638;
    }

    .card,
    .card-print {
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .table-wrap,
    .table-wrap--scroll {
        overflow: visible !important;
        margin: 0 0 2.2mm !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .table-matriz {
        min-width: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
        table-layout: fixed !important;
        font-size: 6.8pt !important;
        border-collapse: collapse;
    }

    .table-matriz .col-tipo { width: 11% !important; }
    .table-matriz .col-mes { width: 5.55% !important; }
    .table-matriz .col-total,
    .table-matriz .col-media { width: 7.2% !important; }
    .table-matriz .col-pct { width: 4.2% !important; }

    .table-matriz th,
    .table-matriz td {
        padding: 0.55mm 0.08mm !important;
        font-size: 6.8pt !important;
        line-height: 1.15;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: clip;
    }

    .table-matriz .matriz-tipo {
        position: static !important;
        min-width: 0 !important;
        max-width: none !important;
        width: auto !important;
        padding-left: 0.8mm !important;
        font-size: 7pt !important;
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: unset !important;
        overflow-wrap: anywhere;
        word-break: break-word;
        hyphens: auto;
        line-height: 1.2;
    }

    .table-matriz .matriz-titulo th {
        font-size: 8pt !important;
        padding: 1mm 0.2mm !important;
        letter-spacing: 0.04em;
    }

    .table-matriz .matriz-valor,
    .table-matriz .matriz-pct,
    .table-matriz .matriz-media,
    .table-matriz .valor-receita,
    .table-matriz .valor-despesa {
        font-size: 6.8pt !important;
        min-width: 0 !important;
        overflow: visible !important;
        text-overflow: unset !important;
        white-space: nowrap !important;
        letter-spacing: -0.03em;
        padding-left: 0.05mm !important;
        padding-right: 0.05mm !important;
    }

    .table-matriz .matriz-saldo th,
    .table-matriz .matriz-saldo td {
        font-size: 7pt !important;
        border-top-width: 1pt;
        border-bottom-width: 1pt;
    }

    .table-matriz .matriz-variacao th,
    .table-matriz .matriz-variacao td {
        font-size: 6.2pt !important;
        padding: 0.4mm 0.05mm !important;
    }

    .table-matriz .matriz-variacao th.matriz-tipo {
        min-width: 0 !important;
        max-width: none !important;
        white-space: normal !important;
        overflow: visible !important;
        font-size: 7pt !important;
    }

    .mes-completo { display: none !important; }
    .mes-curto { display: inline !important; }
    .moeda-rs { display: none !important; }

    .relatorio-detalhado {
        min-width: 0 !important;
        width: 100% !important;
        font-size: 7.5pt !important;
    }

    .relatorio-detalhado th,
    .relatorio-detalhado td {
        padding: 0.7mm 0.6mm !important;
        font-size: 7.5pt !important;
        line-height: 1.25;
        white-space: normal !important;
        overflow: visible !important;
        overflow-wrap: anywhere;
        word-break: break-word;
        hyphens: auto;
    }

    .relatorio-detalhado .col-id,
    .relatorio-detalhado .celula-data,
    .relatorio-detalhado .celula-numero,
    .relatorio-detalhado .valor-receita,
    .relatorio-detalhado .valor-despesa {
        white-space: nowrap !important;
        overflow: visible !important;
        overflow-wrap: normal !important;
        word-break: normal !important;
        hyphens: none !important;
        font-size: 7.4pt !important;
    }

    .relatorio-detalhado .th-sort a {
        color: inherit;
        text-decoration: none;
    }

    .relatorio-mes-titulo td {
        background: #3d2817 !important;
        color: #fff !important;
    }

    .relatorio-parcela td {
        background: #f4eee6 !important;
    }

    .relatorio-mes-total td {
        background: #f0e4d2 !important;
    }

    .relatorio-geral-total td {
        background: #e8d5bc !important;
    }

    * {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        box-shadow: none !important;
    }
}

@media print {
    body.print-portrait .relatorio-print-brand img {
        height: 9mm;
    }

    body.print-portrait .relatorio-print-brand strong,
    body.print-portrait .relatorio-print-meta h1 {
        font-size: 10pt !important;
    }

    body.print-portrait .relatorio-print-meta p,
    body.print-portrait .relatorio-print-brand small {
        font-size: 7pt !important;
    }

    body.print-portrait .table-matriz {
        font-size: 5.2pt !important;
    }

    body.print-portrait .table-matriz th,
    body.print-portrait .table-matriz td {
        font-size: 5.2pt !important;
        padding: 0.3mm 0.04mm !important;
    }

    body.print-portrait .table-matriz .matriz-tipo {
        font-size: 5.4pt !important;
        padding-left: 0.4mm !important;
    }

    body.print-portrait .table-matriz .matriz-titulo th {
        font-size: 7pt !important;
        padding: 0.6mm 0.1mm !important;
    }

    body.print-portrait .table-matriz .matriz-valor,
    body.print-portrait .table-matriz .matriz-pct,
    body.print-portrait .table-matriz .matriz-media,
    body.print-portrait .table-matriz .valor-receita,
    body.print-portrait .table-matriz .valor-despesa,
    body.print-portrait .table-matriz .matriz-saldo th,
    body.print-portrait .table-matriz .matriz-saldo td,
    body.print-portrait .table-matriz .matriz-variacao th,
    body.print-portrait .table-matriz .matriz-variacao td,
    body.print-portrait .table-matriz .matriz-variacao th.matriz-tipo {
        font-size: 5.2pt !important;
        letter-spacing: -0.03em;
    }

    body.print-portrait .table-matriz .col-tipo { width: 12% !important; }
    body.print-portrait .table-matriz .col-mes { width: 5.35% !important; }
    body.print-portrait .table-matriz .col-total,
    body.print-portrait .table-matriz .col-media { width: 6.6% !important; }
    body.print-portrait .table-matriz .col-pct { width: 3.8% !important; }

    body.print-portrait .table-matriz .matriz-tipo,
    body.print-portrait .table-matriz .matriz-variacao th.matriz-tipo {
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: unset !important;
    }
}
