/* ═══════════════════════════════════════════════════════════
   Reports Page
═══════════════════════════════════════════════════════════ */
.main-content {
    padding: 0 20px;
}

.report-filter-bar {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    padding: 14px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.report-filter-bar .filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 140px;
}
.report-filter-bar .filter-group.grow { flex: 1; min-width: 0; }
.report-filter-bar .filter-group label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-3);
    font-weight: 600;
}
.report-filter-bar input,
.report-filter-bar select {
    background: var(--surface-2);
    border: 1px solid var(--border-mid);
    border-radius: var(--radius);
    padding: 6px 10px;
    font-size: 11px;
    font-family: var(--font);
    color: var(--text-1);
    outline: none;
    transition: border-color .15s;
}
.report-filter-bar input:focus,
.report-filter-bar select:focus {
    border-color: var(--teal);
}

.date-range {
    display: flex;
    align-items: center;
    gap: 6px;
}
.date-range span {
    font-size: 10px;
    color: var(--text-3);
}

.quick-ranges {
    flex-direction: row !important;
    flex-wrap: wrap;
    gap: 4px;
    align-items: flex-end;
    padding-bottom: 2px;
}
.quick-ranges button {
    background: var(--surface-2);
    border: 1px solid var(--border-mid);
    border-radius: var(--radius);
    padding: 5px 12px;
    font-size: 10px;
    font-family: var(--font);
    color: var(--text-2);
    cursor: pointer;
    transition: all .15s;
}
.quick-ranges button:hover {
    background: var(--surface-3);
    color: var(--text-1);
}
.quick-ranges button.active {
    background: var(--teal-bg);
    border-color: var(--teal);
    color: var(--teal);
}

.report-record-count {
    font-size: 11px;
    color: var(--text-3);
    font-family: var(--mono);
}

/* Loading */
.report-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 4rem;
    color: var(--text-3);
    font-size: 12px;
}
.report-loading .spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--surface-3);
    border-top-color: var(--teal);
    border-radius: 50%;
    animation: rpt-spin 1s linear infinite;
}
@keyframes rpt-spin { to { transform: rotate(360deg); } }

/* ─── Report Cards ─── */
.report-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
    margin-bottom: 1.5rem;
}
.report-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    cursor: pointer;
    transition: all .2s var(--ease, ease);
    position: relative;
}
.report-card:hover {
    border-color: var(--border-mid);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
}
.report-card.active {
    border-color: var(--teal);
    box-shadow: 0 0 0 2px var(--teal-bg);
}
.report-card .rc-icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 10px;
    background: var(--surface-2);
    color: var(--teal);
}
.report-card .rc-icon svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; }
.report-card h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-1);
    margin-bottom: 4px;
}
.report-card p {
    font-size: 11px;
    color: var(--text-3);
    line-height: 1.4;
}
.report-card .rc-badge {
    position: absolute;
    top: 12px; right: 12px;
    font-size: 9px;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--amber-bg);
    color: var(--amber);
    font-weight: 600;
}

/* ─── Summary Cards ─── */
.report-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    margin-bottom: 1.5rem;
}
.report-summary .rs-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
}
.report-summary .rs-card .rs-label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-3);
    font-weight: 600;
    margin-bottom: 4px;
}
.report-summary .rs-card .rs-value {
    font-size: 20px;
    font-weight: 700;
    font-family: var(--mono);
    color: var(--text-1);
    line-height: 1.2;
}
.report-summary .rs-card .rs-meta {
    font-size: 10px;
    color: var(--text-3);
    margin-top: 2px;
}
.report-summary .rs-card.green  .rs-value { color: var(--green); }
.report-summary .rs-card.amber  .rs-value { color: var(--amber); }
.report-summary .rs-card.red    .rs-value { color: var(--red); }
.report-summary .rs-card.teal   .rs-value { color: var(--teal); }
.report-summary .rs-card.blue   .rs-value { color: var(--blue); }

/* ─── Charts ─── */
.report-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 12px;
    margin-bottom: 1.5rem;
}
.report-chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
}
.report-chart-card h4 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-1);
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.report-chart-card h4 small {
    font-size: 10px;
    color: var(--text-3);
    font-weight: 400;
}

/* Simple inline bar chart (no chart library needed) */
.mini-bar-chart {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.mini-bar-row {
    display: grid;
    grid-template-columns: 100px 1fr 80px;
    gap: 10px;
    align-items: center;
    font-size: 11px;
}
.mini-bar-row .mb-label {
    color: var(--text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mini-bar-row .mb-track {
    height: 8px;
    background: var(--surface-3);
    border-radius: 4px;
    overflow: hidden;
}
.mini-bar-row .mb-fill {
    height: 100%;
    border-radius: 4px;
    transition: width .5s ease;
}
.mini-bar-row .mb-value {
    text-align: right;
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-1);
    white-space: nowrap;
}

/* Donut (CSS-only) */
.donut {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    position: relative;
}
.donut::before {
    content: '';
    position: absolute;
    inset: 18px;
    background: var(--surface);
    border-radius: 50%;
}
.donut .donut-center {
    position: relative;
    text-align: center;
    z-index: 1;
}
.donut .donut-center .dc-value {
    font-size: 20px;
    font-weight: 700;
    font-family: var(--mono);
    color: var(--text-1);
}
.donut .donut-center .dc-label {
    font-size: 9px;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: .06em;
}

/* ─── Data Table ─── */
.report-table-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.report-table-card .rtc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
    flex-wrap: wrap;
}
.report-table-card .rtc-header h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-1);
}
.report-table-card .rtc-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}
.report-table-card .rtc-actions button {
    background: var(--surface-2);
    border: 1px solid var(--border-mid);
    border-radius: var(--radius);
    padding: 5px 12px;
    font-size: 10px;
    font-family: var(--font);
    color: var(--text-2);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.report-table-card .rtc-actions button:hover {
    background: var(--surface-3);
    color: var(--text-1);
}
.report-table-card table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}
.report-table-card thead th {
    background: var(--surface-2);
    color: var(--text-3);
    text-align: left;
    padding: 10px 12px;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.report-table-card thead th.right  { text-align: right; }
.report-table-card thead th.center { text-align: center; }
.report-table-card tbody td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-2);
    vertical-align: middle;
}
.report-table-card tbody tr:last-child td { border-bottom: none; }
.report-table-card tbody tr:hover td { background: var(--surface-2); }
.report-table-card tbody td.right  { text-align: right; font-family: var(--mono); }
.report-table-card tbody td.center { text-align: center; }
.report-table-card tbody td.mono   { font-family: var(--mono); font-size: 10px; }
.report-table-card tbody td.bold   { font-weight: 600; color: var(--text-1); }
.report-table-card tbody td.credit { color: var(--green); }
.report-table-card tbody td.debit  { color: var(--red); }
.report-table-card tbody tr.empty td {
    text-align: center;
    padding: 3rem;
    color: var(--text-3);
    font-style: italic;
}
.report-table-card tfoot td {
    padding: 10px 12px;
    border-top: 2px solid var(--border-mid);
    background: var(--surface-2);
    font-weight: 700;
    color: var(--text-1);
    font-size: 11px;
}
.report-table-card tfoot td.right { text-align: right; font-family: var(--mono); }

/* Pagination */
.report-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 8px;
}
.report-pagination .rp-info {
    font-size: 11px;
    color: var(--text-3);
}
.report-pagination .rp-controls {
    display: flex;
    gap: 4px;
    align-items: center;
}
.report-pagination button {
    background: var(--surface-2);
    border: 1px solid var(--border-mid);
    border-radius: var(--radius);
    padding: 4px 12px;
    font-size: 10px;
    font-family: var(--font);
    color: var(--text-2);
    cursor: pointer;
}
.report-pagination button:disabled {
    opacity: .4;
    cursor: not-allowed;
}
.report-pagination span {
    font-size: 10px;
    color: var(--text-3);
    padding: 0 8px;
}

/* Empty / error states */
.report-empty {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-3);
}
.report-empty .re-icon { font-size: 48px; margin-bottom: 12px; }
.report-empty .re-title { font-size: 14px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
.report-empty .re-sub { font-size: 11px; }

@media (max-width: 768px) {
    .report-filter-bar { flex-direction: column; align-items: stretch; }
    .report-filter-bar .filter-group { min-width: 0; width: 100%; }
    .quick-ranges { justify-content: center; }
    .report-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
    .report-charts { grid-template-columns: 1fr; }
    .mini-bar-row { grid-template-columns: 80px 1fr 70px; font-size: 10px; }
}



.tb-section { margin-bottom: 24px; }
.tb-section-header { 
    display: flex; justify-content: space-between;
    padding: 8px 12px;
    background: var(--surface-2);
    border-bottom: 2px solid var(--teal);
    text-transform: uppercase; letter-spacing: .06em;
    font-size: 10px; font-weight: 600;
}
.tb-row { display: grid; grid-template-columns: 80px 1fr 140px 140px; }
.tb-row .amount { text-align: right; font-family: var(--mono); }
.tb-row .debit { color: var(--text-1); }
.tb-row .credit { color: var(--text-1); }
.tb-totals { border-top: 3px double var(--ink); }
.tb-recon-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tb-recon-card { padding: 12px 16px; border-radius: var(--radius); }
.tb-recon-card.match { background: var(--green-bg); border: 1px solid var(--green-dim); }
.tb-recon-card.warning { background: var(--amber-bg); border: 1px solid rgba(251,191,36,.3); }

@media print {
    .tb-row { grid-template-columns: 80px 1fr 120px 120px; font-size: 11px; }
    .tb-recon-grid { grid-template-columns: 1fr; }
    .reports-actions { display: none; }
    .tb-signature { display: flex; justify-content: space-between; margin-top: 40px; }
}

/* ═══════════════════════════════════════════════════════════
   TRIAL BALANCE — print overrides
   ═══════════════════════════════════════════════════════════ */

@media print {
    /* Hide chrome */
    .sidebar,
    .topbar,
    .report-filter-bar,
    .toast,
    .reports-actions { display: none !important; }

    .main-content { padding: 0 !important; }

    /* Expand table */
    .tb-table { width: 100% !important; font-size: 10px; }
    .tb-table th,
    .tb-table td { padding: 4px 8px !important; }

    /* Show signature block */
    .tb-signature { display: flex !important; }

    /* Page breaks */
    .tb-table { page-break-inside: avoid; }
    .tb-header { page-break-after: avoid; }

    /* Greyscale reconciliation */
    .tb-table [style*="green-bg"],
    .tb-table [style*="amber-bg"] {
        background: transparent !important;
        border: 1px solid #ccc !important;
    }

    /* Force black on white */
    body, .tb-header, .tb-table, .tb-table * {
        color: #000 !important;
        background: #fff !important;
    }
}

/* Screen — reconciliation cards look better than a table */
.tb-table tbody tr:hover { background: var(--surface-2); }

