/* ===========================================================
   SAMEK · Sistema de Gestión para la Producción
   Hoja de estilos corporativa
   Desarrollado por Redline Asesores Tecnológicos
   =========================================================== */

:root {
    --samek-navy:        #0d2138;   /* azul marino corporativo (fondos oscuros) */
    --samek-navy-2:      #102a47;
    --samek-blue:        #1877c9;   /* azul principal (acentos / botones) */
    --samek-blue-dark:   #135ea0;
    --samek-blue-light:  #4aa3e0;
    --samek-gray:        #f4f6f9;   /* fondo claro general */
    --samek-gray-2:      #e6eaf0;
    --samek-text:        #243240;
    --samek-muted:       #6b7a8c;
    --samek-border:      #dfe5ec;
    --samek-white:       #ffffff;
    --radius:            12px;
    --shadow:            0 8px 24px rgba(13, 33, 56, 0.08);
    --shadow-hover:      0 14px 36px rgba(13, 33, 56, 0.16);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--samek-text);
    background: var(--samek-gray);
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }

/* ===================== LOGIN ===================== */

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(1200px 600px at 80% -10%, rgba(24,119,201,0.35), transparent 60%),
        linear-gradient(160deg, var(--samek-navy) 0%, var(--samek-navy-2) 60%, #08182a 100%);
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 410px;
    background: var(--samek-white);
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
    overflow: hidden;
}

.login-head {
    background: linear-gradient(160deg, var(--samek-navy) 0%, var(--samek-navy-2) 100%);
    padding: 34px 32px 28px;
    text-align: center;
}

.login-head img { height: 52px; width: auto; }

.login-head .subtitle {
    color: #b9c6d6;
    font-size: 13px;
    letter-spacing: .5px;
    margin-top: 14px;
    text-transform: uppercase;
}

.login-body { padding: 30px 32px 34px; }

.login-body h1 {
    font-size: 20px;
    margin: 0 0 4px;
    color: var(--samek-navy);
}

.login-body p.lead {
    margin: 0 0 22px;
    color: var(--samek-muted);
    font-size: 14px;
}

.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--samek-text);
}

.form-group input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--samek-border);
    border-radius: 10px;
    font-size: 15px;
    transition: border-color .15s, box-shadow .15s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--samek-blue);
    box-shadow: 0 0 0 3px rgba(24,119,201,0.15);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    padding: 12px 18px;
    border-radius: 10px;
    transition: background .15s, transform .05s, box-shadow .15s;
}

.btn-primary {
    background: var(--samek-blue);
    color: #fff;
    width: 100%;
}
.btn-primary:hover { background: var(--samek-blue-dark); }
.btn-primary:active { transform: translateY(1px); }

.alert {
    background: #fdecea;
    border: 1px solid #f5c6cb;
    color: #842029;
    padding: 11px 14px;
    border-radius: 10px;
    font-size: 13.5px;
    margin-bottom: 18px;
}

.login-foot {
    text-align: center;
    font-size: 12px;
    color: var(--samek-muted);
    padding: 0 32px 26px;
}

/* ===================== APP SHELL ===================== */

.topbar {
    background: linear-gradient(120deg, var(--samek-navy) 0%, var(--samek-navy-2) 100%);
    color: #fff;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.12);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar .brand { display: flex; align-items: center; gap: 14px; }
.topbar .brand img { height: 34px; }
.topbar .brand .app-name {
    font-size: 14px;
    color: #c7d3e0;
    border-left: 1px solid rgba(255,255,255,0.2);
    padding-left: 14px;
    letter-spacing: .3px;
}

.topbar .user-area { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.topbar .user-area .saludo { color: #c7d3e0; }

/* Menú desplegable del usuario */
.user-menu { position: relative; }
.user-trigger {
    display: inline-flex; align-items: center; gap: 8px;
    background: rgba(255,255,255,0.10);
    border: none; color: #fff; cursor: pointer;
    padding: 8px 14px; border-radius: 8px;
    font-size: 14px; font-weight: 600; font-family: inherit;
    transition: background .15s;
}
.user-trigger:hover { background: rgba(255,255,255,0.20); }
.user-trigger .who { color: #fff; }
.user-trigger .caret { font-size: 11px; color: #c7d3e0; }

.user-dropdown {
    position: absolute; right: 0; top: calc(100% + 8px);
    min-width: 190px;
    background: #fff;
    border: 1px solid var(--samek-border);
    border-radius: 10px;
    box-shadow: 0 14px 34px rgba(13,33,56,0.20);
    overflow: hidden;
    z-index: 60;
    padding: 6px;
}
.user-dropdown[hidden] { display: none; }
.user-dropdown form { margin: 0; }
.user-dropdown-item {
    display: flex; align-items: center; gap: 10px;
    width: 100%; text-align: left;
    background: none; border: none; cursor: pointer;
    padding: 10px 12px; border-radius: 8px;
    font-size: 14px; font-weight: 600; color: var(--samek-text);
    font-family: inherit;
}
.user-dropdown-item:hover { background: var(--samek-gray); }
.user-dropdown-item .udi-icon { font-size: 15px; }
.user-dropdown-item.item-danger { color: #c0392b; }
.user-dropdown-item.item-danger:hover { background: #fdecea; }

.perfil-sub {
    font-size: 13px; text-transform: uppercase; letter-spacing: .4px;
    color: var(--samek-blue-dark);
    border-bottom: 1px solid var(--samek-border);
    padding-bottom: 8px; margin: 22px 0 14px;
}
.perfil-sub span { text-transform: none; letter-spacing: 0; color: var(--samek-muted); font-weight: 400; }

/* ===================== DASHBOARD ===================== */

.page { max-width: 1180px; margin: 0 auto; padding: 36px 28px 60px; }

.page-head { margin-bottom: 26px; }
.page-head h1 {
    margin: 0 0 6px;
    font-size: 24px;
    color: var(--samek-navy);
}
.page-head p { margin: 0; color: var(--samek-muted); font-size: 14.5px; }

.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 20px;
}

.block-title {
    font-size: 15px;
    color: var(--samek-navy);
    margin: 30px 0 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--samek-border);
    text-transform: uppercase;
    letter-spacing: .4px;
}
.block-title:first-of-type { margin-top: 8px; }

.btn-mini {
    display: inline-block;
    padding: 5px 11px;
    border-radius: 7px;
    border: 1px solid var(--samek-border);
    background: #fff;
    color: var(--samek-navy);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    margin-left: 4px;
}
.btn-mini:hover { border-color: var(--samek-blue); color: var(--samek-blue); }
.btn-mini-danger { color: #c0392b; }
.btn-mini-danger:hover { border-color: #e23b3b; color: #c0392b; }

.module-card {
    background: var(--samek-white);
    border: 1px solid var(--samek-border);
    border-radius: var(--radius);
    padding: 24px 22px;
    box-shadow: var(--shadow);
    transition: transform .15s, box-shadow .15s, border-color .15s;
    display: flex;
    flex-direction: column;
    gap: 14px;
    position: relative;
    overflow: hidden;
}
.module-card::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--samek-blue);
    opacity: .85;
}
.module-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    border-color: var(--samek-blue-light);
}
.module-card.disabled { opacity: .62; }
.module-card.disabled:hover { transform: none; box-shadow: var(--shadow); border-color: var(--samek-border); }

.module-icon {
    width: 50px; height: 50px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(24,119,201,0.10);
    color: var(--samek-blue);
    font-size: 24px;
}
.module-icon svg { width: 26px; height: 26px; display: block; }

.module-card h3 { margin: 0; font-size: 17px; color: var(--samek-navy); }
.module-card p { margin: 0; font-size: 13.5px; color: var(--samek-muted); line-height: 1.5; }

.module-foot {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 8px;
}
.module-link { font-size: 13.5px; font-weight: 600; color: var(--samek-blue); }
.badge-soon {
    font-size: 11px;
    font-weight: 600;
    color: var(--samek-muted);
    background: var(--samek-gray-2);
    padding: 4px 9px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: .4px;
}

/* ===================== FOOTER ===================== */

.app-foot {
    text-align: center;
    font-size: 12.5px;
    color: var(--samek-muted);
    padding: 24px;
    border-top: 1px solid var(--samek-border);
}
.app-foot a { color: var(--samek-blue); font-weight: 600; }

/* ===================== LISTADO / TABLA ===================== */

.breadcrumb-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}
.breadcrumb { font-size: 13px; color: var(--samek-muted); margin-bottom: 14px; }
.breadcrumb-bar .breadcrumb { margin-bottom: 0; }
.breadcrumb a { color: var(--samek-blue); font-weight: 600; }
.breadcrumb span { margin: 0 6px; }

.list-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }

.btn-secondary {
    background: #fff;
    border: 1px solid var(--samek-border);
    color: var(--samek-navy);
    padding: 9px 16px;
    border-radius: 9px;
    font-size: 13.5px;
    font-weight: 600;
    transition: border-color .15s, color .15s;
    white-space: nowrap;
}
.btn-secondary:hover { border-color: var(--samek-blue); color: var(--samek-blue); }

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 22px 0 18px;
    background: #fff;
    border: 1px solid var(--samek-border);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
}
.filters input, .filters select {
    padding: 10px 12px;
    border: 1px solid var(--samek-border);
    border-radius: 9px;
    font-size: 14px;
}
.filters input:focus, .filters select:focus {
    outline: none;
    border-color: var(--samek-blue);
    box-shadow: 0 0 0 3px rgba(24,119,201,0.15);
}
.filter-search { flex: 1 1 320px; }
.filter-ubic { flex: 0 1 170px; }
.check-inline { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; color: var(--samek-text); padding: 0 6px; cursor: pointer; }
.check-inline input { width: 16px; height: 16px; accent-color: var(--samek-blue); cursor: pointer; }

/* ===================== MODAL ===================== */

.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(13, 33, 56, 0.55);
    display: flex; align-items: center; justify-content: center;
    padding: 20px; z-index: 200;
}
.modal-backdrop[hidden] { display: none; }
.modal {
    background: #fff;
    width: 100%; max-width: 560px;
    border-radius: 14px;
    box-shadow: 0 30px 70px rgba(0,0,0,0.35);
    overflow: hidden;
    max-height: 92vh; display: flex; flex-direction: column;
}
/* La cabecera y el subtítulo no se encogen; el formulario ocupa el resto */
.modal-head, .modal-sub { flex: 0 0 auto; }
.modal form { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 22px;
    background: linear-gradient(120deg, var(--samek-navy), var(--samek-navy-2));
    color: #fff;
}
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-close {
    background: none; border: none; color: #c7d3e0;
    font-size: 26px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.modal-close:hover { color: #fff; }
.modal-sub {
    padding: 14px 22px; border-bottom: 1px solid var(--samek-border);
    background: var(--samek-gray); font-size: 14px;
}
.modal-sub .mono { color: var(--samek-navy); font-weight: 600; }
.modal-stock { margin-top: 4px; color: var(--samek-muted); font-size: 13px; }
.modal-stock strong { color: var(--samek-navy); }
.modal-body { padding: 20px 22px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 4px; }
.modal-check { margin-top: 14px; }
.modal-note { margin: 14px 0 0; font-size: 12.5px; color: var(--samek-muted); font-style: italic; }
.modal-foot {
    flex: 0 0 auto;
    display: flex; gap: 12px; align-items: center;
    padding: 16px 22px; border-top: 1px solid var(--samek-border); background: var(--samek-gray);
}
.form-row-strong {
    background: #f2f8fe; border: 1.5px solid var(--samek-blue);
    border-radius: 10px; padding: 12px 14px; margin-bottom: 16px;
}
.form-row-strong label { color: var(--samek-blue-dark); }

/* Cantidad a descontar (salida): rojo suave */
#modal-salida .form-row-strong { background: #fdf2f2; border-color: #e23b3b; }
#modal-salida .form-row-strong label { color: #c0392b; }
#modal-salida .form-row-strong .form-control { border-color: #e6a3a3; }
#modal-salida .form-row-strong .form-control:focus {
    border-color: #e23b3b; box-shadow: 0 0 0 3px rgba(226,59,59,0.15);
}

/* Cantidad a ingresar (entrada): verde suave */
#modal-entrada .form-row-strong { background: #f0faf3; border-color: #28a745; }
#modal-entrada .form-row-strong label { color: #1a7a45; }
#modal-entrada .form-row-strong .form-control { border-color: #a9d9b8; }
#modal-entrada .form-row-strong .form-control:focus {
    border-color: #28a745; box-shadow: 0 0 0 3px rgba(40,167,69,0.15);
}

.modal-wide { max-width: 820px; }
.mov-loading { padding: 28px; text-align: center; color: var(--samek-muted); font-size: 14px; }
.mov-empty { padding: 28px; text-align: center; color: var(--samek-muted); font-size: 14px; }
.mov-tablewrap .data-table { font-size: 13px; }
.mov-tag {
    display: inline-block; font-size: 11.5px; font-weight: 600;
    padding: 3px 9px; border-radius: 20px; white-space: nowrap;
}
.mov-entrada { background: #e1f3e8; color: #1a7a45; }
.mov-salida { background: #fde3e3; color: #a02828; }
.mov-regularizacion { background: #e3f0fb; color: #135ea0; }

.toast {
    position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
    background: var(--samek-navy); color: #fff;
    padding: 13px 22px; border-radius: 10px; font-size: 14px; font-weight: 600;
    box-shadow: 0 12px 30px rgba(0,0,0,0.3); z-index: 300;
    opacity: 0; transition: opacity .25s, transform .25s;
}
.toast[hidden] { display: block; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 520px) { .modal-grid { grid-template-columns: 1fr; } }

.lote-btn {
    background: none; border: none; cursor: pointer;
    font-size: 13px; line-height: 1; padding: 0 2px; margin-right: 5px;
    opacity: .55; vertical-align: middle;
    transition: opacity .12s;
}
.lote-btn:hover { opacity: 1; }
.lote-btn svg { width: 15px; height: 15px; }
.opt-rojo { color: #e23b3b; }
.opt-naranja { color: #f0a020; }
.opt-verde { color: #28a745; }

.col-acciones { white-space: nowrap; }
/* Denominación: se acorta con puntos suspensivos para no ensanchar la tabla */
.data-table td.col-denom {
    max-width: 230px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.action-group { display: inline-flex; gap: 6px; }
.action-btn {
    width: 30px; height: 30px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--samek-border);
    background: #fff;
    color: var(--samek-muted);
    cursor: pointer;
    font-size: 15px; line-height: 1;
    transition: border-color .12s, color .12s, background .12s;
}
.action-btn svg { width: 17px; height: 17px; }
.action-btn:hover { background: var(--samek-gray); }
.modal-head h3 .modal-ico { width: 18px; height: 18px; vertical-align: -3px; margin-right: 4px; }
.act-in:hover { border-color: #28a745; color: #1a7a45; }
.act-out:hover { border-color: #e23b3b; color: #c0392b; }
.act-adj:hover { border-color: var(--samek-blue); color: var(--samek-blue-dark); }
.act-mov:hover { border-color: var(--samek-navy); color: var(--samek-navy); }

.form-section-title {
    font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
    color: var(--samek-navy); margin: 0 0 14px;
    padding-bottom: 8px; border-bottom: 1px solid var(--samek-border);
}

.col-exp { width: 34px; text-align: center; }
.row-toggle {
    width: 24px; height: 24px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--samek-border); border-radius: 6px;
    background: #fff; color: var(--samek-muted); cursor: pointer;
    transition: background .12s, color .12s, border-color .12s;
}
.row-toggle:hover { background: var(--samek-gray); color: var(--samek-navy); }
.row-toggle .caret { width: 14px; height: 14px; transition: transform .15s; }
.row-toggle.open { border-color: var(--samek-blue); color: var(--samek-blue); }
.row-toggle.open .caret { transform: rotate(90deg); }

.comp-detail > td { background: var(--samek-gray); padding: 0; }
.comp-detail-box {
    margin: 8px 8px 12px 42px;
    background: #fff;
    border: 1px solid var(--samek-border);
    border-left: 3px solid var(--samek-blue);
    border-radius: 8px;
    padding: 6px 12px;
}
.comp-subtable { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.comp-subtable thead th {
    text-align: left; color: var(--samek-muted); font-weight: 600;
    font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
    padding: 6px 8px; border-bottom: 1px solid var(--samek-border);
}
.comp-subtable tbody td { padding: 6px 8px; border-bottom: 1px solid var(--samek-gray); }
.comp-subtable tbody tr:last-child td { border-bottom: none; }
.comp-subtable .right { text-align: right; }

/* Consumibles: caja en rojo suave */
.rep-detail-box { border-left-color: #e23b3b; background: #fdf3f3; }
.rep-detail-box .comp-subtable thead th { color: #b23b3b; border-bottom-color: #f2d5d5; }
.rep-detail-box .comp-subtable tbody td { border-bottom-color: #f6e3e3; }

.op-info { display: inline-flex; align-items: center; justify-content: center; color: var(--samek-blue); cursor: help; }
.op-info .info-ico { width: 17px; height: 17px; }
.op-info:hover { color: var(--samek-blue-dark); }

.rechazo-row { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 10px; }
.rechazo-row .ca-field { display: flex; flex-direction: column; gap: 5px; }
.rechazo-row .ca-field > label { font-size: 12px; color: var(--samek-muted); font-weight: 600; }
.rechazo-row .ca-art { flex: 1 1 300px; }
.rechazo-row .ca-cant { flex: 0 0 120px; }
.rechazo-row .ca-del { flex: 0 0 auto; }
.rechazo-del { display: inline-flex; align-items: center; gap: 5px; height: 38px; font-size: 13px; color: var(--samek-muted); cursor: pointer; }

.of-op { margin-bottom: 12px; }
.of-op-head {
    font-size: 13px; padding: 4px 2px; color: var(--samek-text);
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.of-op-head .of-op-txt { min-width: 0; }
.bono-ctl { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px; }
.bono-btn {
    flex: 0 0 auto;
    width: 30px; height: 30px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--samek-border); border-radius: 8px;
    background: #fff; color: var(--samek-muted); cursor: pointer;
    transition: border-color .12s, color .12s, background .12s;
}
.bono-btn:hover { border-color: var(--samek-blue); color: var(--samek-blue); background: var(--samek-gray); }
.bono-btn svg { width: 17px; height: 17px; }
.bono-count {
    min-width: 22px; height: 22px; padding: 0 7px;
    display: inline-flex; align-items: center; justify-content: center;
    background: #e3f0fb; color: #135ea0;
    font-size: 12px; font-weight: 700; border-radius: 11px;
    font-variant-numeric: tabular-nums;
}
.bono-sub { font-size: 13px; font-weight: 700; color: var(--samek-navy); margin: 4px 0 10px; }
.bono-form-row { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 12px; }
.bono-rechazos-head { font-size: 12px; font-weight: 600; color: var(--samek-muted); text-transform: uppercase; letter-spacing: .04em; margin: 6px 0 8px; }
.modal-actions { display: flex; gap: 10px; align-items: center; }
.of-detail-cols { display: flex; gap: 20px; align-items: flex-start; }
.of-detail-cols .of-detail-main { flex: 0 0 560px; }
.of-detail-cols .of-detail-side { flex: 1 1 auto; min-width: 0; }
@media (max-width: 1000px) {
    .of-detail-cols { flex-direction: column; }
    .of-detail-cols .of-detail-main,
    .of-detail-cols .of-detail-side { flex: 1 1 auto; width: 100%; max-width: 560px; }
}

.btn-pdf {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 4px; border-radius: 8px; text-decoration: none;
    transition: transform .12s, filter .12s;
}
.btn-pdf img { width: 40px; height: auto; display: block; }
/* Icono TicketBai (apaisado): igualar la altura al icono PDF. */
.btn-pdf img.icon-tb { width: auto; height: 49px; }
/* Icono de envío por email. */
.btn-email svg { color: #135ea0; display: block; width: 47px; height: 47px; }
/* Icono de marcar Cobrada/Pagada (dólar, en verde). */
.btn-cobro svg { color: #1a7a45; display: block; width: 44px; height: 44px; }
.btn-cobro:hover svg { color: #146036; }
/* Icono de validar (check, en azul). */
.btn-validar svg { color: #135ea0; display: block; width: 44px; height: 44px; }
.btn-validar:hover svg { color: #0d4677; }
/* Icono de anular (aspa, en rojo). */
.btn-anular svg { color: #c0392b; display: block; width: 44px; height: 44px; }
.btn-anular:hover svg { color: #96271a; }
/* Icono de PDF (documento, en gris pizarra). */
.btn-doc svg { color: #4a5a6b; display: block; width: 44px; height: 44px; }
.btn-doc:hover svg { color: #2f3a45; }
.btn-pdf:hover { transform: translateY(-1px); filter: brightness(1.05); }
.head-actions { display: flex; align-items: center; gap: 12px; }
/* Cabecera del panel de cliente con el icono de ficha a la derecha. */
.panel-cliente-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.ficha-link { display: inline-flex; align-items: center; justify-content: center; color: #135ea0; padding: 3px; border-radius: 6px; transition: background .12s, color .12s; }
.ficha-link:hover { background: #e3f0fb; color: #0d4677; }
/* Caja de resultado TicketBai. */
.tbai-cols { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.tbai-datos { flex: 1 1 320px; }
.tbai-qr img { width: 150px; height: 150px; border: 1px solid var(--samek-border); border-radius: 8px; padding: 4px; background: #fff; }
/* Formulario para añadir vencimientos. */
.venc-form { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.venc-form label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; }
.venc-form input { width: 190px; }

.filter-fecha { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--samek-muted); }
.filter-fecha input { padding: 7px 10px; }

.col-acc { white-space: nowrap; }
.col-acc .btn-mini { margin-left: 5px; }
.col-acc form:first-child .btn-mini { margin-left: 0; }

/* Facturas rectificativas: fila en rojo suave. */
.data-table tbody tr.fila-rectificativa { background: #fdf3f3; }
.data-table tbody tr.fila-rectificativa:hover { background: #fbe9e9; }

/* Botón «Nueva rectificativa» en rojo suave. */
.btn-rectificativa {
    display: inline-flex; align-items: center;
    background: #fbe3e3; color: #b23b3b; border: 1px solid #e6b3b3;
    text-decoration: none; font-weight: 600;
    transition: background .12s, border-color .12s;
}
.btn-rectificativa:hover { background: #f6d2d2; border-color: #d99; }

.col-check { width: 36px; text-align: center; }
.col-check input { width: 16px; height: 16px; cursor: pointer; vertical-align: middle; }
.alb-facturado { display: inline-flex; color: var(--samek-blue); cursor: pointer; text-decoration: none; }
.alb-facturado:hover { color: var(--samek-blue-dark); }
.alb-facturado svg { width: 18px; height: 18px; }
.chk-bloq { cursor: help; }
.chk-bloq input { cursor: not-allowed; }
.seleccion-bar {
    display: flex; align-items: center; gap: 14px;
    background: #eef4fb; border: 1px solid var(--samek-blue);
    border-radius: 10px; padding: 10px 16px; margin-bottom: 12px;
    font-size: 14px;
}
.seleccion-bar strong { color: var(--samek-blue-dark); }

.albaran-totales { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; margin-top: 14px; }
.albaran-totales .tot-row { display: flex; align-items: center; gap: 12px; }
.albaran-totales .tot-row > span { width: 140px; text-align: right; color: var(--samek-muted); font-weight: 600; font-size: 13px; }
.albaran-totales .tot-row input { width: 160px; text-align: right; background: var(--samek-gray); font-variant-numeric: tabular-nums; }
.albaran-totales .tot-total > span { color: var(--samek-navy); }
.albaran-totales .tot-total input { font-weight: 700; font-size: 15px; border-color: var(--samek-blue); }

.lin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px 14px; margin-bottom: 12px; }
.lin-grid .ca-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.lin-grid .ca-field > label { font-size: 12px; color: var(--samek-muted); font-weight: 600; }

/* Campos bloqueados (deshabilitados o solo lectura): fondo gris consistente. */
.form-control:disabled,
.form-control[readonly] { background: #eef1f5; cursor: default; }

.panel-cliente input[readonly],
.panel-cliente textarea[readonly] { background: #eef1f5; cursor: default; }

/* Formulario de maestro con secciones en rejilla de dos columnas (empresas). */
.form-secciones { max-width: 940px; }
.secciones-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.secciones-cols > section { margin: 0; }
@media (max-width: 760px) { .secciones-cols { grid-template-columns: 1fr; } }

.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; }
.info-grid > div { display: flex; flex-direction: column; gap: 2px; }
.info-label { font-size: 11px; color: var(--samek-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }

.operacion-form { max-width: 900px; }
.componentes-card { max-width: 900px; margin-top: 20px; }
.componente-add { margin-top: 16px; border-top: 1px solid var(--samek-border); padding-top: 16px; }
.componente-add-row { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.componente-add-row .ca-field { display: flex; flex-direction: column; gap: 5px; }
.componente-add-row .ca-field > label { font-size: 12px; color: var(--samek-muted); font-weight: 600; }
.componente-add-row .ca-art { flex: 1 1 320px; }
.componente-add-row .ca-info { flex: 0 0 150px; }
.componente-add-row .ca-cant { flex: 0 0 130px; }
.componente-add-row .ca-btn { flex: 0 0 auto; }
.ca-info-box {
    height: 38px; display: flex; align-items: center; gap: 6px;
    padding: 0 12px; border: 1px solid var(--samek-border); border-radius: 8px;
    background: var(--samek-gray); font-weight: 700; font-variant-numeric: tabular-nums;
}
.form-cols { display: flex; gap: 20px; align-items: flex-start; }
.form-cols .form-col-main { flex: 1 1 520px; }
.form-cols .form-col-side { flex: 0 0 300px; }
@media (max-width: 820px) {
    .form-cols { flex-direction: column; }
    .form-cols .form-col-main,
    .form-cols .form-col-side { flex: 1 1 auto; width: 100%; max-width: 520px; }
}

.stock-qty { font-weight: 700; font-variant-numeric: tabular-nums; }
.stock-pos { color: #1a7a45; }
.stock-zero { color: var(--samek-muted); }
.stock-none { color: #c2cbd6; font-weight: 400; }
.btn-inline { width: auto; padding: 10px 22px; }
.btn-clear {
    display: inline-flex; align-items: center;
    padding: 10px 14px; font-size: 13.5px; font-weight: 600;
    color: var(--samek-muted);
}
.btn-clear:hover { color: var(--samek-navy); }

.table-wrap {
    background: #fff;
    border: 1px solid var(--samek-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow-x: auto;
}
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table thead th {
    text-align: left;
    background: var(--samek-gray);
    color: var(--samek-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11.5px;
    letter-spacing: .4px;
    padding: 13px 14px;
    border-bottom: 1px solid var(--samek-border);
    white-space: nowrap;
}
.data-table tbody td { padding: 11px 14px; border-bottom: 1px solid #eef1f5; }
.data-table tbody tr:hover { background: #f8fafc; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .center { text-align: center; }
.data-table .right { text-align: right; }
.data-table .mono { font-family: 'Consolas', 'SFMono-Regular', monospace; color: var(--samek-navy); font-weight: 600; white-space: nowrap; }
.data-table .muted { color: #c2cbd6; }
.data-table .empty { text-align: center; color: var(--samek-muted); padding: 34px; }

.tag {
    display: inline-block;
    font-size: 11.5px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 20px;
    background: var(--samek-gray-2);
    color: var(--samek-text);
    white-space: nowrap;
}
.tag-materia-prima        { background: #e3f0fb; color: #135ea0; }
.tag-semielaborado        { background: #fdf0d9; color: #9a6700; }
.tag-producto-terminado   { background: #e1f3e8; color: #1a7a45; }
.tag-elemento-incorporable{ background: #ece3fb; color: #5b3aa6; }
.tag-repuesto             { background: #fde3e3; color: #a02828; }
.tag-embalaje             { background: #e4e9ef; color: #4a5a6b; }

/* Situación de la orden de fabricación */
.tag-borrador   { background: #e4e9ef; color: #4a5a6b; }
.tag-lanzada    { background: #e3f0fb; color: #135ea0; }
.tag-cerrada    { background: #e1f3e8; color: #1a7a45; }
.tag-cancelada  { background: #fde3e3; color: #a02828; }

/* Estado del documento (albaranes) */
.tag-borrador              { background: #e4e9ef; color: #4a5a6b; }
.tag-pendiente             { background: #ede7fb; color: #5b3aa6; }
.tag-entregado             { background: #e3f0fb; color: #135ea0; }
.tag-facturada-total       { background: #e1f3e8; color: #1a7a45; }
.tag-pendiente-de-facturar { background: #fdf0d9; color: #9a6700; }

/* Estado del documento (facturas) */
.tag-pendiente-de-cobro { background: #fdf0d9; color: #9a6700; }
.tag-pendiente-de-pago  { background: #fdf0d9; color: #9a6700; }
.tag-cobrada            { background: #e1f3e8; color: #1a7a45; }
.tag-pagada             { background: #e1f3e8; color: #1a7a45; }
.tag-anulada           { background: #fde3e3; color: #a02828; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.dot-on { background: #28a745; }
.dot-off { background: #c2cbd6; }

.col-alert { width: 26px; text-align: center; padding-left: 10px !important; padding-right: 0 !important; }
.col-alert .dot { width: 12px; height: 12px; margin: 0; cursor: help; }
.dot-danger { background: #e23b3b; box-shadow: 0 0 0 3px rgba(226,59,59,0.18); }
.dot-warn { background: #f0a020; box-shadow: 0 0 0 3px rgba(240,160,32,0.18); }
.dot-ok { background: #28a745; box-shadow: 0 0 0 3px rgba(40,167,69,0.18); }

.pagination { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 22px; }
.pagination a, .pagination .current {
    padding: 8px 13px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 600;
}
.pagination a { background: #fff; border: 1px solid var(--samek-border); color: var(--samek-navy); }
.pagination a:hover { border-color: var(--samek-blue); color: var(--samek-blue); }
.pagination .current { color: var(--samek-muted); }

.data-table .row-link { cursor: pointer; }
.data-table .mono a { color: var(--samek-blue); }
.data-table .row-link:hover .mono a { text-decoration: underline; }

/* ===================== DETALLE ===================== */

.detail-head {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    background: #fff;
    border: 1px solid var(--samek-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px 24px;
    margin: 16px 0 18px;
}
.detail-photo { flex: 0 0 120px; }
.detail-photo img {
    width: 120px; height: 120px; object-fit: cover;
    border-radius: 12px; border: 1px solid var(--samek-border);
}
.detail-photo-empty {
    width: 120px; height: 120px;
    border-radius: 12px;
    border: 1px dashed var(--samek-border);
    display: flex; align-items: center; justify-content: center;
    color: #b6c0cc; font-size: 13px;
    background: var(--samek-gray);
}
.detail-title h1 { margin: 10px 0 4px; font-size: 23px; color: var(--samek-navy); }
.detail-code { font-size: 14px; color: var(--samek-muted); margin: 0 0 12px; }
.detail-meta { font-size: 14px; color: var(--samek-text); display: flex; flex-wrap: wrap; gap: 10px; }
.detail-meta strong { color: var(--samek-navy); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.chip {
    background: rgba(24,119,201,0.10);
    color: var(--samek-blue-dark);
    border: 1px solid rgba(24,119,201,0.20);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12.5px;
    font-weight: 600;
}
.chip-off {
    background: var(--samek-gray);
    color: #aab4c0;
    border-color: var(--samek-border);
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
    gap: 18px;
    align-items: start;
}
.detail-card {
    background: #fff;
    border: 1px solid var(--samek-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px 8px;
}
.detail-card h2 {
    margin: 0 0 12px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--samek-blue-dark);
    border-bottom: 1px solid var(--samek-border);
    padding-bottom: 10px;
}

/* Caja resaltada (p. ej. Almacén) */
.detail-card-highlight {
    border: 1.5px solid var(--samek-blue);
    background: #f2f8fe;
    box-shadow: 0 10px 28px rgba(24,119,201,0.16);
}
.detail-card-highlight::before {
    content: "";
    position: absolute;
    left: 0; top: 0; right: 0;
    height: 3px;
    background: var(--samek-blue);
}
.detail-card-highlight { position: relative; }
.detail-card-highlight h2 { color: var(--samek-blue); border-bottom-color: #cfe4f7; }
.detail-card dl { margin: 0; }
.detail-row {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    padding: 9px 0;
    border-bottom: 1px solid #eef1f5;
}
.detail-card .detail-row:last-child { border-bottom: none; }
.detail-row dt { color: var(--samek-muted); font-size: 13.5px; flex: 0 0 45%; }
.detail-row dd {
    margin: 0; text-align: right; font-size: 13.5px;
    color: var(--samek-text); font-weight: 500;
    word-break: break-word;
}

.detail-actions { margin-top: 26px; display: flex; align-items: center; gap: 14px; }

/* ===================== FORMULARIO ===================== */

.alert-ok {
    background: #e6f6ec; border: 1px solid #b7e0c4; color: #1a7a45;
    padding: 11px 14px; border-radius: 10px; font-size: 13.5px; margin-bottom: 16px;
}
.alert-error {
    background: #fdecea; border: 1px solid #f5c6cb; color: #842029;
    padding: 11px 14px; border-radius: 10px; font-size: 13.5px; margin-bottom: 16px;
}

.form-fields { display: flex; flex-direction: column; gap: 14px; padding: 4px 0 10px; }
.form-row { display: flex; flex-direction: column; gap: 5px; }
.form-row label { font-size: 13px; font-weight: 600; color: var(--samek-text); }
.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--samek-border);
    border-radius: 9px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
}
.form-control:focus {
    outline: none;
    border-color: var(--samek-blue);
    box-shadow: 0 0 0 3px rgba(24,119,201,0.15);
}
textarea.form-control { min-height: 70px; resize: vertical; }
.form-file { font-size: 13px; }
.form-row .help { color: var(--samek-muted); font-size: 12px; }
.field-error { color: #c0392b; font-size: 12px; font-weight: 600; }

.form-checks { display: flex; flex-direction: column; gap: 12px; padding: 6px 0 12px; }
.check-item { display: flex; align-items: center; gap: 9px; font-size: 14px; cursor: pointer; }
.form-check-input { width: 17px; height: 17px; accent-color: var(--samek-blue); cursor: pointer; }

.readonly-tag {
    font-size: 10.5px; font-weight: 600; color: var(--samek-muted);
    background: var(--samek-gray-2); padding: 2px 7px; border-radius: 10px;
    text-transform: none; letter-spacing: 0; margin-left: 6px;
}

.form-actions {
    margin-top: 24px;
    display: flex;
    align-items: center;
    gap: 14px;
}
.form-hint {
    margin-top: 18px;
    background: #eaf4fc;
    border: 1px solid #c5e0f5;
    color: var(--samek-blue-dark);
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
}

@media (max-width: 560px) {
    .topbar .brand .app-name { display: none; }
    .page { padding: 24px 16px 48px; }
    .list-head { flex-direction: column; align-items: flex-start; }
    .detail-head { flex-direction: column; }
}
