:root {
    color-scheme: light;
    --app-bg: #f8fafc;
    --app-surface: #ffffff;
    --app-text: #0f172a;
    --app-muted: #64748b;
    --app-primary: #2563eb;
    --app-primary-dark: #1e3a8a;
    --app-border: #e2e8f0;
    --app-sidebar-text: #bfdbfe;
    --app-sidebar-muted: #93c5fd;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; font-family: "Manrope", "Segoe UI", sans-serif; background: var(--app-bg); color: var(--app-text); }
a { text-decoration: none; }
.app-shell { min-height: 100vh; }
.app-main { min-height: 100vh; margin-left: 264px; display: flex; flex-direction: column; }
.app-content { width: 100%; max-width: 1580px; padding: 34px 42px 42px; margin: 0 auto; flex: 1; }

.app-sidebar { position: fixed; z-index: 1040; inset: 0 auto 0 0; width: 264px; padding: 28px 18px 20px; display: flex; flex-direction: column; color: #fff; background: linear-gradient(160deg, #1e3a8a 0%, #172554 100%); box-shadow: 12px 0 30px rgba(15,23,42,.08); }
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; padding: 0 12px 36px; }
.brand-link { display: inline-flex; align-items: center; gap: 11px; color: #fff; }
.brand-link strong, .brand-link small { display: block; line-height: 1.15; }
.brand-link strong { font-size: 16px; letter-spacing: -.02em; }
.brand-link small { margin-top: 3px; color: var(--app-sidebar-text); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.brand-mark { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 12px; color: #1e3a8a; background: #fff; font-size: 12px; font-weight: 800; }
.sidebar-label { padding: 0 13px 12px; color: var(--app-sidebar-muted); font-size: 10px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.sidebar-nav { display: grid; gap: 5px; }
.sidebar-link, .sidebar-logout { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 13px; border: 0; border-radius: 11px; color: var(--app-sidebar-text); background: transparent; font: inherit; font-size: 13px; font-weight: 700; transition: .2s ease; }
.sidebar-link:hover, .sidebar-link.active { color: #fff; background: rgba(255,255,255,.13); }
.sidebar-link.active { box-shadow: inset 3px 0 0 #60a5fa; }
.nav-glyph { display: inline-grid; width: 27px; height: 27px; flex: 0 0 27px; place-items: center; border-radius: 8px; color: #bfdbfe; background: rgba(255,255,255,.08); font-size: 9px; font-weight: 800; letter-spacing: -.03em; }
.sidebar-link.active .nav-glyph, .sidebar-logout:hover .nav-glyph { color: #fff; background: var(--app-primary); }
.sidebar-bottom { margin-top: auto; padding-top: 20px; border-top: 1px solid rgba(191,219,254,.14); }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px 10px 18px; }
.user-copy { min-width: 0; display: flex; flex-direction: column; }
.user-copy strong { overflow: hidden; color: #fff; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.user-copy small { overflow: hidden; margin-top: 3px; color: var(--app-sidebar-muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-bottom form { margin: 0; }
.sidebar-logout { width: 100%; cursor: pointer; text-align: left; }
.sidebar-logout:hover { color: #fff; background: rgba(255,255,255,.08); }
.sidebar-close, .sidebar-backdrop { display: none; }

.app-topbar { min-height: 82px; display: flex; align-items: center; gap: 24px; padding: 0 42px; border-bottom: 1px solid var(--app-border); background: rgba(255,255,255,.9); }
.topbar-title { display: flex; flex-direction: column; gap: 4px; }
.topbar-title strong { font-size: 16px; letter-spacing: -.02em; }
.eyebrow { display: block; color: var(--app-muted); font-size: 10px; font-weight: 800; letter-spacing: .12em; line-height: 1.4; text-transform: uppercase; }
.topbar-search { width: min(360px, 34vw); height: 42px; display: flex; align-items: center; gap: 9px; padding: 0 12px; border: 1px solid var(--app-border); border-radius: 10px; background: #f8fafc; }
.topbar-search input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--app-text); background: transparent; font: inherit; font-size: 12px; }
.topbar-search input::placeholder { color: #94a3b8; }
.search-mark { color: var(--app-primary); font-size: 18px; font-weight: 800; }
kbd { padding: 3px 6px; border: 1px solid #cbd5e1; border-radius: 5px; color: #64748b; background: #fff; font-size: 9px; white-space: nowrap; }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.topbar-user strong { color: var(--app-text); font-size: 11px; }
.topbar-user small { color: var(--app-muted); font-size: 10px; }
.avatar { display: inline-grid; width: 34px; height: 34px; flex: 0 0 34px; place-items: center; border-radius: 50%; color: #1d4ed8; background: #dbeafe; font-size: 11px; font-weight: 800; }
.avatar-sm { width: 36px; height: 36px; flex-basis: 36px; color: #fff; background: var(--app-primary); }
.sidebar-toggle { display: none; }

.dashboard-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.display-title { margin-top: 8px; color: var(--app-text); font-size: clamp(1.55rem, 2.4vw, 2.15rem); font-weight: 800; letter-spacing: -.055em; }
.live-pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid #bbf7d0; border-radius: 99px; color: #15803d; background: #f0fdf4; font-size: 11px; font-weight: 800; white-space: nowrap; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 4px #dcfce7; }
.stats-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; }
.stat-card, .dashboard-card, .surface-card { border: 1px solid var(--app-border); border-radius: 16px; background: var(--app-surface); box-shadow: 0 12px 30px rgba(15,23,42,.045); }
.stat-card { min-height: 172px; padding: 19px; }
.stat-card-top { display: flex; align-items: center; justify-content: space-between; }
.metric-icon { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 10px; font-size: 10px; font-weight: 900; }
.metric-blue { color: #2563eb; background: #dbeafe; } .metric-violet { color: #7c3aed; background: #ede9fe; } .metric-orange { color: #ea580c; background: #ffedd5; } .metric-green { color: #16a34a; background: #dcfce7; } .metric-cyan { color: #0891b2; background: #cffafe; } .metric-slate { color: #475569; background: #e2e8f0; }
.trend-mark { color: #22c55e; font-size: 17px; font-weight: 800; }
.stat-label { margin: 17px 0 5px; color: var(--app-muted); font-size: 11px; font-weight: 700; }
.stat-value { color: var(--app-text); font-size: 25px; font-weight: 800; letter-spacing: -.05em; }
.stat-detail { margin-top: 5px; color: #94a3b8; font-size: 10px; }
.dashboard-card { overflow: hidden; }
.section-header { display: flex; align-items: start; justify-content: space-between; gap: 16px; padding: 22px 24px 18px; }
.section-title { margin: 5px 0 0; color: var(--app-text); font-size: 15px; font-weight: 800; letter-spacing: -.025em; }
.section-link { color: var(--app-primary); font-size: 11px; font-weight: 800; white-space: nowrap; }
.section-link span { margin-left: 4px; font-size: 15px; }
.dashboard-table { --bs-table-bg: transparent; --bs-table-border-color: #f1f5f9; color: var(--app-text); font-size: 11px; }
.dashboard-table th { padding: 12px 24px; border-bottom-width: 1px; color: #94a3b8; font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
.dashboard-table td { padding: 15px 24px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.dashboard-table tbody tr:last-child td { border-bottom: 0; }
.dashboard-table td strong { font-size: 11px; font-weight: 800; }
.empty-state { padding: 28px 24px !important; color: #94a3b8; font-size: 11px; text-align: center; }
.code-label { color: #64748b; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 10px; }
.status-badge, .movement-badge { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 6px; font-size: 9px; font-weight: 800; white-space: nowrap; }
.status-badge > span { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status-warning { color: #b45309; background: #fef3c7; } .status-danger { color: #dc2626; background: #fee2e2; } .status-info { color: #0369a1; background: #e0f2fe; } .status-success { color: #15803d; background: #dcfce7; } .status-primary { color: #1d4ed8; background: #dbeafe; }
.movement-entrada { color: #15803d; background: #dcfce7; } .movement-salida { color: #b45309; background: #fef3c7; }
.quick-card { padding-bottom: 12px; }
.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 18px 10px; }
.quick-action { display: flex; align-items: center; gap: 9px; min-width: 0; padding: 11px 9px; border: 1px solid #eef2f7; border-radius: 10px; color: var(--app-text); transition: .2s ease; }
.quick-action:hover { border-color: #bfdbfe; background: #f8fbff; transform: translateY(-1px); }
.quick-action > span:nth-child(2) { min-width: 0; display: flex; flex: 1; flex-direction: column; }
.quick-action strong { font-size: 10px; white-space: nowrap; }
.quick-action small { margin-top: 3px; color: var(--app-muted); font-size: 9px; white-space: nowrap; }
.quick-action b { color: var(--app-primary); font-size: 15px; }
.quick-icon { display: grid; width: 27px; height: 27px; flex: 0 0 27px; place-items: center; border-radius: 8px; color: var(--app-primary); background: #eff6ff; font-size: 16px; font-weight: 700; }
.contact-list { padding: 0 24px 13px; }
.contact-item { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid #f1f5f9; }
.contact-item:last-child { border-bottom: 0; }
.avatar-contact { width: 30px; height: 30px; flex-basis: 30px; color: #7c3aed; background: #ede9fe; font-size: 10px; }
.contact-copy { min-width: 0; display: flex; flex: 1; flex-direction: column; }
.contact-copy strong { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.contact-copy small { overflow: hidden; margin-top: 4px; color: var(--app-muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.contact-meta { display: flex; flex-direction: column; align-items: end; gap: 5px; }
.contact-meta small { color: #94a3b8; font-size: 9px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.filter-bar { display: grid; grid-template-columns: minmax(220px, 1.5fr) repeat(2, minmax(150px, 1fr)) auto auto; gap: 10px; padding: 18px; }
.filter-search { min-width: 0; }
.filter-bar .form-control, .filter-bar .form-select { min-height: 40px; border-color: var(--app-border); font-size: 11px; }
.filter-bar .btn { min-height: 40px; font-size: 11px; font-weight: 800; }
.result-count { display: inline-flex; min-width: 24px; height: 20px; align-items: center; justify-content: center; margin-left: 5px; padding: 0 6px; border-radius: 99px; color: var(--app-primary); background: #dbeafe; font-size: 10px; vertical-align: 2px; }
.product-description { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stock-status { display: block; margin-top: 4px; font-size: 9px; font-weight: 700; }
.stock-normal { color: #16a34a; } .stock-warning { color: #b45309; } .stock-danger { color: #dc2626; }
.table-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.table-actions .btn { font-size: 9px; font-weight: 800; }
.table-actions form { display: inline; }
.pagination-wrap { display: flex; justify-content: end; padding: 15px 24px 20px; border-top: 1px solid #f1f5f9; }
.pagination .page-link { border-color: var(--app-border); color: var(--app-primary); font-size: 10px; }
.pagination .page-item.active .page-link { border-color: var(--app-primary); background: var(--app-primary); }
.product-form-card { overflow: visible; }
.product-form .form-label { color: var(--app-text); font-size: 11px; font-weight: 800; }
.product-form .form-control, .product-form .form-select { border-color: var(--app-border); font-size: 12px; }
.product-form .form-control:focus, .product-form .form-select:focus { border-color: #93c5fd; box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.form-hint { color: var(--app-muted); font-size: 10px; }
.form-actions { display: flex; justify-content: end; gap: 10px; }
.detail-card { overflow: visible; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; margin: 0; padding: 0 24px 22px; }
.detail-grid > div { padding: 15px 15px 15px 0; border-top: 1px solid #f1f5f9; }
.detail-grid dt { color: #94a3b8; font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.detail-grid dd { margin: 6px 0 0; color: var(--app-text); font-size: 12px; font-weight: 700; }
.stock-detail-card { padding: 24px; }
.stock-detail-value { margin-top: 15px; color: var(--app-primary); font-size: 52px; font-weight: 800; letter-spacing: -.08em; line-height: 1; }
.future-action { padding: 12px; border: 1px dashed #bfdbfe; border-radius: 9px; color: var(--app-primary); font-size: 11px; font-weight: 800; }
.future-action small { display: block; margin-top: 4px; color: var(--app-muted); font-size: 9px; font-weight: 500; }
.auth-page { background: radial-gradient(circle at top right, #dbeafe 0, transparent 35%), var(--app-bg); }
.auth-page .surface-card { width: 100%; }
.surface-card { box-shadow: 0 18px 45px rgba(15,23,42,.08); }
.text-muted-soft { color: var(--app-muted); }
.app-footer { padding: 0 42px 24px; color: #94a3b8; font-size: 10px; }

@media (max-width: 1399.98px) { .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 991.98px) {
    .app-main { margin-left: 0; }
    .app-sidebar { transform: translateX(-100%); transition: transform .25s ease; }
    .app-sidebar.is-open { transform: translateX(0); }
    .sidebar-close { display: block; border: 0; color: #bfdbfe; background: transparent; font-size: 24px; line-height: 1; }
    .sidebar-backdrop { position: fixed; z-index: 1030; inset: 0; display: block; visibility: hidden; opacity: 0; background: rgba(15,23,42,.45); transition: .25s ease; }
    .sidebar-backdrop.is-visible { visibility: visible; opacity: 1; }
    .sidebar-toggle { display: inline-flex; width: 34px; height: 34px; flex-direction: column; justify-content: center; gap: 4px; padding: 7px; border: 1px solid var(--app-border); border-radius: 9px; background: #fff; }
    .sidebar-toggle span { display: block; width: 100%; height: 2px; background: var(--app-primary-dark); }
    .app-topbar { padding: 0 24px; }
    .app-content { padding: 28px 24px 36px; }
    .app-footer { padding: 0 24px 24px; }
    .filter-bar { grid-template-columns: 1fr 1fr; }
    .filter-search { grid-column: 1 / -1; }
}
@media (max-width: 575.98px) {
    .app-topbar { min-height: 70px; gap: 12px; padding: 0 16px; }
    .topbar-search { width: auto; flex: 1; }
    .topbar-search kbd { display: none; }
    .app-content { padding: 24px 16px 30px; }
    .dashboard-heading { align-items: start; flex-direction: column; gap: 14px; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-card { min-height: 150px; padding: 14px; }
    .stat-value { font-size: 22px; }
    .section-header { padding: 18px 16px 14px; }
    .dashboard-table th, .dashboard-table td { padding-right: 16px; padding-left: 16px; }
    .quick-grid { grid-template-columns: 1fr; }
    .contact-list { padding-right: 16px; padding-left: 16px; }
    .page-heading { align-items: start; flex-direction: column; }
    .page-actions { width: 100%; }
    .page-actions .btn { flex: 1; }
    .filter-bar { grid-template-columns: 1fr; }
    .filter-search { grid-column: auto; }
    .detail-grid { grid-template-columns: 1fr; padding-right: 16px; padding-left: 16px; }
}
.movement-filter-bar { grid-template-columns: minmax(210px, 1.6fr) minmax(150px, 1fr) repeat(2, minmax(130px, 1fr)) auto auto; }
.filter-date { display: flex; flex-direction: column; gap: 4px; color: var(--app-muted); font-size: 9px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.filter-date .form-control { min-height: 40px; }
.movement-table { min-width: 1050px; }
.movement-badge { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 999px; font-size: 10px; font-weight: 800; }
.movement-in { color: #047857; background: #d1fae5; }
.movement-out { color: #b45309; background: #fef3c7; }
.movement-summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 24px 0 12px; }
.movement-summary div { display: flex; flex-direction: column; gap: 4px; }
.movement-summary small { color: var(--app-muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.movement-summary strong { color: var(--app-text); font-size: 32px; line-height: 1; }
.movement-arrow { color: var(--app-muted); font-weight: 800; }
.customer-filter-bar { grid-template-columns: minmax(260px, 1fr) minmax(170px, .35fr) auto auto; }
.customer-table { min-width: 920px; }
.status-muted { color: #475569; background: #e2e8f0; }
.customer-filter-bar { grid-template-columns: minmax(260px, 1fr) minmax(170px, .35fr) auto auto; }
.customer-table { min-width: 920px; }
.history-filter-bar { grid-template-columns: repeat(5, minmax(130px, 1fr)) auto auto; padding-top: 0; }
.history-table { min-width: 900px; }
.history-status { display: inline-flex; padding: 5px 9px; border-radius: 999px; font-size: 10px; font-weight: 800; }
.history-pendiente { color: #92400e; background: #fef3c7; }
.history-contactado { color: #1d4ed8; background: #dbeafe; }
.history-en_proceso { color: #0369a1; background: #e0f2fe; }
.history-cerrado { color: #047857; background: #d1fae5; }
.history-descartado { color: #475569; background: #e2e8f0; }
.report-link-card { display: flex; align-items: center; gap: 14px; min-height: 108px; padding: 22px; color: var(--app-text); text-decoration: none; transition: transform .2s ease, box-shadow .2s ease; }
.report-link-card:hover { color: var(--app-text); transform: translateY(-2px); box-shadow: 0 14px 28px rgba(15, 23, 42, .08); }
.report-link-card strong, .report-link-card small { display: block; }
.report-link-card strong { font-size: 13px; }
.report-link-card small { margin-top: 4px; color: var(--app-muted); font-size: 11px; }
.report-link-card b { margin-left: auto; color: var(--app-primary); }
.report-stats { grid-template-columns: repeat(6, 1fr); }
.report-filter-bar { grid-template-columns: minmax(230px, 1.5fr) repeat(3, minmax(140px, 1fr)) auto auto; }
.report-table { min-width: 900px; }
.movement-report-table { min-width: 1050px; }
.customer-report-table { min-width: 760px; }
.contact-report-table { min-width: 900px; }
@media (max-width: 1199.98px) { .report-stats { grid-template-columns: repeat(3, 1fr); } .report-filter-bar { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 575.98px) { .report-stats { grid-template-columns: 1fr 1fr; } .report-filter-bar { grid-template-columns: 1fr; } .report-filter-bar .btn { width: 100%; } }
.quick-summary { display: flex; gap: 28px; padding: 20px 24px; border-bottom: 1px solid var(--app-border); }
.quick-summary span { display: flex; flex-direction: column; gap: 4px; }
.quick-summary strong { color: var(--app-text); font-size: 13px; }
.quick-summary small { color: var(--app-muted); font-size: 10px; text-transform: uppercase; }
@media (max-width: 1199.98px) { .history-filter-bar { grid-template-columns: 1fr 1fr 1fr; } .customer-filter-bar { grid-template-columns: 1fr 1fr; } }
@media (max-width: 575.98px) { .history-filter-bar, .customer-filter-bar { grid-template-columns: 1fr; } .history-filter-bar .btn, .customer-filter-bar .btn { width: 100%; } .quick-summary { flex-wrap: wrap; gap: 16px; } }
@media (max-width: 1199.98px) { .movement-filter-bar { grid-template-columns: 1fr 1fr; } .movement-filter-bar .filter-date { grid-column: auto; } }
@media (max-width: 575.98px) { .movement-filter-bar { grid-template-columns: 1fr; } .movement-filter-bar .btn { width: 100%; } }
@media (max-width: 767.98px) { .customer-filter-bar { grid-template-columns: 1fr; } .customer-filter-bar .btn { width: 100%; } }
