:root {
    --primary: #1d4ed8;
    --primary-dark: #1e3a8a;
    --bg: #f5f6f8;
    --card: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --sidebar-width: 220px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.loading-screen {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.login-screen {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 100%);
}

.login-card {
    background: var(--card);
    border-radius: 14px;
    padding: 40px;
    width: 360px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}

.login-title { margin: 0 0 4px; font-size: 26px; font-weight: 700; color: var(--primary-dark); }
.login-sub { margin: 0 0 24px; color: var(--text-muted); font-size: 13px; }
.login-error { color: #dc2626; font-size: 13px; margin-bottom: 12px; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-muted); }
.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
}
.form-control:focus { outline: none; border-color: var(--primary); }

.btn {
    padding: 9px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #f1f5f9; color: var(--text); }
.btn-block { width: 100%; justify-content: center; }

.app { display: flex; height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: #0f172a;
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    padding: 20px 0;
}

.sidebar-brand { font-size: 18px; font-weight: 700; color: white; padding: 0 20px 20px; }

.sidebar-nav { flex: 1; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 14px;
}
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,0.06); color: white; }

.sidebar-footer { padding: 0 20px; }
.sidebar-user { font-size: 13px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 2px; }
.agency-badge { color: #64748b; font-size: 11px; }

.main { flex: 1; overflow-y: auto; padding: 28px 32px; }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-header h1 { margin: 0; font-size: 22px; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 14px; }

.badge-success { background: #dcfce7; color: #15803d; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-muted { background: #f1f5f9; color: #64748b; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }

.switch { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }

/* Botones icono */
.btn-icon {
    background: none; border: none; cursor: pointer;
    color: #64748b; padding: 6px; border-radius: 6px; font-size: 13px;
}
.btn-icon:hover { background: #f1f5f9; color: var(--primary); }

/* Badges de estado */
.badge-success, .badge-muted, .badge-warning, .badge-info, .badge-danger {
    display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.badge-success { background: #dcfce7; color: #15803d; }
.badge-muted { background: #f1f5f9; color: #64748b; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-info { background: #dbeafe; color: #1d4ed8; }
.badge-danger { background: #fee2e2; color: #b91c1c; }

/* Formularios: filas de 2 columnas, marca de requerido */
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
label.required::after { content: ' *'; color: #dc2626; }

/* Stat cards (resumen de comisiones, etc.) */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px; text-align: center; }
.stat-value { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.stat-label { font-size: 12px; color: var(--text-muted); }

/* Modal */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(15,23,42,0.5);
    display: flex; align-items: center; justify-content: center; z-index: 1000;
    padding: 20px;
}
.modal-box {
    background: var(--card); border-radius: 14px; max-height: 88vh; overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 17px; }
.modal-close { background: none; border: none; font-size: 22px; line-height: 1; cursor: pointer; color: #94a3b8; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px 22px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
