:root {
    --bg: #F7F8FA;
    --bg-elevated: #FFFFFF;
    --text: #111827;
    --muted: #6B7280;
    --border: #E5E7EB;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 10px 20px rgba(16, 24, 40, 0.08);
    --shadow-lg: 0 2px 6px rgba(16, 24, 40, 0.06), 0 18px 35px rgba(16, 24, 40, 0.12);
    --radius: 0.95rem;
    --primary: #D52B1E;
    --primary-hover: #B91C1C;
    --ring: rgba(213, 43, 30, 0.2);
}

html, body {
    background: var(--bg);
    color: var(--text);
    min-height: 100%;
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
}

body {
    font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif;
    line-height: 1.6;
}

.mx-bg-glow {
    position: relative;
    overflow: hidden;
}

.mx-bg-glow::before {
    content: '';
    position: absolute;
    inset: -50% -10% auto -10%;
    height: 280px;
    background: radial-gradient(ellipse at center, rgba(213, 43, 30, 0.08), transparent 60%);
    pointer-events: none;
}

.mx-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.mx-pagehead,
.mx-page-title {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
}

.mx-page-description {
    max-width: 46rem;
    color: var(--muted);
}

.mx-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow);
}

.mx-toolbar-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.mx-toolbar-spacer {
    flex: 1 1 auto;
}

.mx-card {
    background: var(--bg-elevated);
    border: 1px solid rgba(17, 24, 39, 0.06);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.mx-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.mx-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.mx-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.mx-section-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.mx-section-subtitle {
    font-size: 0.875rem;
    color: var(--muted);
}

.mx-card-soft {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    box-shadow: var(--shadow);
}

.mx-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    border-radius: 0.8rem;
    font-weight: 600;
    border: 1px solid transparent;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.mx-btn:focus-visible,
.mx-input:focus-visible,
.mx-select:focus-visible,
.mx-textarea:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px var(--ring);
}

.mx-btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 10px 20px rgba(213, 43, 30, 0.18);
}

.mx-btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.mx-btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 6px 14px rgba(213, 43, 30, 0.2);
}

.mx-btn-secondary {
    background: #fff;
    border-color: var(--border);
    color: var(--text);
}

.mx-btn-secondary:hover {
    border-color: #d1d5db;
}

.mx-btn-danger {
    background: #fff;
    border-color: rgba(239, 68, 68, 0.35);
    color: #b91c1c;
}

.mx-btn-danger:hover {
    background: rgba(239, 68, 68, 0.08);
}

.mx-input,
.mx-select,
.mx-textarea {
    width: 100%;
    border-radius: 0.85rem;
    border: 1px solid var(--border);
    background: #fff;
    padding: 0.65rem 0.9rem;
    color: var(--text);
    transition: border 0.15s ease, box-shadow 0.15s ease;
}

.mx-input.sm {
    padding: 0.5rem 0.75rem;
    border-radius: 0.75rem;
    font-size: 0.875rem;
}

.mx-input::placeholder {
    color: #9CA3AF;
}

.mx-table {
    width: 100%;
    border-collapse: collapse;
}

.mx-table thead {
    background: #F9FAFB;
    color: #374151;
}

.mx-table th,
.mx-table td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.mx-table th {
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-weight: 600;
}

.mx-table tr:hover {
    background: #F3F4F6;
}

.mx-table-card {
    overflow: hidden;
    border-radius: 1.25rem;
    border: 1px solid var(--border);
    background: #fff;
    box-shadow: var(--shadow);
}

.mx-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid transparent;
}

.mx-pill.draft { background: #F3F4F6; color: #374151; }
.mx-pill.sent { background: #DBEAFE; color: #1D4ED8; }
.mx-pill.viewed { background: #EDE9FE; color: #6D28D9; }
.mx-pill.paid { background: #D1FAE5; color: #065F46; }
.mx-pill.overdue { background: #FEE2E2; color: #B91C1C; }
.mx-pill.void { background: #F3F4F6; color: #6B7280; text-decoration: line-through; }

.mx-pill-filter {
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid var(--border);
    color: var(--muted);
    background: #fff;
    transition: all 0.15s ease;
}

.mx-pill-filter.is-active {
    border-color: #1f2937;
    background: #111827;
    color: #fff;
}

.mx-alert {
    border-radius: 0.9rem;
    padding: 0.75rem 1rem;
    border: 1px solid;
}

.maplr-alert {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1.1rem 1.25rem;
    border-radius: 1rem;
    border: 1px solid transparent;
    font-size: 0.9rem;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
    animation: maplrFadeIn 0.2s ease-out;
}

.maplr-alert-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 2.1rem;
    width: 2.1rem;
    border-radius: 0.85rem;
    font-size: 1rem;
    flex-shrink: 0;
}

.maplr-alert-success {
    background: #ECFDF3;
    border-color: #A6F4C5;
    color: #065F46;
}

.maplr-alert-success .maplr-alert-icon {
    background: #D1FADF;
    color: #065F46;
}

.maplr-alert-error {
    background: #FEF3F2;
    border-color: #FDA29B;
    color: #B42318;
}

.maplr-alert-error .maplr-alert-icon {
    background: #FEE4E2;
    color: #B42318;
}

.maplr-alert-warning {
    background: #FFFAEB;
    border-color: #FEDF89;
    color: #B54708;
}

.maplr-alert-warning .maplr-alert-icon {
    background: #FEF0C7;
    color: #B54708;
}

.maplr-alert-info {
    background: #EFF8FF;
    border-color: #B2DDFF;
    color: #175CD3;
}

.maplr-alert-info .maplr-alert-icon {
    background: #D1E9FF;
    color: #175CD3;
}

.maplr-alert-message {
    display: grid;
    gap: 0.15rem;
}

.maplr-alert-title {
    font-weight: 600;
}

.maplr-alert-text {
    color: inherit;
    opacity: 0.85;
}

.maplr-verify-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    box-shadow: var(--shadow);
    padding: 2rem;
    width: min(100%, 26rem);
}

.maplr-verify-icon {
    height: 3.25rem;
    width: 3.25rem;
    border-radius: 999px;
    background: rgba(213, 43, 30, 0.12);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.maplr-btn-primary {
    background: var(--primary);
    color: #fff;
    border-radius: 0.75rem;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    transition: background 0.2s ease, transform 0.2s ease;
}

.maplr-btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.maplr-fade-in {
    animation: maplrFadeIn 0.2s ease-out;
}

.mx-toast-stack {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 420px;
}

.mx-toast {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.1rem;
    border-radius: 1rem;
    border: 1px solid transparent;
    background: #fff;
    box-shadow: 0 16px 30px rgba(15, 23, 42, 0.12);
    transform: translateX(8px);
    opacity: 0;
    animation: mxToastIn 0.25s ease-out forwards;
}

.mx-toast.is-leaving {
    animation: mxToastOut 0.2s ease-in forwards;
}

.mx-toast-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 2.1rem;
    width: 2.1rem;
    border-radius: 0.85rem;
    font-size: 1rem;
    flex-shrink: 0;
}

.mx-toast-body {
    display: grid;
    gap: 0.15rem;
    flex: 1;
}

.mx-toast-title {
    font-weight: 600;
}

.mx-toast-message {
    font-size: 0.85rem;
    opacity: 0.9;
}

.mx-toast-close {
    background: transparent;
    border: none;
    color: inherit;
    font-size: 1rem;
    cursor: pointer;
    padding: 0 0.25rem;
    opacity: 0.6;
    transition: opacity 0.15s ease;
}

.mx-toast-close:hover {
    opacity: 1;
}

.mx-toast-success {
    background: #ECFDF3;
    border-color: #A6F4C5;
    color: #065F46;
}

.mx-toast-success .mx-toast-icon {
    background: #D1FADF;
    color: #065F46;
}

.mx-toast-error {
    background: #FEF3F2;
    border-color: #FDA29B;
    color: #B42318;
}

.mx-toast-error .mx-toast-icon {
    background: #FEE4E2;
    color: #B42318;
}

.mx-toast-info {
    background: #EFF8FF;
    border-color: #B2DDFF;
    color: #175CD3;
}

.mx-toast-info .mx-toast-icon {
    background: #D1E9FF;
    color: #175CD3;
}

.mx-toast-warning {
    background: #FFFAEB;
    border-color: #FEDF89;
    color: #B54708;
}

.mx-toast-warning .mx-toast-icon {
    background: #FEF0C7;
    color: #B54708;
}

.mx-toast-progress {
    height: 3px;
    background: rgba(17, 24, 39, 0.1);
    border-radius: 999px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.mx-toast-progress > span {
    display: block;
    height: 100%;
    width: 100%;
    transform-origin: left center;
    animation: mxToastProgress 4.5s linear forwards;
}

.mx-toast-success .mx-toast-progress > span { background: #34D399; }
.mx-toast-error .mx-toast-progress > span { background: #F97066; }
.mx-toast-info .mx-toast-progress > span { background: #53B1FD; }
.mx-toast-warning .mx-toast-progress > span { background: #FEC84B; }

@keyframes mxToastIn {
    from { opacity: 0; transform: translateX(12px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes mxToastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(12px); }
}

@keyframes mxToastProgress {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

@media (max-width: 640px) {
    .mx-toast-stack {
        right: 12px;
        left: 12px;
        max-width: none;
    }
}

@keyframes maplrFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.mx-alert-success {
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.4);
    color: #0f766e;
}

.mx-alert-error {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.4);
    color: #b91c1c;
}

.mx-kpi {
    display: grid;
    gap: 0.35rem;
}

.mx-kpi h3 {
    font-size: 0.875rem;
    color: var(--muted);
}

.mx-kpi p {
    font-size: 2rem;
    font-weight: 700;
}

.mx-stat-card {
    padding: 1.5rem;
    border-radius: 1.25rem;
    border: 1px solid var(--border);
    background: #fff;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.mx-stat-icon {
    height: 2.75rem;
    width: 2.75rem;
    border-radius: 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    background: #F3F4F6;
    color: #4B5563;
}

.mx-stat-meta {
    font-size: 0.75rem;
    color: var(--muted);
}

.mx-nav {
    background: rgba(255, 255, 255, 0.9);
    border-bottom: 1px solid rgba(17, 24, 39, 0.08);
    backdrop-filter: blur(12px);
}

.mx-nav-link {
    position: relative;
    padding: 0.5rem 0.25rem;
    font-weight: 500;
    color: var(--muted);
    transition: color 0.15s ease;
}

.mx-nav-link:hover {
    color: var(--text);
}

.mx-nav-link.is-active {
    color: var(--text);
    font-weight: 600;
}

.mx-nav-link.is-active::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -12px;
    height: 2px;
    border-radius: 999px;
    background: var(--primary);
}

.mx-muted {
    color: var(--muted);
}

.maplr-subtle-gradient {
    background: linear-gradient(140deg, rgba(213, 43, 30, 0.12), rgba(255, 255, 255, 0.6));
}
