/* ══════════════════════════════════════════════════════════════
   AxionERP - Styles
   ══════════════════════════════════════════════════════════════ */

/* ─── RESET & BASE ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: #ecf0f1;
    color: #2c3e50;
    min-height: 100vh;
    overflow-x: hidden;
}
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 13px; }
a { text-decoration: none; color: inherit; }

/* ─── VARIABLES ─── */
:root {
    --primary:   #2563eb;
    --primary-d: #1e40af;
    --success:   #16a34a;
    --warn:      #d97706;
    --danger:    #dc2626;
    --info:      #0891b2;
    --muted:     #64748b;
    --accent:    #7c3aed;
    --border:    #d1d5db;
    --bg-card:   #ffffff;
    --bg-page:   #f1f5f9;
    --text:      #1e293b;
    --text-muted:#64748b;
    --header-bg: #1e293b;
    --header-h:  52px;
    --radius:    8px;
    --shadow:    0 2px 8px rgba(0,0,0,.12);
    --shadow-lg: 0 8px 24px rgba(0,0,0,.18);
}

/* ─── APP WRAPPER ─── */
#app { display: flex; flex-direction: column; min-height: 100vh; }

/* ──────────────────────────────────────────────────────────────
   HEADER
   ────────────────────────────────────────────────────────────── */
#header {
    position: fixed; top: 0; left: 0; right: 0;
    height: var(--header-h);
    background: var(--header-bg);
    color: #fff;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 16px;
    z-index: 1000;
    box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.header-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.logo-symbol { font-size: 20px; color: #facc15; }
.logo-text { font-size: 18px; letter-spacing: .5px; color: #f8fafc; }
.logo-text strong { color: #60a5fa; }
.btn-back {
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.2);
    color: #fff;
    padding: 5px 8px;
    border-radius: 6px;
    font-size: 14px;
    transition: background .2s;
    line-height: 1;
}
.btn-back:hover { background: rgba(255,255,255,.22); }
.module-title {
    font-size: 13px; font-weight: 600; color: #94a3b8; letter-spacing: .5px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.module-title .mod-sep { color: #64748b; margin: 0 2px; }
.module-title .sub-part { color: #e2e8f0; }
@media (max-width: 640px) {
  .module-title.has-sub .mod-part,
  .module-title.has-sub .mod-sep { display: none; }
}
.btn-refresh {
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.2);
    color: #94a3b8;
    width: 30px; height: 30px;
    border-radius: 50%;
    font-size: 16px;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s, color .15s, transform .3s;
    flex-shrink: 0;
    line-height: 1;
}
.btn-refresh:hover { background: rgba(255,255,255,.22); color: #fff; }
.btn-refresh.spin { animation: refreshSpin .6s ease; }
@keyframes refreshSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.header-right { display: flex; align-items: center; }

/* ─── User dropdown menu ─── */
.user-menu { position: relative; }
.user-chip {
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.15);
    padding: 5px 12px; border-radius: 20px;
    font-size: 12px; color: #cbd5e1;
    cursor: pointer; transition: background .15s;
    white-space: nowrap;
    display: inline-flex; align-items: center; gap: 6px;
}
.user-chip:hover { background: rgba(255,255,255,.18); }
.user-chip .tenant-logo {
    width: 22px; height: 22px; object-fit: contain;
    border-radius: 4px; background: #fff;
    padding: 1px; flex-shrink: 0;
}
.user-chip .user-name-text {
    max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-dropdown {
    display: none; position: absolute; right: 0; top: calc(100% + 8px);
    background: #fff; border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.18), 0 1px 4px rgba(0,0,0,.1);
    min-width: 220px; overflow: hidden;
    z-index: 2000;
    animation: ddSlide .15s ease;
}
.user-dropdown.open { display: block; }
@keyframes ddSlide { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.dd-item { padding: 10px 16px; font-size: 13px; color: #334155; }
.dd-name { font-weight: 700; font-size: 14px; color: #0f172a; padding-bottom: 2px; }
.dd-rol { font-size: 11px; color: #64748b; padding-top: 0; font-weight: 600; letter-spacing: .5px; }
.dd-clock { color: #64748b; font-size: 12px; font-variant-numeric: tabular-nums; }
.dd-divider { height: 1px; background: #e2e8f0; margin: 0; }
.dd-logout {
    width: 100%; text-align: left; background: none; border: none;
    cursor: pointer; color: #dc2626; font-weight: 600;
    transition: background .15s;
}
.dd-logout:hover { background: #fef2f2; }

/* ──────────────────────────────────────────────────────────────
   MAIN / VIEWS
   ────────────────────────────────────────────────────────────── */
#main-content {
    margin-top: var(--header-h);
    flex: 1;
    min-height: calc(100vh - var(--header-h));
}
.view { display: none; }
.view.active { display: block; }
.module-content { padding: 16px; }

/* ──────────────────────────────────────────────────────────────
   HOME MENU
   ────────────────────────────────────────────────────────────── */
.home-wrap {
    min-height: calc(100vh - var(--header-h));
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 16px 16px 32px;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
}
@media (min-width: 721px) {
    .home-wrap::before { content: ''; flex: 1; }
    .home-wrap::after  { content: ''; flex: 3; }
    .home-wrap { justify-content: flex-start; }
}
.home-header { text-align: center; margin-bottom: 32px; }
.home-header h1 { font-size: 24px; color: #1e293b; margin-bottom: 6px; }
.home-header p { color: #64748b; font-size: 14px; }

.menu-grid {
    display: grid;
    grid-template-columns: repeat(4, 160px);
    gap: 16px;
}
@media (max-width: 720px) {
    .menu-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}

.menu-btn {
    position: relative;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 10px;
    padding: 24px 12px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    transition: transform .15s, box-shadow .15s, border-color .15s;
    min-height: 120px;
}
.menu-btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}
.menu-btn.accent  { border-color: var(--accent);  background: #f5f3ff; }
.menu-btn.success { border-color: var(--success); background: #f0fdf4; }
.menu-btn.warn    { border-color: var(--warn);    background: #fffbeb; }
.menu-btn.info    { border-color: var(--info);    background: #f0f9ff; }
.menu-btn.muted   { border-color: var(--muted);   background: #f8fafc; }
.mbtn-icon  { font-size: 30px; }
.mbtn-label { font-size: 11px; font-weight: 700; letter-spacing: .8px; color: var(--text); }
.mbtn-badge {
    position: absolute; top: 8px; right: 8px;
    background: var(--danger); color: #fff;
    border-radius: 50%; width: 20px; height: 20px;
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 700;
}

/* ──────────────────────────────────────────────────────────────
   CARDS / PANELS
   ────────────────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}
.card-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    background: #f8fafc;
    border-radius: var(--radius) var(--radius) 0 0;
}
.card-header h2 { font-size: 14px; font-weight: 700; color: var(--text); }
.card-body { padding: 16px; }

/* Sub-tabs — estilo Chrome tabs */
.sub-tabs {
    display: flex; gap: 0; margin-bottom: 0; flex-wrap: wrap;
    padding: 8px 8px 0;
    background: #e8ecf0;
    border-radius: 8px 8px 0 0;
    position: relative;
}
.sub-tabs::after {
    content: ''; position: absolute; bottom: 0; left: 0; right: 0;
    height: 1px; background: var(--border); z-index: 0;
}
.sub-tab {
    padding: 8px 22px 7px;
    border: none;
    border-radius: 10px 10px 0 0;
    background: transparent;
    font-size: 12px; font-weight: 600;
    color: var(--text-muted);
    position: relative;
    z-index: 0;
    transition: all .15s;
    margin: 0 1px;
}
.sub-tab:hover { background: rgba(255,255,255,.45); color: var(--text); }
.sub-tab.active {
    background: #fff;
    color: var(--primary);
    z-index: 1;
    box-shadow: 0 -1px 3px rgba(0,0,0,.08);
    border: 1px solid var(--border);
    border-bottom: 1px solid #fff;
    margin-bottom: -1px;
}

/* Sub-module grid — replaces sub-tabs as entry screen */
.submod-grid {
    display: flex; gap: 16px; flex-wrap: wrap;
    justify-content: center; align-content: center;
    padding: 40px 20px;
}
/* When submod-grid is the only child of module-content, center it vertically */
.module-content > .submod-grid:only-child,
.module-content > .submod-wrap:only-child {
    min-height: calc(100vh - var(--header-h) - 32px);
}
.submod-wrap {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
}
@media (min-width: 721px) {
    .module-content > .submod-grid:only-child {
        align-content: flex-start;
        padding-top: calc((100vh - var(--header-h)) / 4);
    }
    .module-content > .submod-wrap:only-child {
        justify-content: flex-start;
    }
    .submod-wrap::before { content: ''; flex: 1; }
    .submod-wrap::after  { content: ''; flex: 3; }
}
.submod-btn {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    border: 2px solid var(--border); border-radius: var(--radius);
    background: var(--bg-card); padding: 20px 24px;
    min-width: 140px; min-height: 110px;
    cursor: pointer; font-family: inherit;
    transition: transform .15s, box-shadow .15s, border-color .15s;
}
.submod-btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}
.submod-icon  { font-size: 28px; margin-bottom: 8px; }
.submod-label { font-size: 11px; font-weight: 700; letter-spacing: .8px; color: var(--text); }
@media (max-width: 720px) {
    .submod-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 20px 12px;
    }
    .submod-btn {
        min-width: unset;
        min-height: 80px;
        padding: 14px 8px;
    }
    .submod-icon  { font-size: 22px; margin-bottom: 4px; }
    .submod-label { font-size: 10px; letter-spacing: .4px; }
}

/* ──────────────────────────────────────────────────────────────
   BUTTONS
   ────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 7px 14px; border-radius: 6px; border: none;
    font-size: 12px; font-weight: 600;
    transition: opacity .15s, transform .1s;
}
.btn:hover { opacity: .88; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary);  color: #fff; }
.btn-success { background: var(--success);  color: #fff; }
.btn-danger  { background: var(--danger);   color: #fff; }
.btn-warn    { background: var(--warn);     color: #fff; }
.btn-info    { background: var(--info);     color: #fff; }
.btn-muted   { background: #e2e8f0;         color: var(--text); border: 1px solid var(--border); }
.btn-outline { background: transparent; border: 1px solid var(--primary); color: var(--primary); }
.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-lg { padding: 10px 20px; font-size: 14px; }

/* ──────────────────────────────────────────────────────────────
   FORMS
   ────────────────────────────────────────────────────────────── */
.form-grid { display: grid; gap: 12px; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; }
@media (max-width: 720px) {
    .form-grid-2, .form-grid-3, .form-grid-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
    .form-grid-2, .form-grid-3, .form-grid-4 { grid-template-columns: 1fr; }
    .form-grid [style*="grid-column"] { grid-column: 1 !important; }
}
.form-control {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    color: var(--text);
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
    width: 100%;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.form-control[readonly] { background: #f8fafc; color: var(--text-muted); }

/* ──────────────────────────────────────────────────────────────
   TABLES (general)
   ────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 12px; background: #fff; }
thead { background: #1e293b; color: #fff; }
thead th { padding: 9px 10px; text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .5px; white-space: nowrap; }
tbody tr { border-bottom: 1px solid #f1f5f9; transition: background .1s; }
tbody tr:hover { background: #f8fafc; }
tbody td { padding: 8px 10px; vertical-align: middle; }
tfoot { background: #f1f5f9; font-weight: 600; }
tfoot td { padding: 8px 10px; }

/* ── OP DRAFT HINT (indicador en botones de operación) ── */
.op-draft-hint {
    display: block; font-size: 10px; color: #6366f1; font-weight: 600;
    margin-top: 2px; animation: opDraftPulse 2s ease-in-out infinite;
}
@keyframes opDraftPulse { 0%,100%{opacity:1} 50%{opacity:.5} }

/* ──────────────────────────────────────────────────────────────
   OPERATION SHEET (Boleta / hoja de calculo)
   ────────────────────────────────────────────────────────────── */
.op-sheet-wrap {
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,.1);
    overflow: hidden;
    max-width: 960px;
    margin: 0 auto;
}
.op-sheet-header {
    background: #1e293b;
    color: #fff;
    padding: 10px 16px;
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 8px;
}
.op-sheet-title { font-size: 15px; font-weight: 700; letter-spacing: .5px; }
.op-sheet-meta { font-size: 11px; color: #94a3b8; }

/* Scroll horizontal en la tabla de la hoja */
.grid-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* The spreadsheet table */
.grid-table { width: 100%; border-collapse: collapse; font-size: var(--grid-font, 12px); color: var(--grid-color, inherit); font-weight: var(--grid-weight, 400); font-style: var(--grid-style, normal); font-family: var(--grid-family, inherit); }
.grid-table thead th {
    background: #334155;
    color: #e2e8f0;
    padding: 7px 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .4px;
    border-right: 1px solid #475569;
    white-space: nowrap;
    text-align: center;
}
.grid-table thead th:first-child { text-align: left; }
.grid-table tbody tr { border-bottom: 1px solid #e2e8f0; }
.grid-table tbody tr:nth-child(even) { background: #f8fafc; }
.grid-table tbody tr:hover { background: #eff6ff; }
.grid-table tbody td {
    padding: 0;
    border-right: 1px solid #e2e8f0;
    vertical-align: middle;
    height: 34px;
}
.grid-table tbody td:last-child { border-right: none; }

/* cell display (non-editing) */
.cell-display {
    display: block;
    padding: 6px 8px;
    min-height: 34px;
    cursor: text;
    width: 100%;
    color: var(--text);
}
.cell-display:hover { background: #dbeafe; }
.cell-display.placeholder { color: #94a3b8; font-style: italic; }

/* cell input (editing) */
.cell-input {
    width: 100%;
    height: 34px;
    padding: 4px 8px;
    border: 2px solid var(--primary);
    border-radius: 0;
    font-size: var(--grid-font, 12px);
    color: var(--grid-color, inherit);
    font-weight: var(--grid-weight, 400);
    font-style: var(--grid-style, normal);
    font-family: var(--grid-family, inherit);
    background: #eff6ff;
    outline: none;
}
.cell-input.right { text-align: right; }
/* Ocultar flechas de incremento en celdas numéricas */
.cell-input[type="number"]::-webkit-inner-spin-button,
.cell-input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.cell-input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

/* Grid columns */
.col-cant { width: 56px; }
.col-desc { min-width: 150px; }
.col-pres { width: 90px; }
.col-punit { width: 82px; }
.col-sub { width: 82px; background: #f8fafc; }
.col-del { width: 30px; text-align: center; }

/* FAB Finalizar — solo visible en móvil dentro de venta */
.fab-finalizar {
    display: none;
    position: fixed;
    bottom: 66px;
    right: 16px;
    z-index: 998;
    background: var(--primary, #2563eb);
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 9px 24px;
    font-size: 12px;
    font-weight: 700;
    box-shadow: 0 3px 12px rgba(0,0,0,.25);
    cursor: pointer;
    white-space: nowrap;
    letter-spacing: .4px;
}
.fab-finalizar:active { transform: scale(.95); }

.show-mob { display: none; }

@media (max-width: 768px) {
    .fab-finalizar { display: block; }
    .btn-finalizar-desktop { display: none !important; }
    .op-sheet-meta { display: none !important; }
    .hide-mob { display: none !important; }
    .show-mob { display: inline !important; }
}

/* Totals area */
.totals-section {
    padding: 12px 16px;
    background: #f8fafc;
    border-top: 2px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
}
.totals-box { min-width: 280px; }
.total-row {
    display: flex; justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px dashed #e2e8f0;
    font-size: 12px;
}
.total-row:last-child { border-bottom: none; }
.total-row.grand {
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
    border-top: 2px solid #334155;
    padding-top: 8px;
    margin-top: 4px;
}
.total-row.grand .total-val {
    font-size: 22px;
    font-weight: 800;
    color: #0f172a;
}
.total-label { color: var(--text-muted); }
.total-val { font-weight: 600; font-variant-numeric: tabular-nums; }
.promo-gift-icon {
    display: inline-block; cursor: pointer; font-size: 22px; margin-right: 6px;
    animation: promo-shake 1.5s ease-in-out infinite;
    vertical-align: middle; filter: drop-shadow(0 0 4px rgba(245,158,11,.5));
}
.promo-gift-icon:hover { transform: scale(1.25); filter: drop-shadow(0 0 8px rgba(245,158,11,.8)); }
@keyframes promo-shake {
    0%,100% { transform: rotate(0deg); }
    10% { transform: rotate(-12deg) scale(1.1); }
    20% { transform: rotate(12deg) scale(1.1); }
    30% { transform: rotate(-8deg); }
    40% { transform: rotate(8deg); }
    50% { transform: rotate(0deg); }
}

/* Op action bar */
.op-actions {
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; flex-wrap: wrap;
}
.op-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ──────────────────────────────────────────────────────────────
   AUTOCOMPLETE DROPDOWN
   ────────────────────────────────────────────────────────────── */
.autocomplete-dropdown {
    position: fixed;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: var(--shadow-lg);
    z-index: 9000;
    max-height: 220px;
    overflow-y: auto;
    min-width: 280px;
}
.ac-item {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    display: flex; flex-direction: column; gap: 2px;
}
.ac-item:hover { background: #eff6ff; }
.ac-item:last-child { border-bottom: none; }
.ac-item.ac-highlighted { background: #dbeafe; }
.ac-item.ac-highlighted .ac-name { color: var(--primary); }
.ac-name { font-weight: 600; font-size: 12px; }
.ac-meta { font-size: 11px; color: var(--text-muted); }
.ac-new { color: var(--success); font-style: italic; }

/* Presentation dropdown */
.pres-dropdown {
    position: fixed;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: var(--shadow-lg);
    z-index: 9000;
    min-width: 200px;
}
.pres-item {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    display: flex; justify-content: space-between;
}
.pres-item:hover { background: #eff6ff; }
.pres-item.pres-highlighted { background: #dbeafe; }
.pres-item.pres-highlighted span:first-child { color: var(--primary); font-weight: 700; }

/* ──────────────────────────────────────────────────────────────
   MODAL
   ────────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 8000;
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
}
.modal-box {
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 600px;
    max-height: var(--modal-max-h, calc(100vh - 32px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.modal-box.modal-lg { max-width: 860px; }
.modal-box.modal-xl { max-width: 1200px; width: 95vw; }
.modal-box.modal-sm { max-width: 420px; }

/* ─── RRHH Grid (Excel-like) ─── */
.grid-input {
    width: 85px; padding: 3px 5px; border: 1px solid #e2e8f0; border-radius: 3px;
    font-size: 13px; text-align: right; background: #fffde7;
}
.grid-input:focus { border-color: #3b82f6; outline: none; background: #fff; }
.grid-calc { background: #f8fafc; color: #334155; }
.tbl-grid th { font-size: 12px; white-space: nowrap; padding: 6px 4px; }
.tbl-grid td { padding: 4px; vertical-align: middle; }
.estado-activo, .estado-pendiente { color: #d97706; font-weight: 600; }
.estado-vigente, .estado-declarado { color: #059669; font-weight: 600; }
.estado-terminado, .estado-cesado, .estado-vencido { color: #dc2626; font-weight: 600; }
.estado-inactivo { color: #64748b; font-weight: 600; }
.modal-header {
    padding: 14px 18px;
    background: #1e293b;
    color: #fff;
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0;
}
.modal-header h3 { font-size: 15px; font-weight: 600; }
.modal-close-btn {
    background: none; border: none;
    color: #94a3b8; font-size: 16px;
    width: 28px; height: 28px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s, color .15s;
}
.modal-close-btn:hover { background: rgba(255,255,255,.15); color: #fff; }
.modal-body { padding: 18px; overflow-y: auto; flex: 1 1 0%; min-height: 0; }
.modal-footer {
    padding: 12px 18px;
    border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end; gap: 8px;
    flex-wrap: wrap;
    flex-shrink: 0;
}
@media (max-width: 720px) {
    .modal-overlay { padding: 4px; }
    .modal-box { max-height: var(--modal-max-h, calc(100vh - 8px)); max-width: 100%; border-radius: 8px; }
    .modal-box.modal-sm,
    .modal-box.modal-lg,
    .modal-box.modal-xl { max-width: 100%; width: 100%; }
    .modal-header { padding: 10px 14px; }
    .modal-header h3 { font-size: 13px; }
    .modal-body { padding: 12px; overflow-y: auto; flex: 1 1 0%; min-height: 0; -webkit-overflow-scrolling: touch; }
    .modal-footer {
        padding: 10px 14px; gap: 6px; justify-content: center;
        background: #fff; border-top: 1px solid var(--border);
    }
    .modal-footer .btn { font-size: 11px; padding: 6px 10px; flex: 1 1 auto; min-width: 0; text-align: center; }
}

/* ──────────────────────────────────────────────────────────────
   FINALIZE MODAL OPTIONS
   ────────────────────────────────────────────────────────────── */
.fin-options { display: flex; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.fin-opt {
    flex: 1; min-width: 120px;
    padding: 14px;
    border: 2px solid var(--border);
    border-radius: 10px;
    text-align: center;
    cursor: pointer;
    transition: all .15s;
}
.fin-opt:hover { border-color: var(--primary); background: #eff6ff; }
.fin-opt.selected { border-color: var(--primary); background: #dbeafe; }
.fin-opt-icon { font-size: 22px; }
.fin-opt-label { font-size: 12px; font-weight: 700; margin-top: 4px; color: var(--text); }
.fin-opt-desc { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

.pago-options { display: flex; gap: 8px; margin-bottom: 12px; }
.pago-opt {
    flex: 1; padding: 10px;
    border: 2px solid var(--border); border-radius: 8px;
    text-align: center; cursor: pointer; transition: all .15s;
    font-size: 12px; font-weight: 600;
}
.pago-opt:hover { border-color: var(--success); }
.pago-opt.selected { border-color: var(--success); background: #f0fdf4; color: var(--success); }

.cpe-options { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.cpe-opt {
    flex: 1; min-width: 100px;
    padding: 10px; border: 2px solid var(--border); border-radius: 8px;
    text-align: center; cursor: pointer; transition: all .15s;
    font-size: 12px; font-weight: 600;
}
.cpe-opt:hover { border-color: var(--primary); }
.cpe-opt.selected { border-color: var(--primary); background: #eff6ff; color: var(--primary); }

/* ──────────────────────────────────────────────────────────────
   BADGES / STATUS
   ────────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 2px 8px; border-radius: 20px;
    font-size: 10px; font-weight: 700; letter-spacing: .4px;
    text-transform: uppercase;
}
.badge-success { background: #dcfce7; color: #16a34a; }
.badge-danger  { background: #fee2e2; color: #dc2626; }
.badge-warn    { background: #fef3c7; color: #b45309; }
.badge-info    { background: #e0f2fe; color: #0369a1; }
.badge-muted   { background: #f1f5f9; color: #64748b; }
.badge-primary { background: #dbeafe; color: #1d4ed8; }

/* ──────────────────────────────────────────────────────────────
   TOAST NOTIFICATIONS
   ────────────────────────────────────────────────────────────── */
.toast-container {
    position: fixed; bottom: 20px; right: 20px;
    z-index: 10000;
    display: flex; flex-direction: column; gap: 8px;
    pointer-events: none;
}
.toast {
    pointer-events: all;
    padding: 12px 18px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    font-size: 13px; font-weight: 500;
    animation: slideInRight .3s ease;
    max-width: 320px;
    display: flex; align-items: center; gap: 8px;
}
.toast-success { background: #16a34a; color: #fff; }
.toast-error   { background: #dc2626; color: #fff; }
.toast-info    { background: #0891b2; color: #fff; }
.toast-warn    { background: #d97706; color: #fff; }
@keyframes slideInRight {
    from { transform: translateX(100px); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

/* ──────────────────────────────────────────────────────────────
   INVENTARIO MODULE
   ────────────────────────────────────────────────────────────── */
.inv-toolbar {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 12px; flex-wrap: wrap;
}
.inv-search {
    flex: 1; min-width: 200px;
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: 6px; font-size: 13px;
}
.inv-search:focus { outline: none; border-color: var(--primary); }

/* ──────────────────────────────────────────────────────────────
   AJUSTES / CRUD TABLES
   ────────────────────────────────────────────────────────────── */
.crud-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
.crud-search { padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; }

/* ──────────────────────────────────────────────────────────────
   PRINT STYLES (CPE/Boleta)
   ────────────────────────────────────────────────────────────── */
.print-area { display: none; }

@media (max-width: 600px) {
    /* Header: solo icono de usuario en móvil */
    .user-name-text { display: none; }
    .user-chip { padding: 6px 10px; border-radius: 50%; font-size: 18px; line-height: 1; }

    /* Cero márgenes laterales en móvil */
    .module-content { padding: 0; }

    /* Hoja de operación ocupa todo el ancho */
    .op-sheet-wrap {
        border-left: none;
        border-right: none;
        border-radius: 0;
        box-shadow: none;
    }

    /* Columnas compactas en móvil */
    .col-cant  { width: 40px; }
    .col-desc  { min-width: 120px; }
    .col-pres  { width: 68px; }
    .col-punit { width: 64px; }
    .col-sub   { width: 68px; }

    /* Texto de cabeceras y celdas más pequeño */
    .grid-table { font-size: 11px; }
    .grid-table thead th { padding: 6px 3px; font-size: 10px; }
    .cell-display { padding: 5px 3px; }
    .cell-input   { padding: 4px 3px; font-size: 11px; }

    /* Totals a ancho completo en móvil */
    .totals-section { justify-content: stretch; }
    .totals-box { min-width: 0; width: 100%; }
}

@page { margin: 0; padding: 0; }

@media print {
    html, body { margin: 0 !important; padding: 0 !important; width: 100% !important; }
    body > *:not(#print-area) { display: none !important; }
    #print-area {
        display: block !important;
        position: absolute; left: 0; top: 0;
        width: 100%;
        background: #fff;
        z-index: 99999;
        padding: 0;
        margin: 0;
    }
    #print-area .receipt-preview {
        border: none !important;
        box-shadow: none !important;
        /* Fill the full print page width — thermal printer driver sets the paper */
        width: 100% !important;
        max-width: none !important;
        margin: 0;
        padding: 2mm;
        font-size: 11px;
    }
    /* If PrintConfig injected a @page size, the browser will use that.
       The receipt fills 100% of whatever page size is active. */

    .receipt {
        width: 100%;
        margin: 0;
        font-family: 'Courier New', monospace;
        font-size: 10px;
        color: #000;
    }
    .receipt-header { text-align: center; margin-bottom: 8px; }
    .receipt-title { font-size: 12px; font-weight: 700; }
    .receipt-subtitle { font-size: 10px; }
    .receipt-divider { border-top: 1px dashed #000; margin: 6px 0; }
    .receipt table { width: 100%; font-size: 9px; }
    .receipt table th, .receipt table td { padding: 1px 2px; }
    .receipt .right { text-align: right; }
    .receipt .total-line { font-weight: 700; border-top: 1px solid #000; }
}

/* screen preview — most styles overridden by PrintConfig.inlineStyle() */
.receipt-preview {
    max-width: 100%;
    background: #fff;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    padding: 4mm;
    color: #000;
    margin: 0 auto;
    width: 80mm;
}
.receipt-preview .rp-header { text-align: center; margin-bottom: 8px; }
.receipt-preview .rp-title { font-weight: 700; font-size: 13px; }
.receipt-preview .rp-divider { border-top: 1px dashed #999; margin: 6px 0; }
.receipt-preview table { width: 100%; font-size: 10px; border-collapse: collapse; }
/* Thermal-friendly: no background, bold black text for headers */
.receipt-preview table thead th {
    background: none;
    color: #000;
    font-weight: 700;
    text-align: left;
    border-bottom: 1px solid #000;
    padding: 1px 2px;
}
.receipt-preview .rp-row-total { font-weight: 700; border-top: 1px solid #000; }
.receipt-preview .right { text-align: right; }

/* ──────────────────────────────────────────────────────────────
   PENDIENTES
   ────────────────────────────────────────────────────────────── */
.pend-item {
    background: #fff;
    border: 1px solid var(--border);
    border-left: 4px solid var(--warn);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 10px;
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 12px; flex-wrap: wrap;
}
.pend-info { flex: 1; }
.pend-title { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.pend-meta { font-size: 11px; color: var(--text-muted); }
.pend-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ──────────────────────────────────────────────────────────────
   CAJA MODULE
   ────────────────────────────────────────────────────────────── */
.caja-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all .15s;
}
.caja-card:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.caja-nombre { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.caja-saldo  { font-size: 24px; font-weight: 800; color: var(--success); }
.caja-estado { font-size: 11px; margin-top: 4px; }

/* ──────────────────────────────────────────────────────────────
   MISC / HELPERS
   ────────────────────────────────────────────────────────────── */
.text-right  { text-align: right !important; }
.text-center { text-align: center !important; }
.text-muted  { color: var(--text-muted); }
.fw-700      { font-weight: 700; }
.mt-8        { margin-top: 8px; }
.mt-16       { margin-top: 16px; }
.mb-8        { margin-bottom: 8px; }
.flex        { display: flex; }
.flex-between{ display: flex; justify-content: space-between; align-items: center; }
.gap-8       { gap: 8px; }
.gap-12      { gap: 12px; }
.empty-state {
    text-align: center; padding: 40px 20px;
    color: var(--text-muted); font-size: 13px;
}
.empty-state .empty-icon { font-size: 36px; margin-bottom: 8px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

/* form tab toggle (product form) */
.fp-form-tab { background: #e2e8f0; color: var(--muted); border: 1px solid var(--border); }
.fp-form-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ──────────────────────────────────────────────────────────────
   PWA INSTALL BANNER
   ────────────────────────────────────────────────────────────── */
.pwa-banner {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(120px);
    background: #1e293b; color: #f1f5f9;
    border: 1px solid rgba(250,204,21,.3);
    border-radius: 12px; box-shadow: 0 8px 32px rgba(0,0,0,.35);
    padding: 14px 20px; display: flex; align-items: center; gap: 14px;
    z-index: 11000; max-width: 420px; width: calc(100% - 32px);
    transition: transform .4s cubic-bezier(.4,0,.2,1), opacity .4s;
    opacity: 0;
}
.pwa-banner.pwa-visible { transform: translateX(-50%) translateY(0); opacity: 1; }
.pwa-banner-icon { font-size: 28px; flex-shrink: 0; }
.pwa-banner-text { flex: 1; }
.pwa-banner-title { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.pwa-banner-sub { font-size: 11px; color: #94a3b8; }
.pwa-banner-install {
    background: #facc15; color: #1e293b; border: none; border-radius: 8px;
    padding: 8px 16px; font-size: 12px; font-weight: 700; cursor: pointer;
    white-space: nowrap; transition: background .15s;
}
.pwa-banner-install:hover { background: #fde047; }
.pwa-banner-close {
    background: none; border: none; color: #64748b; font-size: 18px;
    cursor: pointer; padding: 4px; line-height: 1; flex-shrink: 0;
}
.pwa-banner-close:hover { color: #f1f5f9; }

/* banner advertencia régimen tributario */
#home-regimen-banner { display:flex; flex-direction:column; gap:8px; }
.regimen-banner { border-radius:10px; padding:12px 16px; font-size:13px; line-height:1.5; }
.regimen-banner-warn   { background:#fef9c3; border:1px solid #fde047; color:#854d0e; }
.regimen-banner-alert  { background:#ffedd5; border:1px solid #fdba74; color:#9a3412; }
.regimen-banner-danger { background:#fee2e2; border:1px solid #fca5a5; color:#991b1b; }

/* ─── PRICE SUGGESTION DROPDOWN ─── */
.price-suggest {
    position: fixed; background: #fff; border: 1px solid var(--border);
    border-radius: 6px; box-shadow: var(--shadow-lg); z-index: 9000;
    min-width: 200px;
}
.price-suggest-item {
    padding: 8px 12px; cursor: pointer; font-size: 12px;
    color: #1e40af; display: flex; align-items: center; gap: 6px;
}
.price-suggest-item:hover { background: #eff6ff; }

/* ─── CONSULTAR PRODUCTO ─── */
.cons-item {
    padding: 8px 10px; cursor: pointer; border-bottom: 1px solid #f1f5f9;
    display: flex; justify-content: space-between; align-items: center;
    font-size: 12px; transition: background .1s;
}
.cons-item:hover { background: #eff6ff; }
.cons-item.cons-hl { background: #dbeafe; }

/* ─── SA-DOCS MODULE ─── */
.sa-docs-list { padding: 0 8px; }
.sa-docs-header { text-align: center; margin-bottom: 24px; }
.sa-docs-header h2 { font-size: 20px; color: #1e293b; margin: 0 0 4px; }
.sa-docs-header p { color: #64748b; font-size: 13px; margin: 0; }
.doc-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; max-width: 900px; margin: 0 auto; }
.doc-card {
  display: flex; align-items: center; gap: 14px; padding: 16px 18px;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 10px;
  cursor: pointer; transition: all .15s;
}
.doc-card:hover { border-color: #2563eb; box-shadow: 0 2px 8px rgba(37,99,235,.12); transform: translateY(-1px); }
.doc-card-icon { font-size: 28px; flex-shrink: 0; }
.doc-card-info { flex: 1; min-width: 0; }
.doc-card-name { font-weight: 600; color: #1e293b; font-size: 14px; }
.doc-card-meta { color: #94a3b8; font-size: 11px; margin-top: 2px; }
.doc-card-arrow { color: #94a3b8; font-size: 22px; font-weight: 300; }

.sa-doc-viewer { display: flex; gap: 0; min-height: calc(100vh - 140px); }
.sa-doc-sidebar {
  width: 240px; flex-shrink: 0; border-right: 1px solid #e2e8f0;
  padding: 12px 0; overflow-y: auto; position: sticky; top: 0; max-height: calc(100vh - 140px);
}
.sa-doc-toc-title { font-weight: 700; font-size: 12px; color: #64748b; padding: 0 14px 8px; text-transform: uppercase; letter-spacing: .5px; }
.sa-doc-toc { display: flex; flex-direction: column; }
.toc-link {
  display: block; padding: 4px 14px; font-size: 12px; color: #475569;
  text-decoration: none; border-left: 2px solid transparent; transition: all .1s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.toc-link:hover { color: #2563eb; background: #eff6ff; border-left-color: #2563eb; }
.toc-h1 { font-weight: 700; font-size: 13px; }
.toc-h2 { font-weight: 600; }
.toc-empty { padding: 8px 14px; color: #94a3b8; font-size: 12px; }

.sa-doc-main { flex: 1; padding: 0 24px 40px; min-width: 0; overflow-x: auto; }
.sa-doc-title { font-size: 22px; font-weight: 700; color: #1e293b; padding: 8px 0 16px; border-bottom: 2px solid #e2e8f0; margin-bottom: 20px; }

/* Markdown body */
.markdown-body { font-size: 14px; line-height: 1.7; color: #334155; word-wrap: break-word; }
.markdown-body h1 { font-size: 22px; font-weight: 700; color: #0f172a; margin: 28px 0 12px; padding-bottom: 6px; border-bottom: 1px solid #e2e8f0; }
.markdown-body h2 { font-size: 18px; font-weight: 700; color: #1e293b; margin: 24px 0 10px; }
.markdown-body h3 { font-size: 15px; font-weight: 600; color: #334155; margin: 20px 0 8px; }
.markdown-body h4 { font-size: 14px; font-weight: 600; color: #475569; margin: 16px 0 6px; }
.markdown-body strong { font-weight: 700; color: #1e293b; }
.markdown-body em { font-style: italic; }
.markdown-body a { color: #2563eb; text-decoration: underline; }
.markdown-body a:hover { color: #1d4ed8; }
.markdown-body hr { border: none; border-top: 1px solid #e2e8f0; margin: 20px 0; }
.markdown-body blockquote { border-left: 3px solid #2563eb; padding: 8px 16px; margin: 12px 0; background: #eff6ff; color: #1e40af; border-radius: 0 6px 6px 0; }
.markdown-body ul, .markdown-body ol { padding-left: 8px; margin: 8px 0; }
.markdown-body li { margin: 2px 0; }
.markdown-body img { max-width: 100%; border-radius: 6px; }

.md-code-block {
  background: #1e293b; color: #e2e8f0; padding: 14px 16px; border-radius: 8px;
  overflow-x: auto; font-size: 12px; line-height: 1.5; margin: 12px 0;
}
.md-code-block code { background: none; padding: 0; color: inherit; font-size: inherit; }
.md-inline-code { background: #f1f5f9; color: #e11d48; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.md-table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 13px; }
.md-table th { background: #f8fafc; font-weight: 600; text-align: left; padding: 8px 10px; border: 1px solid #e2e8f0; }
.md-table td { padding: 6px 10px; border: 1px solid #e2e8f0; }
.md-table tr:hover { background: #f8fafc; }

@media (max-width: 768px) {
  .sa-doc-sidebar { display: none; }
  .sa-doc-main { padding: 0 12px 24px; }
  .doc-cards { grid-template-columns: 1fr; }
}

/* ─── TIMELINE (Bitácora) ─── */
.tl-header { text-align: center; margin-bottom: 24px; padding: 0 16px; }
.tl-header h2 { font-size: 20px; color: #1e293b; margin: 0 0 4px; }
.tl-header p { color: #64748b; font-size: 13px; margin: 0 0 12px; }
.tl-toggle { display: flex; gap: 6px; justify-content: center; }

.tl-container {
    position: relative;
    max-width: 740px;
    margin: 0 auto;
    padding: 0 16px 40px 36px;
}
.tl-container::before {
    content: '';
    position: absolute;
    left: 44px;
    top: 0; bottom: 0;
    width: 3px;
    background: linear-gradient(to bottom, #2563eb 0%, #e2e8f0 100%);
    border-radius: 2px;
}

.tl-item {
    position: relative;
    padding: 0 0 24px 32px;
}
.tl-dot {
    position: absolute;
    left: -6px;
    top: 6px;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid #94a3b8;
    z-index: 1;
}
.tl-dot-latest { border-color: #2563eb; background: #dbeafe; box-shadow: 0 0 0 4px rgba(37,99,235,.15); }
.tl-date {
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    letter-spacing: .3px;
    margin-bottom: 4px;
}
.tl-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 14px 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,.05);
    transition: box-shadow .15s;
}
.tl-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.1); }
.tl-card-latest { border-color: #2563eb; border-left: 3px solid #2563eb; }
.tl-title { font-size: 14px; font-weight: 700; color: #1e293b; margin-bottom: 6px; }
.tl-solicitud { font-size: 12px; color: #334155; line-height: 1.5; margin-bottom: 6px; }
.tl-comportamiento { font-size: 12px; color: #475569; line-height: 1.5; margin-bottom: 6px; }
.tl-detalle { font-size: 12px; color: #64748b; line-height: 1.5; margin-bottom: 6px; font-style: italic; padding-left: 8px; border-left: 2px solid #e2e8f0; }
.tl-meta { font-size: 11px; color: #94a3b8; font-weight: 600; }

.tl-latest .tl-date { color: #2563eb; }

@media (max-width: 600px) {
    .tl-container { padding-left: 28px; }
    .tl-container::before { left: 36px; }
}

/* ─── HELP FLOAT BUTTON ─── */
.btn-help-float {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #1e40af;
    color: #fff;
    border: none;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
    z-index: 999;
    transition: transform .15s, background .15s;
}
.btn-help-float:hover { transform: scale(1.1); background: #1e3a8a; }

/* scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 3px; }

/* loading spinner */
@keyframes fp-spin { to { transform: rotate(360deg); } }
.loading-spinner { animation: fp-spin 0.8s linear infinite; }

/* ─── Módulo WWW ─── */
.www-tabs { display: flex; gap: 4px; border-bottom: 2px solid #e2e8f0; margin-bottom: 1.5rem; flex-wrap: wrap; }
.www-tab { padding: 8px 16px; border: none; background: none; cursor: pointer; font-size: 0.9rem; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .15s; color: #64748b; }
.www-tab:hover { color: #1e293b; }
.www-tab.active { color: #2563eb; border-bottom-color: #2563eb; font-weight: 600; }
.www-form-grid { display: flex; flex-direction: column; gap: 1.5rem; }
.www-form-grid fieldset { border: 1px solid #e2e8f0; border-radius: 8px; padding: 1rem 1.25rem; }
.www-form-grid legend { font-weight: 600; font-size: 0.95rem; padding: 0 6px; color: #334155; }
.fg { margin-bottom: 0.6rem; }
.fg label { display: block; font-size: 0.85rem; font-weight: 500; margin-bottom: 2px; color: #475569; }
.fg input, .fg textarea, .fg select { width: 100%; padding: 6px 10px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 0.9rem; }
.fg input[type="color"] { width: 60px; height: 32px; padding: 2px; cursor: pointer; }
.fg input[type="checkbox"] { width: auto; }
.fg-row { display: flex; gap: 12px; flex-wrap: wrap; }
.fg-row .fg { flex: 1; min-width: 120px; }
.badge-ok { background: #059669; color: #fff; }
.badge-warn { background: #f59e0b; color: #fff; }

/* ─── Sortable table headers ─── */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; position: relative; }
th.sortable:hover { background: rgba(37,99,235,.08); }
th.sortable::after { content: '\2195'; margin-left: 4px; font-size: 10px; color: #94a3b8; }
th.sortable.sort-asc::after { content: '\25B2'; color: #2563eb; }
th.sortable.sort-desc::after { content: '\25BC'; color: #2563eb; }

/* ─── Menú acciones (⋮) en ventas ─── */
.acciones-wrap { position: relative; display: inline-block; }
.acciones-trigger { background: none; border: 1px solid #d1d5db; border-radius: 6px; padding: 2px 8px; font-size: 18px; line-height: 1; cursor: pointer; color: #475569; }
.acciones-trigger:hover { background: #f1f5f9; border-color: #94a3b8; }
.acciones-menu { position: absolute; right: 0; top: 100%; z-index: 200; background: #fff; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.18); min-width: 200px; display: none; overflow: hidden; }
.acciones-menu.open { display: block; }
.acciones-menu button { display: block; width: 100%; text-align: left; padding: 9px 14px; border: none; background: none; font-size: 13px; color: #1e293b; cursor: pointer; white-space: nowrap; }
.acciones-menu button:hover { background: #f1f5f9; }
.acciones-menu button:disabled { color: #9ca3af; cursor: not-allowed; }
.acciones-menu button:disabled:hover { background: none; }
.acciones-menu .am-divider { height: 1px; background: #e2e8f0; margin: 2px 0; }

/* ─── Modal Nota de Crédito ─── */
.nc-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; font-size: 13px; margin-bottom: 14px; padding: 10px 14px; background: #f8fafc; border-radius: 8px; border: 1px solid #e2e8f0; }
.nc-info-grid .nc-label { color: #64748b; font-size: 11px; }
.nc-info-grid .nc-val { font-weight: 600; color: #1e293b; }
.nc-items-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 12px; }
.nc-items-table th { background: #1e293b; color: #fff; padding: 6px 10px; font-size: 11px; text-transform: uppercase; }
.nc-items-table td { padding: 6px 10px; border-bottom: 1px solid #e2e8f0; }
.nc-items-table input[type="number"] { width: 64px; text-align: center; padding: 3px 4px; border: 1px solid #cbd5e1; border-radius: 4px; font-size: 13px; }
.nc-totales { display: grid; grid-template-columns: 1fr auto; gap: 4px 20px; font-size: 13px; max-width: 280px; margin-left: auto; padding: 10px 14px; background: #f8fafc; border-radius: 8px; border: 1px solid #e2e8f0; }
.nc-totales .nc-tot-label { color: #64748b; text-align: right; }
.nc-totales .nc-tot-val { font-weight: 700; text-align: right; color: #1e293b; }
.nc-totales .nc-tot-total { font-size: 15px; color: #dc2626; }

/* ─── LISTA RÁPIDA (LR) ─── */
.btn-lr-split { display:inline-flex; border:1px solid #ec4899; border-radius:4px; overflow:hidden; }
.btn-lr-split button:hover { opacity:.85; }
.lr-config-grid td { vertical-align:middle; }
.lr-config-grid input { border:1px solid #e2e8f0; border-radius:3px; transition:border-color .15s; }
.lr-config-grid input:focus { border-color:#ec4899; outline:none; box-shadow:0 0 0 2px rgba(236,72,153,.15); }
.lr-suggest { position:absolute; top:100%; left:0; right:24px; z-index:1000; background:#fff; border:1px solid #e2e8f0; border-radius:6px; box-shadow:0 4px 12px rgba(0,0,0,.12); max-height:180px; overflow-y:auto; }
.lr-sug-item { padding:5px 8px; cursor:pointer; font-size:11px; border-bottom:1px solid #f1f5f9; }
.lr-sug-item:hover { background:#f0fdf4; }

/* ─── SERVER MONITOR DASHBOARD ─── */
.mon-dashboard { padding: 12px; }
.mon-gauges { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.mon-gauge-wrap { background: #fff; border-radius: 10px; padding: 10px; text-align: center; border: 1px solid #e2e8f0; }
.mon-gauge-wrap canvas { display: block; margin: 0 auto; width: 100%; max-width: 160px; height: auto; }
.mon-gauge-label { font-size: 12px; font-weight: 700; color: #475569; margin-top: 2px; }
.mon-gauge-val { font-size: 14px; font-weight: 600; color: #1e293b; }
.mon-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.mon-stat { background: #fff; border-radius: 10px; padding: 14px 10px; text-align: center; border: 1px solid #e2e8f0; }
.mon-stat-val { font-size: 22px; font-weight: 700; color: #1e293b; }
.mon-stat-lbl { font-size: 11px; color: #64748b; margin-top: 2px; text-transform: uppercase; }
.mon-mini-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.mon-mini-wrap { background: #fff; border-radius: 10px; padding: 10px; border: 1px solid #e2e8f0; }
.mon-mini-title { font-size: 11px; font-weight: 600; color: #64748b; margin-bottom: 4px; text-transform: uppercase; }
.mon-mini-wrap canvas { display: block; width: 100%; height: 100px; }
.mon-info { background: #f1f5f9; color: #475569; font-size: 11px; padding: 8px 14px; border-radius: 8px; text-align: center; }
.mon-hist-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; padding: 10px 14px; background: #fff; border-radius: 8px; border: 1px solid #e2e8f0; }
.mon-range-btns { display: flex; gap: 6px; }
.mon-hist-actions { display: flex; gap: 6px; }
.mon-hist-status { font-size: 12px; color: #64748b; margin-bottom: 8px; text-align: center; }
.mon-hist-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mon-hchart-wrap { background: #fff; border-radius: 10px; padding: 10px; border: 1px solid #e2e8f0; }
.mon-hchart-title { font-size: 11px; font-weight: 600; color: #64748b; margin-bottom: 4px; text-transform: uppercase; }
.mon-hchart-wrap canvas { display: block; width: 100%; height: 160px; }
/* PM2 table */
.mon-pm2-section { margin: 14px 0; }
.mon-pm2-title { font-size: 12px; font-weight: 700; color: #475569; text-transform: uppercase; margin-bottom: 8px; }
.mon-pm2-table-wrap { overflow-x: auto; }
.tbl-pm2 { width: 100%; border-collapse: collapse; font-size: 12px; background: #fff; border-radius: 8px; overflow: hidden; border: 1px solid #e2e8f0; }
.tbl-pm2 th { background: #f8fafc; padding: 8px 10px; text-align: left; font-weight: 600; color: #475569; border-bottom: 1px solid #e2e8f0; }
.tbl-pm2 td { padding: 6px 10px; border-bottom: 1px solid #f1f5f9; }
.tbl-pm2 tr.pm2-error td { background: #fef2f2; }
.pm2-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 700; text-transform: uppercase; }
.pm2-badge.pm2-online { background: #dcfce7; color: #166534; }
.pm2-badge.pm2-error { background: #fee2e2; color: #991b1b; }
.mon-pm2-empty { color: #94a3b8; font-size: 12px; padding: 12px; text-align: center; }

/* Alertas */
.mon-alerts-tabs { display: flex; gap: 6px; margin-bottom: 14px; padding: 10px 14px; background: #fff; border-radius: 8px; border: 1px solid #e2e8f0; }
.mon-alert-rules { padding: 0 4px; }
.mon-alert-header { margin-bottom: 12px; }
.mon-alert-empty { color: #94a3b8; font-size: 13px; text-align: center; padding: 24px; }
.mon-alert-error { color: #ef4444; font-size: 13px; text-align: center; padding: 12px; }
.tbl-alerts { width: 100%; border-collapse: collapse; font-size: 12px; background: #fff; border-radius: 8px; overflow: hidden; border: 1px solid #e2e8f0; }
.tbl-alerts th { background: #f8fafc; padding: 8px 10px; text-align: left; font-weight: 600; color: #475569; border-bottom: 1px solid #e2e8f0; }
.tbl-alerts td { padding: 6px 10px; border-bottom: 1px solid #f1f5f9; }
.tbl-alerts code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-size: 11px; }
.td-muted { color: #64748b; font-size: 11px; }
.td-msg { max-width: 300px; font-size: 11px; white-space: pre-wrap; word-break: break-word; }
.tbl-alert-log { margin-top: 12px; }

/* Alert form */
.mon-alert-form { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 14px; margin-bottom: 14px; }
.mon-alert-form .form-row { display: flex; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.mon-alert-form label { display: flex; flex-direction: column; font-size: 11px; font-weight: 600; color: #475569; gap: 4px; flex: 1; min-width: 120px; }
.mon-alert-form input, .mon-alert-form select { padding: 6px 10px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 13px; }
.mon-alert-form .form-actions { display: flex; gap: 8px; }

/* Alert config */
.mon-alert-config { padding: 4px; }
.mon-alert-config .form-row { margin-bottom: 12px; }
.toggle-label { display: flex; align-items: center; gap: 12px; font-size: 13px; font-weight: 600; color: #1e293b; }
.mon-phones-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.mon-phone-item { display: flex; align-items: center; gap: 6px; background: #f1f5f9; border-radius: 6px; padding: 4px 10px; }
.mon-phone-item code { font-size: 12px; }
.mon-phone-add { display: flex; gap: 8px; align-items: center; }
.mon-phone-add input { padding: 6px 10px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 13px; width: 160px; }
.mon-test-ok { color: #166534; font-size: 12px; margin-top: 8px; white-space: pre-wrap; }
.mon-test-err { color: #ef4444; font-size: 12px; margin-top: 8px; }

/* Toggle small */
.toggle-sm { position: relative; display: inline-block; width: 36px; height: 20px; }
.toggle-sm input { opacity: 0; width: 0; height: 0; }
.toggle-sm span { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: #cbd5e1; border-radius: 20px; transition: .2s; }
.toggle-sm span:before { content: ''; position: absolute; height: 16px; width: 16px; left: 2px; bottom: 2px; background: #fff; border-radius: 50%; transition: .2s; }
.toggle-sm input:checked + span { background: #10b981; }
.toggle-sm input:checked + span:before { transform: translateX(16px); }

@media (max-width: 768px) {
  .mon-gauges { grid-template-columns: repeat(2, 1fr); }
  .mon-stats { grid-template-columns: repeat(2, 1fr); }
  .mon-mini-charts { grid-template-columns: 1fr; }
  .mon-hist-charts { grid-template-columns: 1fr; }
  .mon-hist-toolbar { flex-direction: column; align-items: stretch; }
  .mon-alert-form .form-row { flex-direction: column; }
  .tbl-alerts { font-size: 11px; }
  .tbl-alerts th, .tbl-alerts td { padding: 4px 6px; }
}

/* ─── UploadZone ─── */
.uz-zone { border: 2px dashed #cbd5e1; border-radius: 8px; padding: 18px 12px; text-align: center; cursor: pointer; transition: border-color .2s, background .2s; outline: none; }
.uz-zone:hover, .uz-zone:focus { border-color: #818cf8; background: #f5f3ff; }
.uz-zone.uz-dragover { border-color: #6366f1; background: #eef2ff; }
.uz-label { font-size: 13px; font-weight: 600; color: #475569; }
.uz-sublabel { font-size: 11px; color: #94a3b8; margin-top: 2px; }
.uz-thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.uz-thumb { position: relative; width: 120px; height: 120px; border-radius: 6px; overflow: hidden; border: 1px solid #e2e8f0; background: #f8fafc; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.uz-thumb img { width: 100%; height: 100%; object-fit: cover; }
.uz-thumb-icon { font-size: 28px; }
.uz-thumb-x { position: absolute; top: 2px; right: 2px; background: rgba(239,68,68,.9); color: #fff; border: none; border-radius: 50%; width: 18px; height: 18px; font-size: 12px; line-height: 18px; text-align: center; cursor: pointer; padding: 0; }
.uz-thumb-name { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,.55); color: #fff; font-size: 9px; padding: 1px 3px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.uz-thumb-new { border-color: #818cf8; border-style: dashed; }
.uz-list { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.uz-list-row { display: flex; align-items: center; gap: 8px; padding: 4px 8px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 6px; font-size: 12px; }
.uz-list-icon { font-size: 16px; }
.uz-list-name { flex: 1; color: #2563eb; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uz-list-name:hover { text-decoration: underline; }
.uz-list-size { color: #94a3b8; font-size: 11px; white-space: nowrap; }
.uz-list-x { background: none; border: none; color: #ef4444; cursor: pointer; font-size: 16px; padding: 0 4px; }
