* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f1f5f9;
    color: #1e293b;
    line-height: 1.45;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: #0a3161;
    color: #ffffff;
    border-bottom: 3px solid #066cda;
}

.topbar-inner {
    max-width: 1340px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-sm {
    height: 44px;
    width: auto;
    border-radius: 5px;
    background: #ffffff;
    padding: 3px;
}

.brand h1 {
    font-size: 1.15rem;
    font-weight: 700;
}

.brand small {
    color: #cbd5e1;
    font-size: 0.8rem;
}

.user-box {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.user-meta {
    text-align: right;
    font-size: 0.82rem;
}

.user-meta strong {
    display: block;
    color: #ffffff;
}

.user-meta span {
    color: #cbd5e1;
}

.subnav {
    background: #072448;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.subnav-inner {
    max-width: 1340px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    gap: 4px;
    overflow-x: auto;
}

.nav-link {
    color: #dbeafe;
    text-decoration: none;
    padding: 10px 14px;
    font-size: 0.86rem;
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
}

.nav-link:hover,
.nav-link.active {
    color: #ffffff;
    background: rgba(6, 108, 218, 0.25);
    border-bottom-color: #38bdf8;
}

.container {
    width: 100%;
    max-width: 1340px;
    margin: 20px auto;
    padding: 0 20px;
    flex: 1;
}

/* KPIs */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.kpi-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-left: 4px solid #0a3161;
    border-radius: 8px;
    padding: 13px 14px;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: transform 0.15s, box-shadow 0.15s;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.08);
}

.kpi-card.kpi-primary { border-left-color: #066cda; }
.kpi-card.kpi-danger  { border-left-color: #dc2626; }
.kpi-card.kpi-warning { border-left-color: #d97706; }
.kpi-card.kpi-purple  { border-left-color: #7c3aed; }
.kpi-card.kpi-info    { border-left-color: #0284c7; }
.kpi-card.kpi-success { border-left-color: #16a34a; }

.kpi-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
}

.kpi-value {
    display: block;
    font-size: 1.55rem;
    color: #0a3161;
    margin: 2px 0;
}

.kpi-card small {
    font-size: 0.76rem;
    color: #64748b;
}

/* Panels */
.panel {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 18px 20px;
    margin-bottom: 18px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.panel h2 {
    font-size: 1.05rem;
    color: #0a3161;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.quick-actions,
.filter-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.input-sm {
    padding: 7px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    font-size: 0.86rem;
    background: #ffffff;
}

.input-sm:focus {
    outline: none;
    border-color: #066cda;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 5px;
    text-decoration: none;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.15s;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.8rem;
}

.btn-primary {
    background: #066cda;
    color: #ffffff;
}

.btn-primary:hover {
    background: #0556b0;
}

.btn-secondary {
    background: #e2e8f0;
    color: #1e293b;
}

.btn-secondary:hover {
    background: #cbd5e1;
}

.btn-danger-outline {
    background: transparent;
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.5);
}

.btn-danger-outline:hover {
    background: #dc2626;
    border-color: #dc2626;
}

/* Flow diagram */
.flow-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
}

.flow-step {
    border: 1px solid #cbd5e1;
    border-top: 3px solid #066cda;
    border-radius: 6px;
    padding: 12px;
    background: #f8fafc;
}

.step-tag {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    color: #066cda;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.flow-step strong {
    display: block;
    font-size: 0.9rem;
    color: #0a3161;
    margin-bottom: 4px;
}

.flow-step p {
    font-size: 0.81rem;
    color: #475569;
}

/* Table */
.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
}

.data-table th,
.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
    vertical-align: top;
}

.data-table th {
    background: #f8fafc;
    color: #0a3161;
    font-weight: 700;
    border-top: 1px solid #e2e8f0;
}

.data-table tr:hover td {
    background: #f8fafc;
}

.doc-tag {
    color: #066cda;
    font-weight: 600;
}

.text-muted {
    color: #64748b;
}

.text-danger {
    color: #dc2626;
    font-weight: 600;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 700;
}

.badge-primary { background: #dbeafe; color: #1d4ed8; }
.badge-info    { background: #e0f2fe; color: #0369a1; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #b91c1c; }
.badge-purple  { background: #f3e8ff; color: #6d28d9; }
.badge-success { background: #dcfce7; color: #15803d; }
.badge-neutral { background: #e2e8f0; color: #334155; }

.empty {
    text-align: center;
    color: #64748b;
    padding: 24px;
}

.footer {
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    padding: 12px 0;
    font-size: 0.8rem;
    color: #64748b;
}

.footer-inner {
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

/* Formularios y alertas */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.alert-danger {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
    border-left: 4px solid #dc2626;
}

.alert-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
    border-left: 4px solid #16a34a;
}

.alert-success h3 {
    font-size: 1rem;
    margin-bottom: 4px;
}

.error-list {
    margin-top: 6px;
    padding-left: 20px;
}

.form-section {
    border: 1px solid #dbe3ee;
    border-radius: 7px;
    padding: 16px;
    margin-bottom: 16px;
    background: #f8fafc;
}

.form-section legend {
    padding: 0 8px;
    font-weight: 700;
    font-size: 0.92rem;
    color: #0a3161;
}

.grid-2,
.grid-3,
.grid-4 {
    display: grid;
    gap: 12px;
    margin-bottom: 12px;
}

.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.span-2 {
    grid-column: span 2;
}

@media (max-width: 720px) {
    .span-2 {
        grid-column: span 1;
    }
}

.form-group label {
    display: block;
    font-size: 0.84rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 5px;
}

.form-control {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    font-size: 0.9rem;
    background: #ffffff;
    color: #0f172a;
}

.form-control:focus {
    outline: none;
    border-color: #066cda;
    box-shadow: 0 0 0 3px rgba(6, 108, 218, 0.14);
}

.form-control:disabled {
    background: #e2e8f0;
    color: #64748b;
    cursor: not-allowed;
}

.checkbox-row {
    background: #fffbeb;
    border: 1px solid #fde68a;
    padding: 10px 12px;
    border-radius: 6px;
}

.check-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    color: #78350f;
    cursor: pointer;
}

.form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}