body.login-active {
    overflow: auto;
}

body:not(.login-active) {
    overflow: hidden;
}

.revenue-logo,
.sidebar-logo-icon.revenue-logo {
    background: var(--brand-logo-gradient, linear-gradient(135deg, #2563eb 0%, #22c4ff 100%));
    color: var(--brand-logo-text, #ffffff);
}

#content {
    min-width: 0;
    display: grid;
    gap: 16px;
}

.metric-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.metric-card {
    min-height: 116px;
}

#sidebar .menu-group {
    margin-bottom: 3px;
}

#sidebar .menu-item {
    width: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    font: inherit;
    text-align: left;
    border-radius: 12px;
    box-shadow: none;
}

#sidebar .menu-item:hover {
    background: var(--sidebar-pill-hover, rgba(37, 99, 235, .09));
}

#sidebar .menu-item.active {
    background: var(--sidebar-item-active, linear-gradient(90deg, rgba(37, 99, 235, .22), rgba(14, 165, 233, .16)));
    color: var(--sidebar-active-text, #0f172a);
    border: 0;
    box-shadow: none;
}

#sidebar .menu-item.active i,
#sidebar .menu-item.active span {
    color: var(--sidebar-active-text, #0f172a);
}

#sidebar .menu-item.active .menu-left i {
    background: var(--sidebar-active-icon-bg, rgba(37, 99, 235, .18));
    color: var(--accent-color, #2563eb);
}

#sidebar .menu-left {
    width: 100%;
}

#sidebar .menu-left i {
    width: 18px;
    flex: 0 0 18px;
}

.menu-spacer {
    flex: 1 1 auto;
}

.account-menu .topbar-avatar {
    width: 38px;
    height: 38px;
}

.toolbar-title h3 {
    margin: 0 0 4px;
    color: var(--text-color);
    font-size: 18px;
    font-weight: 700;
}

.toolbar-title p {
    margin: 0;
    color: var(--text-muted);
    font-size: 13px;
}

.form-grid label,
.toolbar label {
    display: grid;
    gap: 6px;
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 700;
}

.toolbar {
    display: flex;
    align-items: end;
    gap: 12px;
    flex-wrap: wrap;
}

.toolbar label {
    min-width: 180px;
    flex: 1 1 180px;
}

.master-page {
    display: grid;
    gap: 12px;
    min-width: 0;
}

.master-form {
    width: min(70%, 860px);
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: end;
    gap: 8px 10px;
    margin-bottom: 0;
}

.master-page .module-field-grid {
    display: contents;
}

.master-form label {
    display: grid;
    gap: 4px;
    margin: 0;
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 700;
}

.master-form .form-control,
.master-form .form-select,
.reports-page .form-control,
.reports-page .form-select {
    min-height: 42px;
    height: 42px;
    padding-top: 7px;
    padding-bottom: 7px;
    border-radius: var(--radius-sm, 12px);
}

.master-actions {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.master-page .zr-grid-table th,
.master-page .zr-grid-table td {
    padding-top: 8px;
    padding-bottom: 8px;
}

.search-box {
    max-width: 320px;
}

.skeleton-card,
.skeleton-field,
.skeleton-line {
    display: block;
    border-radius: 12px;
}

.skeleton-card {
    height: 118px;
}

.skeleton-field {
    height: 42px;
}

.skeleton-line {
    height: 18px;
}

.row-action {
    width: 34px;
    height: 34px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    display: inline-grid;
    place-items: center;
    background: var(--surface-muted);
    color: var(--text-color);
    cursor: pointer;
}

.row-action:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-hover);
}

.row-action.edit {
    color: var(--accent-color);
}

.row-action.delete {
    color: var(--danger);
}

.action-cell {
    display: inline-flex;
    gap: 8px;
    justify-content: flex-end;
}

.toast-box {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 1400;
    max-width: min(380px, calc(100vw - 32px));
    padding: 13px 15px;
    border: 1px solid color-mix(in oklab, var(--accent-color) 34%, transparent);
    border-radius: 12px;
    background: var(--card-bg);
    color: var(--text-color);
    box-shadow: var(--shadow-soft);
    font-weight: 600;
}

.confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 1500;
    display: grid;
    place-items: center;
    padding: 20px;
    background: color-mix(in oklab, var(--text-color) 32%, transparent);
}

.confirm-dialog {
    width: min(420px, 100%);
    display: grid;
    gap: 12px;
    padding: 22px;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    background: var(--card-bg);
    color: var(--text-color);
    box-shadow: var(--shadow-soft);
    text-align: center;
}

.confirm-icon {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    justify-self: center;
    border-radius: 50%;
    background: color-mix(in oklab, var(--danger) 16%, transparent);
    color: var(--danger);
    font-weight: 900;
}

.confirm-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.progress,
.progress-bar {
    border-radius: 999px;
}

.report-paper {
    display: grid;
    gap: 16px;
}

.legacy-report {
    width: min(1120px, 100%);
    margin: 0 auto;
    padding: 28px 32px;
    background: #ffffff;
    color: #111827;
    border: 1px solid #d1d5db;
    box-shadow: 0 12px 30px rgba(15, 23, 42, .08);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    line-height: 1.35;
    color-scheme: light;
}

.legacy-page {
    break-after: page;
    margin-bottom: 22px;
}

.legacy-page:last-child {
    break-after: auto;
}

.legacy-report-header {
    text-align: center;
    margin-bottom: 16px;
    line-height: 1.6;
    font-weight: 700;
}

.legacy-report-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 800;
    text-transform: uppercase;
}

.legacy-report h5 {
    margin: 18px 0 8px;
    font-size: 13px;
    font-weight: 800;
    text-align: center;
    text-transform: uppercase;
}

.legacy-table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0 14px;
    table-layout: fixed;
    background: #ffffff;
    color: #111827;
}

.legacy-table th,
.legacy-table td {
    border: 1px solid #111827;
    padding: 4px 6px;
    vertical-align: top;
    word-break: break-word;
    color: #111827;
}

.legacy-table th {
    background: #f3f4f6;
    font-weight: 800;
    text-align: center;
}

.legacy-table td {
    background: #ffffff;
}

.legacy-table tr:hover td {
    background: #ffffff;
    color: #111827;
}

.legacy-table td:nth-child(n+3),
.legacy-table th:nth-child(n+3) {
    text-align: right;
}

.legacy-table td:first-child,
.legacy-table th:first-child,
.legacy-table td:nth-child(2),
.legacy-table th:nth-child(2) {
    text-align: left;
}

.legacy-total-row td {
    font-weight: 800;
    background: #f9fafb;
}

.legacy-summary {
    width: min(420px, 100%);
    margin: 10px auto 16px;
    display: grid;
    gap: 5px;
}

.legacy-summary > div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.legacy-summary strong {
    text-align: center;
    font-size: 13px;
}

.legacy-empty {
    border: 1px dashed #9ca3af;
    padding: 18px;
    text-align: center;
    color: #111827;
    background: #ffffff;
}

@media (max-width: 900px) {
    .metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .metric-card {
        min-height: 110px;
    }

    .search-box {
        max-width: none;
    }

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

    .master-form {
        width: 100%;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

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

    .metric-card {
        min-height: 104px;
    }

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

    .master-actions {
        justify-content: stretch;
    }

    .master-actions > * {
        flex: 1 1 140px;
    }
}

@media print {
    body {
        background: #ffffff !important;
        overflow: visible !important;
    }

    .no-print,
    #sidebar,
    #topbar,
    .toast-box,
    .confirm-overlay {
        display: none !important;
    }

    .app-shell,
    .main-area,
    #app-content,
    #content,
    .report-paper {
        display: block !important;
        height: auto !important;
        overflow: visible !important;
        padding: 0 !important;
        background: #ffffff !important;
    }

    .legacy-report {
        width: auto;
        margin: 0;
        padding: 8mm;
        background: #ffffff !important;
        color: #111827 !important;
        border: 0;
        box-shadow: none;
        page-break-after: always;
    }

    .legacy-table,
    .legacy-table th,
    .legacy-table td,
    .legacy-empty {
        color: #111827 !important;
    }

    .legacy-table,
    .legacy-table td,
    .legacy-empty {
        background: #ffffff !important;
    }

    .legacy-table th,
    .legacy-total-row td {
        background: #f3f4f6 !important;
    }

    .legacy-report:last-child {
        page-break-after: auto;
    }

    @page {
        size: A4 landscape;
        margin: 8mm;
    }
}
