/* GasOps — tema aplicación (claro, estilo sistema / ERP) */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
    --mg-sidebar-w: 240px;
    --mg-topbar-h: 52px;
    --mg-sidebar: #6f42c1;
    --mg-sidebar-deep: #5a32a8;
    --mg-sidebar-hover: rgba(255, 255, 255, 0.12);
    --mg-sidebar-active: rgba(255, 255, 255, 0.18);
    --mg-bg0: #f4f7f6;
    --mg-bg: #f8f9fa;
    --mg-bg2: #f1f3f5;
    --mg-surface: #ffffff;
    --mg-surface2: #fafbfc;
    --mg-border: #dee2e6;
    --mg-border2: #ced4da;
    --mg-text: #333333;
    --mg-muted: #6c757d;
    --mg-accent: #007bff;
    --mg-accent-hover: #0056b3;
    --mg-accent-muted: rgba(0, 123, 255, 0.12);
    --mg-stat-blue: #007bff;
    --mg-stat-green: #28a745;
    --mg-stat-yellow: #ffc107;
    --mg-stat-cyan: #17a2b8;
    --mg-warm: #d97706;
    --mg-danger: #dc3545;
    --mg-radius: 10px;
    --mg-radius-sm: 8px;
    --mg-font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --mg-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.06);
    --mg-shadow-md: 0 4px 14px rgba(0, 0, 0, 0.07);
    --mg-glow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

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

.mg-body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--mg-font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--mg-text);
    background: var(--mg-bg);
}

.mg-body--app {
    overflow-x: hidden;
}

.mg-body ::selection {
    background: rgba(0, 123, 255, 0.2);
    color: var(--mg-text);
}

/* ——— Cabecera (barra tipo app) ——— */
.mg-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 16px;
    min-height: 48px;
    background: var(--mg-surface);
    border-bottom: 1px solid var(--mg-border);
    position: sticky;
    top: 0;
    z-index: 40;
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

.mg-header h1 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--mg-text);
}

.mg-header .brand {
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: -0.01em;
    color: var(--mg-text);
    padding: 10px 0;
}

.mg-header .brand span {
    display: block;
    margin-top: 2px;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--mg-muted);
}

.mg-header .brand span a {
    color: var(--mg-accent);
    text-decoration: none;
}

.mg-header .brand span a:hover {
    text-decoration: underline;
}

.mg-header nav {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    align-items: center;
    padding: 6px 0;
}

.mg-header nav a {
    color: var(--mg-muted);
    text-decoration: none;
    padding: 7px 12px;
    border-radius: var(--mg-radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid transparent;
    transition: color 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.mg-header nav a:hover {
    color: var(--mg-text);
    background: var(--mg-bg2);
    border-color: var(--mg-border);
}

.mg-header nav a.mg-cta {
    color: #fff;
    background: var(--mg-accent);
    border-color: var(--mg-accent);
    font-weight: 600;
}

.mg-header nav a.mg-cta:hover {
    background: var(--mg-accent-hover);
    border-color: var(--mg-accent-hover);
    box-shadow: var(--mg-glow);
}

/* ——— Contenedores ——— */
.wrap,
.shell,
.mg-container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 16px 16px 40px;
}

.shell {
    max-width: 1340px;
}

/* ——— Títulos página ——— */
h1.page-title,
.wrap > h1:first-of-type {
    margin: 0 0 6px;
    font-size: clamp(1.15rem, 2vw, 1.35rem);
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--mg-text);
}

.sub {
    color: var(--mg-muted);
    margin: 0 0 18px;
    font-size: 0.86rem;
}

/* ——— Tarjetas / paneles ——— */
.card,
.mg-card {
    background: var(--mg-surface);
    border: 1px solid var(--mg-border);
    border-radius: var(--mg-radius);
    padding: 16px 18px;
    box-shadow: var(--mg-shadow);
}

.card h2,
.mg-card h2 {
    margin: 0 0 12px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--mg-text);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

/* ——— Dashboard KPI ——— */
.grid-kpi {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.kpi {
    position: relative;
    overflow: hidden;
    padding: 14px 16px;
    border-radius: var(--mg-radius);
    background: var(--mg-surface);
    border: 1px solid var(--mg-border);
    box-shadow: var(--mg-shadow);
}

.kpi::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 3px;
    background: var(--mg-accent);
    border-radius: 2px 0 0 2px;
}

.kpi .label {
    font-size: 0.65rem;
    color: var(--mg-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

.kpi .value {
    font-size: 1.35rem;
    font-weight: 700;
    margin-top: 6px;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    color: var(--mg-text);
}

.kpi .hint {
    font-size: 0.72rem;
    color: var(--mg-muted);
    margin-top: 6px;
}

.caja-cuadro__head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.caja-cuadro__grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

@media (max-width: 720px) {
    .caja-cuadro__grid {
        grid-template-columns: 1fr;
    }
}

.caja-cuadro__item {
    border-radius: var(--mg-radius);
    border: 1px solid var(--mg-border);
    padding: 14px 16px;
    background: var(--mg-bg);
}

.caja-cuadro__item--ing { border-left: 4px solid var(--mg-stat-green, #28a745); }
.caja-cuadro__item--egr { border-left: 4px solid var(--mg-danger, #dc3545); }
.caja-cuadro__item--efe { border-left: 4px solid var(--mg-accent); }

.caja-cuadro__label {
    display: block;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    color: var(--mg-muted);
}

.caja-cuadro__value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 6px;
    font-variant-numeric: tabular-nums;
}

.caja-cuadro__hint {
    display: block;
    font-size: 0.72rem;
    color: var(--mg-muted);
    margin-top: 6px;
    line-height: 1.35;
}

.layout {
    display: grid;
    grid-template-columns: 1.12fr 0.88fr;
    gap: 14px;
    align-items: start;
}

@media (max-width: 960px) {
    .layout:not(form) {
        grid-template-columns: 1fr;
    }
}

/* ——— Tablas ——— */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

th,
td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--mg-border);
}

th {
    color: var(--mg-muted);
    font-weight: 600;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--mg-bg2);
}

tbody tr:hover {
    background: #f3f5f8;
}

tr:last-child td {
    border-bottom: none;
}

.pill {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border: 1px solid var(--mg-border);
}

.pill-ticket {
    background: #f1f3f5;
    color: #495057;
}

.pill-boleta {
    background: #e7f1f8;
    color: #0d4f75;
    border-color: #b8d4ea;
}

.pill-factura {
    background: #fff4e6;
    color: #8a4b00;
    border-color: #f0d9b5;
}

.muted {
    color: var(--mg-muted);
    font-size: 0.82rem;
}

.txt-muted {
    color: var(--mg-muted);
    font-size: 0.82rem;
}

.list-act {
    list-style: none;
    margin: 0;
    padding: 0;
}

.list-act li {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--mg-border);
    font-size: 0.84rem;
}

.list-act li:last-child {
    border-bottom: none;
}

.list-act time {
    color: var(--mg-muted);
    font-size: 0.72rem;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.alertas {
    margin-top: 14px;
}

.alertas ul {
    margin: 0;
    padding-left: 18px;
    color: var(--mg-muted);
}

.alertas li {
    margin: 4px 0;
    font-size: 0.84rem;
}

.alertas strong {
    color: var(--mg-warm);
    font-weight: 600;
}

.empty {
    color: var(--mg-muted);
    font-size: 0.86rem;
    margin: 0;
}

/* ——— Formularios ——— */
label {
    display: block;
    margin-top: 12px;
    margin-bottom: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--mg-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

label:first-of-type,
.mg-card form > label:first-child {
    margin-top: 0;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 8px 10px;
    margin-top: 0;
    border: 1px solid var(--mg-border);
    border-radius: var(--mg-radius-sm);
    background: var(--mg-surface);
    color: var(--mg-text);
    font: inherit;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

input::placeholder,
textarea::placeholder {
    color: #9aa3af;
    opacity: 1;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--mg-accent);
    box-shadow: 0 0 0 2px var(--mg-accent-muted);
}

textarea {
    resize: vertical;
    min-height: 88px;
}

button,
.mg-btn {
    font: inherit;
    cursor: pointer;
}

.mg-btn-primary,
button[type="submit"]:not(.btn):not(.qty-btn) {
    margin-top: 14px;
    padding: 10px 18px;
    width: auto;
    border: none;
    border-radius: var(--mg-radius-sm);
    background: var(--mg-accent);
    color: #fff;
    font-weight: 600;
    transition: background 0.12s ease, box-shadow 0.12s ease;
}

.mg-btn-primary:hover,
button[type="submit"]:not(.btn):not(.qty-btn):hover {
    background: var(--mg-accent-hover);
    box-shadow: var(--mg-shadow-md);
}

.mg-card > form > button[type="submit"]:not(.btn):not(.qty-btn) {
    width: 100%;
}

.cart-sticky .btn.btn-primary {
    width: 100%;
    margin-top: 12px;
    padding: 12px 14px;
}

/* ——— Botones ——— */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--mg-radius-sm);
    border: 1px solid var(--mg-border);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8rem;
    background: var(--mg-surface);
    color: var(--mg-text);
    transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.btn:hover {
    background: var(--mg-bg2);
    border-color: var(--mg-border2);
}

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

.btn-primary:hover {
    background: var(--mg-accent-hover);
    border-color: var(--mg-accent-hover);
    box-shadow: var(--mg-glow);
}

.btn-ghost {
    background: transparent;
    color: var(--mg-muted);
    border-color: transparent;
}

.btn-ghost:hover {
    color: var(--mg-text);
    background: var(--mg-bg2);
    border-color: var(--mg-border);
}

.btn-danger {
    background: #fef2f2;
    color: var(--mg-danger);
    border-color: #fecaca;
}

.btn-danger:hover {
    background: #fee2e2;
}

/* ——— Mensajes ——— */
.msg,
.mensaje,
.error {
    padding: 10px 14px;
    border-radius: var(--mg-radius-sm);
    margin-bottom: 14px;
    font-size: 0.84rem;
    font-weight: 500;
    border: 1px solid var(--mg-border);
}

.msg-ok,
.mensaje {
    background: #ecfdf3;
    color: #166534;
    border-color: #bbf7d0;
}

.msg-err,
.error {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

.msg-warn {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
    border-radius: var(--mg-radius, 8px);
    padding: 10px 14px;
    margin-bottom: 12px;
    font-size: 0.92rem;
    line-height: 1.45;
}

/* ——— POS layout ——— */
form.layout {
    grid-template-columns: 1fr minmax(280px, 360px);
    gap: 14px;
}

@media (max-width: 1024px) {
    form.layout {
        grid-template-columns: 1fr;
    }
}

.row3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

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

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-end;
    margin: 6px 0 12px;
}

.toolbar .grow {
    flex: 1 1 200px;
}

.toolbar label {
    margin-top: 0;
}

.cliente-box {
    display: none;
    margin-top: 10px;
    padding: 12px 14px;
    border-radius: var(--mg-radius-sm);
    background: #f0f7fb;
    border: 1px solid #cfe8f4;
    font-size: 0.86rem;
}

.cliente-box.show {
    display: block;
}

.grid-productos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}

.p-card {
    border: 1px solid var(--mg-border);
    border-radius: var(--mg-radius);
    padding: 12px;
    background: var(--mg-surface);
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.p-card:hover {
    border-color: #9db8cc;
    box-shadow: var(--mg-shadow-md);
}

.p-card.in-cart {
    border-color: var(--mg-accent);
    box-shadow: 0 0 0 1px rgba(29, 107, 159, 0.25);
}

.p-card.out {
    opacity: 0.55;
    cursor: not-allowed;
}

.p-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--mg-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    font-weight: 700;
    background: #e8f0f6;
    color: var(--mg-accent);
    flex-shrink: 0;
    border: 1px solid #d0e3f0;
}

.p-meta {
    font-size: 0.68rem;
    color: var(--mg-muted);
    letter-spacing: 0.03em;
    font-weight: 500;
}

.p-title {
    font-weight: 600;
    font-size: 0.84rem;
    line-height: 1.35;
    min-height: 2.4em;
}

.p-price {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--mg-accent);
    font-variant-numeric: tabular-nums;
}

.p-stock {
    font-size: 0.72rem;
    color: var(--mg-muted);
}

.p-stock.warn {
    color: var(--mg-warm);
    font-weight: 600;
}

.p-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
    align-items: center;
    margin-top: auto;
}

.qty-pill {
    text-align: center;
    font-weight: 700;
    font-size: 0.88rem;
    padding: 6px 4px;
    border-radius: var(--mg-radius-sm);
    background: var(--mg-bg2);
    border: 1px solid var(--mg-border);
    font-variant-numeric: tabular-nums;
}

.qty-btn {
    padding: 8px;
    border-radius: var(--mg-radius-sm);
    border: 1px solid var(--mg-border);
    background: var(--mg-surface);
    color: var(--mg-text);
    font-weight: 700;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}

.qty-btn:hover:not(:disabled) {
    background: #e8f0f6;
    border-color: var(--mg-accent);
}

.qty-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.hint-kbd {
    font-size: 0.72rem;
    color: var(--mg-muted);
    margin-top: 6px;
}

.cart-sticky {
    position: sticky;
    top: 56px;
}

.cart-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 10px;
}

.cart-head strong {
    font-size: 0.95rem;
    font-weight: 600;
}

.cart-lines {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 46vh;
    overflow: auto;
    padding-right: 4px;
}

.cart-empty {
    color: var(--mg-muted);
    font-size: 0.82rem;
    padding: 6px 2px;
}

.cline {
    border: 1px solid var(--mg-border);
    border-radius: var(--mg-radius-sm);
    padding: 10px;
    background: var(--mg-bg2);
}

.cline-top {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-weight: 600;
    font-size: 0.82rem;
}

.cline-sub {
    font-size: 0.74rem;
    color: var(--mg-muted);
    margin-top: 3px;
}

.cline-sub.txt-muted {
    color: var(--mg-muted);
}

.cline-ctrl {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 6px;
    align-items: center;
    margin-top: 8px;
}

.cline-ctrl input {
    padding: 6px;
    font-size: 0.8rem;
}

.cline-ctrl .cart-qty {
    text-align: center;
    font-variant-numeric: tabular-nums;
    min-width: 2.75rem;
}

.cline-ctrl .cart-qty.cart-qty--editing {
    border-color: var(--mg-accent);
    box-shadow: var(--mg-glow);
}

.totals {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--mg-border);
    font-size: 0.82rem;
}

.totals div {
    display: flex;
    justify-content: space-between;
    margin: 4px 0;
}

.totals .big {
    font-size: 1.05rem;
    font-weight: 700;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--mg-border);
    font-variant-numeric: tabular-nums;
}

.hidden-fields {
    display: none;
}

.historial {
    margin-top: 14px;
}

.historial table {
    font-size: 0.78rem;
}

.historial th,
.historial td {
    padding: 6px;
}

/* ——— Reportes: estadísticas amigables ——— */
.rpt-periodo {
    font-size: 0.88rem;
    color: var(--mg-muted);
    margin: 0 0 18px;
}

.rpt-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.rpt-kpi {
    border: 1px solid var(--mg-border);
    border-radius: var(--mg-radius);
    padding: 14px 16px;
    background: var(--mg-surface);
    box-shadow: var(--mg-shadow);
}

.rpt-kpi__val {
    font-size: 1.45rem;
    font-weight: 700;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
    color: var(--mg-accent);
}

.rpt-kpi__lbl {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--mg-text);
    margin-top: 6px;
}

.rpt-kpi__hint {
    font-size: 0.7rem;
    color: var(--mg-muted);
    margin-top: 4px;
    line-height: 1.35;
}

.rpt-insights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.rpt-insight-card h2 {
    margin: 0 0 4px;
    font-size: 1rem;
}

.rpt-insight-card .sub {
    margin: 0 0 12px;
    font-size: 0.8rem;
}

.rpt-rank {
    list-style: none;
    margin: 0;
    padding: 0;
}

.rpt-rank li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--mg-border);
}

.rpt-rank li:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.rpt-rank__pos {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 999px;
    background: var(--mg-bg2);
    color: var(--mg-muted);
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rpt-rank li:nth-child(1) .rpt-rank__pos {
    background: #fef3c7;
    color: #b45309;
}

.rpt-rank li:nth-child(2) .rpt-rank__pos {
    background: #f1f5f9;
    color: #475569;
}

.rpt-rank li:nth-child(3) .rpt-rank__pos {
    background: #ffedd5;
    color: #c2410c;
}

.rpt-rank__body {
    flex: 1;
    min-width: 0;
}

.rpt-rank__name {
    font-weight: 600;
    font-size: 0.88rem;
    line-height: 1.3;
}

.rpt-rank__meta {
    font-size: 0.75rem;
    color: var(--mg-muted);
    margin-top: 2px;
}

.rpt-rank__badge {
    flex-shrink: 0;
    text-align: right;
    font-size: 0.8rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.rpt-empty {
    font-size: 0.85rem;
    color: var(--mg-muted);
    margin: 0;
    padding: 8px 0;
}

.rpt-section-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 24px 0 12px;
    letter-spacing: -0.02em;
}

/* ——— Login ——— */
.mg-body--login {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--mg-bg0);
}

.login-wrap {
    width: 100%;
    max-width: 380px;
}

.login-card {
    padding: 28px 26px 26px;
    border-radius: var(--mg-radius);
    background: var(--mg-surface);
    border: 1px solid var(--mg-border);
    box-shadow: var(--mg-shadow-md);
    text-align: center;
}

.login-card .logo-mark {
    width: 48px;
    height: 48px;
    margin: 0 auto 14px;
    border-radius: var(--mg-radius-sm);
    background: var(--mg-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1rem;
    color: #fff;
    letter-spacing: -0.02em;
    overflow: hidden;
}

.login-card .logo-mark--img {
    width: auto;
    max-width: 160px;
    height: auto;
    min-height: 48px;
    max-height: 72px;
    background: transparent;
    border-radius: 0;
    padding: 0;
}

.login-card .logo-mark--img img {
    display: block;
    max-width: 160px;
    max-height: 72px;
    width: auto;
    height: auto;
    object-fit: contain;
}

.cfg-logo-preview {
    display: inline-block;
    margin-top: 10px;
    max-width: 180px;
    max-height: 80px;
    object-fit: contain;
    border: 1px solid var(--mg-border);
    border-radius: var(--mg-radius-sm);
    padding: 6px;
    background: #fff;
}

.login-card h2 {
    margin: 0 0 6px;
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.login-card .ruc {
    color: var(--mg-muted);
    font-size: 0.82rem;
    margin: 0 0 18px;
}

.login-card form {
    text-align: left;
}

.login-card label {
    text-align: left;
}

.login-card button[type="submit"] {
    width: 100%;
    margin-top: 18px;
}

.p-card__row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.p-card__main {
    flex: 1;
    min-width: 0;
}

.cart-badge {
    color: var(--mg-muted);
    font-size: 0.8rem;
}

/* ——— Utilidades ——— */
.mg-stack {
    margin-bottom: 14px;
}

.mg-header nav a.mg-nav-active {
    color: var(--mg-accent);
    background: var(--mg-accent-muted);
    border-color: transparent;
}

.mg-header nav a.mg-cta.mg-nav-active {
    color: #fff;
    background: var(--mg-accent-hover);
}

.hub-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    margin-top: 6px;
}

.hub-grid--compact {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
}

.hub-card {
    display: block;
    padding: 14px 14px;
    border-radius: var(--mg-radius);
    border: 1px solid var(--mg-border);
    background: var(--mg-surface);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.12s, box-shadow 0.12s;
    box-shadow: var(--mg-shadow);
}

.hub-card:hover {
    border-color: #9db8cc;
    box-shadow: var(--mg-shadow-md);
}

.hub-card--accent {
    border-color: var(--mg-accent);
    background: linear-gradient(165deg, #f0f7fb 0%, var(--mg-surface) 100%);
}

.hub-card--small {
    padding: 12px;
}

.hub-card--small h2 {
    font-size: 0.9rem;
    margin: 0 0 4px;
    text-transform: none;
    letter-spacing: 0;
}

.hub-card--small p {
    font-size: 0.78rem;
    margin: 0;
    color: var(--mg-muted);
}

.hub-card h2 {
    font-size: 0.95rem;
    margin: 0 0 6px;
    text-transform: none;
    letter-spacing: -0.01em;
}

.hub-card p {
    margin: 0;
    font-size: 0.82rem;
    color: var(--mg-muted);
    line-height: 1.4;
}

.hub-icon {
    display: block;
    font-size: 1.25rem;
    margin-bottom: 6px;
    opacity: 0.85;
}

.hub-status .msg {
    margin-bottom: 8px;
}

.row-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.td-wrap {
    max-width: 220px;
    white-space: normal;
    word-break: break-word;
}

.pill-pendiente {
    background: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
}

.pill-en_camino {
    background: #e8f4fc;
    border-color: #b8d4ea;
    color: #0d4f75;
}

.pill-entregado {
    background: #ecfdf3;
    border-color: #bbf7d0;
    color: #166534;
}

/* ——— Pedidos: tarjetas en móvil ——— */
.pedidos-gadgets {
    display: none;
}

.pedido-gadget {
    border: 1px solid var(--mg-border);
    border-radius: var(--mg-radius);
    background: var(--mg-surface);
    box-shadow: var(--mg-shadow-sm);
    overflow: hidden;
}

.pedido-gadget--pendiente {
    border-left: 4px solid #f59e0b;
}

.pedido-gadget--en_camino {
    border-left: 4px solid var(--mg-accent);
}

.pedido-gadget--entregado {
    border-left: 4px solid var(--mg-stat-green, #28a745);
}

.pedido-gadget__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 14px 10px;
    border-bottom: 1px solid var(--mg-border);
    background: var(--mg-bg2);
}

.pedido-gadget__id {
    display: block;
    font-size: 1rem;
    line-height: 1.2;
}

.pedido-gadget__fecha {
    display: block;
    font-size: 0.75rem;
    color: var(--mg-muted);
    margin-top: 2px;
}

.pedido-gadget__body {
    display: grid;
    gap: 10px;
    padding: 14px;
}

.pedido-gadget__row {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.pedido-gadget__label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    color: var(--mg-muted);
}

.pedido-gadget__value {
    font-size: 0.9rem;
    line-height: 1.4;
    word-break: break-word;
}

.pedido-gadget__tel {
    color: var(--mg-accent);
    text-decoration: none;
    font-weight: 600;
}

.pedido-gadget__actions {
    display: grid;
    gap: 12px;
    padding: 14px;
    border-top: 1px solid var(--mg-border);
    background: #fafbfc;
}

.pedido-gadget__form {
    margin: 0;
}

.pedido-gadget__form-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
    margin-top: 4px;
}

.pedido-gadget__form-row select {
    min-width: 0;
    width: 100%;
}

.pedido-gadget__form--danger .btn {
    width: 100%;
}

@media (max-width: 768px) {
    .pedidos-table-wrap {
        display: none;
    }

    .pedidos-gadgets {
        display: grid;
        gap: 12px;
    }
}

.sunat-banner .sunat-list {
    margin: 0;
    padding-left: 1.2rem;
    color: var(--mg-muted);
}

.sunat-banner .mono {
    font-size: 0.74rem;
    word-break: break-all;
    color: var(--mg-text);
}

.sunat-estado {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    border: 1px solid var(--mg-border);
    background: var(--mg-bg2);
    color: var(--mg-text);
}

.sunat-estado--borrador {
    color: var(--mg-muted);
}

.sunat-estado--aceptado {
    border-color: #bbf7d0;
    background: #ecfdf3;
    color: #166534;
}

.sunat-estado--pendiente_envio {
    border-color: #fde68a;
    background: #fffbeb;
    color: #92400e;
}

.sunat-estado--observado {
    border-color: #fecaca;
    background: #fef2f2;
    color: #991b1b;
}

.tr-note td {
    font-size: 0.78rem;
    color: var(--mg-muted);
    padding-top: 0;
    border-top: none;
    background: #fafbfc;
}

.post-sale-tools {
    margin-top: 10px;
}

.wrap-toolbar {
    flex-wrap: wrap;
    gap: 8px;
}

table th.num,
table td.num {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* ——— Layout app: sidebar + contenido (referencia UI) ——— */
.mg-shell {
    display: flex;
    min-height: 100vh;
}

.mg-sidebar {
    width: var(--mg-sidebar-w);
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--mg-sidebar) 0%, var(--mg-sidebar-deep) 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: sticky;
    top: 0;
    align-self: flex-start;
    z-index: 50;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.08);
}

.mg-sidebar__brand {
    padding: 20px 16px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    gap: 12px;
}

.mg-sidebar__avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.mg-sidebar__user strong {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
}

.mg-sidebar__user span {
    font-size: 0.72rem;
    opacity: 0.85;
}

.mg-sidebar__nav {
    flex: 1;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}

.mg-sidebar__link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--mg-radius-sm);
    color: rgba(255, 255, 255, 0.92);
    text-decoration: none;
    font-size: 0.84rem;
    font-weight: 500;
    transition: background 0.12s ease;
}

.mg-sidebar__link:hover {
    background: var(--mg-sidebar-hover);
}

.mg-sidebar__link.is-active {
    background: var(--mg-sidebar-active);
}

.mg-sidebar__link--cta {
    font-weight: 600;
}

.mg-sidebar__link--cta.is-active {
    box-shadow: inset 3px 0 0 #fff;
}

.mg-sidebar__footer {
    padding: 12px 10px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mg-sidebar__link--sub {
    font-size: 0.8rem;
    opacity: 0.95;
}

.mg-ico {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.95;
}

.mg-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--mg-bg);
}

.mg-topbar {
    height: var(--mg-topbar-h);
    min-height: var(--mg-topbar-h);
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--mg-surface);
    border-bottom: 1px solid var(--mg-border);
    flex-shrink: 0;
}

.mg-topbar__left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mg-topbar__logo {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--mg-stat-blue);
    flex-shrink: 0;
}

.mg-topbar__logo--img {
    width: auto;
    height: 28px;
    max-width: 96px;
    border-radius: 4px;
    background: transparent;
    object-fit: contain;
}

.mg-topbar__title {
    font-weight: 700;
    font-size: 0.88rem;
    letter-spacing: 0.02em;
    color: var(--mg-text);
}

.mg-topbar__right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.mg-topbar__clock {
    font-size: 0.8rem;
    color: var(--mg-muted);
    font-variant-numeric: tabular-nums;
}

.mg-usermenu {
    position: relative;
}

.mg-usermenu__btn {
    list-style: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: var(--mg-radius-sm);
    border: 1px solid var(--mg-border);
    background: var(--mg-surface2);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--mg-text);
}

.mg-usermenu__btn::-webkit-details-marker {
    display: none;
}

.mg-usermenu__btn:hover {
    border-color: var(--mg-border2);
}

.mg-usermenu__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--mg-stat-green);
}

.mg-usermenu__panel {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 180px;
    padding: 6px;
    background: var(--mg-surface);
    border: 1px solid var(--mg-border);
    border-radius: var(--mg-radius-sm);
    box-shadow: var(--mg-shadow-md);
    z-index: 60;
}

.mg-usermenu__panel a {
    display: block;
    padding: 8px 10px;
    border-radius: 6px;
    color: var(--mg-text);
    text-decoration: none;
    font-size: 0.82rem;
}

.mg-usermenu__panel a:hover {
    background: var(--mg-bg2);
}

.mg-content {
    flex: 1;
    padding: 18px 22px 32px;
    overflow-x: auto;
}

.mg-content-title {
    margin: 0 0 14px;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--mg-text);
    letter-spacing: -0.02em;
}

/* Tarjetas resumen estilo dashboard referencia */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stat-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 18px;
    background: var(--mg-surface);
    border: 1px solid var(--mg-border);
    border-radius: var(--mg-radius);
    box-shadow: var(--mg-shadow);
}

.stat-card__icon {
    width: 48px;
    height: 48px;
    border-radius: var(--mg-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-card__icon--blue {
    background: rgba(0, 123, 255, 0.12);
    color: var(--mg-stat-blue);
}

.stat-card__icon--green {
    background: rgba(40, 167, 69, 0.12);
    color: var(--mg-stat-green);
}

.stat-card__icon--yellow {
    background: rgba(255, 193, 7, 0.18);
    color: #b38600;
}

.stat-card__icon--cyan {
    background: rgba(23, 162, 184, 0.12);
    color: var(--mg-stat-cyan);
}

.stat-card__icon svg {
    width: 24px;
    height: 24px;
}

.stat-card__value {
    font-size: 1.65rem;
    font-weight: 700;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.stat-card__label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--mg-text);
    margin-top: 4px;
}

.stat-card__hint {
    font-size: 0.72rem;
    color: var(--mg-muted);
    margin-top: 2px;
}

.cart-sticky {
    top: calc(var(--mg-topbar-h) + 18px);
}

.mg-nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid var(--mg-border);
    border-radius: var(--mg-radius-sm);
    background: var(--mg-surface2);
    color: var(--mg-text);
    cursor: pointer;
    flex-shrink: 0;
}

.mg-nav-toggle svg {
    width: 20px;
    height: 20px;
}

.mg-nav-toggle:hover {
    border-color: var(--mg-border2);
    background: var(--mg-bg2);
}

.mg-sidebar-backdrop {
    display: none;
}

body.mg-nav-open {
    overflow: hidden;
}

@media (max-width: 900px) {
    .mg-nav-toggle {
        display: inline-flex;
    }

    .mg-sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 140;
        background: rgba(15, 23, 42, 0.45);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.2s ease, visibility 0.2s ease;
    }

    .mg-shell.is-nav-open .mg-sidebar-backdrop {
        opacity: 1;
        visibility: visible;
    }

    .mg-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(280px, 88vw);
        min-height: 100vh;
        min-height: 100dvh;
        transform: translateX(-105%);
        transition: transform 0.22s ease;
        z-index: 150;
        flex-direction: column;
        flex-wrap: nowrap;
        align-items: stretch;
    }

    .mg-shell.is-nav-open .mg-sidebar {
        transform: translateX(0);
    }

    .mg-sidebar__brand {
        border-bottom: 1px solid rgba(255, 255, 255, 0.12);
        border-right: none;
        flex-shrink: 0;
    }

    .mg-sidebar__nav {
        flex: 1;
        flex-direction: column;
        flex-wrap: nowrap;
        padding: 12px 10px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .mg-sidebar__link {
        flex-shrink: 0;
        width: 100%;
    }

    .mg-sidebar__footer {
        flex-direction: column;
        border-top: 1px solid rgba(255, 255, 255, 0.12);
        border-left: none;
        flex-shrink: 0;
    }

    .mg-topbar__clock {
        display: none;
    }

    .mg-content {
        padding: 14px 12px 28px;
    }
}

@media print {
    .mg-header,
    .mg-sidebar,
    .mg-topbar,
    .hub-grid,
    .toolbar {
        display: none !important;
    }
    .print-break {
        break-inside: avoid;
    }
}
