.erp-page {
    max-width: 92rem;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
}

.erp-page--wide {
    max-width: 112rem;
}

.erp-stack {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.erp-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem;
    border: 1px solid var(--erp-border, #e5e7eb);
    border-radius: 0.75rem;
    background: var(--erp-surface, #ffffff);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.erp-page-kicker {
    margin: 0 0 0.35rem;
    color: #b45309;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.erp-page-title {
    margin: 0;
    color: #111827;
    font-size: clamp(1.5rem, 2vw, 2.25rem);
    font-weight: 800;
    line-height: 1.15;
}

.erp-page-description {
    max-width: 56rem;
    margin: 0.6rem 0 0;
    color: #4b5563;
    font-size: 0.98rem;
    line-height: 1.65;
}

.erp-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
}

.erp-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.4rem;
    padding: 0.55rem 0.85rem;
    border: 1px solid #d1d5db;
    border-radius: 0.55rem;
    background: #ffffff;
    color: #374151;
    font-size: 0.875rem;
    font-weight: 700;
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.erp-button:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

.erp-button--primary {
    border-color: #d97706;
    background: #d97706;
    color: #ffffff;
}

.erp-button--primary:hover {
    border-color: #b45309;
    background: #b45309;
}

.erp-button--danger {
    border-color: #dc2626;
    background: #dc2626;
    color: #ffffff;
}

.erp-button--success {
    border-color: #16a34a;
    background: #16a34a;
    color: #ffffff;
}

.erp-button--warning {
    border-color: #f59e0b;
    background: #fef3c7;
    color: #92400e;
}

.erp-button:disabled,
.erp-button.is-disabled {
    cursor: not-allowed;
    border-color: #e5e7eb;
    background: #f3f4f6;
    color: #9ca3af;
}

.erp-stat-grid {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: 1rem;
}

.erp-stat-card {
    min-width: 0;
    padding: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    background: #ffffff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.erp-stat-card__label {
    margin: 0;
    color: #6b7280;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.erp-stat-card__value {
    margin: 0.45rem 0 0;
    color: #111827;
    font-size: 1.55rem;
    font-weight: 800;
    line-height: 1.15;
    overflow-wrap: anywhere;
}

.erp-stat-card__note {
    margin: 0.35rem 0 0;
    color: #6b7280;
    font-size: 0.82rem;
    line-height: 1.45;
}

.erp-stat-card--success {
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.erp-stat-card--warning {
    border-color: #fde68a;
    background: #fffbeb;
}

.erp-stat-card--danger {
    border-color: #fecaca;
    background: #fef2f2;
}

.erp-stat-card--info {
    border-color: #bfdbfe;
    background: #eff6ff;
}

.erp-section-card {
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    background: #ffffff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
    overflow: hidden;
}

.erp-section-card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.1rem;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
}

.erp-section-card__title {
    margin: 0;
    color: #111827;
    font-size: 1rem;
    font-weight: 800;
}

.erp-section-card__description {
    margin: 0.25rem 0 0;
    color: #6b7280;
    font-size: 0.875rem;
    line-height: 1.5;
}

.erp-section-card__body {
    padding: 1rem;
}

.erp-grid {
    display: grid;
    gap: 1rem;
}

.erp-grid--2,
.erp-grid--3,
.erp-grid--4,
.erp-grid--5,
.erp-grid--6 {
    grid-template-columns: repeat(1, minmax(0, 1fr));
}

.erp-filter-bar {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: 0.8rem;
    padding: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    background: #ffffff;
}

.erp-field {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 0.35rem;
}

.erp-label {
    color: #374151;
    font-size: 0.8rem;
    font-weight: 800;
}

.erp-input,
.erp-select,
.erp-textarea {
    width: 100%;
    min-height: 2.5rem;
    border: 1px solid #d1d5db;
    border-radius: 0.55rem;
    background: #ffffff;
    color: #111827;
    font: inherit;
    font-size: 0.9rem;
}

.erp-input,
.erp-select {
    padding: 0.45rem 0.7rem;
}

.erp-textarea {
    padding: 0.7rem;
    resize: vertical;
}

.erp-input:focus,
.erp-select:focus,
.erp-textarea:focus {
    border-color: #d97706;
    box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.16);
    outline: none;
}

.erp-table-wrap {
    width: 100%;
    overflow-x: auto;
}

.erp-data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 760px;
    font-size: 0.875rem;
}

.erp-data-table th {
    padding: 0.75rem 0.9rem;
    border-bottom: 1px solid #d1d5db;
    background: #f3f4f6;
    color: #374151;
    font-weight: 800;
    text-align: left;
    white-space: nowrap;
}

.erp-data-table td {
    padding: 0.75rem 0.9rem;
    border-bottom: 1px solid #e5e7eb;
    color: #1f2937;
    vertical-align: top;
}

.erp-data-table tbody tr:nth-child(even) td {
    background: #fcfcfd;
}

.erp-data-table tbody tr:hover td {
    background: #fffbeb;
}

.erp-data-table .is-right {
    text-align: right;
}

.erp-data-table .is-nowrap {
    white-space: nowrap;
}

.erp-cell-muted {
    color: #6b7280;
}

.erp-workflow-card {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 0.55rem;
    padding: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    background: linear-gradient(180deg, #ffffff 0%, #fafaf9 100%);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.erp-workflow-card__step {
    margin: 0;
    color: #b45309;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.erp-workflow-card__title {
    margin: 0;
    color: #111827;
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.3;
}

.erp-workflow-card__body {
    margin: 0;
    color: #4b5563;
    font-size: 0.9rem;
    line-height: 1.6;
}

.erp-status-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.erp-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    border-radius: 999px;
    padding: 0.22rem 0.55rem;
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1.1;
    white-space: nowrap;
}

.erp-status-badge--success {
    background: #dcfce7;
    color: #166534;
}

.erp-status-badge--warning {
    background: #fef3c7;
    color: #92400e;
}

.erp-status-badge--danger {
    background: #fee2e2;
    color: #991b1b;
}

.erp-status-badge--info {
    background: #dbeafe;
    color: #1e40af;
}

.erp-status-badge--gray {
    background: #f3f4f6;
    color: #374151;
}

.erp-status-badge--primary {
    background: #ffedd5;
    color: #9a3412;
}

.erp-inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.erp-action-link {
    display: inline-flex;
    align-items: center;
    border-radius: 0.45rem;
    padding: 0.32rem 0.55rem;
    background: #f3f4f6;
    color: #374151;
    font-size: 0.76rem;
    font-weight: 800;
    text-decoration: none;
}

.erp-action-link:hover {
    background: #ffedd5;
    color: #9a3412;
}

.erp-warning-card,
.erp-empty-state {
    border-radius: 0.75rem;
    padding: 1rem;
}

.erp-warning-card {
    border: 1px solid #fcd34d;
    background: #fffbeb;
    color: #78350f;
}

.erp-warning-card__title,
.erp-empty-state__title {
    margin: 0;
    font-weight: 800;
}

.erp-warning-card__body,
.erp-empty-state__body {
    margin: 0.4rem 0 0;
    font-size: 0.9rem;
    line-height: 1.55;
}

.erp-empty-state {
    border: 1px dashed #d1d5db;
    background: #f9fafb;
    color: #4b5563;
    text-align: center;
}

.erp-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.4rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    background: #f9fafb;
}

.erp-tab {
    border: 0;
    border-radius: 0.55rem;
    padding: 0.55rem 0.8rem;
    background: transparent;
    color: #4b5563;
    font: inherit;
    font-size: 0.875rem;
    font-weight: 800;
    cursor: pointer;
}

.erp-tab.is-active {
    background: #ffffff;
    color: #b45309;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.erp-stepper {
    display: grid;
    gap: 0.75rem;
}

.erp-step {
    display: flex;
    gap: 0.8rem;
    padding: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    background: #ffffff;
}

.erp-step__number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 2rem;
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    background: #d97706;
    color: #ffffff;
    font-weight: 900;
}

.erp-step__title {
    margin: 0;
    color: #111827;
    font-weight: 800;
}

.erp-step__body {
    margin: 0.25rem 0 0;
    color: #6b7280;
    font-size: 0.88rem;
    line-height: 1.5;
}

.erp-money-negative {
    color: #dc2626;
    font-weight: 800;
}

.erp-money-positive {
    color: #16a34a;
    font-weight: 800;
}

.erp-kv-list {
    display: grid;
    gap: 0.65rem;
}

.erp-kv {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.65rem 0;
    border-bottom: 1px solid #f3f4f6;
}

.erp-kv span {
    color: #6b7280;
    font-size: 0.875rem;
}

.erp-kv strong {
    color: #111827;
    font-size: 0.9rem;
    text-align: right;
}

.erp-markdown {
    color: #1f2937;
    font-size: 0.95rem;
    line-height: 1.7;
}

.erp-markdown > *:first-child {
    margin-top: 0;
}

.erp-markdown h1,
.erp-markdown h2,
.erp-markdown h3 {
    color: #111827;
    font-weight: 850;
    line-height: 1.25;
}

.erp-markdown h1 {
    margin: 0 0 1rem;
    font-size: 1.75rem;
}

.erp-markdown h2 {
    margin: 2rem 0 0.7rem;
    font-size: 1.28rem;
}

.erp-markdown h3 {
    margin: 1.35rem 0 0.45rem;
    font-size: 1.05rem;
}

.erp-markdown p,
.erp-markdown ul,
.erp-markdown ol,
.erp-markdown table,
.erp-markdown pre {
    margin: 0.75rem 0;
}

.erp-markdown ul,
.erp-markdown ol {
    padding-left: 1.25rem;
}

.erp-markdown ul {
    list-style: disc;
}

.erp-markdown ol {
    list-style: decimal;
}

.erp-markdown a {
    color: #b45309;
    font-weight: 750;
    text-decoration: underline;
    text-underline-offset: 0.18em;
}

.erp-markdown code {
    border-radius: 0.35rem;
    background: #f3f4f6;
    padding: 0.12rem 0.3rem;
    color: #111827;
    font-size: 0.86em;
}

.erp-markdown pre {
    overflow-x: auto;
    border: 1px solid #e5e7eb;
    border-radius: 0.7rem;
    background: #f9fafb;
    padding: 0.9rem;
}

.erp-markdown pre code {
    background: transparent;
    padding: 0;
}

.erp-markdown table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.erp-markdown th,
.erp-markdown td {
    border: 1px solid #e5e7eb;
    padding: 0.6rem 0.7rem;
    text-align: left;
    vertical-align: top;
}

.erp-markdown th {
    background: #f3f4f6;
    color: #374151;
    font-weight: 850;
}

@media (min-width: 640px) {
    .erp-stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .erp-filter-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .erp-grid--2,
    .erp-grid--3,
    .erp-grid--4,
    .erp-grid--5,
    .erp-grid--6 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .erp-page {
        padding: 2rem 1.5rem 4rem;
    }

    .erp-stat-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .erp-filter-bar {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

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

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

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

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

/*
 * Filament can be in light mode while the operating system prefers dark mode.
 * These ERP report components must follow the app theme, not the device media
 * preference, otherwise light pages render with black cards and tables.
 */
html.dark .erp-page-header,
html.dark .erp-stat-card,
html.dark .erp-section-card,
html.dark .erp-filter-bar,
html.dark .erp-step,
html.dark .erp-workflow-card {
    border-color: #27272a;
    background: #18181b;
}

html.dark .erp-section-card__header,
html.dark .erp-data-table th,
html.dark .erp-tabs {
    border-color: #27272a;
    background: #111113;
}

html.dark .erp-page-title,
html.dark .erp-stat-card__value,
html.dark .erp-section-card__title,
html.dark .erp-data-table td,
html.dark .erp-step__title,
html.dark .erp-kv strong,
html.dark .erp-workflow-card__title {
    color: #fafafa;
}

html.dark .erp-page-description,
html.dark .erp-stat-card__label,
html.dark .erp-stat-card__note,
html.dark .erp-section-card__description,
html.dark .erp-cell-muted,
html.dark .erp-step__body,
html.dark .erp-kv span,
html.dark .erp-workflow-card__body {
    color: #a1a1aa;
}

html.dark .erp-data-table td {
    border-color: #27272a;
}

html.dark .erp-data-table tbody tr:nth-child(even) td {
    background: #141416;
}

html.dark .erp-data-table tbody tr:hover td {
    background: #272018;
}

html.dark .erp-input,
html.dark .erp-select,
html.dark .erp-textarea,
html.dark .erp-button {
    border-color: #3f3f46;
    background: #09090b;
    color: #fafafa;
}

html.dark .erp-markdown,
html.dark .erp-markdown h1,
html.dark .erp-markdown h2,
html.dark .erp-markdown h3,
html.dark .erp-markdown code {
    color: #fafafa;
}

html.dark .erp-markdown code,
html.dark .erp-markdown pre {
    border-color: #27272a;
    background: #111113;
}

html.dark .erp-markdown th,
html.dark .erp-markdown td {
    border-color: #27272a;
}

html.dark .erp-markdown th {
    background: #111113;
    color: #d4d4d8;
}
