/* Optimizador de corte Muriel. Todo bajo .mco para no chocar con el tema. */

.mco {
    --mco-primary: #002659;
    --mco-primary-light: #003d8f;
    --mco-accent: #ffa300;
    --mco-text: #1a1a1a;
    --mco-muted: #5f6b7a;
    --mco-border: #dde2e8;
    --mco-bg: #f5f7fa;
    --mco-radius: 12px;
    max-width: 1100px;
    margin: 0 auto;
    color: var(--mco-text);
    font-size: 15px;
    line-height: 1.5;
    text-align: left;
}

.mco *,
.mco *::before,
.mco *::after {
    box-sizing: border-box;
}

.mco-intro {
    margin: 0 0 1.5rem;
    text-align: center;
}

.mco-intro h2 {
    margin: 0 0 .4rem;
    color: var(--mco-primary);
}

.mco-intro p {
    margin: 0 auto;
    max-width: 640px;
    color: var(--mco-muted);
}

.mco-card {
    margin-bottom: 1rem;
    padding: 1.25rem 1.5rem;
    background: #fff;
    border: 1px solid var(--mco-border);
    border-radius: var(--mco-radius);
    box-shadow: 0 2px 8px rgba(0, 0, 0, .04);
}

.mco h3,
.mco h4 {
    margin: 0 0 .75rem;
    font-size: 1.1rem;
    line-height: 1.3;
    color: var(--mco-primary);
}

.mco h4 {
    font-size: 1rem;
}

.mco-step {
    display: flex;
    align-items: center;
    gap: .6rem;
}

.mco-step span {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    font-size: .9rem;
    color: #fff;
    background: var(--mco-accent);
    border-radius: 50%;
}

.mco-hint {
    margin: .5rem 0 .75rem;
    font-size: .85rem;
    color: var(--mco-muted);
}

.mco-row {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem 1rem;
}

/* --- Campos --- */
.mco .mco-field {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    margin: 0;
    min-width: 0;
}

.mco .mco-field > span {
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .2px;
    color: var(--mco-muted);
}

.mco-grow {
    flex: 1 1 260px;
}

.mco .mco-field input,
.mco .mco-field select {
    width: 100%;
    height: 42px;
    margin: 0;
    padding: 0 .7rem;
    font: inherit;
    font-size: 15px;
    color: var(--mco-text);
    background: #fff;
    border: 1.5px solid var(--mco-border);
    border-radius: 8px;
    box-shadow: none;
}

.mco .mco-field select {
    -webkit-appearance: none;
    appearance: none;
    padding-right: 2rem;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23002659' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right .7rem center;
}

.mco .mco-field input:focus,
.mco .mco-field select:focus {
    outline: none;
    border-color: var(--mco-primary);
    box-shadow: 0 0 0 3px rgba(0, 38, 89, .12);
}

.mco .mco-field input.mco-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.mco-custom {
    margin-top: .75rem;
}

.mco-custom .mco-field {
    flex: 1 1 180px;
}

/* --- Piezas --- */
.mco-piezas {
    display: flex;
    flex-direction: column;
    gap: .6rem;
}

.mco-pieza {
    display: grid;
    grid-template-columns: 32px 1fr auto;
    gap: .75rem;
    align-items: center;
    padding: .7rem .75rem;
    background: var(--mco-bg);
    border: 1px solid var(--mco-border);
    border-radius: 10px;
}

.mco-pieza__num {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    font-weight: 700;
    font-size: .9rem;
    color: var(--mco-primary);
    border-radius: 8px;
}

.mco-pieza__fields {
    display: grid;
    grid-template-columns: minmax(120px, 1.4fr) repeat(3, minmax(70px, .8fr)) repeat(2, 64px) auto auto;
    gap: .6rem;
    align-items: end;
}

.mco-pieza__fields .mco-field--sm {
    min-width: 110px;
}

.mco .mco-check {
    display: flex;
    align-items: center;
    gap: .4rem;
    height: 42px;
    margin: 0;
    font-size: .85rem;
    white-space: nowrap;
    cursor: pointer;
}

.mco .mco-check input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--mco-primary);
}

.mco-pieza__tools {
    display: flex;
    gap: .25rem;
}

.mco .mco-icon {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    margin: 0;
    padding: 0;
    font-size: 18px;
    line-height: 1;
    color: var(--mco-muted);
    background: #fff;
    border: 1px solid var(--mco-border);
    border-radius: 8px;
    box-shadow: none;
    transform: none;
    cursor: pointer;
}

.mco .mco-icon:hover {
    color: var(--mco-primary);
    background: #fff;
    border-color: var(--mco-primary);
    box-shadow: none;
    transform: none;
}

.mco .mco-icon--del:hover {
    color: #c0392b;
    border-color: #c0392b;
}

/* --- Botones --- */
.mco .mco-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    width: auto;
    min-height: 42px;
    margin: 0;
    padding: .6rem 1.1rem;
    font: inherit;
    font-weight: 600;
    font-size: .95rem;
    line-height: 1.2;
    text-decoration: none;
    text-transform: none;
    letter-spacing: 0;
    border: 1.5px solid transparent;
    border-radius: 8px;
    box-shadow: none;
    transform: none;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}

.mco .mco-btn:hover {
    transform: none;
    box-shadow: none;
}

.mco .mco-btn--primary {
    color: #fff;
    background: var(--mco-primary);
}

.mco .mco-btn--primary:hover {
    color: #fff;
    background: var(--mco-primary-light);
}

.mco .mco-btn--lg {
    min-height: 52px;
    padding: .8rem 2rem;
    font-size: 1.05rem;
}

.mco .mco-btn--ghost {
    color: var(--mco-primary);
    background: #fff;
    border-color: var(--mco-primary);
}

.mco .mco-btn--ghost:hover {
    color: #fff;
    background: var(--mco-primary);
}

.mco .mco-btn--link {
    color: var(--mco-muted);
    background: transparent;
    text-decoration: underline;
}

.mco .mco-btn--link:hover {
    color: #c0392b;
    background: transparent;
}

.mco .mco-btn--wa,
.mco .mco-btn--wa:visited {
    color: #fff;
    background: #25d366;
}

.mco .mco-btn--wa:hover {
    color: #fff;
    background: #1da851;
}

.mco-actions-inline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .75rem;
    margin-top: .9rem;
}

.mco-calc {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .75rem;
    margin: 1.25rem 0 2rem;
}

.mco-msg {
    width: 100%;
    padding: .8rem 1rem;
    font-size: .9rem;
    color: #721c24;
    background: #fbe9eb;
    border-left: 4px solid #dc3545;
    border-radius: 8px;
}

.mco-msg[hidden] {
    display: none;
}

/* --- Resultado --- */
.mco-result:empty {
    display: none;
}

.mco-card--result {
    border-top: 4px solid var(--mco-accent);
}

.mco-result__head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.mco-result__head .mco-hint {
    margin: 0;
}

.mco-result__actions {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
}

.mco-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: .75rem;
    margin-top: 1rem;
}

.mco-kpi {
    padding: .8rem 1rem;
    background: var(--mco-bg);
    border-radius: 10px;
}

.mco-kpi strong {
    display: block;
    font-size: 1.5rem;
    line-height: 1.2;
    color: var(--mco-primary);
    font-variant-numeric: tabular-nums;
}

.mco-kpi span {
    font-size: .8rem;
    color: var(--mco-muted);
}

.mco-sheet__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .5rem;
}

.mco-sheet__head h4 {
    margin: 0;
}

.mco-badge {
    padding: .2rem .65rem;
    font-size: .8rem;
    font-weight: 600;
    color: var(--mco-primary);
    background: #e8eef7;
    border-radius: 999px;
}

.mco-svg-wrap {
    width: 100%;
    overflow: hidden;
}

.mco-svg {
    display: block;
    width: 100%;
    max-width: 960px;
    height: auto;
    margin: 0 auto;
}

.mco-svg .mco-cota {
    fill: var(--mco-muted);
    font-family: inherit;
    font-weight: 600;
}

.mco-svg .mco-label {
    fill: #1b2638;
    font-family: inherit;
    font-weight: 700;
}

.mco-svg .mco-label--num {
    fill: #44516a;
    font-weight: 600;
}

.mco-table-wrap {
    overflow-x: auto;
}

.mco-table {
    width: 100%;
    margin: 0;
    border-collapse: collapse;
    font-size: .9rem;
}

.mco-table th,
.mco-table td {
    padding: .55rem .6rem;
    text-align: left;
    border: 0;
    border-bottom: 1px solid var(--mco-border);
}

.mco-table th {
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .3px;
    text-transform: uppercase;
    color: var(--mco-muted);
    background: var(--mco-bg);
}

.mco-table .mco-r {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.mco-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: .4rem;
    border: 1px solid rgba(0, 0, 0, .15);
    border-radius: 3px;
}

.mco-legend__canto,
.mco-legend__waste {
    display: inline-block;
    width: 18px;
    height: 10px;
    vertical-align: middle;
    border-radius: 2px;
}

.mco-legend__canto {
    height: 4px;
    background: #e4572e;
}

.mco-legend__waste {
    background: repeating-linear-gradient(45deg, #c9ced6 0 3px, #fff 3px 6px);
    border: 1px solid #c9ced6;
}

/* --- Responsive --- */
@media (max-width: 900px) {
    .mco-pieza__fields {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .mco-pieza__fields .mco-field--name {
        grid-column: 1 / -1;
    }

    .mco-pieza__fields .mco-field--sm {
        grid-column: span 2;
        min-width: 0;
    }
}

@media (max-width: 600px) {
    .mco-card {
        padding: 1rem;
    }

    .mco-pieza {
        grid-template-columns: 1fr auto;
        grid-template-areas: "num tools" "fields fields";
        gap: .5rem;
    }

    .mco-pieza__num { grid-area: num; }
    .mco-pieza__tools { grid-area: tools; }
    .mco-pieza__fields { grid-area: fields; }

    .mco-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .mco .mco-btn--lg,
    .mco-result__actions,
    .mco-result__actions .mco-btn {
        width: 100%;
    }
}

/* --- Impresión: solo el resultado --- */
@media print {
    body * {
        visibility: hidden;
    }

    .mco-result,
    .mco-result * {
        visibility: visible;
    }

    .mco-result {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
    }

    .mco-result__actions {
        display: none !important;
    }

    .mco-card {
        break-inside: avoid;
        box-shadow: none;
    }
}
