/* Buhsite additions on top of crm.css (shell copied from the coupon CRM). */
[hidden] { display: none !important; }

:root {
    --neg: #ff5c5c;
    --warn: #f0b429;
    --muted: #8a92a6;
    --auto-bg: #1d2330;
}

/* ---- Layout: no horizontal page overflow ---- */
.wrapper { min-height: 100vh; }
#content { min-width: 0; }
#page-content { min-width: 0; }

/* ---- Sidebar: fixed 240px column on lg+, offcanvas below ---- */
#sidebar { background: var(--bg-sidebar) !important; }
#sidebar .sidebar-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
#sidebar .sidebar-brand { color: inherit; text-decoration: none; }
#sidebar .sidebar-group-toggle { color: inherit; text-decoration: none; }
#sidebar .sidebar-group-toggle.collapsed .sidebar-group-chevron { transform: rotate(-90deg); }
#sidebar .sidebar-group-items { max-height: none; }
#sidebar .sidebar-sep { height: 1px; margin: 8px 16px; background: var(--border-color); }
#sidebar ul li.active > a { font-weight: 600; }

@media (min-width: 992px) {
    #sidebar { max-height: 100vh; }
}
@media (max-width: 991.98px) {
    #sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        width: 240px;
        height: 100vh;
        min-height: 0;
    }
    #content { padding: 1rem; }
    .navbar { margin-bottom: 1rem !important; }
}

/* ---- Top navbar ---- */
#content > .navbar .container-fluid { padding: 0; gap: 8px; }
.navbar .page-title { margin: 0; font-size: 1.15rem; font-weight: 600; color: var(--text-primary); overflow-wrap: anywhere; }
.navbar .navbar-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.period-badge {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 6px;
    background: linear-gradient(135deg, rgba(99,102,241,0.12) 0%, rgba(168,85,247,0.12) 100%);
    border: 1px solid rgba(168,85,247,0.25);
    color: #e0e4f0;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ---- Hints / warnings / numbers ---- */
.hint { color: var(--muted); font-size: 12px; }
.warn, .hint.warn { color: var(--warn); }
.err { color: var(--neg); }
.neg, .table td.neg, .table th.neg { color: var(--neg) !important; }
.sync-hint { margin: -1rem 0 1.25rem; }
@media (max-width: 991.98px) { .sync-hint { margin: -0.5rem 0 1rem; } }

/* ---- Tables ---- */
.table-responsive { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-responsive > .table { margin-bottom: 0; }
.table td, .table th { white-space: nowrap; }
.dataTables_wrapper { max-width: 100%; }
.dataTables_wrapper .row { margin-left: 0; margin-right: 0; }
.dataTables_wrapper .row > * { padding-left: 0; padding-right: 0; }

/* ---- Modals / forms (Bootstrap, dark) ---- */
.modal-content { background: var(--bg-card); border: 1px solid var(--border-color); color: var(--text-primary); }
.modal-header, .modal-footer { border-color: var(--border-color); }
.form-label { color: var(--text-muted); font-size: 0.85rem; }
.period-presets { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---- Login ---- */
.login-page { min-height: 100vh; height: auto; padding: 16px; }
.login-box { width: 100%; max-width: 400px; }
@media (max-width: 420px) { .login-box { padding: 1.5rem; } }

/* ---- Tab tables (one DataTable per tab) ---- */
#page-content .card-header h5 { font-size: 1.05rem; }
#page-content .card-header .hint { font-size: 12px; }
#page-content .card-body { padding: 1rem; }
@media (max-width: 575.98px) { #page-content .card-body { padding: 0.75rem; } }
.report-warnings { max-height: 9rem; overflow-y: auto; }
.table td.num, .table th.num { font-variant-numeric: tabular-nums; }
.table td.net { font-weight: 600; }
.table td.rates-cell { color: var(--muted); font-size: 12px; }
#page-content .table td.wrap-cell { white-space: normal !important; min-width: 180px; max-width: 360px; }
.table td.actions-cell { white-space: nowrap; }
.table td.actions-cell .btn + .btn { margin-left: 4px; }
table.dataTable tfoot th, .totals-table tfoot th {
    color: var(--text-primary);
    font-weight: 700;
    border-top: 2px solid var(--border-color);
    padding: 10px 0.5rem;
    text-align: center;
}
table.dataTable tfoot th.num.net, .totals-table tfoot th { color: #9ee493; }
table.dataTable tfoot th.num.net.neg, .totals-table tfoot th.neg { color: var(--neg) !important; }

/* expand cell + child row */
#page-content .table td.dt-expand { width: 36px; padding: 0 !important; }
.table td.dt-expand .expand-btn { color: #a5b4fc; padding: 2px 8px; box-shadow: none; }
.table td.dt-expand .expand-btn i { transition: transform 0.15s ease; }
.table tr.shown td.dt-expand .expand-btn i { transform: rotate(90deg); }
table.dataTable tbody tr.shown > * { background-color: rgba(99, 102, 241, 0.08) !important; }
#page-content table.dataTable tbody tr.detail-row > td {
    background-color: #17181e !important;
    padding: 12px 16px !important;
    text-align: left !important;
    white-space: normal;
}
.detail-box { max-width: 100%; }
.detail-title { color: var(--text-primary); font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.detail-box .table-responsive { max-width: 100%; }
#page-content .table.detail-table { color: var(--text-primary); margin-bottom: 0; width: auto; }
#page-content .table.detail-table > :not(caption) > * > * { padding: 6px 10px !important; background-color: transparent; }
.table.detail-table thead th {
    background-color: #20212a;
    font-size: 0.7rem;
    letter-spacing: 0.5px;
    padding: 6px 10px !important;
}
#page-content .table.detail-table td, #page-content .table.detail-table th { white-space: nowrap; text-align: right !important; }
#page-content .table.detail-table td.text-start, #page-content .table.detail-table th:first-child { text-align: left !important; }
.table.detail-table tr.auto > td { color: var(--muted); }

/* automatic expense rows */
table.dataTable tbody tr.auto > td { color: var(--muted) !important; background-color: var(--auto-bg) !important; }
.badge-auto {
    background: rgba(138, 146, 166, 0.18);
    color: var(--muted);
    border: 1px solid rgba(138, 146, 166, 0.35);
    font-weight: 500;
    font-size: 10px;
    letter-spacing: 0.3px;
    vertical-align: middle;
}

/* rates: inline inputs, missing rate rows */
.table input.rate { width: 110px; min-width: 90px; margin: 0 auto; text-align: right; }
table.dataTable tbody tr.missing > * { background-color: rgba(240, 180, 41, 0.10) !important; }
table.dataTable tbody tr.missing:hover > * { background-color: rgba(240, 180, 41, 0.16) !important; }
table.dataTable tbody tr.missing > td.col-date { box-shadow: inset 3px 0 0 var(--warn); }

/* DataTables filter at phone width */
@media (max-width: 575.98px) {
    .dataTables_wrapper .dataTables_filter { text-align: left; }
    .dataTables_wrapper .dataTables_filter input { width: 100%; max-width: 220px; margin-left: 0.25rem; }
    .dataTables_wrapper .dataTables_paginate .pagination { flex-wrap: wrap; justify-content: flex-start !important; }
}

/* totals: let long labels wrap instead of overflowing the card */
#page-content .totals-table td:first-child, #page-content .totals-table th:first-child { white-space: normal; text-align: left; }

/* DataTables controls: length select wide enough for the arrow; search right-aligned on the same row */
#page-content .dataTables_wrapper .dataTables_length select { padding: 4px 32px 4px 10px !important; min-width: 5.5rem; }
#page-content .dataTables_wrapper .dataTables_filter { text-align: right; }
#page-content .dataTables_wrapper .dataTables_filter label { margin-bottom: 0; }
#page-content .dataTables_wrapper .dataTables_paginate { text-align: right; }
@media (max-width: 575.98px) { #page-content .dataTables_wrapper .dataTables_filter, #page-content .dataTables_wrapper .dataTables_paginate { text-align: left; } }
