/* ==========================================================================
   CYB - Sistema de Almacén · Hoja de estilos principal
   Diseño limpio: superficies blancas, bordes suaves, un solo color de acento.
   ========================================================================== */
:root {
    /* Marca */
    --primary-color: #2453c9;
    --primary-light: #3b6ef5;
    --primary-dark: #1a3a8f;
    --primary-50: #eef3ff;
    --primary-100: #dce6ff;
    --secondary-color: #f59e0b;
    --accent-color: #f97316;

    /* Estados */
    --danger-color: #dc2626;
    --success-color: #16a34a;
    --warning-color: #f59e0b;
    --info-color: #0284c7;

    /* Neutros */
    --light-color: #f1f5f9;
    --dark-color: #1e293b;
    --gray-color: #94a3b8;
    --body-bg: #f5f7fb;
    --surface: #ffffff;
    --text-color: #0f172a;
    --muted: #64748b;
    --border: #e5e9f0;
    --border-strong: #d4dae3;

    /* Sidebar */
    --sidebar-bg: #0d1a3a;
    --sidebar-text: #c3cde3;
    --sidebar-hover: rgba(255, 255, 255, .06);
    --sidebar-active: rgba(59, 110, 245, .22);
    --sidebar-background: var(--sidebar-bg);
    --sidebar-width: 264px;

    /* Forma */
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, .12);
    --ring: 0 0 0 3px rgba(59, 110, 245, .18);
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: var(--font);
    font-size: 14px;
    color: var(--text-color);
    background: var(--body-bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary-color); text-decoration: none; }
a:hover { color: var(--primary-dark); }
h1, h2, h3, h4, h5 { color: var(--text-color); margin: 0 0 12px; font-weight: 650; letter-spacing: -.01em; }
small, .text-muted { color: var(--muted); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-danger { color: var(--danger-color); }
.text-success { color: var(--success-color); }
.hidden, [hidden] { display: none !important; }
::selection { background: var(--primary-100); }

/* ------------------------------------------------------------------ Sidebar */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    overflow-y: auto;
    z-index: 1000;
    display: flex; flex-direction: column;
    transition: transform .25s ease;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 3px; }

.sidebar-brand { padding: 20px 18px 14px; }
.sidebar-brand a { color: #fff; display: flex; align-items: center; gap: 12px; text-decoration: none; }
.sidebar-brand img { width: 40px; height: 40px; object-fit: contain; background: #fff; border-radius: 10px; padding: 3px; flex-shrink: 0; }
.sidebar-brand .brand-name { font-weight: 700; font-size: 15px; letter-spacing: .2px; line-height: 1.25; }
.sidebar-brand .brand-razon { margin-top: 8px; font-size: 11px; color: #8592b0; text-transform: uppercase; letter-spacing: .3px; line-height: 1.35; }

.sidebar-search { padding: 4px 14px 10px; position: relative; }
.sidebar-search i { position: absolute; left: 26px; top: 50%; transform: translateY(-60%); color: #7180a3; font-size: 12px; }
.sidebar-search input {
    width: 100%; padding: 9px 12px 9px 32px; border-radius: var(--radius-sm); border: 1px solid rgba(255,255,255,.08);
    background: rgba(255,255,255,.06); color: #fff; font: inherit; font-size: 13px; outline: none; transition: border-color .15s, background .15s;
}
.sidebar-search input::placeholder { color: #7180a3; }
.sidebar-search kbd {
    position: absolute; right: 24px; top: 50%; transform: translateY(-60%); font: 600 10.5px var(--font); color: #7180a3;
    border: 1px solid rgba(255,255,255,.14); border-radius: 5px; padding: 1px 6px; pointer-events: none;
}
.sidebar-search input:focus + kbd, .sidebar-search input:not(:placeholder-shown) + kbd { display: none; }
.sidebar-search input::-webkit-search-cancel-button { filter: invert(1) opacity(.5); }
.sidebar-search input:focus { border-color: rgba(59,110,245,.7); background: rgba(255,255,255,.09); }
.sidebar-empty { padding: 10px 22px; font-size: 12.5px; color: #7180a3; display: none; }

.sidebar-menu { list-style: none; margin: 0; padding: 6px 10px 18px; flex: 1; }
.sidebar-menu .menu-sep { height: 1px; background: rgba(255,255,255,.07); margin: 10px 8px; }
.sidebar-menu a.menu-link,
.sidebar-menu .menu-group-toggle {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 12px;
    margin: 2px 0;
    color: var(--sidebar-text);
    font-size: 13.5px; font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, color .15s;
    user-select: none;
}
.sidebar-menu a.menu-link i,
.sidebar-menu .menu-group-toggle i.menu-icon { width: 18px; text-align: center; font-size: 14px; color: #8592b0; transition: color .15s; }
.sidebar-menu a.menu-link:hover,
.sidebar-menu .menu-group-toggle:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-menu a.menu-link:hover i,
.sidebar-menu .menu-group-toggle:hover i.menu-icon { color: #fff; }
.sidebar-menu .menu-group-toggle .caret { margin-left: auto; font-size: 10px; color: #7180a3; transition: transform .2s; }
.sidebar-menu .menu-group.open > .menu-group-toggle { color: #fff; }
.sidebar-menu .menu-group.open > .menu-group-toggle i.menu-icon { color: #fff; }
.sidebar-menu .menu-group.open > .menu-group-toggle .caret { transform: rotate(180deg); }
.sidebar-menu .submenu { list-style: none; margin: 0 0 4px 21px; padding: 0 0 0 10px; display: none; border-left: 1px solid rgba(255,255,255,.09); }
.sidebar-menu .menu-group.open > .submenu,
.sidebar-menu .menu-group.buscando > .submenu { display: block; }
.sidebar-menu .submenu a.menu-link { padding: 7px 10px; font-size: 13px; gap: 10px; }
.sidebar-menu .submenu a.menu-link i { font-size: 12.5px; width: 16px; }
.sidebar-menu a.menu-link.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.sidebar-menu a.menu-link.active i { color: #8fb0ff; }
.sidebar-menu .logout-link:hover { background: rgba(220,38,38,.16); }

/* ------------------------------------------------------------------ Layout */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 0 28px 40px;
    min-height: 100vh;
    transition: margin-left .25s ease;
}
body.sidebar-collapsed .sidebar { transform: translateX(-100%); }
body.sidebar-collapsed .main-content { margin-left: 0; }

.header {
    position: sticky; top: 0; z-index: 900;
    background: rgba(245, 247, 251, .85);
    backdrop-filter: saturate(180%) blur(10px);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
    padding: 14px 0;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
}
.header-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.header-titles { min-width: 0; }
.header h1 { font-size: 20px; margin: 0; display: flex; align-items: center; gap: 10px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header .breadcrumb { font-size: 12px; color: var(--muted); margin-bottom: 1px; display: flex; gap: 6px; align-items: center; }
.header .breadcrumb a { color: var(--muted); }
.header .breadcrumb a:hover { color: var(--primary-color); }
.toggle-btn {
    width: 38px; height: 38px; flex-shrink: 0; border-radius: var(--radius-sm); border: 1px solid var(--border); background: #fff;
    color: var(--dark-color); font-size: 15px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
    transition: background .15s, border-color .15s;
}
.toggle-btn:hover { background: var(--light-color); border-color: var(--border-strong); }
.user-info {
    display: flex; align-items: center; gap: 10px; padding: 5px 10px 5px 5px; position: relative; cursor: pointer;
    border-radius: 999px; border: 1px solid var(--border); background: #fff; transition: border-color .15s, box-shadow .15s;
}
.user-info:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.user-avatar {
    width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
    background: linear-gradient(135deg, var(--primary-light), var(--primary-dark));
    color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; text-transform: uppercase;
}
.user-meta { display: flex; flex-direction: column; text-align: left; line-height: 1.2; }
.user-meta strong { color: var(--text-color); font-size: 13px; font-weight: 600; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta span { font-size: 11.5px; color: var(--muted); }
.user-info .fa-chevron-down { font-size: 10px; color: var(--muted); }
.user-dropdown {
    display: none; position: absolute; right: 0; top: calc(100% + 8px); min-width: 210px; background: #fff; padding: 6px;
    border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 1100;
}
.user-dropdown.open { display: block; animation: modalIn .15s ease-out; }
.user-dropdown a, .user-dropdown button {
    display: flex; width: 100%; gap: 10px; align-items: center; padding: 9px 12px; color: var(--text-color); border-radius: var(--radius-sm);
    background: none; border: none; font: inherit; font-size: 13.5px; cursor: pointer; text-decoration: none; text-align: left;
}
.user-dropdown a i, .user-dropdown button i { width: 16px; color: var(--muted); }
.user-dropdown a:hover, .user-dropdown button:hover { background: var(--light-color); }
.user-dropdown form { margin: 4px 0 0; padding-top: 4px; border-top: 1px solid var(--border); }
.user-dropdown form button { color: var(--danger-color); }
.user-dropdown form button i { color: var(--danger-color); }

/* ------------------------------------------------------------------ Dashboard */
.company-banner {
    background: linear-gradient(120deg, var(--primary-dark) 0%, var(--primary-color) 60%, var(--primary-light) 100%);
    color: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow);
    padding: 24px 26px; display: flex; align-items: center; gap: 20px; position: relative; margin: 0 0 24px; overflow: hidden;
}
.company-banner::after {
    content: ""; position: absolute; right: -60px; top: -60px; width: 240px; height: 240px; border-radius: 50%;
    background: rgba(255,255,255,.08); pointer-events: none;
}
.company-banner img { width: 68px; height: 68px; object-fit: contain; background: #fff; border-radius: 14px; padding: 6px; flex-shrink: 0; }
.company-banner h2 { color: #fff; font-size: 22px; margin: 0 0 4px; }
.company-banner p { margin: 0; font-size: 13px; opacity: .9; }
.company-banner .banner-saludo { font-size: 13px; opacity: .85; margin-bottom: 4px; }
.company-banner .banner-edit {
    position: absolute; right: 22px; top: 22px; z-index: 1; color: #fff; font-size: 12.5px; font-weight: 600;
    background: rgba(255,255,255,.16); padding: 7px 12px; border-radius: 999px; transition: background .15s;
}
.company-banner .banner-edit:hover { background: rgba(255,255,255,.26); color: #fff; }

.section-title {
    font-size: 16px; color: var(--text-color); margin: 0 0 14px; display: flex; align-items: center; gap: 10px; font-weight: 650;
}
.page-title-underline { display: inline-block; font-size: 22px; font-weight: 700; }

.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; margin: 0 0 28px; }
.module-card {
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 20px;
    color: var(--text-color); text-decoration: none; transition: transform .15s, box-shadow .15s, border-color .15s;
    display: flex; flex-direction: column; gap: 4px; position: relative;
}
.module-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--primary-100); color: var(--text-color); }
.module-card .emoji, .module-card .module-icon {
    width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
    font-size: 19px; margin-bottom: 12px; background: var(--primary-50); color: var(--primary-color);
}
.module-card h3 { color: var(--text-color); font-size: 15px; margin: 0; }
.module-card p { color: var(--muted); margin: 0; font-size: 13px; }
.module-card .module-go { position: absolute; right: 18px; top: 22px; color: var(--gray-color); font-size: 12px; transition: transform .15s, color .15s; }
.module-card:hover .module-go { transform: translateX(3px); color: var(--primary-color); }
.tono-azul { background: #eef3ff !important; color: #2453c9 !important; }
.tono-verde { background: #e8f8ee !important; color: #15803d !important; }
.tono-naranja { background: #fff4e6 !important; color: #c2410c !important; }
.tono-violeta { background: #f3efff !important; color: #6d28d9 !important; }
.tono-cian { background: #e6f7fb !important; color: #0e7490 !important; }
.tono-rosa { background: #fdecf3 !important; color: #be185d !important; }

.dash-panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin: 0 0 24px; }
.dash-panel { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 18px 20px; }
.dash-panel h4 { color: var(--text-color); padding: 0 0 12px; margin: 0 0 4px; font-size: 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.dash-panel h4 i { color: var(--primary-color); }
.dash-panel ul { list-style: none; margin: 0; padding: 0; }
.dash-panel li { border-bottom: 1px solid var(--border); }
.dash-panel li:last-child { border-bottom: 0; }
.dash-panel li a { display: flex; align-items: center; gap: 10px; padding: 10px 6px; color: var(--text-color); border-radius: var(--radius-sm); }
.dash-panel li a:hover { background: var(--light-color); color: var(--primary-color); }
.dash-panel li a i:first-child { width: 18px; text-align: center; color: var(--muted); }
.dash-panel li a .fa-chevron-right { margin-left: auto; font-size: 11px; color: var(--gray-color); }

/* ------------------------------------------------------------------ Cards */
.card {
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
    padding: 20px; margin-bottom: 20px;
}
.card-header {
    background: transparent; color: var(--text-color); padding: 14px 20px; margin: -20px -20px 18px;
    border-bottom: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0;
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.card-header h3, .card-header h4 { color: var(--text-color); margin: 0; font-size: 15px; }
.card-header .form-control { max-width: 320px; }
.card-title-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }

/* ------------------------------------------------------------------ KPIs */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi {
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm);
    position: relative; overflow: hidden;
}
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--primary-light); }
.kpi .kpi-value { font-size: 24px; font-weight: 700; color: var(--text-color); line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi .kpi-label { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.kpi.kpi-warning::before { background: var(--warning-color); }
.kpi.kpi-success::before { background: var(--success-color); }
.kpi.kpi-danger::before { background: var(--danger-color); }

/* ------------------------------------------------------------------ Botones */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 8px 15px; border: 1px solid transparent; border-radius: var(--radius-sm); cursor: pointer;
    font: inherit; font-size: 13.5px; font-weight: 600; line-height: 1.35;
    color: #fff; background: #64748b; text-decoration: none; white-space: nowrap;
    transition: background .15s, border-color .15s, box-shadow .15s, transform .05s, filter .15s;
}
.btn:hover { filter: brightness(.94); text-decoration: none; color: #fff; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled, .btn.disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btn-primary { background: var(--primary-color); }
.btn-primary:hover { background: var(--primary-dark); filter: none; }
.btn-secondary, .btn-light, .btn-outline {
    background: #fff; color: var(--dark-color); border-color: var(--border-strong); box-shadow: var(--shadow-sm);
}
.btn-secondary:hover, .btn-light:hover, .btn-outline:hover { background: var(--light-color); color: var(--text-color); filter: none; }
.btn-outline { color: var(--primary-color); border-color: var(--primary-100); }
.btn-outline:hover { background: var(--primary-50); color: var(--primary-dark); }
.btn-success { background: var(--success-color); }
.btn-danger { background: var(--danger-color); }
.btn-warning { background: var(--warning-color); color: #fff; }
.btn-info { background: var(--info-color); }
.btn-dark { background: var(--dark-color); }
.btn-violet { background: #6d5ce7; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn-xs { padding: 3px 8px; font-size: 11.5px; border-radius: 6px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }
.btn-icon { width: 32px; height: 30px; padding: 0; }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }

/* ------------------------------------------------------------------ Formularios */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-all { grid-column: 1 / -1; }
.form-group { margin-bottom: 16px; }
.form-grid .form-group { margin-bottom: 0; }
label, .form-label { display: block; font-size: 12.5px; font-weight: 600; color: #334155; margin-bottom: 6px; }
.form-control {
    width: 100%; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font: inherit; font-size: 13.5px;
    background: #fff; color: var(--text-color); transition: border-color .15s, box-shadow .15s;
}
.form-control::placeholder { color: #9aa5b8; }
.form-control:hover { border-color: #c2cad6; }
.form-control:focus { outline: none; border-color: var(--primary-light); box-shadow: var(--ring); }
.form-control[readonly], .form-control:disabled { background: #f6f8fb; color: #475569; }
textarea.form-control { min-height: 84px; resize: vertical; }
select.form-control {
    cursor: pointer; appearance: none; -webkit-appearance: none; padding-right: 34px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
}
select.form-control[multiple] { background-image: none; padding-right: 12px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary-color); width: 15px; height: 15px; vertical-align: middle; }
.form-help { font-size: 12px; color: var(--muted); margin-top: 6px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.check-inline { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; margin: 0; cursor: pointer; }
.req { color: var(--danger-color); }
.field-error { color: var(--danger-color); font-size: 12px; margin-top: 4px; }

.subsection {
    background: #f9fafc; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-top: 18px;
}
.subsection h3 { font-size: 14.5px; color: var(--text-color); margin-bottom: 8px; }
.subsection-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

/* Buscador con resultados */
.search-box { position: relative; }
.search-results {
    position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 50; background: #fff; border: 1px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); max-height: 280px; overflow-y: auto; display: none; padding: 4px;
}
.search-results .opt { padding: 9px 12px; cursor: pointer; border-radius: 6px; }
.search-results .opt:hover { background: var(--primary-50); }
.search-results .opt small { display: block; color: var(--muted); }

/* ------------------------------------------------------------------ Tablas */
.table-responsive { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.table { width: 100%; border-collapse: collapse; background: #fff; }
.table thead th {
    background: #f8fafc; color: #475569; text-align: left; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em;
    padding: 12px; white-space: nowrap; border-bottom: 1px solid var(--border);
}
.table tbody td { padding: 12px; border-bottom: 1px solid #eef1f5; vertical-align: middle; font-size: 13.5px; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: #f8faff; }
.table tfoot td { padding: 12px; font-weight: 700; background: #f8fafc; border-top: 1px solid var(--border); }
.table.table-compact tbody td, .table.table-compact thead th { padding: 8px 10px; }
.table-dark-head thead th { background: #f1f5f9; color: #334155; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table input.form-control, .table select.form-control { padding: 6px 8px; font-size: 12.5px; }
.table select.form-control { padding-right: 28px; background-position: right 8px center; }
.empty-row td { text-align: center; color: var(--muted); padding: 34px !important; }

.pagination { display: flex; gap: 6px; justify-content: center; align-items: center; flex-wrap: wrap; margin-top: 18px; }
.pagination .btn { min-width: 34px; }
.pagination .btn-primary:disabled { opacity: 1; }
.pagination .dots { color: var(--muted); padding: 0 4px; }

/* ------------------------------------------------------------------ Badges (estilo "píldora" suave) */
.badge {
    display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; line-height: 1.5;
    color: #475569; background: #eef1f5; white-space: nowrap;
}
.badge-activo, .badge-active, .badge-completado, .badge-success, .badge-aprobado, .badge-aceptado, .badge-recibida-completa { background: #e7f8ee; color: #15803d; }
.badge-inactivo, .badge-anulado, .badge-danger, .badge-rechazado, .badge-cancelado, .badge-rechazada, .badge-anulada, .badge-urgente { background: #fdecec; color: #b91c1c; }
.badge-pendiente, .badge-warning, .badge-creado, .badge-borrador, .badge-recibida-parcial,
.badge-esperando-aprobacion, .badge-espera-presupuesto, .badge-en-camino-al-almacen, .badge-servicio { background: #fff4e0; color: #b45309; }
.badge-atendiendo, .badge-info, .badge-en-proceso, .badge-procesado, .badge-emitida, .badge-bien { background: #e6f4fb; color: #0369a1; }
.badge-programado, .badge-primary, .badge-aprobada, .badge-oc-generada, .badge-generado, .badge-recibido { background: var(--primary-50); color: var(--primary-color); }
.badge-asignado, .badge-despachando { background: #e6f7f8; color: #0e7490; }
.badge-mixta, .badge-mixta-por-articulo { background: #f3efff; color: #6d28d9; }
.badge-light, .badge-secondary { background: #eef1f5; color: #475569; }
.badge-dark { background: var(--dark-color); color: #fff; }
.badge-outline { background: #fff; color: var(--primary-color); border: 1px solid var(--primary-100); }
.badge-cerrado-con-saldo-no-aprobado { background: #f1f2f4; color: #475467; }
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; background: var(--primary-50); color: var(--primary-dark); font-size: 11.5px; font-weight: 500; margin: 1px 2px; }

/* ------------------------------------------------------------------ Modales */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(15, 23, 42, .45); backdrop-filter: blur(2px); display: none; align-items: flex-start; justify-content: center;
    z-index: 2000; padding: 48px 16px; overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal-box {
    background: #fff; border-radius: var(--radius-lg); box-shadow: 0 24px 60px rgba(15,23,42,.25); width: 100%; max-width: 640px;
    animation: modalIn .18s ease-out;
}
.modal-box.modal-lg { max-width: 920px; }
.modal-box.modal-xl { max-width: 1200px; }
.modal-box.modal-sm { max-width: 420px; }
@keyframes modalIn { from { transform: translateY(-8px) scale(.99); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.modal-head h3 { margin: 0; font-size: 16px; color: var(--text-color); }
.modal-close {
    background: none; border: none; width: 32px; height: 32px; border-radius: var(--radius-sm); font-size: 20px; cursor: pointer;
    color: var(--muted); line-height: 1; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.modal-close:hover { background: var(--light-color); color: var(--text-color); }
.modal-body { padding: 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); background: #f9fafc; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* Alertas / confirmaciones */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13.5px; border: 1px solid transparent; }
.alert-success { background: #ecfdf3; color: #05603a; border-color: #bbf0d0; }
.alert-danger { background: #fef3f2; color: #912018; border-color: #fdd5d1; }
.alert-warning { background: #fffaeb; color: #93370d; border-color: #fde7a8; }
.alert-info { background: #eff6ff; color: #1e4fb8; border-color: #cfe0ff; }

.toast-container { position: fixed; top: 18px; right: 18px; z-index: 3000; display: flex; flex-direction: column; gap: 10px; }
.toast {
    min-width: 280px; max-width: 420px; padding: 13px 16px 13px 42px; border-radius: var(--radius); color: var(--text-color);
    background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: modalIn .2s ease-out; font-size: 13.5px;
    position: relative; font-weight: 500;
}
.toast::before {
    content: "i"; position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; color: #fff; background: var(--dark-color);
}
.toast.success::before { content: "✓"; background: var(--success-color); }
.toast.error::before { content: "✕"; background: var(--danger-color); }
.toast.warning::before { content: "!"; background: var(--warning-color); }
.toast.info::before { background: var(--info-color); }

.dialog-icon { width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 4px auto 14px; font-size: 24px; font-weight: 700; background: #fff4e0; color: #b45309; }
.dialog-icon.exito { background: #e7f8ee; color: #15803d; }
.dialog-icon.error { background: #fdecec; color: #b91c1c; }

.loading { text-align: center; padding: 30px; color: var(--muted); }
.spinner { display: inline-block; width: 30px; height: 30px; border: 3px solid #dbe3ee; border-top-color: var(--primary-light); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tabs .tab-btn {
    background: none; border: none; padding: 10px 14px; cursor: pointer; font: inherit; font-size: 13.5px; color: var(--muted); font-weight: 600;
    border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .15s, border-color .15s;
}
.tabs .tab-btn:hover { color: var(--text-color); }
.tabs .tab-btn.active { color: var(--primary-color); border-bottom-color: var(--primary-color); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ------------------------------------------------------------------ Documentos */
.doc-item {
    display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); background: #fff; margin-top: 8px; flex-wrap: wrap;
}
.doc-item .doc-title { font-weight: 600; color: var(--text-color); display: block; }
.doc-item .doc-extra { font-size: 12px; color: var(--muted); }
.check-card { border: 1px solid var(--border); background: #fff; border-radius: var(--radius-sm); padding: 10px 12px; margin-top: 8px; }
.check-card label { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; cursor: pointer; }
.warning-box { background: #fffaeb; border: 1px solid #fde7a8; color: #93370d; padding: 10px 12px; border-radius: var(--radius-sm); }
.fila-bloqueada { background: #fff7ed !important; }

.pdf-viewer { width: 100%; height: 75vh; border: 0; }

/* Documento imprimible (OC, requerimiento, etc.): se mantiene sobrio a propósito */
.doc-print { background: #fff; padding: 28px; color: #111; font-size: 12px; max-width: 960px; margin: 0 auto; font-family: Arial, Helvetica, sans-serif; }
.doc-print table { width: 100%; border-collapse: collapse; }
.doc-print th, .doc-print td { border: 1px solid #333; padding: 5px 7px; }
.doc-print th { background: #e5e7eb; text-transform: none; letter-spacing: 0; font-size: inherit; color: #111; }
.doc-print .no-border td, .doc-print .no-border th { border: none; }
.doc-print h2 { color: #111; text-align: center; font-size: 16px; }
.firma-box { text-align: center; padding-top: 50px; }
.firma-box img { max-height: 70px; display: block; margin: 0 auto 4px; }
.firma-box .linea { border-top: 1px solid #111; padding-top: 4px; margin: 0 20px; }

/* ------------------------------------------------------------------ Login */
.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: #fff; }
.login-aside {
    position: relative; overflow: hidden; color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
    background: radial-gradient(circle at 20% 15%, #3b6ef5 0%, transparent 45%), radial-gradient(circle at 85% 90%, #1e4fd8 0%, transparent 40%), var(--sidebar-bg);
}
.login-aside::after {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background-image: linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px);
    background-size: 44px 44px; mask-image: linear-gradient(180deg, transparent, #000 40%, #000 60%, transparent);
    -webkit-mask-image: linear-gradient(180deg, transparent, #000 40%, #000 60%, transparent);
}
.login-aside > * { position: relative; z-index: 1; }
.login-marca { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 22px; letter-spacing: .5px; }
.login-marca .marca-icono {
    width: 44px; height: 44px; border-radius: 12px; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.2);
    display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.login-aside h2 { color: #fff; font-size: 34px; line-height: 1.15; margin: 0 0 14px; max-width: 440px; letter-spacing: -.02em; }
.login-aside p { color: #c3cde3; font-size: 15px; max-width: 420px; margin: 0; }
.login-puntos { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; }
.login-puntos li { display: flex; align-items: center; gap: 12px; color: #dfe6f5; font-size: 14px; }
.login-puntos i { width: 30px; height: 30px; border-radius: 8px; background: rgba(255,255,255,.1); display: flex; align-items: center; justify-content: center; font-size: 13px; color: #9db8ff; }
.login-aside .login-pie { font-size: 12px; color: #8592b0; }

.login-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--body-bg); }
.login-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 36px 32px; width: 100%; max-width: 400px; }
.login-simple { display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--body-bg); }
.login-card .login-logo { margin-bottom: 24px; }
.login-card .login-logo .icon {
    width: 48px; height: 48px; border-radius: 12px; background: var(--primary-50); color: var(--primary-color);
    display: flex; align-items: center; justify-content: center; font-size: 20px; margin-bottom: 16px;
}
.login-card .login-logo .marca-movil {
    display: none; width: 44px; height: 44px; border-radius: 12px; background: var(--sidebar-bg); color: #fff;
    align-items: center; justify-content: center; font-weight: 800; font-size: 13px; letter-spacing: .5px; margin-bottom: 16px;
}
.login-card h1 { font-size: 22px; margin: 0 0 4px; }
.login-card p.sub { color: var(--muted); margin: 0; }
.login-card .btn-primary { width: 100%; padding: 11px; font-size: 14.5px; margin-top: 6px; }
.login-card .form-control { padding-top: 11px; padding-bottom: 11px; }
.input-icon { position: relative; }
.input-icon > i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--gray-color); font-size: 14px; pointer-events: none; }
.input-icon .form-control { padding-left: 38px; }
.input-icon .form-control.con-boton { padding-right: 44px; }
.input-icon .ver-clave {
    position: absolute; right: 5px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer;
    color: var(--muted); width: 34px; height: 34px; border-radius: 6px;
}
.input-icon .ver-clave:hover { background: var(--light-color); color: var(--text-color); }

/* ------------------------------------------------------------------ Utilidades */
.flex { display: flex; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .wrap { flex-wrap: wrap; }
.items-center { align-items: center; } .justify-between { justify-content: space-between; } .justify-end { justify-content: flex-end; }
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.w-100 { width: 100%; } .nowrap { white-space: nowrap; } .fw-600 { font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.info-list { display: grid; grid-template-columns: 180px 1fr; gap: 8px 14px; }
.info-list dt { font-weight: 600; color: #475569; }
.info-list dd { margin: 0; }

/* ------------------------------------------------------------------ Responsive */
.sidebar-backdrop { display: none; }
@media (max-width: 992px) {
    .sidebar { transform: translateX(-100%); }
    body.sidebar-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
    body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 999; }
    .main-content { margin-left: 0; padding: 0 16px 30px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .form-grid, .form-grid.cols-3, .form-grid.cols-4 { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: auto; }
    .header { padding: 10px 0; margin-bottom: 16px; }
    .header h1 { font-size: 17px; }
    .header .breadcrumb { display: none; }
    .user-meta, .user-info .fa-chevron-down { display: none; }
    .user-info { padding: 4px; }
    .company-banner { flex-direction: column; text-align: center; padding: 22px 18px; }
    .company-banner .banner-edit { position: static; }
    .module-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .module-card { padding: 16px; }
    .module-card .module-go { display: none; }
    .info-list { grid-template-columns: 1fr; }
    .card-header .form-control, .card-title-bar .form-control { max-width: none; flex: 1 1 100%; }
    .card-title-bar > div:has(.form-control) { flex: 1 1 100% !important; max-width: none !important; }
    .modal-overlay { padding: 16px 10px; }
    .modal-body { padding: 18px; }

    .login-page { grid-template-columns: 1fr; }
    .login-aside { display: none; }
    .login-card { box-shadow: var(--shadow); padding: 30px 22px; }
    .login-card .login-logo .marca-movil { display: inline-flex; }

    /* Tablas como tarjetas */
    .table-responsive:has(.table-cards) { border: 0; background: transparent; }
    .table-cards thead { display: none; }
    .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
    .table-cards { background: transparent; }
    .table-cards tr { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; padding: 8px 4px; box-shadow: var(--shadow-sm); }
    .table-cards tr:hover { background: #fff; }
    .table-cards td { border: none !important; padding: 6px 12px; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
    .table-cards td::before { content: attr(data-label); font-weight: 600; color: var(--muted); text-align: left; font-size: 12.5px; }
    .table-cards td[data-label=""]::before, .table-cards .empty-row td::before { content: none; }
}
@media (max-width: 480px) {
    .module-grid { grid-template-columns: 1fr; }
    .module-card { flex-direction: row; align-items: center; gap: 14px; }
    .module-card .emoji, .module-card .module-icon { margin-bottom: 0; flex-shrink: 0; }
}

@media print {
    .sidebar, .header, .no-print, .toast-container { display: none !important; }
    .main-content { margin: 0; padding: 0; }
    body { background: #fff; }
    .card { box-shadow: none; border: 0; }
}
