body {
    font-family: Arial, Helvetica, sans-serif;
    background: #f3f4f6;
    margin: 0;
    color: #1f2933;
}

.container {
    width: 95%;
    max-width: 1200px;
    margin: 0 auto;
}

.topbar {
    background: #0f172a;
    color: #fff;
    padding: 12px 0;
}

.brand {
    font-size: 20px;
    font-weight: bold;
}

.user-info {
    float: right;
    font-size: 14px;
}

.user-info a {
    color: #fff;
    margin-left: 12px;
}

.menu {
    background: #1e293b;
    padding: 10px 0;
}

.menu a {
    color: #cbd5f5;
    margin-right: 18px;
    text-decoration: none;
    font-size: 14px;
}

.menu a.active,
.menu a:hover {
    color: #fff;
    font-weight: bold;
}

.menu-item {
    display: inline-block;
    position: relative;
    margin-right: 18px;
}

.menu-item summary {
    list-style: none;
}

.menu-item summary::-webkit-details-marker {
    display: none;
}

.menu-item summary::marker {
    content: "";
}

.menu-label {
    color: #cbd5f5;
    font-size: 14px;
    cursor: pointer;
}

.menu-item.active .menu-label,
.menu-label:hover,
.menu-item:focus-within .menu-label {
    color: #fff;
    font-weight: bold;
}

.submenu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 230px;
    background: #0f172a;
    border-radius: 6px;
    padding: 8px 0;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.2);
    z-index: 20;
}

.menu-item:hover .submenu,
.menu-item:focus-within .submenu,
.menu-item[open] .submenu {
    display: block;
}

.submenu a {
    display: block;
    margin: 0;
    padding: 6px 14px;
}

.submenu a.active,
.submenu a:hover {
    color: #fff;
    font-weight: bold;
    background: rgba(255, 255, 255, 0.08);
}

.content {
    padding: 24px 0 40px;
}

.panel {
    background: #fff;
    padding: 16px;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    margin-bottom: 18px;
}

.panel h2 {
    margin-top: 0;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
}

.form-row label {
    display: block;
    font-size: 13px;
    margin-bottom: 4px;
}

.form-row input,
.form-row select,
.form-row textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #cbd5f5;
    border-radius: 4px;
    font-size: 14px;
}

.form-group {
    flex: 1;
    min-width: 180px;
}

.permission-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
    margin-top: 8px;
}

.permission-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.action-row {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    align-items: center;
    white-space: nowrap;
}

.action-row .button {
    padding: 6px 10px;
    font-size: 12px;
}

button,
.button {
    background: #1d4ed8;
    color: #fff;
    border: none;
    padding: 8px 14px;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    font-size: 14px;
}

button.secondary,
.button.secondary {
    background: #64748b;
}

.button.active {
    background: #0f172a;
}

.print-options {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    font-size: 13px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table th,
.table td {
    padding: 8px 10px;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
}

.badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    display: inline-block;
}

.badge.open {
    background: #fee2e2;
    color: #b91c1c;
}

.badge.paid {
    background: #dcfce7;
    color: #166534;
}

.badge.active {
    background: #dcfce7;
    color: #166534;
}

.badge.inactive {
    background: #fee2e2;
    color: #b91c1c;
}

.amount-positive {
    color: #166534;
    font-weight: bold;
}

.amount-negative {
    color: #b91c1c;
    font-weight: bold;
}

.notice {
    padding: 10px 12px;
    background: #e0f2fe;
    border: 1px solid #bae6fd;
    border-radius: 4px;
    margin-bottom: 12px;
}

.footer {
    text-align: center;
    padding: 20px 0;
    color: #94a3b8;
    font-size: 13px;
}

.carnet-sheet {
    border: 1px solid #1f2933;
    padding: 0;
    margin-bottom: 18px;
    background: #fff;
}

.carnet-client-block {
    margin-bottom: 28px;
}

.carnet-client-header {
    border: 1px solid #cbd5f5;
    background: #f8fafc;
    padding: 10px 12px;
    border-radius: 6px;
    margin-bottom: 12px;
}

.carnet-client-name {
    font-size: 15px;
    font-weight: bold;
}

.carnet-client-meta {
    font-size: 12px;
    color: #4b5563;
    margin-top: 4px;
}

.carnet-contract-header {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 12px;
    font-weight: bold;
    color: #1f2933;
    margin: 10px 0 8px;
}

.boleto {
    display: flex;
    flex-wrap: wrap;
    font-size: 12px;
    line-height: 1.2;
    color: #111827;
}

.boleto-stub {
    width: 30%;
    min-width: 220px;
    padding: 10px;
    border-right: 1px dashed #94a3b8;
    box-sizing: border-box;
}

.boleto-body {
    flex: 1;
    min-width: 320px;
    padding: 10px;
    box-sizing: border-box;
}

.stub-block {
    border-bottom: 1px solid #1f2933;
    padding: 6px 0;
}

.stub-block:last-child {
    border-bottom: none;
}

.stub-title,
.section-title,
.cell-title {
    font-size: 11px;
    text-transform: uppercase;
    color: #374151;
    margin-bottom: 2px;
}

.stub-value,
.section-value {
    font-size: 13px;
    font-weight: bold;
}

.stub-sub {
    font-size: 11px;
    color: #4b5563;
    margin-top: 2px;
}

.body-header {
    display: flex;
    border-bottom: 1px solid #1f2933;
    padding-bottom: 6px;
    margin-bottom: 6px;
}

.body-cedente {
    flex: 1;
    padding-right: 8px;
}

.cedente-header {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.cedente-logo {
    width: 64px;
    height: 64px;
    object-fit: contain;
    border: 1px solid #e2e8f0;
    background: #fff;
    padding: 4px;
}

.cedente-info {
    flex: 1;
}

.cedente-portal {
    text-align: center;
    min-width: 100px;
}

.cedente-portal img {
    width: 60px;
    height: 60px;
}

.body-parcela {
    width: 180px;
    border-left: 1px solid #1f2933;
    padding-left: 8px;
    box-sizing: border-box;
}

.section-text,
.cell-value,
.cell-sub {
    font-size: 12px;
}

.body-grid {
    display: flex;
    flex-wrap: wrap;
}

.body-left {
    flex: 1;
    min-width: 260px;
    padding-right: 8px;
    box-sizing: border-box;
}

.body-values {
    width: 180px;
    border-left: 1px solid #1f2933;
    padding-left: 8px;
    box-sizing: border-box;
}

.doc-grid {
    display: flex;
    border-bottom: 1px solid #1f2933;
}

.doc-cell {
    flex: 1;
    padding: 6px;
    border-right: 1px solid #1f2933;
    box-sizing: border-box;
}

.doc-cell:last-child {
    border-right: none;
}

.body-section {
    border-bottom: 1px solid #1f2933;
    padding: 6px 0;
}

.body-section:last-child {
    border-bottom: none;
}

.value-row {
    border-bottom: 1px solid #1f2933;
    padding: 6px 0;
}

.value-row:last-child {
    border-bottom: none;
}

.value-row .cell-value {
    font-weight: bold;
}

.late-highlight {
    background: #fef3c7;
    border: 1px solid #f59e0b;
}

.late-highlight .cell-value,
.late-highlight .stub-value {
    color: #92400e;
}

.stamp-box {
    margin-top: 6px;
    height: 70px;
    border: 1px dashed #94a3b8;
}

.blank-box {
    margin-top: 6px;
    height: 28px;
    border: 1px dashed #94a3b8;
}

.pix-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-start;
    margin-top: 6px;
}

.pix-qr {
    min-width: 140px;
}

.pix-info {
    flex: 1;
    min-width: 180px;
}


.pix-info .cell-value {
    word-break: break-all;
}


.company-logo-preview {
    margin-top: 8px;
}

.company-logo-preview img {
    max-height: 70px;
    border: 1px solid #e2e8f0;
    background: #fff;
    padding: 4px;
}

@media (max-width: 900px) {
    .boleto-stub {
        width: 100%;
        border-right: none;
        border-bottom: 1px dashed #94a3b8;
    }

    .boleto-body {
        width: 100%;
    }

    .body-parcela,
    .body-values {
        width: 100%;
        border-left: none;
        border-top: 1px solid #1f2933;
        margin-top: 6px;
        padding-left: 0;
    }

    .doc-grid {
        flex-direction: column;
    }

    .doc-cell {
        border-right: none;
        border-bottom: 1px solid #1f2933;
    }

    .doc-cell:last-child {
        border-bottom: none;
    }
}

@media print {
    .topbar,
    .menu,
    .footer,
    .no-print {
        display: none;
    }

    body {
        background: #fff;
    }

    .carnet-sheet {
        page-break-inside: avoid;
    }

    .carnet-client-block {
        page-break-before: always;
        break-before: page;
    }

    .carnet-client-block.first {
        page-break-before: auto;
        break-before: auto;
    }

    body.print-80mm .content,
    body.print-80mm .container {
        width: 80mm;
        max-width: 80mm;
        margin: 0;
        padding: 0;
    }

    body.print-80mm .boleto {
        flex-direction: column;
    }

    body.print-80mm .boleto-stub {
        width: 100%;
        border-right: none;
        border-bottom: 1px dashed #94a3b8;
    }

    body.print-80mm .boleto-body {
        width: 100%;
    }

    body.print-80mm .body-parcela,
    body.print-80mm .body-values {
        width: 100%;
        border-left: none;
        border-top: 1px solid #1f2933;
        margin-top: 6px;
        padding-left: 0;
    }

    body.print-80mm .doc-grid {
        flex-direction: column;
    }

    body.print-80mm .doc-cell {
        border-right: none;
        border-bottom: 1px solid #1f2933;
    }

    body.print-80mm .doc-cell:last-child {
        border-bottom: none;
    }
}

/* Dashboard */
body.dashboard-page {
    background: #f8fafc;
    background-image: radial-gradient(circle at 10% 10%, rgba(14, 165, 233, 0.12), transparent 45%),
        radial-gradient(circle at 90% 5%, rgba(234, 179, 8, 0.12), transparent 45%),
        radial-gradient(circle at 85% 85%, rgba(34, 197, 94, 0.12), transparent 45%);
}

.dashboard-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px;
    border-radius: 12px;
    background: linear-gradient(120deg, #0ea5e9 0%, #22c55e 55%, #f97316 100%);
    color: #fff;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.18);
    position: relative;
    overflow: hidden;
    margin-bottom: 18px;
}

.dashboard-hero::after {
    content: "";
    position: absolute;
    top: -40px;
    right: -30px;
    width: 180px;
    height: 180px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
}

.dashboard-hero h1 {
    margin: 0 0 6px 0;
    font-size: 24px;
}

.dashboard-hero p {
    margin: 0;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.9);
}

.dashboard-cta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    position: relative;
    z-index: 1;
}

.dashboard-hero .button {
    background: #0f172a;
}

.dashboard-hero .button.secondary {
    background: rgba(15, 23, 42, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.35);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.stat-card {
    background: linear-gradient(135deg, #ffffff 0%, rgba(var(--accent-rgb), 0.12) 100%);
    border: 1px solid rgba(var(--accent-rgb), 0.35);
    border-radius: 10px;
    padding: 14px 16px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
    position: relative;
    overflow: hidden;
}

.stat-card.link-card {
    display: block;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card.link-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 18px rgba(15, 23, 42, 0.12);
}

.stat-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgb(var(--accent-rgb));
}

.stat-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #475569;
}

.stat-value {
    margin-top: 6px;
    font-size: 26px;
    font-weight: bold;
    color: #0f172a;
}

.stat-value.positive {
    color: #166534;
}

.stat-value.negative {
    color: #b91c1c;
}

.stat-meta {
    margin-top: 6px;
    font-size: 12px;
    color: #475569;
}

.stat-link {
    margin-top: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #1d4ed8;
}

.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.chart-card {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 12px;
}

.chart-header h3 {
    margin: 0;
    font-size: 16px;
}

.chart-sub {
    font-size: 12px;
    color: #64748b;
}

.chart-body {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
}

.pie-chart {
    width: 220px;
    height: 220px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.05);
}

.pie-center {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.12);
}

.pie-value {
    font-size: 22px;
    font-weight: bold;
    color: #0f172a;
}

.pie-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
}

.legend-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 160px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-label {
    flex: 1;
    color: #334155;
}

.legend-value {
    font-weight: bold;
    color: #0f172a;
}

.bar-chart {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.bar-row {
    display: grid;
    grid-template-columns: 140px 1fr 120px;
    gap: 10px;
    align-items: center;
}

.bar-label {
    font-size: 13px;
    color: #334155;
}

.bar-track {
    height: 10px;
    border-radius: 999px;
    background: #f1f5f9;
    overflow: hidden;
}

.bar-fill {
    display: block;
    height: 100%;
    width: var(--bar-width);
    background: var(--bar-color);
    border-radius: 999px;
    animation: bar-fill 0.9s ease;
}

.bar-value {
    font-size: 13px;
    text-align: right;
    color: #0f172a;
    font-weight: 600;
}

.dashboard-shortcuts .shortcut-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

@keyframes bar-fill {
    from {
        width: 0;
    }
}

@media (max-width: 900px) {
    .dashboard-hero {
        flex-direction: column;
        align-items: flex-start;
    }

    .chart-body {
        justify-content: center;
    }

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

    .bar-value {
        text-align: left;
    }
}
