/* ERP RD — Hoja de estilos principal */
:root {
    --bg:       #f4f6f9;
    --surface:  #ffffff;
    --border:   #e2e8f0;
    --primary:  #1a56db;
    --success:  #057a55;
    --warning:  #c27803;
    --danger:   #c81e1e;
    --muted:    #6b7280;
    --text:     #111827;
    --sidebar-w: 240px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

/* Layout */
.erp-wrapper { display: flex; height: 100vh; overflow: hidden; }
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.page-content { flex: 1; overflow-y: auto; padding: 20px; }

/* Sidebar */
.sidebar { width: var(--sidebar-w); background: #1e2d3d; display: flex; flex-direction: column;
           overflow-y: auto; transition: width .2s; flex-shrink: 0; }
.sidebar.collapsed { width: 56px; }
.sidebar-brand { padding: 16px 14px; display: flex; align-items: center; gap: 10px;
                 border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-icon { width: 34px; height: 34px; background: #f59e0b; border-radius: 8px;
              display: flex; align-items: center; justify-content: center;
              font-weight: 800; font-size: 12px; color: #000; flex-shrink: 0; }
.brand-name { font-size: 14px; font-weight: 700; color: #fff; white-space: nowrap; }
.brand-sub  { font-size: 11px; color: rgba(255,255,255,.45); white-space: nowrap; overflow: hidden; }
.sidebar-nav { flex: 1; padding: 8px 0; }
.nav-section-label { padding: 10px 14px 4px; font-size: 10px; text-transform: uppercase;
                     letter-spacing: .8px; color: rgba(255,255,255,.3); font-weight: 600; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 14px;
            color: rgba(255,255,255,.6); text-decoration: none; font-size: 13.5px;
            transition: background .12s, color .12s; white-space: nowrap; overflow: hidden; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.active { background: rgba(245,158,11,.25); color: #f59e0b; border-left: 3px solid #f59e0b; padding-left: 11px; font-weight: 700; }
.nav-link:not(.active) { border-left: 3px solid transparent; padding-left: 11px; }
.nav-icon { font-size: 16px; flex-shrink: 0; }
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .nav-link span:not(.nav-icon) { display: none; }
.sidebar-footer { padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.08);
                  display: flex; align-items: center; justify-content: space-between; }
.user-name { font-size: 13px; font-weight: 600; color: #fff; }
.user-role { font-size: 11px; color: rgba(255,255,255,.4); }
.btn-logout { color: rgba(255,255,255,.4); font-size: 18px; text-decoration: none; }

/* Topbar */
.topbar { height: 52px; background: var(--surface); border-bottom: 1px solid var(--border);
          display: flex; align-items: center; padding: 0 20px; gap: 12px; flex-shrink: 0; }
.sidebar-toggle { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--muted); }
.page-title { font-size: 17px; font-weight: 700; flex: 1; }
.topbar-right { display: flex; gap: 8px; }
.empresa-badge, .fecha-badge { background: #f1f5f9; border-radius: 20px; padding: 3px 10px;
                                 font-size: 12px; color: var(--muted); }

/* Alerts */
.alert { padding: 10px 16px; margin: 12px 20px 0; border-radius: 6px; font-size: 13px; }
.alert-danger  { background: #fef2f2; color: var(--danger); border: 1px solid #fca5a5; }
.alert-success { background: #f0fdf4; color: var(--success); border: 1px solid #86efac; }
.alert-warning { background: #fffbeb; color: var(--warning); border: 1px solid #fcd34d; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.card-header { display: flex; align-items: center; justify-content: space-between;
               padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-header h3 { font-size: 14px; font-weight: 700; }
.card > .table { border-top: none; }

/* KPI Grid */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
            padding: 16px 18px; }
.kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
             color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.kpi-value { font-size: 22px; font-weight: 800; }
.kpi-sub   { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Tables */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table thead th { text-align: left; padding: 10px 14px; border-bottom: 2px solid #166534; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: #ffffff; font-weight: 800; white-space: nowrap; background: #166534; }
.table tbody tr { border-bottom: 1px solid var(--border); }
.table tbody tr:last-child { border-bottom: none; }
.table tbody tr:hover { background: #f8fafc; }
.table tbody td { padding: 10px 14px; }
.table.card { border-radius: 8px; }
.text-center { text-align: center; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-emitida, .badge-registrada, .badge-activo { background: #dbeafe; color: #1d4ed8; }
.badge-pagada,  .badge-activo                    { background: #d1fae5; color: #065f46; }
.badge-pendiente                                  { background: #fef3c7; color: #92400e; }
.badge-anulada, .badge-bloqueado                  { background: #fee2e2; color: #991b1b; }
.badge-abono                                      { background: #ede9fe; color: #5b21b6; }

/* Botones */
.btn { display: inline-flex; align-items: center; gap: 5px; padding: 7px 14px;
       border-radius: 6px; border: 1px solid var(--border); background: var(--surface);
       color: var(--text); font-size: 13px; cursor: pointer; text-decoration: none;
       font-weight: 500; transition: background .12s; white-space: nowrap; }
.btn:hover { background: #f1f5f9; }
.btn-primary  { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: #1e40af; }
.btn-danger   { background: #fef2f2; color: var(--danger); border-color: #fca5a5; }
.btn-secondary { background: #f1f5f9; color: var(--text); }
.btn-sm, .btn-xs { padding: 4px 10px; font-size: 12px; }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted);
        text-transform: uppercase; letter-spacing: .3px; margin-bottom: 5px; }
input[type="text"], input[type="email"], input[type="date"],
input[type="number"], input[type="password"], select, textarea {
    width: 100%; padding: 8px 11px; border: 1px solid var(--border);
    border-radius: 6px; font-size: 13.5px; background: #fff; color: var(--text);
    outline: none; transition: border-color .15s; font-family: inherit;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
textarea { resize: vertical; }

.filter-form { display: flex; gap: 8px; align-items: center; }
.filter-form input { width: 140px; }
.toolbar { display: flex; gap: 8px; align-items: center; }

/* Alert list */
.alert-list { list-style: none; padding: 12px 18px; }
.alert-item { display: flex; justify-content: space-between; padding: 8px 12px;
              margin-bottom: 6px; border-radius: 6px; font-size: 13px; }
.alert-item.alert-warning { background: #fffbeb; border-left: 3px solid #f59e0b; }
.alert-item.alert-danger  { background: #fef2f2; border-left: 3px solid #ef4444; }

/* Misc */
.row-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.mt-4 { margin-top: 16px; } .mt-3 { margin-top: 12px; } .mt-2 { margin-top: 8px; }
.text-muted { color: var(--muted); }
.text-warning { color: var(--warning); }
.hidden { display: none; }
.totales-row td { padding: 4px 14px; }
.total-general td { font-size: 16px; font-weight: 800; color: var(--primary); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 14px;
                border-top: 1px solid var(--border); margin-top: 14px; }
.info-box { background: #f0f9ff; border: 1px solid #bae6fd; border-radius: 6px;
            padding: 8px 12px; font-size: 12px; margin-top: 6px; }
.actions { white-space: nowrap; }
.actions .btn { margin-right: 4px; }

/* Login */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center;
              background: #1e2d3d; }
.login-card { background: #fff; border-radius: 12px; padding: 40px; width: 380px; }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .brand-icon { margin: 0 auto 10px; width: 52px; height: 52px; font-size: 18px; }
.login-title { font-size: 20px; font-weight: 800; }
.login-sub   { font-size: 13px; color: var(--muted); }

@media (max-width: 768px) {
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .row-2col { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
}
select { background-color: #f0fdf4; border-color: #166534; color: #166534; font-weight: 600; }
select:focus { border-color: #14532d; background-color: #dcfce7; }
select option { background: #ffffff; color: #111827; font-weight: 400; }