:root {
    --app-blue: #2563eb;
    --app-green: #16a34a;
    --app-bg: #f4f7fb;
    --app-border: #dbe4f0;
    --app-text: #1f2937;
    --space-1: 6px;
    --space-2: 10px;
    --space-3: 14px;
    --space-4: 18px;
    --space-5: 24px;
}

body {
    background: var(--app-bg);
    color: var(--app-text);
}

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

.sidebar {
    width: 280px;
    min-height: 100vh;
    padding: 18px;
    background: #fff;
    border-right: 1px solid var(--app-border);
    position: sticky;
    top: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 10px 20px;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--app-blue);
}

.app-logo {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    object-fit: contain;
}

.app-logo-sm {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    object-fit: contain;
}

.nav-link {
    min-height: 48px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #334155;
    font-weight: 600;
}

.nav-link i {
    width: 22px;
    text-align: center;
}

.nav-link.active,
.nav-link:hover {
    background: #e8f0ff;
    color: var(--app-blue);
}

.logout-link {
    color: #dc2626;
}

.content {
    flex: 1;
    padding: var(--space-5);
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: var(--space-4);
}

.page-header h1,
.page-header p {
    margin-bottom: 0;
}

.stat-card,
.panel-card {
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    padding: var(--space-4);
    height: auto;
}

.row > [class*="col-"] > .stat-card,
.row > [class*="col-"] > .panel-card {
    height: 100%;
}

.content > .alert,
.content > form.panel-card,
.content > .panel-card,
.content > .row,
.content > .list-toolbar,
.content > .mobile-card {
    margin-bottom: var(--space-4) !important;
}

.content > :last-child {
    margin-bottom: 0 !important;
}

.panel-card > :first-child,
.stat-card > :first-child {
    margin-top: 0;
}

.panel-card > :last-child,
.stat-card > :last-child {
    margin-bottom: 0;
}

.panel-card h2,
.panel-card .h5,
.mobile-card h2,
.mobile-card .h5 {
    margin-bottom: var(--space-3);
}

.panel-card hr {
    margin: var(--space-3) 0;
}

.panel-card .table {
    margin-bottom: 0;
}

.table > :not(caption) > * > * {
    padding: 0.7rem 0.65rem;
}

.table thead th {
    color: #475569;
    font-size: 0.88rem;
    font-weight: 700;
    white-space: nowrap;
    background: #f8fafc;
}

.table tbody td {
    vertical-align: middle;
}

.stat-card .icon {
    width: 46px;
    height: 46px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    margin-bottom: var(--space-2);
}

.icon-blue { background: var(--app-blue); }
.icon-green { background: var(--app-green); }
.icon-slate { background: #64748b; }

.btn-lg {
    min-height: 48px;
}

.quick-actions .btn,
.mobile-first-form .btn {
    min-height: 52px;
    font-weight: 700;
}

.form-control-lg,
.form-select-lg {
    min-height: 50px;
}

.list-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: var(--space-2) !important;
}

.search-compact {
    width: min(100%, 360px);
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    padding: 6px 10px;
}

.search-compact i {
    color: #64748b;
}

.search-compact .form-control {
    border: 0;
    box-shadow: none;
    padding: 4px 0;
}

.select-card {
    min-height: 58px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: #fff;
}

.select-card input {
    width: 20px;
    height: 20px;
}

.select-card span {
    display: grid;
    gap: 2px;
}

.select-card small {
    color: #64748b;
}

.report-surface .stat-card {
    padding: 12px;
}

.statement-actions .btn {
    min-width: 150px;
}

.statement-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-3);
}

.statement-summary-item {
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: #f8fafc;
    padding: 12px;
}

.statement-summary-item .h5 {
    margin-bottom: 0;
}

.statement-mobile-item {
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: #fff;
    padding: var(--space-3);
    margin-bottom: var(--space-3);
}

.statement-mobile-item:last-child {
    margin-bottom: 0;
}

.unpaid-statement {
    border-top: 1px solid var(--app-border);
    margin-top: var(--space-4);
    padding-top: var(--space-4);
}

.mobile-card {
    display: none;
}

.mobile-card .panel-card {
    height: auto;
}

.form-label {
    margin-bottom: 6px;
    font-weight: 600;
    color: #334155;
}

.form-text {
    margin-top: 5px;
}

.alert {
    border-radius: 8px;
    padding: 12px 14px;
}

@media (max-width: 991.98px) {
    .content {
        padding: var(--space-3);
        width: 100%;
    }

    .page-header {
        align-items: stretch;
        flex-direction: column;
        gap: var(--space-3);
        margin-bottom: var(--space-3);
    }

    .stat-card,
    .panel-card {
        padding: var(--space-3);
    }

    .content > .alert,
    .content > form.panel-card,
    .content > .panel-card,
    .content > .row,
    .content > .list-toolbar,
    .content > .mobile-card {
        margin-bottom: var(--space-3) !important;
    }

    .desktop-table {
        display: none;
    }

    .mobile-card {
        display: block;
    }

    .mobile-card > .panel-card,
    .mobile-card > [data-filter-row] {
        margin-bottom: var(--space-3) !important;
    }

    .mobile-card > :last-child {
        margin-bottom: 0 !important;
    }

    .list-toolbar {
        justify-content: stretch;
    }

    .search-compact {
        width: 100%;
    }

    .statement-summary {
        grid-template-columns: 1fr;
    }

    .mobile-first-form .row > [class*="col-"] {
        width: 100%;
        flex: 0 0 auto;
    }
}

@media print {
    @page {
        size: A4 landscape;
        margin: 10mm;
    }

    .no-print,
    .sidebar,
    .navbar,
    .offcanvas,
    .btn {
        display: none !important;
    }

    body {
        background: #fff;
    }

    .app-shell,
    .content {
        display: block;
        padding: 0;
    }

    .page-header {
        display: flex;
        flex-direction: row;
        align-items: flex-start;
        justify-content: space-between;
        margin-bottom: 10px;
    }

    .apartment-print-summary {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        margin-bottom: 10px !important;
    }

    .apartment-print-summary > [class*="col-"] {
        width: auto;
        max-width: none;
        padding: 0;
    }

    .panel-card,
    .stat-card {
        border: 0;
        padding: 8px 0;
    }

    .apartment-print-summary .stat-card,
    .statement-summary-item {
        border: 1px solid #cbd5e1;
        border-radius: 8px;
        background: #f8fafc;
        padding: 10px 12px;
        height: auto;
    }

    .unpaid-statement {
        border-top: 1px solid #cbd5e1;
        margin-top: 10px;
        padding-top: 10px;
    }

    .apartment-print-summary .h4,
    .statement-summary-item .h5 {
        font-size: 1.15rem;
        margin-bottom: 0;
    }

    .statement-print {
        display: block !important;
    }

    .statement-summary {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .desktop-table {
        display: block !important;
    }

    .mobile-card {
        display: none !important;
    }
}
