/* ITALIA ERP · Inventario en Proceso · UI PRO 2.0 */
/* Conserva todos los selectores originales y agrega una capa visual moderna. */

: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-600: #667085;
    --slate-500: #7b8798;
    --slate-300: #d0d5dd;
    --slate-200: #e4e7ec;
    --slate-100: #f2f4f7;
    --slate-50: #f8fafc;
    --green-700: #067647;
    --green-100: #d1fadf;
    --amber-700: #b54708;
    --amber-100: #fef0c7;
    --money-700: #0b5f75;
    --money-100: #dff4f7;
    --red-700: #b42318;
    --red-100: #fee4e2;
    --white: #ffffff;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-md: 0 10px 24px rgba(15, 35, 60, 0.10);
    --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 33%),
        var(--slate-50);
    font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 14px;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

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

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 20px 28px;
    color: var(--white);
    background: linear-gradient(125deg, var(--blue-950), var(--blue-800));
    box-shadow: var(--shadow-md);
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 16px;
    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.36);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.12);
    font-size: 27px;
    font-weight: 900;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.20);
}

.eyebrow {
    margin-bottom: 3px;
    color: #b9d9f8;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

.app-header h1 {
    margin: 0;
    font-size: clamp(21px, 2.3vw, 30px);
    line-height: 1.12;
}

.app-header p {
    margin: 5px 0 0;
    color: #d7e9fa;
    font-size: 12px;
}

.header-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.btn {
    min-height: 38px;
    padding: 8px 14px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-weight: 750;
    transition: transform 120ms ease, background-color 120ms ease, border-color 120ms ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    color: var(--blue-950);
    background: var(--white);
    border-color: rgba(255, 255, 255, 0.72);
}

.btn-secondary {
    color: var(--white);
    background: rgba(255, 255, 255, 0.10);
    border-color: rgba(255, 255, 255, 0.30);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.18);
}

.btn-ghost {
    color: var(--blue-800);
    background: var(--white);
    border-color: var(--slate-300);
}

.app-main {
    width: min(1520px, calc(100% - 32px));
    margin: 22px auto 48px;
}

.filter-panel {
    display: grid;
    grid-template-columns: minmax(260px, 1.6fr) minmax(190px, 0.8fr) minmax(180px, 0.7fr) auto;
    align-items: end;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.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: 11px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.filter-field input,
.filter-field select {
    width: 100%;
    height: 40px;
    padding: 8px 11px;
    color: var(--slate-950);
    border: 1px solid var(--slate-300);
    border-radius: var(--radius-sm);
    outline: none;
    background: var(--white);
}

.filter-field input:focus,
.filter-field select:focus {
    border-color: var(--blue-600);
    box-shadow: 0 0 0 3px rgba(36, 119, 200, 0.14);
}

.filter-actions {
    display: flex;
    align-items: end;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 175px));
    justify-content: start;
    gap: 8px;
    margin: 12px 0;
}

.kpi-card {
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
    background: var(--white);
    box-shadow: var(--shadow-sm);
}

.kpi-label {
    color: var(--slate-600);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.kpi-value {
    margin-top: 5px;
    color: var(--blue-950);
    font-size: 26px;
    font-weight: 850;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.kpi-note {
    margin-top: 7px;
    color: var(--slate-500);
    font-size: 11px;
}

.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: 750;
}

.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,
.department-card,
.outsource-card {
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
    background: var(--white);
    box-shadow: var(--shadow-sm);
}

.panel-header,
.department-header,
.outsource-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 17px;
    border-bottom: 1px solid var(--slate-200);
}

.panel-header h2,
.department-header h2,
.outsource-header h2 {
    margin: 0;
    color: var(--blue-950);
    font-size: 17px;
}

.panel-header p,
.department-header p,
.outsource-header p {
    margin: 4px 0 0;
    color: var(--slate-600);
    font-size: 12px;
}

.panel-body {
    padding: 16px;
}

.badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 7px;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    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-money {
    color: var(--money-700);
    background: var(--money-100);
}

.cost-note,
.order-legend,
.tracking-help {
    margin-bottom: 13px;
    padding: 10px 12px;
    border: 1px solid #c9dff3;
    border-left: 4px solid var(--blue-700);
    border-radius: 8px;
    color: var(--slate-700, #475467);
    background: var(--blue-50);
    font-size: 12px;
    line-height: 1.5;
}

.order-legend {
    margin: 0 0 14px;
    box-shadow: var(--shadow-sm);
}

.order-chip {
    display: inline-flex;
    margin: 0 5px;
    padding: 2px 7px;
    border-radius: 999px;
    color: var(--white);
    background: var(--blue-800);
    font-weight: 850;
    font-variant-numeric: tabular-nums;
}

.department-sequence {
    margin-bottom: 3px;
    color: var(--blue-700);
    font-size: 10px;
    font-weight: 850;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.stack {
    display: grid;
    gap: 14px;
}

.subsection {
    padding: 0 16px 16px;
}

.subsection-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 16px 0 8px;
}

.subsection-title h3 {
    margin: 0;
    color: var(--slate-800);
    font-size: 14px;
}

.table-shell {
    width: 100%;
    overflow: auto;
    border: 1px solid var(--slate-200);
    border-radius: 10px;
}

.report-table {
    width: 100%;
    min-width: 720px;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--white);
}

.report-table th,
.report-table td {
    padding: 9px 10px;
    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: 11px;
    font-weight: 850;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    white-space: nowrap;
}

.report-table th.is-sortable {
    cursor: pointer;
    user-select: none;
}

.report-table th.is-sortable:hover {
    background: #dcecff;
}

.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 {
    font-weight: 800;
}

.report-table .muted {
    color: var(--slate-500);
}

.report-table .money {
    color: var(--money-700);
    font-variant-numeric: tabular-nums;
}

.cost-pivot-table {
    min-width: 1040px;
}

.period-heading {
    min-width: 112px;
    line-height: 1.15;
}

.period-code {
    display: block;
    color: var(--blue-950);
    font-size: 11px;
    font-weight: 900;
}

.period-detail {
    display: block;
    margin-top: 3px;
    color: var(--slate-600);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
    white-space: normal;
}

.pivot-main-label,
.order-code {
    color: var(--blue-950);
    font-weight: 850;
}

.pivot-description {
    margin-top: 3px;
    color: var(--slate-800);
    font-weight: 650;
}

.pivot-meta,
.order-date {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    margin-top: 4px;
    color: var(--slate-500);
    font-size: 10px;
    font-weight: 600;
}

.sequence-cell {
    color: var(--blue-700);
    font-weight: 850;
}

.order-tracking-table {
    min-width: 980px;
}

.client-group-row td {
    color: var(--blue-950);
    background: #f1f7fd;
    font-weight: 800;
}

.order-child-row td:nth-child(2) {
    padding-left: 22px;
}

.tree-marker {
    margin-right: 5px;
    color: var(--blue-700);
    font-weight: 900;
}

.location-cell {
    min-width: 220px;
    color: var(--slate-700, #475467);
    font-size: 11px;
    line-height: 1.45;
}

.report-table .style-row td {
    color: var(--blue-950);
    background: #f3f8fe;
    font-weight: 800;
}

.report-table .order-row td:first-child {
    padding-left: 26px;
}

.report-table .total-row td {
    color: var(--blue-950);
    background: #eaf3fc;
    font-weight: 850;
    border-top: 1px solid #b7d3ef;
}

.report-table .sticky-left {
    position: sticky;
    left: 0;
    z-index: 1;
    background: inherit;
}

.report-table thead .sticky-left {
    z-index: 3;
}

.summary-table td:first-child {
    font-weight: 700;
}

.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, 0.72);
}

.empty-state strong {
    display: block;
    margin-bottom: 5px;
    color: var(--blue-950);
    font-size: 16px;
}

.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
}

.table-toolbar-info {
    color: var(--slate-600);
    font-size: 12px;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 11px;
}

.pagination button,
.pagination select {
    min-height: 34px;
    padding: 6px 10px;
    border: 1px solid var(--slate-300);
    border-radius: 7px;
    color: var(--slate-800);
    background: var(--white);
}

.pagination button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.sort-indicator {
    display: inline-block;
    min-width: 12px;
    margin-left: 5px;
    color: var(--blue-700);
}

.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 100;
    max-width: min(420px, 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: 1000;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(10, 37, 64, 0.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: 0 24px 70px rgba(0, 0, 0, 0.26);
    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);
}

@media (max-width: 1120px) {
    .kpi-grid {
        grid-template-columns: repeat(2, minmax(170px, 1fr));
    }
}

@media (max-width: 850px) {
    .app-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .header-actions {
        justify-content: flex-start;
    }

    .filter-panel {
        grid-template-columns: 1fr 1fr;
    }

    .filter-field-search {
        grid-column: 1 / -1;
    }
}

@media (max-width: 620px) {
    .app-header {
        padding: 17px;
    }

    .app-main {
        width: min(100% - 20px, 1520px);
        margin-top: 12px;
    }

    .filter-panel,
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .filter-field-search {
        grid-column: auto;
    }

    .filter-actions .btn {
        width: 100%;
    }

    .header-actions {
        width: 100%;
    }

    .header-actions .btn {
        flex: 1 1 110px;
    }

    .panel-header,
    .department-header,
    .outsource-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .badges {
        justify-content: flex-start;
    }
}

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

    body {
        background: var(--white);
        font-size: 10px;
    }

    .no-print,
    .header-actions,
    .toast {
        display: none !important;
    }

    .app-header {
        padding: 0 0 10px;
        color: var(--blue-950);
        background: var(--white);
        box-shadow: none;
        border-bottom: 2px solid var(--blue-800);
    }

    .brand-mark {
        color: var(--white);
        background: var(--blue-800);
    }

    .eyebrow,
    .app-header p {
        color: var(--slate-600);
    }

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

    .kpi-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 5px;
        margin: 8px 0;
    }

    .kpi-card {
        padding: 8px;
        box-shadow: none;
    }

    .kpi-value {
        font-size: 17px;
    }

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

    .panel,
    .department-card,
    .outsource-card {
        break-inside: avoid;
        box-shadow: none;
    }

    .table-shell {
        overflow: visible;
    }

    .report-table {
        min-width: 0;
    }

    .report-table th,
    .report-table td {
        padding: 4px 5px;
        font-size: 8px;
    }

    .report-table thead th,
    .report-table .sticky-left {
        position: static;
    }
}

/* ========================================================================== */
/* ITALIA ERP · UI PRO 2.0                                                    */
/* Modernización visual compatible con el HTML y reporte.js actuales.         */
/* ========================================================================== */

:root {
    --brand-950: #0b1f3a;
    --brand-900: #102a4c;
    --brand-800: #143d6b;
    --brand-700: #175da8;
    --brand-600: #1f78d1;
    --brand-500: #2f8fe6;
    --brand-200: #b9dcfb;
    --brand-100: #dceeff;
    --brand-50: #f2f8ff;

    --surface-app: #f3f6fb;
    --surface-soft: #f8faff;
    --surface-hover: #f5f9ff;

    --ui-border: #dce4ef;
    --ui-border-strong: #c7d4e5;
    --ui-text: #152238;
    --ui-muted: #66758a;

    --success-700: #087a55;
    --success-100: #daf7e9;
    --warning-700: #b45309;
    --warning-100: #ffefd0;
    --danger-700: #c4322b;
    --danger-100: #ffe3e0;

    --shadow-card:
        0 1px 2px rgba(15, 35, 60, 0.04),
        0 8px 24px rgba(20, 61, 107, 0.07);
    --shadow-card-hover:
        0 2px 4px rgba(15, 35, 60, 0.06),
        0 14px 34px rgba(20, 61, 107, 0.12);
    --shadow-float:
        0 22px 60px rgba(13, 49, 88, 0.18);

    --radius-control: 10px;
    --radius-card: 16px;
    --radius-panel: 20px;
}

html {
    background: var(--surface-app);
    scroll-behavior: smooth;
}

body {
    color: var(--ui-text);
    background:
        radial-gradient(circle at 92% -5%, rgba(47, 143, 230, 0.13), transparent 30%),
        radial-gradient(circle at -10% 45%, rgba(23, 96, 168, 0.07), transparent 29%),
        linear-gradient(180deg, #f9fbfe 0, var(--surface-app) 280px);
    font-size: 13px;
    line-height: 1.45;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

::selection {
    color: var(--white);
    background: var(--brand-600);
}

button,
input,
select {
    letter-spacing: 0;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid rgba(47, 143, 230, 0.24);
    outline-offset: 2px;
}

/* Header: más ligero y similar a una aplicación SaaS moderna. */

.app-header {
    position: sticky;
    top: 0;
    z-index: 40;
    min-height: 78px;
    padding: 14px clamp(18px, 2.5vw, 36px);
    color: var(--ui-text);
    border-bottom: 1px solid rgba(199, 212, 229, 0.82);
    background:
        linear-gradient(90deg, rgba(255, 255, 255, 0.98), rgba(247, 251, 255, 0.96));
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.94) inset,
        0 6px 20px rgba(20, 61, 107, 0.07);
    backdrop-filter: blur(14px);
}

.app-header::after {
    position: absolute;
    right: 0;
    bottom: -1px;
    left: 0;
    height: 2px;
    content: "";
    background: linear-gradient(
        90deg,
        var(--brand-700),
        var(--brand-500) 42%,
        rgba(47, 143, 230, 0.08) 85%
    );
}

.brand-block {
    gap: 13px;
}

.brand-mark {
    width: 46px;
    height: 46px;
    color: var(--white);
    border: 0;
    border-radius: 14px;
    background:
        linear-gradient(145deg, var(--brand-500), var(--brand-800));
    box-shadow:
        0 9px 20px rgba(23, 96, 168, 0.24),
        inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.eyebrow {
    margin-bottom: 2px;
    color: var(--brand-600);
    font-size: 10px;
    letter-spacing: 0.15em;
}

.app-header h1 {
    color: var(--brand-950);
    font-size: clamp(20px, 2vw, 28px);
    letter-spacing: -0.025em;
}

.app-header p {
    margin-top: 3px;
    color: var(--ui-muted);
}

.header-actions {
    gap: 7px;
}

.btn {
    min-height: 37px;
    padding: 8px 13px;
    border-radius: var(--radius-control);
    font-size: 12px;
    font-weight: 780;
    box-shadow: 0 1px 1px rgba(15, 35, 60, 0.03);
    transition:
        transform 140ms ease,
        box-shadow 140ms ease,
        color 140ms ease,
        background-color 140ms ease,
        border-color 140ms ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(20, 61, 107, 0.12);
}

.btn-primary {
    color: var(--white);
    border-color: var(--brand-700);
    background: linear-gradient(135deg, var(--brand-600), var(--brand-800));
}

.btn-primary:hover {
    border-color: var(--brand-800);
    background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
}

.btn-secondary {
    color: var(--brand-800);
    border-color: var(--brand-200);
    background: var(--brand-50);
}

.btn-secondary:hover {
    color: var(--brand-950);
    border-color: #8fc5f1;
    background: #e8f4ff;
}

.btn-ghost {
    color: var(--brand-700);
    border-color: var(--ui-border-strong);
    background: rgba(255, 255, 255, 0.92);
}

.btn-ghost:hover {
    border-color: var(--brand-200);
    background: var(--brand-50);
}

/* Área de trabajo. */

.app-main {
    width: min(1680px, calc(100% - 30px));
    margin: 18px auto 54px;
}

.filter-panel {
    grid-template-columns:
        minmax(260px, 1.65fr)
        minmax(190px, 0.85fr)
        minmax(180px, 0.75fr)
        auto;
    gap: 10px;
    padding: 13px;
    border: 1px solid rgba(220, 228, 239, 0.9);
    border-radius: var(--radius-card);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow-card);
    backdrop-filter: blur(10px);
}

.filter-field label {
    margin-bottom: 5px;
    color: #65748a;
    font-size: 10px;
    letter-spacing: 0.055em;
}

.filter-field input,
.filter-field select {
    height: 38px;
    padding: 7px 11px;
    color: var(--ui-text);
    border-color: var(--ui-border-strong);
    border-radius: var(--radius-control);
    background-color: rgba(255, 255, 255, 0.98);
    box-shadow: 0 1px 2px rgba(15, 35, 60, 0.025) inset;
    transition:
        border-color 140ms ease,
        box-shadow 140ms ease,
        background-color 140ms ease;
}

.filter-field input:hover,
.filter-field select:hover {
    border-color: #9fc4e5;
}

.filter-field input:focus,
.filter-field select:focus {
    border-color: var(--brand-500);
    background: var(--white);
    box-shadow:
        0 0 0 3px rgba(47, 143, 230, 0.13),
        0 1px 2px rgba(15, 35, 60, 0.02) inset;
}

/* KPIs compactos, con acento visual y mayor jerarquía. */

.kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(154px, 188px));
    gap: 9px;
    margin: 13px 0;
}

.kpi-card {
    --kpi-accent: var(--brand-600);

    position: relative;
    min-height: 94px;
    padding: 12px 13px 11px;
    overflow: hidden;
    border: 1px solid var(--ui-border);
    border-radius: var(--radius-card);
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.99), rgba(247, 251, 255, 0.98));
    box-shadow: var(--shadow-card);
    transition:
        transform 150ms ease,
        box-shadow 150ms ease,
        border-color 150ms ease;
}

.kpi-card::before {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 3px;
    content: "";
    background: linear-gradient(90deg, var(--kpi-accent), transparent 82%);
}

.kpi-card::after {
    position: absolute;
    top: -28px;
    right: -24px;
    width: 84px;
    height: 84px;
    border-radius: 50%;
    content: "";
    background: color-mix(in srgb, var(--kpi-accent) 10%, transparent);
    pointer-events: none;
}

.kpi-card:nth-child(2),
.kpi-card:nth-child(6) {
    --kpi-accent: #4f7fdb;
}

.kpi-card:nth-child(3),
.kpi-card:nth-child(7) {
    --kpi-accent: #0f9d77;
}

.kpi-card:nth-child(4) {
    --kpi-accent: #d97706;
}

.kpi-card:nth-child(5),
.kpi-card:nth-child(8) {
    --kpi-accent: #0b7b94;
}

.kpi-card:hover {
    z-index: 1;
    border-color: #b8d3ec;
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-2px);
}

.kpi-label {
    position: relative;
    z-index: 1;
    max-width: 90%;
    color: var(--ui-muted);
    font-size: 10px;
    letter-spacing: 0.055em;
}

.kpi-value {
    position: relative;
    z-index: 1;
    margin-top: 6px;
    color: var(--brand-950);
    font-size: clamp(20px, 1.7vw, 25px);
    font-weight: 860;
    letter-spacing: -0.035em;
}

.kpi-note {
    position: relative;
    z-index: 1;
    margin-top: 6px;
    color: #718096;
    font-size: 10px;
    line-height: 1.35;
}

/* Tabs tipo producto SaaS. */

.tabs {
    gap: 3px;
    padding: 4px;
    border-color: var(--ui-border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: var(--shadow-card);
    backdrop-filter: blur(8px);
}

.tab {
    position: relative;
    min-height: 36px;
    padding: 8px 14px;
    color: #607087;
    border-radius: 10px;
    font-size: 12px;
    transition:
        color 140ms ease,
        background-color 140ms ease,
        box-shadow 140ms ease;
}

.tab:hover {
    color: var(--brand-800);
    background: var(--brand-50);
}

.tab.is-active {
    color: var(--brand-800);
    background: var(--white);
    box-shadow:
        0 1px 2px rgba(15, 35, 60, 0.05),
        0 5px 13px rgba(20, 61, 107, 0.09);
}

.tab.is-active::after {
    position: absolute;
    right: 18px;
    bottom: 3px;
    left: 18px;
    height: 2px;
    border-radius: 2px;
    content: "";
    background: var(--brand-600);
}

/* Cards, paneles y encabezados. */

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

.panel,
.department-card,
.outsource-card {
    overflow: hidden;
    border-color: var(--ui-border);
    border-radius: var(--radius-panel);
    background: rgba(255, 255, 255, 0.97);
    box-shadow: var(--shadow-card);
}

.panel:hover,
.department-card:hover,
.outsource-card:hover {
    border-color: #cfdeed;
}

.panel-header,
.department-header,
.outsource-header {
    padding: 14px 17px;
    border-bottom-color: var(--ui-border);
    background:
        linear-gradient(90deg, #fbfdff, #f4f9ff 70%, #fbfdff);
}

.panel-header h2,
.department-header h2,
.outsource-header h2 {
    color: var(--brand-950);
    font-size: 16px;
    letter-spacing: -0.015em;
}

.panel-header p,
.department-header p,
.outsource-header p {
    margin-top: 3px;
    color: var(--ui-muted);
    line-height: 1.4;
}

.panel-body {
    padding: 14px;
}

.stack {
    gap: 13px;
}

.subsection {
    padding: 0 14px 14px;
}

.subsection-title {
    margin: 14px 0 8px;
}

.subsection-title h3 {
    color: #30445e;
    font-size: 13px;
}

.badges {
    gap: 6px;
}

.badge {
    min-height: 25px;
    padding: 4px 9px;
    border: 1px solid transparent;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.badge-blue {
    color: var(--brand-700);
    border-color: #c8e1f8;
    background: #edf7ff;
}

.badge-green {
    color: var(--success-700);
    border-color: #bce9d5;
    background: var(--success-100);
}

.badge-amber {
    color: var(--warning-700);
    border-color: #f5d9a4;
    background: var(--warning-100);
}

.badge-money {
    color: #07687d;
    border-color: #b9e2e9;
    background: #e8f8fa;
}

.cost-note,
.order-legend,
.tracking-help {
    padding: 10px 12px;
    border-color: #c6ddf3;
    border-left-width: 3px;
    border-radius: 10px;
    background:
        linear-gradient(90deg, #eef7ff, #f8fbff);
    box-shadow: none;
}

.order-chip {
    background: linear-gradient(135deg, var(--brand-600), var(--brand-800));
}

.department-sequence {
    color: var(--brand-600);
}

/* Tablas: mejor lectura, menor apariencia de hoja de cálculo antigua. */

.table-shell {
    border-color: var(--ui-border);
    border-radius: 13px;
    background: var(--white);
    box-shadow:
        0 1px 2px rgba(15, 35, 60, 0.025),
        0 0 0 1px rgba(255, 255, 255, 0.6) inset;
    scrollbar-width: thin;
    scrollbar-color: #b7c8dc transparent;
}

.table-shell::-webkit-scrollbar {
    width: 9px;
    height: 9px;
}

.table-shell::-webkit-scrollbar-track {
    background: #f4f7fb;
}

.table-shell::-webkit-scrollbar-thumb {
    border: 2px solid #f4f7fb;
    border-radius: 999px;
    background: #afc2d7;
}

.table-shell::-webkit-scrollbar-thumb:hover {
    background: #8fa9c5;
}

.report-table th,
.report-table td {
    padding: 8px 9px;
    border-right-color: #e7edf4;
    border-bottom-color: #e7edf4;
}

.report-table thead th {
    color: #234464;
    background:
        linear-gradient(180deg, #edf6ff, #e5f0fb);
    font-size: 10px;
    letter-spacing: 0.035em;
    box-shadow: 0 1px 0 #ccdeef;
}

.report-table th.is-sortable:hover {
    color: var(--brand-800);
    background: #dcecff;
}

.report-table tbody tr:nth-child(even):not(.style-row):not(.client-group-row) td {
    background: #fbfcfe;
}

.report-table tbody tr:hover td {
    background: #f1f7fd !important;
}

.report-table .style-row td {
    color: #173f67;
    background:
        linear-gradient(90deg, #edf6ff, #f7fbff);
}

.report-table .order-row td {
    color: #465a72;
}

.report-table .total-row td {
    color: var(--brand-950);
    border-top-color: #aac9e7;
    background:
        linear-gradient(180deg, #e7f2fc, #dcecf9);
}

.client-group-row td {
    color: #193d60;
    background:
        linear-gradient(90deg, #eaf4fd, #f5faff);
}

.pivot-main-label,
.order-code {
    color: #153f6a;
}

.pivot-description {
    color: #344b66;
}

.sequence-cell,
.sort-indicator,
.tree-marker {
    color: var(--brand-600);
}

.money {
    font-weight: 680;
}

.location-cell {
    color: #52667f;
}

.table-toolbar {
    margin-bottom: 9px;
}

.table-toolbar-info,
.pagination {
    color: var(--ui-muted);
}

.pagination {
    gap: 6px;
}

.pagination button,
.pagination select {
    min-height: 33px;
    padding: 6px 9px;
    border-color: var(--ui-border-strong);
    border-radius: 9px;
    transition:
        border-color 120ms ease,
        background-color 120ms ease,
        color 120ms ease;
}

.pagination button:hover:not(:disabled),
.pagination select:hover {
    color: var(--brand-800);
    border-color: var(--brand-200);
    background: var(--brand-50);
}

/* Mensajes y estados. */

.empty-state {
    min-height: 210px;
    border-color: #b9cce1;
    border-radius: var(--radius-panel);
    background:
        radial-gradient(circle at 50% 0, rgba(47, 143, 230, 0.10), transparent 55%),
        rgba(255, 255, 255, 0.82);
}

.toast {
    right: 18px;
    bottom: 18px;
    padding: 11px 15px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 12px;
    background:
        linear-gradient(135deg, var(--brand-950), var(--brand-700));
    box-shadow: var(--shadow-float);
}

.fatal-error {
    background: rgba(9, 31, 58, 0.68);
    backdrop-filter: blur(8px);
}

.fatal-error-card {
    border: 1px solid rgba(220, 228, 239, 0.9);
    border-radius: 22px;
    box-shadow: var(--shadow-float);
}

/* Responsive */

@media (max-width: 1280px) {
    .kpi-grid {
        grid-template-columns: repeat(4, minmax(150px, 1fr));
    }
}

@media (max-width: 1120px) {
    .kpi-grid {
        grid-template-columns: repeat(3, minmax(155px, 1fr));
    }
}

@media (max-width: 850px) {
    .app-header {
        position: relative;
    }

    .filter-panel {
        grid-template-columns: 1fr 1fr;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, minmax(150px, 1fr));
    }
}

@media (max-width: 620px) {
    body {
        font-size: 12px;
    }

    .app-main {
        width: calc(100% - 16px);
    }

    .filter-panel,
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .kpi-card {
        min-height: 86px;
    }

    .tabs {
        border-radius: 12px;
    }
}

@media print {
    .app-header {
        position: static;
        min-height: 0;
        border-bottom: 2px solid var(--brand-700);
        background: var(--white);
    }

    .app-header::after,
    .kpi-card::before,
    .kpi-card::after,
    .tab.is-active::after {
        display: none;
    }

    .panel,
    .department-card,
    .outsource-card,
    .kpi-card {
        border-radius: 6px;
        background: var(--white);
    }

    .report-table thead th {
        color: var(--brand-950);
        background: #e6f1fb;
    }
}

/* ========================================================================== */
/* ITALIA ERP · UI PRO 2.1                                                    */
/* KPI con iconografía de fondo y matriz global de maquilas.                   */
/* ========================================================================== */

.kpi-card {
    isolation: isolate;
}

.kpi-card::after {
    top: -30px;
    right: -22px;
    width: 96px;
    height: 96px;
    opacity: 0.86;
}

.kpi-icon {
    position: absolute;
    right: 4px;
    bottom: -9px;
    z-index: 0;
    display: grid;
    width: 68px;
    height: 68px;
    place-items: center;
    color: var(--kpi-icon-color, #63e6ff);
    opacity: 0.34;
    filter:
        drop-shadow(0 0 5px color-mix(in srgb, var(--kpi-icon-color) 62%, transparent))
        drop-shadow(0 4px 8px rgba(15, 35, 60, 0.10));
    pointer-events: none;
    transform: rotate(-7deg);
}

.kpi-icon svg {
    width: 100%;
    height: 100%;
    stroke-width: 1.55;
}

.kpi-label,
.kpi-value,
.kpi-note {
    position: relative;
    z-index: 2;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.92);
}

/* No cambia el ancho del KPI: el ícono vive en posición absoluta. */

.period-alias {
    display: block;
    margin-top: 3px;
    color: #228be6;
    font-size: 8px;
    font-weight: 900;
    letter-spacing: 0.035em;
    line-height: 1.1;
    text-transform: uppercase;
    white-space: nowrap;
}

.period-detail {
    margin-top: 2px;
}

/* La primera columna queda útil pero ya no domina toda la tabla. */

.cost-pivot-table .pivot-label-column,
.cost-pivot-table .pivot-label-cell,
.cost-pivot-table th:first-child,
.cost-pivot-table td:first-child {
    width: 270px;
    min-width: 235px;
    max-width: 300px;
    white-space: normal;
}

.cost-pivot-table .pivot-main-label,
.cost-pivot-table .pivot-description,
.cost-pivot-table .order-code,
.cost-pivot-table .order-date,
.cost-pivot-table .pivot-meta {
    overflow-wrap: anywhere;
}

.cost-pivot-table .period-heading {
    min-width: 118px;
}

/* KPIs horizontales de maquilas. */

.provider-kpi-section {
    margin: 0 0 13px;
    padding: 13px;
    border: 1px solid var(--ui-border);
    border-radius: var(--radius-card);
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(242, 248, 255, 0.96));
    box-shadow: var(--shadow-card);
}

.provider-kpi-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 10px;
}

.provider-kpi-heading h2 {
    margin: 0;
    color: var(--brand-950);
    font-size: 15px;
}

.provider-kpi-heading p {
    margin: 3px 0 0;
    color: var(--ui-muted);
    font-size: 10px;
}

.provider-kpi-scroll {
    display: flex;
    gap: 9px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 2px 9px;
    scroll-behavior: smooth;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
    scrollbar-color: #9fb7cf transparent;
}

.provider-kpi-scroll::-webkit-scrollbar {
    height: 8px;
}

.provider-kpi-scroll::-webkit-scrollbar-track {
    border-radius: 999px;
    background: #eaf0f7;
}

.provider-kpi-scroll::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: linear-gradient(90deg, var(--brand-500), #4fd1c5);
}

.provider-kpi-card {
    position: relative;
    flex: 0 0 188px;
    min-height: 123px;
    padding: 11px 12px;
    overflow: hidden;
    border: 1px solid #d5e2ef;
    border-radius: 14px;
    background:
        radial-gradient(circle at 100% 0, rgba(99, 230, 255, 0.20), transparent 42%),
        var(--white);
    box-shadow: 0 6px 16px rgba(20, 61, 107, 0.07);
    scroll-snap-align: start;
}

.provider-kpi-card::after {
    position: absolute;
    right: -22px;
    bottom: -26px;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    content: "";
    background: rgba(47, 143, 230, 0.08);
}

.provider-kpi-name {
    position: relative;
    z-index: 1;
    overflow: hidden;
    color: #5f6f85;
    font-size: 9px;
    font-weight: 900;
    letter-spacing: 0.055em;
    line-height: 1.25;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}

.provider-kpi-pairs {
    position: relative;
    z-index: 1;
    margin-top: 7px;
    color: var(--brand-950);
    font-size: 23px;
    font-weight: 880;
    letter-spacing: -0.035em;
    line-height: 1;
}

.provider-kpi-pairs small {
    color: var(--ui-muted);
    font-size: 9px;
    font-weight: 750;
    letter-spacing: 0;
}

.provider-kpi-share {
    position: relative;
    z-index: 1;
    margin-top: 6px;
    color: var(--brand-600);
    font-size: 10px;
    font-weight: 850;
}

.provider-kpi-progress {
    position: relative;
    z-index: 1;
    height: 4px;
    margin-top: 5px;
    overflow: hidden;
    border-radius: 999px;
    background: #e4edf6;
}

.provider-kpi-progress span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #228be6, #2dd4bf);
}

.provider-kpi-meta,
.provider-kpi-value {
    position: relative;
    z-index: 1;
}

.provider-kpi-meta {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 7px;
    color: #708096;
    font-size: 9px;
}

.provider-kpi-value {
    margin-top: 4px;
    color: #07687d;
    font-size: 10px;
    font-weight: 800;
}

/* Matriz global: todas las maquilas comparten exactamente las mismas O.P. */

.outsource-global-table {
    min-width: 1120px;
}

.outsource-provider-row td {
    color: #123d68;
    border-top: 2px solid #a9cbea;
    background:
        linear-gradient(90deg, #dfefff, #eff7ff 72%, #f8fbff) !important;
    font-weight: 800;
}

.outsource-provider-row:first-child td {
    border-top-width: 0;
}

.provider-row-name {
    color: var(--brand-900);
    font-size: 12px;
    font-weight: 900;
}

.provider-row-meta {
    margin-top: 3px;
    color: #61758e;
    font-size: 9px;
    font-weight: 650;
    line-height: 1.35;
}

.provider-style-row td {
    background: #f8fbff;
}

.provider-style-row td:first-child {
    padding-left: 20px;
}

.provider-order-row td:first-child {
    padding-left: 34px;
}

.provider-order-row td {
    color: #52667f;
}

@media (max-width: 850px) {
    .provider-kpi-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .provider-kpi-card {
        flex-basis: 176px;
    }

    .cost-pivot-table .pivot-label-column,
    .cost-pivot-table .pivot-label-cell,
    .cost-pivot-table th:first-child,
    .cost-pivot-table td:first-child {
        width: 230px;
        min-width: 210px;
        max-width: 250px;
    }
}

@media print {
    .kpi-icon {
        opacity: 0.12;
        filter: none;
    }

    .provider-kpi-scroll {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        overflow: visible;
    }

    .provider-kpi-card {
        min-height: 0;
        break-inside: avoid;
    }
}



/* ========================================================================== */
/* ITALIA ERP · UI PRO 2.2                                                    */
/* FechaProgramacion para órdenes libres y orden alfabético de maquilas.       */
/* ========================================================================== */

.order-legend-secondary {
    margin-top: 7px;
    padding-top: 7px;
    border-top: 1px dashed #bdd4e9;
}

.period-heading .period-code {
    overflow: hidden;
    max-width: 132px;
    text-overflow: ellipsis;
}

/* ITALIA ERP · Centro de Producción 1.8 · Seguimiento integral */
.pedido-flow-summary{margin:13px 0}.pedido-flow-summary:empty{display:none}
.pedido-flow-shell{overflow:hidden;border:1px solid var(--ui-border,#dce4ef);border-radius:var(--radius-card,16px);background:#fff;box-shadow:var(--shadow-card,0 8px 24px rgba(20,61,107,.07))}
.pedido-flow-head{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:12px 15px;border-bottom:1px solid var(--ui-border,#dce4ef);background:linear-gradient(90deg,#fbfdff,#f2f8ff 72%,#fbfdff)}
.pedido-flow-head h2{margin:0;color:var(--brand-950,#0b1f3a);font-size:15px}.pedido-flow-head p{margin:3px 0 0;color:#66758a;font-size:10px}
.pedido-flow-total{padding:5px 10px;border:1px solid #c8e1f8;border-radius:999px;color:#175da8;background:#edf7ff;font-size:11px;font-weight:850;white-space:nowrap}
.pedido-flow-stages{display:grid;grid-template-columns:repeat(4,minmax(145px,1fr))}.pedido-flow-stages.has-cancelled{grid-template-columns:repeat(5,minmax(125px,1fr))}
.pedido-flow-stage{padding:11px 13px 10px;border-right:1px solid #e4ebf3}.pedido-flow-stage:last-child{border-right:0}
.pedido-flow-label{display:flex;align-items:center;gap:7px;color:#65748a;font-size:9px;font-weight:900;text-transform:uppercase}
.pedido-flow-dot{width:9px;height:9px;border-radius:50%;box-shadow:0 0 0 4px rgba(47,143,230,.08)}
.stage-programacion .pedido-flow-dot{background:#6c7ae0}.stage-produccion .pedido-flow-dot{background:#2f8fe6}.stage-pt .pedido-flow-dot{background:#0f9d77}.stage-facturado .pedido-flow-dot{background:#0b7b94}.stage-cancelado .pedido-flow-dot{background:#c4322b}
.pedido-flow-value{margin-top:5px;color:#0b1f3a;font-size:24px;font-weight:880;line-height:1}.pedido-flow-note{margin-top:5px;color:#66758a;font-size:9px}
.integral-pedido-table{min-width:1180px}.integral-pedido-table .pedido-master-row td{color:#173f67;background:linear-gradient(90deg,#edf6ff,#f7fbff);font-weight:800}
.integral-pedido-table .pedido-partida-row td:nth-child(2){padding-left:22px}
.integral-pedido-help{margin-bottom:12px;padding:10px 12px;border:1px solid #c6ddf3;border-left:3px solid #1f78d1;border-radius:10px;color:#52667f;background:linear-gradient(90deg,#eef7ff,#f8fbff);font-size:11px}
.location-cell{min-width:220px;font-size:10px;line-height:1.45}.document-cell{min-width:180px;font-size:10px;line-height:1.45}.seguimiento-empty{padding:12px 15px;color:#66758a;font-size:11px}
@media(max-width:900px){.pedido-flow-stages,.pedido-flow-stages.has-cancelled{grid-template-columns:repeat(2,minmax(150px,1fr))}}
@media(max-width:620px){.pedido-flow-head{align-items:flex-start;flex-direction:column}.pedido-flow-stages,.pedido-flow-stages.has-cancelled{grid-template-columns:1fr}}

/* ==========================================================================
   ITALIA ERP · Centro de Producción 1.9
   Filtros completos + KPI reactivos
   ========================================================================== */

.filter-panel {
    grid-template-columns: repeat(7, minmax(118px, 1fr)) auto;
    align-items: end;
}

.filter-field-search {
    grid-column: 1 / -1;
}

.filter-actions .btn {
    height: 38px;
    white-space: nowrap;
}

.kpi-grid {
    grid-template-columns: repeat(7, minmax(132px, 1fr));
    justify-content: stretch;
}

@media (max-width: 1450px) {
    .filter-panel {
        grid-template-columns: repeat(4, minmax(150px, 1fr));
    }

    .filter-field-search {
        grid-column: 1 / -1;
    }

    .kpi-grid {
        grid-template-columns: repeat(4, minmax(145px, 1fr));
    }
}

@media (max-width: 1000px) {
    .filter-panel {
        grid-template-columns: repeat(2, minmax(150px, 1fr));
    }

    .filter-field-search {
        grid-column: 1 / -1;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, minmax(150px, 1fr));
    }
}

@media (max-width: 620px) {
    .filter-panel,
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .filter-field-search {
        grid-column: auto;
    }
}


/* ==========================================================================
   ITALIA ERP · Centro de Producción 2.0
   Programación separada de Producción WIP
   ========================================================================== */

.kpi-card .kpi-note {
    min-height: 13px;
}

.pedido-flow-stage.stage-programacion .pedido-flow-note,
.pedido-flow-stage.stage-produccion .pedido-flow-note {
    font-weight: 600;
}


/* ==========================================================================
   ITALIA ERP · Centro de Producción 2.1
   Exportaciones: Resumen + Vista actual + Detalle WIP
   ========================================================================== */


/* ==========================================================================
   ITALIA ERP · Centro de Producción 2.2 FINAL
   Exportación por pestaña activa + Business Blue
   ========================================================================== */


/* ==========================================================================
   ITALIA ERP · Centro de Producción 2.3 FINAL FINAL
   XLSX estilado offline, sin dependencia de xlsx-js-style.
   ========================================================================== */
