:root {
    --blue-950: #0a2540;
    --blue-900: #0d3158;
    --blue-800: #124578;
    --blue-700: #1760a8;
    --blue-600: #2477c8;
    --blue-100: #dceeff;
    --blue-50: #eff7ff;
    --slate-950: #172033;
    --slate-800: #344054;
    --slate-700: #475467;
    --slate-600: #667085;
    --slate-500: #7b8798;
    --slate-300: #d0d5dd;
    --slate-200: #e4e7ec;
    --slate-100: #f2f4f7;
    --slate-50: #f8fafc;
    --green-800: #05603a;
    --green-700: #067647;
    --green-100: #d1fadf;
    --green-50: #ecfdf3;
    --amber-800: #934b06;
    --amber-700: #b54708;
    --amber-100: #fef0c7;
    --amber-50: #fffaeb;
    --red-800: #912018;
    --red-700: #b42318;
    --red-100: #fee4e2;
    --red-50: #fff4f2;
    --purple-700: #6941c6;
    --purple-100: #ebe9fe;
    --cyan-700: #0e7090;
    --cyan-100: #cff9fe;
    --white: #ffffff;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-md: 0 10px 24px rgba(15, 35, 60, 0.10);
    --shadow-lg: 0 24px 70px rgba(10, 37, 64, 0.22);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--slate-50); }
body {
    min-height: 100vh;
    margin: 0;
    color: var(--slate-950);
    background:
        radial-gradient(circle at top right, rgba(36, 119, 200, 0.10), transparent 34%),
        var(--slate-50);
    font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 14px;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible {
    outline: 3px solid rgba(36, 119, 200, 0.24);
    outline-offset: 2px;
}

.app-shell { min-height: 100vh; }
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
    padding: 13px 22px;
    color: var(--white);
    background:
        radial-gradient(circle at 82% -35%, rgba(56, 139, 236, .46), transparent 34%),
        linear-gradient(118deg, #082c54, #0d3f78 54%, #0d55a2);
    box-shadow: var(--shadow-md);
}
.brand-block { display: flex; align-items: center; gap: 14px; min-width: 320px; }
.brand-copy { min-width: 0; }
.brand-mark {
    display: grid;
    flex: 0 0 auto;
    width: 48px;
    height: 48px;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.42);
    border-radius: 14px;
    color: #e8f4ff;
    background: linear-gradient(145deg, rgba(255,255,255,.16), rgba(255,255,255,.07));
    font-size: 25px;
    font-weight: 900;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.22), 0 8px 20px rgba(0, 30, 70, .18);
}
.eyebrow {
    margin-bottom: 3px;
    color: #c5ddfb;
    font-size: 10px;
    font-weight: 850;
    letter-spacing: .12em;
    text-transform: uppercase;
}
.app-header h1 { margin: 0; font-size: clamp(21px, 2vw, 29px); line-height: 1.08; }
.app-header p { margin: 5px 0 0; color: #d9e9fb; font-size: 10px; }
.header-session {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
}
.session-item {
    position: relative;
    min-width: 104px;
    max-width: 210px;
    padding: 7px 10px 7px 11px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.20);
    border-radius: 10px;
    background: rgba(255,255,255,.07);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}
.session-item::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    border-radius: 10px 0 0 10px;
    background: #7fc2ff;
}
.session-item.session-user::before { background: #c7a6ff; }
.session-item.session-update::before { background: #70e3ad; }
.session-item span {
    display: block;
    color: #bed8f7;
    font-size: 8px;
    font-weight: 850;
    letter-spacing: .055em;
    text-transform: uppercase;
}
.session-item strong {
    display: block;
    margin-top: 3px;
    overflow: hidden;
    color: #fff;
    font-size: 10px;
    font-weight: 820;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.header-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.btn {
    min-height: 36px;
    padding: 7px 12px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-weight: 780;
    transition: transform 120ms ease, background-color 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { cursor: not-allowed; opacity: .58; transform: none; }
.btn-header {
    color: #eef7ff;
    background: rgba(255,255,255,.065);
    border-color: rgba(154, 205, 255, .58);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}
.btn-header:hover { background: rgba(255,255,255,.13); border-color: rgba(196,225,255,.92); }
.btn-refresh { color: #dfffee; background: rgba(40, 194, 120, .13); border-color: #68e3aa; }
.btn-refresh:hover { background: rgba(40, 194, 120, .22); border-color: #96f2c8; }
.btn-refresh.is-loading span { display: inline-block; animation: header-spin .8s linear infinite; }
.btn-excel { color: #e4fff0; background: rgba(31, 163, 93, .11); border-color: #6bd79d; }
.btn-pdf { color: #ffeaea; background: rgba(225, 87, 87, .10); border-color: #ef9696; }
.btn-print { color: #f1eaff; background: rgba(139, 105, 219, .12); border-color: #bca5ee; }
.btn-centers { color: #e4fbff; background: rgba(38, 175, 196, .11); border-color: #7ad7e5; }
.btn-danger {
    color: #ffe2df;
    background: rgba(255, 91, 78, .16);
    border-color: #ff6257;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 0 0 1px rgba(255,98,87,.08);
}
.btn-danger:hover {
    color: #fff;
    background: rgba(255, 91, 78, .27);
    border-color: #ff8178;
    box-shadow: 0 0 0 2px rgba(255,98,87,.12);
}
@keyframes header-spin { to { transform: rotate(360deg); } }
.btn-ghost { color: var(--blue-800); background: var(--white); border-color: var(--slate-300); }
.btn-small { min-height: 31px; padding: 5px 9px; font-size: 11px; }
.btn-link {
    padding: 0;
    color: var(--blue-700);
    border: 0;
    background: transparent;
    font-weight: 800;
    text-align: left;
}
.btn-link:hover { color: var(--blue-950); text-decoration: underline; }

.app-main { width: min(1540px, calc(100% - 32px)); margin: 22px auto 48px; }
.filter-panel {
    display: grid;
    grid-template-columns: minmax(220px, 1.35fr) minmax(160px, .8fr) repeat(4, minmax(118px, .58fr)) minmax(205px, .82fr) minmax(138px, .62fr) auto;
    align-items: end;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
    background: rgba(255,255,255,.96);
    box-shadow: var(--shadow-sm);
}
.filter-field { min-width: 0; }
.filter-field label {
    display: block;
    margin-bottom: 6px;
    color: var(--slate-600);
    font-size: 10px;
    font-weight: 850;
    letter-spacing: .045em;
    text-transform: uppercase;
}
.filter-field input, .filter-field select {
    width: 100%;
    height: 39px;
    padding: 7px 10px;
    color: var(--slate-950);
    border: 1px solid var(--slate-300);
    border-radius: var(--radius-sm);
    outline: none;
    background: var(--white);
}
.filter-field input:disabled { color: var(--slate-600); background: var(--slate-100); }
.filter-field input:focus, .filter-field select:focus {
    border-color: var(--blue-600);
    box-shadow: 0 0 0 3px rgba(36,119,200,.14);
}
.filter-actions { display: flex; align-items: end; }
.residual-control { display: grid; grid-template-columns: minmax(118px, 1fr) 92px; gap: 6px; align-items: center; }
.money-input { position: relative; min-width: 0; }
.money-input span { position: absolute; left: 9px; top: 50%; z-index: 1; color: var(--slate-600); font-size: 11px; font-weight: 800; transform: translateY(-50%); pointer-events: none; }
.money-input input { padding-left: 21px; text-align: right; font-variant-numeric: tabular-nums; }
.money-input input:disabled { color: var(--slate-500); background: var(--slate-100); }
.filter-help { display: block; min-height: 12px; margin-top: 4px; color: var(--slate-500); font-size: 8px; font-weight: 700; white-space: nowrap; }

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
    gap: 8px;
    margin: 12px 0;
}
.kpi-card {
    position: relative;
    min-width: 0;
    overflow: hidden;
    padding: 12px 13px;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
    background: var(--white);
    box-shadow: var(--shadow-sm);
}
.kpi-card::after {
    content: "";
    position: absolute;
    right: -18px;
    top: -22px;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: var(--kpi-soft, var(--blue-50));
}
.kpi-label { position: relative; z-index: 1; color: var(--slate-600); font-size: 10px; font-weight: 850; letter-spacing: .04em; text-transform: uppercase; }
.kpi-value { position: relative; z-index: 1; margin-top: 5px; color: var(--kpi-color, var(--blue-950)); font-size: 24px; font-weight: 880; line-height: 1.08; font-variant-numeric: tabular-nums; }
.kpi-note { position: relative; z-index: 1; margin-top: 6px; color: var(--slate-500); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 5px;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
    background: var(--white);
    box-shadow: var(--shadow-sm);
}
.tab {
    flex: 0 0 auto;
    padding: 9px 14px;
    color: var(--slate-600);
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    font-weight: 760;
}
.tab:hover { color: var(--blue-800); background: var(--blue-50); }
.tab.is-active { color: var(--white); background: var(--blue-800); }
.report-content { margin-top: 14px; }

.panel {
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
    background: var(--white);
    box-shadow: var(--shadow-sm);
}
.panel + .panel { margin-top: 14px; }
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--slate-200);
}
.panel-header h2 { margin: 0; color: var(--blue-950); font-size: 16px; }
.panel-header p { margin: 4px 0 0; color: var(--slate-600); font-size: 11px; }
.panel-body { padding: 15px; }
.panel-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 14px; }
.panel-grid.equal { grid-template-columns: 1fr 1fr; }

.badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 850;
    white-space: nowrap;
}
.badge-blue { color: var(--blue-800); background: var(--blue-100); }
.badge-green { color: var(--green-700); background: var(--green-100); }
.badge-amber { color: var(--amber-700); background: var(--amber-100); }
.badge-red { color: var(--red-700); background: var(--red-100); }
.badge-purple { color: var(--purple-700); background: var(--purple-100); }
.badge-cyan { color: var(--cyan-700); background: var(--cyan-100); }
.badge-slate { color: var(--slate-700); background: var(--slate-100); }

.summary-callout {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 14px 16px;
    border: 1px solid #c9dff3;
    border-left: 4px solid var(--blue-700);
    border-radius: 10px;
    color: var(--slate-700);
    background: var(--blue-50);
}
.summary-callout strong { color: var(--blue-950); }
.summary-callout-metric { flex: 0 0 auto; color: var(--blue-950); font-size: 18px; font-weight: 900; }

.balance-stack { margin-top: 9px; }
.balance-track {
    display: flex;
    width: 100%;
    height: 24px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--slate-100);
}
.balance-segment { min-width: 2px; transition: width 220ms ease; }
.balance-segment.current { background: linear-gradient(90deg, #179a6d, #42c996); }
.balance-segment.due-soon { background: linear-gradient(90deg, #d88408, #f5b94c); }
.balance-segment.overdue { background: linear-gradient(90deg, #c62f26, #ee6a62); }
.balance-legend { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.legend-item { padding: 9px 10px; border: 1px solid var(--slate-200); border-radius: 9px; background: var(--slate-50); }
.legend-label { display: flex; align-items: center; gap: 6px; color: var(--slate-600); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }
.legend-value { margin-top: 4px; color: var(--slate-950); font-size: 15px; font-weight: 880; }
.legend-percent { margin-top: 2px; color: var(--slate-500); font-size: 10px; }

.bar-list { display: grid; gap: 10px; }
.bar-item { min-width: 0; }
.bar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 5px; }
.bar-label { min-width: 0; overflow: hidden; color: var(--slate-700); font-size: 11px; font-weight: 760; text-overflow: ellipsis; white-space: nowrap; }
.bar-value { flex: 0 0 auto; color: var(--blue-950); font-size: 11px; font-weight: 860; }
.bar-track { height: 8px; overflow: hidden; border-radius: 999px; background: var(--slate-100); }
.bar-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue-700), #57a4e8); }
.bar-fill.is-danger { background: linear-gradient(90deg, var(--red-700), #ef776f); }

.aging-cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.aging-card { padding: 11px; border: 1px solid var(--slate-200); border-radius: 10px; background: var(--white); }
.aging-card[data-level="0"] { border-top: 4px solid var(--green-700); }
.aging-card[data-level="1"] { border-top: 4px solid #e0a11b; }
.aging-card[data-level="2"] { border-top: 4px solid #db7b1a; }
.aging-card[data-level="3"] { border-top: 4px solid #d34a31; }
.aging-card[data-level="4"] { border-top: 4px solid #a61b1b; }
.aging-card-title { color: var(--slate-600); font-size: 10px; font-weight: 850; text-transform: uppercase; }
.aging-card-value { margin-top: 5px; color: var(--blue-950); font-size: 18px; font-weight: 900; }
.aging-card-meta { margin-top: 4px; color: var(--slate-500); font-size: 10px; }

.table-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 9px; }
.table-toolbar-info { color: var(--slate-600); font-size: 11px; }
.table-shell { width: 100%; overflow: auto; border: 1px solid var(--slate-200); border-radius: 10px; }
.report-table { width: 100%; min-width: 900px; border-collapse: separate; border-spacing: 0; background: var(--white); }
.report-table th, .report-table td {
    padding: 8px 9px;
    border-right: 1px solid var(--slate-200);
    border-bottom: 1px solid var(--slate-200);
    text-align: left;
    vertical-align: middle;
}
.report-table th:last-child, .report-table td:last-child { border-right: 0; }
.report-table tr:last-child td { border-bottom: 0; }
.report-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    color: var(--blue-950);
    background: #eaf3fc;
    font-size: 10px;
    font-weight: 880;
    letter-spacing: .02em;
    text-transform: uppercase;
    white-space: nowrap;
}
.report-table tbody tr:hover td { background: #f8fbff; }
.report-table .number { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.report-table .center { text-align: center; }
.report-table .strong { color: var(--blue-950); font-weight: 820; }
.report-table .muted { color: var(--slate-500); }
.report-table .money { color: #07596d; font-weight: 760; }
.report-table .danger { color: var(--red-700); font-weight: 830; }
.report-table .warning { color: var(--amber-700); font-weight: 830; }
.report-table .sticky-left { position: sticky; left: 0; z-index: 1; background: var(--white); }
.report-table thead .sticky-left { z-index: 3; background: #eaf3fc; }
.report-table .sticky-right { position: sticky; right: 0; z-index: 2; background: var(--white); box-shadow: -6px 0 10px rgba(15,35,60,.06); }
.report-table thead .sticky-right { z-index: 4; background: #eaf3fc; }
.report-table .total-row .sticky-right { background: #eaf3fc; }
.document-table .col-document { width: 132px; max-width: 132px; }
.document-table .col-provider { width: 230px; max-width: 230px; }
.document-table .col-cfdi { width: 155px; max-width: 155px; }
.document-table .col-reference { width: 150px; max-width: 150px; }
.document-table .col-actions { width: 78px; min-width: 78px; max-width: 78px; }
.document-table.is-compact .col-provider { width: 210px; max-width: 210px; }
.provider-name-ellipsis { display:block; max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.report-table .total-row td { color: var(--blue-950); background: #eaf3fc; font-weight: 880; border-top: 1px solid #b7d3ef; }
.report-table .heat-0 { background: #f0fbf5; color: var(--green-800); }
.report-table .heat-1 { background: #fffae8; color: #9b6500; }
.report-table .heat-2 { background: #fff1df; color: #9a4d08; }
.report-table .heat-3 { background: #ffe7df; color: #a43220; }
.report-table .heat-4 { background: #ffe0de; color: #8d1c18; }
.cell-main { color: var(--blue-950); font-weight: 820; }
.cell-sub { margin-top: 2px; color: var(--slate-500); font-size: 9px; }
.row-actions { display: flex; justify-content: center; gap: 5px; }
.icon-button {
    display: inline-grid;
    width: 29px;
    height: 29px;
    place-items: center;
    border: 1px solid var(--slate-300);
    border-radius: 7px;
    color: var(--blue-800);
    background: var(--white);
    font-size: 13px;
    font-weight: 900;
}
.icon-button:hover { border-color: var(--blue-600); background: var(--blue-50); }

.priority-line { display: flex; align-items: center; gap: 8px; }
.priority-dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: var(--slate-300); }
.priority-dot.high { background: var(--red-700); box-shadow: 0 0 0 4px var(--red-100); }
.priority-dot.medium { background: var(--amber-700); box-shadow: 0 0 0 4px var(--amber-100); }
.priority-dot.low { background: var(--green-700); box-shadow: 0 0 0 4px var(--green-100); }

.empty-state {
    display: grid;
    min-height: 220px;
    place-items: center;
    padding: 30px;
    text-align: center;
    border: 1px dashed var(--slate-300);
    border-radius: var(--radius-md);
    color: var(--slate-600);
    background: rgba(255,255,255,.72);
}
.empty-state strong { display: block; margin-bottom: 5px; color: var(--blue-950); font-size: 16px; }

.modal { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 18px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(10,37,64,.66); backdrop-filter: blur(3px); }
.modal-card {
    position: relative;
    z-index: 1;
    width: min(1040px, 100%);
    max-height: calc(100vh - 36px);
    overflow: auto;
    border-radius: var(--radius-lg);
    background: var(--white);
    box-shadow: var(--shadow-lg);
}
.modal-provider-wide .modal-card { width: min(1680px, 96vw); }
.modal-provider-wide .modal-body { padding: 16px; }

.modal-header {
    position: sticky;
    top: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    color: var(--white);
    background: linear-gradient(125deg, var(--blue-950), var(--blue-800));
}
.modal-header h2 { margin: 2px 0 0; font-size: 20px; }
.modal-header-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
.modal-action {
    min-height: 32px;
    padding: 6px 9px;
    border: 1px solid rgba(255,255,255,.32);
    border-radius: 8px;
    color: var(--white);
    background: rgba(255,255,255,.10);
    font-size: 10px;
    font-weight: 820;
}
.modal-action:hover { background: rgba(255,255,255,.18); }
.modal-eyebrow { color: #b9d9f8; font-size: 10px; font-weight: 850; letter-spacing: .09em; text-transform: uppercase; }
.modal-close { display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid rgba(255,255,255,.35); border-radius: 9px; color: var(--white); background: rgba(255,255,255,.10); font-size: 24px; }
.modal-body { padding: 18px; }
.detail-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.detail-item { min-width: 0; padding: 10px 11px; border: 1px solid var(--slate-200); border-radius: 9px; background: var(--slate-50); }
.detail-item.span-2 { grid-column: span 2; }
.detail-label { color: var(--slate-500); font-size: 9px; font-weight: 850; letter-spacing: .04em; text-transform: uppercase; }
.detail-value { margin-top: 4px; overflow-wrap: anywhere; color: var(--slate-950); font-size: 12px; font-weight: 760; }
.detail-highlight { margin: 14px 0; padding: 14px; border: 1px solid var(--slate-200); border-radius: 10px; background: linear-gradient(100deg, #f2f8ff, #ffffff); }
.detail-highlight-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.detail-number-label { color: var(--slate-500); font-size: 9px; font-weight: 850; text-transform: uppercase; }
.detail-number-value { margin-top: 4px; color: var(--blue-950); font-size: 19px; font-weight: 900; }
.detail-section-title { margin: 18px 0 8px; color: var(--blue-950); font-size: 14px; }
.cfdi-alert {
    margin: 12px 0;
    padding: 11px 12px;
    border: 1px solid var(--red-100);
    border-left: 4px solid var(--red-700);
    border-radius: 9px;
    color: var(--red-800);
    background: var(--red-50);
    font-size: 11px;
    line-height: 1.45;
}
.cfdi-ok {
    margin: 12px 0;
    padding: 10px 12px;
    border: 1px solid var(--green-100);
    border-left: 4px solid var(--green-700);
    border-radius: 9px;
    color: var(--green-800);
    background: var(--green-50);
    font-size: 11px;
}
.currency-reference { color: var(--purple-700); font-weight: 760; }
.document-blocked td { background: #fff9f8; }
.document-blocked:hover td { background: #fff4f2 !important; }
.reference-note { margin-top: 3px; color: var(--slate-500); font-size: 9px; }
.stage-note { margin-top: 12px; padding: 10px 12px; border: 1px dashed var(--slate-300); border-radius: 9px; color: var(--slate-600); background: var(--slate-50); font-size: 10px; }

.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1200;
    max-width: min(430px, calc(100% - 40px));
    padding: 11px 14px;
    border-radius: 9px;
    color: var(--white);
    background: var(--blue-950);
    box-shadow: var(--shadow-md);
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: opacity 160ms ease, transform 160ms ease;
}
.toast.is-visible { opacity: 1; transform: translateY(0); }
.fatal-error { position: fixed; inset: 0; z-index: 1300; display: grid; place-items: center; padding: 20px; background: rgba(10,37,64,.72); backdrop-filter: blur(4px); }
.fatal-error[hidden] { display: none; }
.fatal-error-card { width: min(520px, 100%); padding: 28px; border-radius: var(--radius-lg); background: var(--white); box-shadow: var(--shadow-lg); text-align: center; }
.fatal-error-icon { display: grid; width: 54px; height: 54px; margin: 0 auto 14px; place-items: center; border-radius: 50%; color: var(--red-700); background: var(--red-100); font-size: 27px; font-weight: 900; }
.fatal-error h2 { margin: 0 0 8px; color: var(--blue-950); }
.fatal-error p { color: var(--slate-600); }
.fatal-error code { color: var(--red-700); }

.print-only { display: none; }
body.pdf-mode .no-print { display: none !important; }
body.pdf-mode .app-main { width: 100%; margin: 10px 0; }
body.pdf-mode .app-header { padding: 10px 14px; color: var(--white); background: linear-gradient(125deg, var(--blue-950), var(--blue-800)); box-shadow: none; border-bottom: 0; }
body.pdf-mode .brand-mark { color: var(--blue-950); background: var(--white); }
body.pdf-mode .eyebrow, body.pdf-mode .app-header p { color: #d7e9fa; }
body.pdf-mode .kpi-card { background: var(--kpi-soft, var(--blue-50)); border-top: 3px solid var(--kpi-color, var(--blue-800)); }

@media (max-width: 1240px) {
    .filter-panel { grid-template-columns: minmax(240px, 1.6fr) repeat(3, minmax(145px, .8fr)); }
    .filter-field-date, .filter-actions { grid-row: 2; }
    .kpi-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 1100px) {
    .app-header { align-items: flex-start; flex-direction: column; }
    .header-session { width: 100%; justify-content: flex-start; }
    .header-actions { justify-content: flex-start; }
}

@media (max-width: 880px) {
    .session-item { flex: 1 1 150px; max-width: none; }
    .header-actions { justify-content: flex-start; }
    .filter-panel { grid-template-columns: 1fr 1fr; }
    .filter-field-search { grid-column: 1 / -1; }
    .filter-field-residual { grid-column: span 2; }
    .filter-field-date, .filter-actions { grid-row: auto; }
    .panel-grid, .panel-grid.equal { grid-template-columns: 1fr; }
    .aging-cards { grid-template-columns: repeat(2, 1fr); }
    .detail-grid, .detail-highlight-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 620px) {
    .app-header { padding: 17px; }
    .app-main { width: min(100% - 20px, 1540px); margin-top: 12px; }
    .filter-panel, .kpi-grid, .aging-cards { grid-template-columns: 1fr; }
    .filter-field-search, .filter-field-residual { grid-column: auto; }
    .residual-control { grid-template-columns: 1fr 92px; }
    .filter-actions .btn { width: 100%; }
    .header-actions { width: 100%; }
    .header-actions .btn { flex: 1 1 110px; }
    .panel-header { align-items: flex-start; flex-direction: column; }
    .badges { justify-content: flex-start; }
    .balance-legend { grid-template-columns: 1fr; }
    .detail-grid, .detail-highlight-grid { grid-template-columns: 1fr; }
    .detail-item.span-2 { grid-column: auto; }
}

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

    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    html, body { background: #fff !important; }
    body { font-size: 9px; }
    .no-print, .header-actions, .tabs, .toast, .modal-close { display: none !important; }

    body.modal-print-mode .app-shell { display: none !important; }
    body.modal-print-mode .modal { display: block !important; }
    body.modal-print-mode .modal-card { border-radius: 0; }

    .print-only { display: block; }

    .app-header {
        min-height: 0;
        padding: 7px 10px;
        color: #fff !important;
        background: linear-gradient(125deg, #0a2540, #124578) !important;
        box-shadow: none;
        border: 0;
    }
    .brand-mark {
        width: 34px;
        height: 34px;
        border-radius: 9px;
        color: #0d3158 !important;
        background: #fff !important;
        font-size: 20px;
    }
    .app-header h1 { color: #fff !important; font-size: 17px; }
    .eyebrow, .app-header p { color: #d7e9fa !important; }
    .eyebrow { font-size: 8px; }
    .app-header p { margin-top: 2px; font-size: 8px; }
    .header-session { gap: 4px; }
    .session-item { min-width: 78px; padding: 4px 6px; border-radius: 5px; background: rgba(255,255,255,.08) !important; }
    .session-item span { font-size: 6px; }
    .session-item strong { font-size: 7px; }

    .app-main { width: 100%; margin: 5px 0 0; }

    .kpi-grid {
        grid-template-columns: repeat(7, 1fr);
        gap: 3px;
        margin: 5px 0 6px;
    }
    .kpi-card {
        min-height: 0;
        padding: 5px 6px;
        border: 1px solid #d0d5dd;
        border-top: 3px solid var(--kpi-color, #124578);
        border-radius: 6px;
        background: var(--kpi-soft, #eff7ff) !important;
        box-shadow: none;
    }
    .kpi-card::after { display: none; }
    .kpi-label { color: #475467 !important; font-size: 7px; }
    .kpi-value { margin-top: 2px; color: var(--kpi-color, #0d3158) !important; font-size: 11px; }
    .kpi-note { margin-top: 2px; color: #667085 !important; font-size: 6.5px; }

    .report-content { margin-top: 5px; }

    /* No obligar al panel completo a pasar a la hoja siguiente. */
    .panel {
        break-inside: auto;
        page-break-inside: auto;
        box-shadow: none;
        border-color: #d0d5dd;
    }
    .panel + .panel { margin-top: 6px; }
    .panel-header {
        break-after: avoid;
        page-break-after: avoid;
        padding: 6px 7px;
        background: #eff7ff !important;
        border-bottom: 1px solid #b7d3ef;
    }
    .panel-header h2 { font-size: 11px; }
    .panel-header p { margin-top: 2px; font-size: 7px; }
    .panel-body { padding: 6px; }

    .summary-callout { padding: 6px 8px; margin-bottom: 5px; background: #eff7ff !important; }
    .summary-callout-metric { font-size: 13px; }
    .aging-cards { gap: 3px; }
    .aging-card { padding: 5px; }
    .aging-card-value { font-size: 11px; }

    .table-shell { overflow: visible; border-radius: 4px; }
    .report-table { min-width: 0 !important; width: 100% !important; }
    .report-table thead { display: table-header-group; }
    .report-table tfoot { display: table-footer-group; }
    .report-table tr { break-inside: avoid; page-break-inside: avoid; }
    .report-table th, .report-table td { padding: 3px 4px; font-size: 6.5px; }
    .report-table thead th {
        position: static;
        color: #fff !important;
        background: #124578 !important;
        border-color: #0d3158;
        font-size: 6.5px;
    }
    .report-table .sticky-left,
    .report-table .sticky-right { position: static; box-shadow: none; }
    .report-table .total-row td { color: #0d3158 !important; background: #dceeff !important; }
    .report-table .heat-0 { background: #f0fbf5 !important; }
    .report-table .heat-1 { background: #fffae8 !important; }
    .report-table .heat-2 { background: #fff1df !important; }
    .report-table .heat-3 { background: #ffe7df !important; }
    .report-table .heat-4 { background: #ffe0de !important; }
    .document-blocked td { background: #fff4f2 !important; }

    .badge { min-height: 17px; padding: 2px 5px; font-size: 6.5px; }
    .badge-blue { background: #dceeff !important; }
    .badge-green { background: #d1fadf !important; }
    .badge-amber { background: #fef0c7 !important; }
    .badge-red { background: #fee4e2 !important; }
    .badge-purple { background: #ebe9fe !important; }
    .badge-cyan { background: #cff9fe !important; }
    .badge-slate { background: #f2f4f7 !important; }

    .modal { position: static; display: block; padding: 0; }
    .modal[hidden] { display: none; }
    .modal-backdrop { display: none; }
    .modal-card,
    .modal-provider-wide .modal-card {
        width: 100%;
        max-height: none;
        overflow: visible;
        border-radius: 0;
        box-shadow: none;
    }
    .modal-header {
        position: static;
        padding: 7px 9px;
        color: #fff !important;
        background: linear-gradient(125deg, #0a2540, #124578) !important;
        border-bottom: 0;
    }
    .modal-header h2 { color: #fff !important; font-size: 14px; }
    .modal-eyebrow { color: #d7e9fa !important; }
    .modal-body { padding: 7px; }
    .detail-grid { gap: 4px; }
    .detail-item { padding: 5px 6px; }
    .detail-highlight {
        margin: 6px 0;
        padding: 6px;
        background: #eff7ff !important;
        border-top: 3px solid #1760a8;
    }
    .detail-highlight-grid { gap: 5px; }
    .detail-number-value { font-size: 11px; }
    .detail-section-title { margin: 7px 0 4px; font-size: 9px; }
    .cfdi-alert { background: #fff4f2 !important; }
    .cfdi-ok { background: #ecfdf3 !important; }
}


/* ============================================================
   Centro CxP v1.2.5 · botones de header pastel / outline
   ============================================================ */
.header-actions .btn-header {
    color: #eef7ff;
    background: rgba(220, 238, 255, .08);
    border-color: rgba(185, 217, 248, .62);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}
.header-actions .btn-header:hover {
    color: #fff;
    background: rgba(220, 238, 255, .17);
    border-color: #8fc8ff;
}
.header-actions .btn-refresh {
    color: #d9f7e8;
    background: rgba(209, 250, 223, .09);
    border-color: rgba(126, 232, 167, .72);
}
.header-actions .btn-refresh:hover {
    background: rgba(209, 250, 223, .18);
    border-color: #62ee9c;
}
.header-actions .btn-danger {
    color: #ffe6e3;
    background: rgba(254, 228, 226, .12);
    border-color: #ff665c;
}
.header-actions .btn-danger:hover {
    color: #fff;
    background: rgba(180, 35, 24, .72);
    border-color: #ff4d42;
}

/* Órdenes de Compra v0.1.1 · base visual CxP v1.2.5 */
body { font-size: 13px; }
.app-header { gap: 16px; }
.app-header h1 { font-size: clamp(20px, 1.65vw, 26px); line-height: 1.16; }
.app-header p { font-size: 11px; line-height: 1.4; }
.brand-block { min-width: 350px; }
.brand-mark svg { width: 30px; height: 30px; stroke: currentColor; fill: none; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.header-session { max-width: 780px; }
.session-item strong { font-size: 11px; }
.session-company { max-width: 230px; }
.header-actions { width: 100%; }
.header-actions .btn { min-height: 32px; padding: 6px 10px; font-size: 11px; }
.app-main { width: min(1640px, calc(100% - 28px)); margin: 14px auto 26px; }
.demo-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 12px; padding: 9px 12px; border: 1px solid #d8ceef; border-radius: 10px; color: #493478; background: #f4f0fc; font-size: 12px; }
.demo-banner strong { margin-left: auto; font-size: 11px; }
.demo-banner.real { border-color: #b9decf; color: #05603a; background: #f0faf5; }
.filter-panel { grid-template-columns: minmax(230px,1.35fr) minmax(160px,1fr) minmax(175px,1fr) minmax(130px,.8fr) minmax(180px,1fr) minmax(190px,1.1fr) auto; padding: 12px; }
.filter-field label { color: #475467; font-size: 10px; }
.filter-field input, .filter-field select { height: 35px; font-size: 12px; }
.filter-actions .btn { min-height: 35px; font-size: 12px; }
.scope-bar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 5px; padding: 9px 2px 0; color: #475467; font-size: 11px; }
.scope-bar b { color: #124578; }
.kpi-grid { grid-template-columns: repeat(6,minmax(0,1fr)); }
.kpi-card { border-top: 3px solid var(--kpi-color); padding: 11px 12px; }
.kpi-label { color: #475467; font-size: 10px; }
.kpi-value { font-size: clamp(20px,1.7vw,28px); }
.kpi-note { color: #475467; font-size: 11px; white-space: normal; line-height: 1.35; }
.kpi-card[data-kpi-action] { cursor: pointer; }
.kpi-card[data-kpi-action]:hover { background: var(--kpi-soft); }
.week-navigation { display: flex; align-items: center; gap: 12px; margin: 2px 0 12px; }
.week-label { flex: 0 0 auto; color: #475467; font-size: 11px; font-weight: 800; }
.week-strip { display: flex; flex-wrap: wrap; gap: 6px; }
.week-chip { display: inline-flex; align-items: center; gap: 7px; min-height: 32px; padding: 6px 10px; border: 1px solid #cbd8e8; border-radius: 8px; color: #344054; background: #fff; font-size: 11px; }
.week-chip b { color: #124578; }
.week-chip.is-current { border-color: #7ab6e5; background: #f0f7ff; }
.week-chip.is-active { color: #fff; border-color: #124578; background: #124578; }
.week-chip.is-active b { color: #fff; }
.week-chip:hover { box-shadow: 0 0 0 2px #dceeff; }
.tab { font-size: 12px; padding: 8px 13px; }
.report-content { margin-top: 12px; }
.panel-header { padding: 11px 14px; }
.panel-header h2 { font-size: 15px; }
.panel-header p { color: #475467; line-height: 1.4; font-size: 11px; }
.panel-body { padding: 13px; }
.oc-callout { margin-bottom: 12px; background: linear-gradient(110deg,#eff7ff,#f8fbff); }
.oc-callout p { margin: 4px 0 0; line-height: 1.45; }
.summary-layout { display: grid; grid-template-columns: minmax(0,1.1fr) minmax(0,.9fr); gap: 12px; margin-bottom: 12px; }
.summary-layout .panel + .panel { margin-top: 0; }
.alert-list { display: grid; gap: 9px; }
.alert-card { display: flex; gap: 10px; align-items: center; padding: 11px; border: 1px solid #e4e7ec; border-left: 4px solid #b54708; border-radius: 9px; background: #fffcf3; }
.alert-card.danger { border-left-color: #b42318; background: #fff5f3; }
.alert-card.info { border-left-color: #1760a8; background: #f2f8ff; }
.alert-card > .alert-count { flex: 0 0 auto; display: grid; place-items: center; min-width: 35px; height: 35px; border-radius: 8px; color: #934b06; background: #fef0c7; font-size: 17px; font-weight: 900; }
.alert-card.danger > .alert-count { color: #b42318; background: #fee4e2; }
.alert-card.info > .alert-count { color: #1760a8; background: #dceeff; }
.alert-copy { flex: 1; min-width: 0; }
.alert-copy strong { display: block; color: #172033; font-size: 12px; }
.alert-copy small { display: block; margin-top: 3px; color: #475467; font-size: 11px; line-height: 1.4; }
.delivery-track { display: flex; height: 12px; margin-top: 6px; border-radius: 8px; overflow: hidden; background: #eff2f6; }
.delivery-track .received { background: #35a87c; }
.delivery-track .pending { background: #84b4de; }
.delivery-track .overdue { background: #da736a; }
.delivery-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 7px; color: #475467; font-size: 11px; }
.delivery-legend i { display: inline-block; width: 8px; height: 8px; margin-right: 4px; border-radius: 2px; }
.week-board { display: grid; grid-template-columns: repeat(auto-fit,minmax(180px,1fr)); gap: 8px; }
.week-card { text-align: left; padding: 12px; border: 1px solid #d7e3ee; border-radius: 10px; background: #f9fbfe; }
.week-card.current { border-top: 3px solid #2477c8; background: #eff7ff; }
.week-card.past { border-top: 3px solid #d57065; background: #fff7f5; }
.week-card.selected { box-shadow: 0 0 0 2px #2477c8; }
.week-card:hover { background: #edf5ff; }
.week-card > span { display: block; color: #475467; font-size: 11px; }
.week-card > strong { display: block; margin: 7px 0; color: #124578; font-size: 22px; }
.week-card > small { display: block; color: #475467; font-size: 11px; line-height: 1.45; }
.week-card .mini-progress { margin: 8px 0; }
.mini-progress { display: flex; align-items: center; gap: 7px; min-width: 80px; }
.mini-progress > div { flex: 1; height: 6px; border-radius: 6px; background: #e5edf3; overflow: hidden; }
.mini-progress i { display: block; height: 100%; border-radius: inherit; background: #26a576; }
.mini-progress span { color: #344054; font-size: 10px; white-space: nowrap; }
.report-table { min-width: 860px; }
.report-table th, .report-table td { font-size: 12px; padding: 9px 10px; vertical-align: middle; }
.report-table th { font-size: 10px; }
.report-table .number { font-variant-numeric: tabular-nums; }
.report-table td small { display: block; margin-top: 3px; color: #475467; font-size: 10px; line-height: 1.4; }
.report-table .name-cell { min-width: 180px; }
.report-table .money-pending { color: #124578; font-weight: 800; }
.report-table .late-row { background: #fff8f6; }
.report-table .muted-row { color: #667085; }
.report-table .quantity-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.report-table .quantity-badges span { display: inline-block; padding: 3px 5px; border-radius: 5px; color: #344054; background: #edf2f7; font-size: 10px; white-space: nowrap; }
.table-note { padding: 9px 12px; color: #475467; font-size: 11px; line-height: 1.4; border-top: 1px solid #e4e7ec; }
.icon-button { min-width: 28px; min-height: 28px; }
.badge { font-size: 10px; min-height: 22px; }
.empty-message { padding: 35px 20px; text-align: center; color: #475467; }
.empty-message strong { display: block; margin-bottom: 8px; color: #124578; font-size: 16px; }
.error-panel { padding: 24px; border: 1px solid #f4bbb5; border-radius: 12px; color: #912018; background: #fff4f2; }
.error-panel h2 { margin: 0 0 9px; }
.error-panel p { line-height: 1.5; }
.error-panel .btn { margin-top: 8px; }
.modal-card { width: min(1360px,100%); }
.modal-header h2 { font-size: 20px; }
.modal-eyebrow { font-size: 10px; }
.modal-body { padding: 14px; }
.modal-scope { padding: 9px 12px; margin: 10px 0; border: 1px solid #cbdced; border-radius: 8px; color: #344054; background: #f4f8fd; font-size: 11px; line-height: 1.45; }
.modal-body .report-table { min-width: 870px; }
.report-footer { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; padding: 15px 2px 0; color: #475467; font-size: 10px; }
.print-report { display: none; }
@media (max-width:1450px) { .filter-panel { grid-template-columns: minmax(230px,1.3fr) repeat(3,minmax(145px,1fr)); } .filter-actions { grid-row: auto; } }
@media (max-width:1100px) { .brand-block { min-width: 0; } .header-session { max-width: none; } .header-actions { justify-content: flex-start; } .kpi-grid { grid-template-columns: repeat(3,minmax(0,1fr)); } }
@media (max-width:880px) { .filter-panel { grid-template-columns: 1fr 1fr; } .summary-layout { grid-template-columns: 1fr; } .week-navigation { flex-direction: column; align-items: flex-start; } .demo-banner strong { margin-left: 0; } }
@media (max-width:620px) { .filter-panel { grid-template-columns: 1fr; } .kpi-grid { grid-template-columns: repeat(2,minmax(0,1fr)); } .kpi-value { font-size: 21px; } .session-item { flex: 1 1 130px; } .brand-mark { width: 40px; height: 40px; } .app-header { padding: 13px; } .brand-block { gap: 9px; } .app-header h1 { font-size: 21px; } .oc-callout { align-items: flex-start; flex-direction: column; } .modal-header { flex-wrap: wrap; } .modal-header-actions { flex-wrap: wrap; } }
@media print {
    @page { size: A4 landscape; margin: 9mm; }
    .app-shell, .modal, body.modal-print-mode .modal, .toast { display: none !important; }
    .print-report { display: block !important; color: #172033; font-size: 8pt; }
    .print-head { padding: 10px 12px; color: #fff !important; background: #124578 !important; }
    .print-head h1 { margin: 0 0 4px; font-size: 16pt; }
    .print-head p { margin: 3px 0; color: #e8f4ff !important; font-size: 8pt; }
    .print-demo { padding: 6px 8px; margin-top: 5px; border: 1px solid #d5c7f0; color: #493478 !important; background: #f4f0fc !important; font-weight: 700; }
    .print-kpis { display: grid; grid-template-columns: repeat(6,1fr); gap: 5px; margin: 7px 0; }
    .print-kpis > div { padding: 6px; border: 1px solid #d0d5dd; border-top: 3px solid var(--kpi-color); border-radius: 5px; background: #f8fafc !important; }
    .print-kpis span { display: block; font-size: 6.5pt; color: #475467 !important; }
    .print-kpis strong { display: block; margin-top: 4px; font-size: 10pt; color: var(--kpi-color) !important; }
    .print-section h2 { margin: 10px 0 5px; font-size: 10pt; color: #124578 !important; break-after: avoid; }
    .print-table { width: 100%; border-collapse: collapse; table-layout: auto; }
    .print-table thead { display: table-header-group; }
    .print-table th { color: #fff !important; background: #124578 !important; text-align: left; }
    .print-table th, .print-table td { padding: 4px 5px; border: 1px solid #d0d5dd; font-size: 6.5pt; overflow-wrap: anywhere; }
    .print-table td.num { text-align: right; white-space: nowrap; }
    .print-table tr { break-inside: avoid; }
    .print-table tr:nth-child(even) td { background: #f4f8fb !important; }
    .print-foot { margin-top: 7px; font-size: 6.5pt; color: #475467 !important; }
}
