/* Estilos comunes del sistema (CORE).
   Ya no se exige compatibilidad con Firefox 32; el bloque mobile (final del archivo) usa media queries modernas. */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--nb-light, #f4f8ff); color: #1f2933; font: 13.5px/1.5 var(--nb-font, "Segoe UI", Tahoma, Arial, sans-serif); -webkit-font-smoothing: antialiased; }
a { color: var(--nb-blue-osc, #0062cc); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; color: var(--nb-navy, #0b2d5b); letter-spacing: -.01em; }
.muted { color: #6b7785; }
.small { font-size: 12px; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.mono { font-family: Consolas, Menlo, monospace; }

/* ---------------------------------------------------------- Estructura */
.pg { max-width: 1400px; margin: 0 auto; padding: 18px 20px 40px; }
.pg-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 14px; }
.pg-head h1 { font-size: 22px; }
.pg-head .sub { color: #6b7785; margin-left: 10px; font-size: 13px; font-weight: 400; }
.pg-actions { display: flex; flex-wrap: wrap; }
.pg-actions .btn { margin-left: 8px; }

.card { background: #fff; border: 1px solid #e1e6ee; border-radius: 8px; box-shadow: 0 1px 2px rgba(16, 24, 40, .05); margin-bottom: 16px; }
.card-h { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid #0b2d5b; font-weight: 700; color: #fff; background: #0b2d5b; background: linear-gradient(135deg, #0b2d5b 0%, #0a4aa6 100%); border-radius: 7px 7px 0 0; }
.card-b { padding: 16px; }
.card-h .hint { font-weight: 400; color: #dbeaff; font-size: 12px; }
.card-h .btn:not(.btn-primary):not(.btn-danger) { color: #0b2d5b; }

.row { display: flex; flex-wrap: wrap; margin: 0 -8px; }
.row > .f { padding: 0 8px; margin-bottom: 12px; }
.c1 { flex: 0 0 8.3333%; max-width: 8.3333%; }
.c2 { flex: 0 0 16.6667%; max-width: 16.6667%; }
.c3 { flex: 0 0 25%; max-width: 25%; }
.c4 { flex: 0 0 33.3333%; max-width: 33.3333%; }
.c5 { flex: 0 0 41.6667%; max-width: 41.6667%; }
.c6 { flex: 0 0 50%; max-width: 50%; }
.c7 { flex: 0 0 58.3333%; max-width: 58.3333%; }
.c8 { flex: 0 0 66.6667%; max-width: 66.6667%; }
.c9 { flex: 0 0 75%; max-width: 75%; }
.c10 { flex: 0 0 83.3333%; max-width: 83.3333%; }
.c11 { flex: 0 0 91.6667%; max-width: 91.6667%; }
.c12 { flex: 0 0 100%; max-width: 100%; }
.split { display: flex; flex-wrap: wrap; margin: 0 -8px; }
.split > .main { flex: 1 1 640px; padding: 0 8px; min-width: 0; }
.split > .side { flex: 0 0 340px; max-width: 100%; padding: 0 8px; margin-left: auto; }

/* ------------------------------------------------------------ Formularios */
label.l { display: block; margin-bottom: 4px; font-size: 12px; font-weight: 600; color: #4a5563; }
label.l .req { color: #c0392b; }
.in, select.in, textarea.in {
    display: block; width: 100%; height: 34px; padding: 6px 10px; font: inherit; color: #1f2933;
    background: #fff; border: 1px solid #c9d2de; border-radius: 5px; transition: border-color .15s, box-shadow .15s;
}
textarea.in { height: auto; min-height: 70px; resize: vertical; }
.in:focus { outline: none; border-color: #007aff; box-shadow: 0 0 0 3px rgba(29, 111, 184, .18); }
.in[disabled], .in[readonly] { background: #f3f5f8; color: #6b7785; }
.in.err { border-color: #c0392b; box-shadow: 0 0 0 3px rgba(192, 57, 43, .12); }
.err-msg { color: #c0392b; font-size: 12px; margin-top: 3px; }
.warn-msg { color: #8a5a00; background: #fff6e0; border: 1px solid #f5d98a; border-radius: 5px; padding: 6px 10px; font-size: 12px; margin-top: 4px; }
.warn-msg a { font-weight: 600; }
.input-grp { display: flex; }
.input-grp .in { flex: 1 1 auto; min-width: 0; }
.input-grp .in:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-grp .btn { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; }
.check { display: inline-flex; align-items: center; font-size: 13px; cursor: pointer; }
.check input { margin: 0 6px 0 0; }

/* ---------------------------------------------------------------- Botones */
.btn {
    display: inline-flex; align-items: center; justify-content: center; height: 34px; padding: 0 14px; font: inherit; font-weight: 600;
    color: #1f2933; background: #fff; border: 1px solid #c9d2de; border-radius: 5px; cursor: pointer; white-space: nowrap; text-decoration: none;
    transition: background .15s, border-color .15s;
}
.btn:hover { background: #f3f5f8; text-decoration: none; }
.btn:focus { outline: none; box-shadow: 0 0 0 3px rgba(29, 111, 184, .25); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn .ic { margin-right: 6px; }
.btn-primary { color: #fff; background: #007aff; background: linear-gradient(135deg, #007aff 0%, #00a3f0 100%); border-color: #007aff; box-shadow: 0 2px 6px rgba(0, 122, 255, .28); }
.btn-primary:hover { background: #0062cc; background: linear-gradient(135deg, #0062cc 0%, #0088d6 100%); border-color: #0062cc; }
.btn-success { color: #fff; background: #2e8b57; border-color: #2e8b57; }
.btn-success:hover { background: #257248; }
.btn-danger { color: #fff; background: #c0392b; border-color: #c0392b; }
.btn-danger:hover { background: #a02f23; }
.btn-warn { color: #4a3300; background: #f5b83d; border-color: #f5b83d; }
.btn-warn:hover { background: #e8a91f; }
.btn-ghost { background: transparent; border-color: transparent; color: #0062cc; }
.btn-ghost:hover { background: #e8f1fa; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-icon { width: 30px; height: 30px; padding: 0; border-color: transparent; background: transparent; color: #4a5563; }
.btn-icon .ic { margin: 0; }
.btn-icon:hover { background: #e8ecf2; }
.btn-icon.danger:hover { background: #fdeaea; color: #c0392b; }
.btn-icon.ok:hover { background: #e3f4ea; color: #2e8b57; }
.ic { width: 18px; height: 18px; fill: currentColor; vertical-align: middle; flex: 0 0 auto; }

/* ----------------------------------------------------------------- Filtros */
.filters .row { align-items: flex-end; }
.filters .f { margin-bottom: 10px; }
.filters .btns { display: flex; }
.filters .btns .btn { margin-right: 8px; }
.more { border-top: 1px dashed #dde3ec; margin-top: 4px; padding-top: 12px; }

/* ------------------------------------------------------------------ Tablas */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: #4a5563; background: #eef2f7; padding: 9px 12px; border-bottom: 1px solid #dde3ec; white-space: nowrap; }
.tbl th.sortable { cursor: pointer; user-select: none; -moz-user-select: none; }
.tbl th.sortable:hover { background: #e3e9f1; }
.tbl th .arr { font-size: 10px; color: #0062cc; margin-left: 3px; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid #edf0f5; vertical-align: middle; }
.tbl tbody tr:hover td { background: #f7fafd; }
.tbl tr.fila { cursor: pointer; }
.tbl td.actions { white-space: nowrap; text-align: right; padding-right: 6px; }
.tbl .desc { max-width: 460px; }
.tbl .desc .l1 { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.tbl .thumb { width: 36px; height: 36px; border-radius: 5px; background: #eef2f7; display: flex; align-items: center; justify-content: center; overflow: hidden; color: #9aa5b4; }
.tbl .thumb img { max-width: 36px; max-height: 36px; }
.tbl.compact td, .tbl.compact th { padding: 6px 10px; }
.stock-neg { color: #c0392b; font-weight: 700; }
.stock-low { color: #b26a00; font-weight: 700; }
.empty { padding: 44px 16px; text-align: center; color: #6b7785; }
.empty .ic { width: 40px; height: 40px; color: #b7c0cc; display: block; margin: 0 auto 8px; }
.loading { opacity: .45; pointer-events: none; transition: opacity .15s; }

.badge { display: inline-block; padding: 2px 8px; font-size: 11px; font-weight: 700; border-radius: 999px; background: #e8ecf2; color: #4a5563; white-space: nowrap; }
.badge.t1 { background: #fff1d6; color: #8a5a00; }
.badge.t2 { background: #e0f0ff; color: #0a4fa8; }
.badge.t3 { background: #ece3fb; color: #5b3aa6; }
.badge.t4 { background: #e0f5ec; color: #1f7a4d; }
.badge.ok { background: #e3f4ea; color: #1f7a4d; }
.badge.off { background: #f1f3f6; color: #6b7785; }

/* --------------------------------------------------------------- Paginador */
.meta-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid #edf0f5; font-size: 13px; color: #4a5563; }
.meta-bar select { height: 28px; margin-left: 6px; border: 1px solid #c9d2de; border-radius: 5px; background: #fff; font: inherit; }
.pager { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; padding: 12px; }
.pager a, .pager span { min-width: 32px; height: 32px; padding: 0 8px; margin: 2px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid #d5dce6; border-radius: 5px; background: #fff; color: #1f2933; cursor: pointer; text-decoration: none; }
.pager a:hover { background: #e8f1fa; text-decoration: none; }
.pager .cur { background: #007aff; border-color: #007aff; color: #fff; cursor: default; }
.pager .dis { opacity: .45; cursor: default; }
.pager .gap { border: none; background: none; cursor: default; }

/* -------------------------------------------------------------------- Tabs */
.tabs { display: flex; flex-wrap: wrap; border-bottom: 1px solid #dde3ec; padding: 0 10px; }
.tab { padding: 11px 16px; margin-bottom: -1px; cursor: pointer; color: #4a5563; font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.tab:hover { color: #0062cc; }
.tab.on { color: #0062cc; border-bottom-color: #007aff; }
.tab .cnt { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 6px; font-size: 11px; line-height: 18px; text-align: center; border-radius: 9px; background: #e8ecf2; color: #4a5563; }
.tab.on .cnt { background: #dbeaff; color: #0a4fa8; }
.panel { display: none; padding: 16px; }
.panel.on { display: block; }
.panel .add-row { display: flex; flex-wrap: wrap; align-items: flex-end; margin: 0 -6px 12px; padding: 12px; background: #f7f9fc; border: 1px solid #e6ebf2; border-radius: 6px; }
.panel .add-row > .f { padding: 0 6px; margin-bottom: 4px; }
.panel .note { padding: 26px 10px; text-align: center; color: #6b7785; }
.attrs { display: flex; flex-wrap: wrap; margin: 0 -8px; }
.attrs > .attr { flex: 1 1 260px; padding: 0 8px; margin-bottom: 14px; min-width: 240px; }
.attr h4 { font-size: 13px; margin-bottom: 8px; }

/* ------------------------------------------------------ Barra de acciones */
.actionbar { position: fixed; top: 0; left: 0; right: 0; z-index: 900; background: #fff; border-bottom: 1px solid #dde3ec; box-shadow: 0 2px 6px rgba(16, 24, 40, .08); }
.actionbar .in-bar { max-width: 1400px; margin: 0 auto; padding: 9px 20px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.actionbar .ttl { font-size: 16px; font-weight: 600; margin-right: 12px; }
.actionbar .grp { display: flex; align-items: center; flex-wrap: wrap; }
.actionbar .grp .btn { margin-left: 8px; }
.with-bar { padding-top: 66px; }
.dirty-dot { display: none; width: 9px; height: 9px; border-radius: 50%; background: #e8a317; margin-left: 8px; }
.dirty .dirty-dot { display: inline-block; }

/* ------------------------------------------------------------- Imagen etc. */
.imgbox { position: relative; background: #f3f5f8; border: 1px dashed #c9d2de; border-radius: 8px; min-height: 200px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.imgbox img { max-width: 100%; max-height: 300px; display: block; }
.imgbox .ph { text-align: center; color: #9aa5b4; }
.imgbox .ph .ic { width: 44px; height: 44px; display: block; margin: 0 auto 6px; }
.barbox { text-align: center; padding: 8px 0 2px; }
.barbox img { max-width: 100%; }
.stockbig { font-size: 30px; font-weight: 700; line-height: 1.1; }
.kv { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid #f0f2f6; }
.kv:last-child { border-bottom: none; }

/* ------------------------------------------------------ Modal, toasts, etc. */
.modal-bg { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 2000; background: rgba(16, 24, 40, .55); display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 60px 16px 20px; }
.modal { width: 560px; max-width: 100%; background: #fff; border-radius: 10px; box-shadow: 0 20px 50px rgba(0, 0, 0, .3); }
.modal.wide { width: 820px; }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid #edf0f5; font-size: 16px; font-weight: 600; }
.modal-b { padding: 18px; }
.modal-f { padding: 12px 18px; border-top: 1px solid #edf0f5; display: flex; justify-content: flex-end; }
.modal-f .btn { margin-left: 8px; }
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 3000; width: 340px; max-width: 90%; }
.toast { margin-top: 8px; padding: 11px 14px; border-radius: 7px; color: #fff; background: #2b3542; box-shadow: 0 6px 18px rgba(0, 0, 0, .25); }
.toast.ok { background: #2e8b57; }
.toast.err { background: #c0392b; }
.toast.warn { background: #b26a00; }

.suggest { position: relative; }
.suggest .list { position: absolute; left: 0; right: 0; top: 100%; z-index: 50; margin-top: 2px; background: #fff; border: 1px solid #c9d2de; border-radius: 6px; box-shadow: 0 8px 20px rgba(16, 24, 40, .15); max-height: 260px; overflow-y: auto; }
.suggest .item { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid #f0f2f6; }
.suggest .item:last-child { border-bottom: none; }
.suggest .item:hover, .suggest .item.on { background: #e8f1fa; }
.suggest .none { padding: 10px 12px; color: #6b7785; }

.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid #c9d2de; border-top-color: #007aff; border-radius: 50%; animation: giro .7s linear infinite; vertical-align: middle; }
@keyframes giro { to { transform: rotate(360deg); } }
@-moz-keyframes giro { to { -moz-transform: rotate(360deg); } }

.perm-fila { padding: 3px 0; }

/* --------------------------------------------------------------- Impresión */
.var-precio { margin: 8px 0; padding: 8px 12px; border-radius: 6px; border: 1px solid; font-size: 13px; line-height: 1.4; }
.var-precio.baja { color: #a61e1e; background: #fdecec; border-color: #f2b8b5; }
.var-precio.sube { color: #1b6e2f; background: #eaf7ee; border-color: #b7e0c1; }
.var-precio.igual { color: #7a5b00; background: #fff6dc; border-color: #f0dc9a; }
@media print {
    body { background: #fff; }
    .no-print, .actionbar, .filters, .pager { display: none !important; }
    .card { box-shadow: none; border: none; }
    .pg { padding: 0; max-width: none; }
    .tbl th { background: #eee !important; -moz-print-color-adjust: exact; }
}
@media (max-width: 760px) {
    .c1, .c2, .c3, .c4, .c5, .c6, .c7, .c8, .c9, .c10, .c11 { flex: 0 0 100%; max-width: 100%; }
    .c1, .c2, .c3 { flex: 0 0 50%; max-width: 50%; }   /* campos cortos (cantidad, descuento, fecha...) van de a dos */
    .split > .side { flex: 1 1 100%; margin-left: 0; }
}

/* Filas de tabla según estado (peligro / alerta / éxito / información) */
.tbl tbody tr.fila-danger > td { background: #fde8e8; }
.tbl tbody tr.fila-warning > td { background: #fff3cd; }
.tbl tbody tr.fila-success > td { background: #dff5e5; }
.tbl tbody tr.fila-info > td { background: #e0f0ff; }
.tbl tbody tr.fila-muted > td { background: #f1f3f6; color: #6b7785; }

/* Modal grande con una pantalla dentro (alta rápida de productos) */
.modal.xl { width: 1150px; }
.modal.xl .modal-b { padding: 0; }

/* ------------------------------------------------------------------ Mobile
   Objetivo tactil de 44px y texto de 16px en campos (con menos, iOS hace zoom al enfocar). */
@media (max-width: 760px) {
    .pg { padding: 12px 10px 32px; }
    .pg-head { align-items: flex-start; }
    .pg-head h1 { font-size: 19px; }
    .pg-head .sub { display: block; margin-left: 0; }
    .pg-actions { width: 100%; margin-top: 8px; }
    .pg-actions .btn { margin: 0 8px 8px 0; }
    .card-h { padding: 10px 12px; }
    .card-b { padding: 12px; }
    .in, select.in, textarea.in { height: 44px; font-size: 16px; }
    textarea.in { height: auto; }
    .btn { height: 44px; padding: 0 16px; }
    .btn-sm { height: 36px; }
    .btn-icon { width: 40px; height: 40px; }
    .tbl td, .tbl th { padding: 10px 10px; }
    .tbl.compact td, .tbl.compact th { padding: 8px 8px; }
    .suggest .item { padding: 12px; }
    .check { min-height: 36px; font-size: 14px; }
    .modal-bg { padding: 12px 8px; }
    .modal, .modal.wide, .modal.xl { width: 100%; }
    .modal-b { padding: 14px; }
    .modal-f { flex-wrap: wrap; }
    .modal-f .btn { flex: 1 1 auto; margin: 4px 0 0 8px; }
    .toasts { left: 10px; right: 10px; bottom: 10px; width: auto; max-width: none; }
}
