:root {
    color-scheme: light;
    --bg: #f6f8fb;
    --surface: #ffffff;
    --surface-strong: #f0f4f8;
    --border: #d8e2ef;
    --text: #1e293b;
    --muted: #64748b;
    --primary: #FF8F02;
    --primary-dark: #E67E00;
    --primary-soft: #FFF4E5;
    --primary-alt: #FF8A00;
    --primary-muted: #b45309;
    --primary-muted-2: #c46a00;
    --warning: #ea580c;
    --primary-shadow: rgba(255, 143, 2, 0.18);
    --primary-shadow-strong: rgba(255, 143, 2, 0.32);
    --success: #16a34a;
    --danger: #dc2626;
    --shadow: 0 24px 64px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
}

html, body {
    height: 100%;
}

.layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

.sidebar {
    width: 280px;
    padding: 32px 24px;
    background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 4px 0 30px rgba(15, 23, 42, 0.18);
    position: sticky;
    top: 0;
    height: 100vh;
    max-height: 100vh;
    overflow-y: auto;
}

.sidebar .brand {
    display: grid;
    gap: 10px;
    align-items: center;
    grid-template-columns: auto 1fr;
    margin-bottom: 28px;
}

.brand-mark {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    background: var(--primary);
    border-radius: 12px;
    font-size: 1.2rem;
    font-weight: 800;
    color: white;
}

.brand strong {
    display: block;
    font-size: 1.2rem;
    letter-spacing: 0.06em;
}

.brand p {
    margin: 0;
    color: rgba(255, 255, 255, 0.65);
    font-size: 0.85rem;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 14px;
    color: rgba(255, 255, 255, 0.92);
    text-decoration: none;
    padding: 14px 18px;
    border-radius: 16px;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.04);
    transition: background 180ms ease, transform 180ms ease, color 180ms ease;
}

.sidebar nav a:hover,
.sidebar nav a.active {
    background: rgba(255, 143, 2, 0.16);
    color: white;
    transform: translateX(1px);
}

.sidebar nav a.disabled {
    opacity: 0.55;
    pointer-events: none;
}

.sidebar nav a i {
    width: 24px;
    text-align: center;
    font-size: 0.95rem;
}

.sidebar-footer {
    margin-top: 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 20px;
}

.sidebar-footer span {
    display: block;
    margin-bottom: 4px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.sidebar-footer .sidebar-user-name {
    display: block;
    margin-bottom: 14px;
    color: #ffffff;
    font-size: 1rem;
    font-weight: 700;
}

.sidebar-footer .link-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    transition: background 180ms ease, transform 180ms ease;
}

.sidebar-footer .link-button:hover {
    background: rgba(255, 143, 2, 0.22);
    transform: translateX(1px);
}

.content {
    padding: 32px 44px 36px 48px;
    background: var(--bg);
    overflow: auto;
    margin-left: 0;
    min-height: 100vh;
}

.content.auth-page {
    margin-left: 0;
    padding: 32px;
    background: linear-gradient(180deg, #0d1220 0%, #111827 58%, #0b1220 100%);
}

.logout-form {
    margin: 0;
}

.topbar {
    margin-bottom: 24px;
}

.topbar h1 {
    margin: 0 0 4px;
    font-size: 2rem;
}

.subtitle {
    margin: 0;
    color: var(--muted);
}

.page-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}

.search-form {
    display: flex;
    width: min(100%, 640px);
    gap: 8px;
    position: relative;
}

.search-field-wrapper {
    position: relative;
    flex: 1;
}

.search-form input {
    width: 100%;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 16px;
    padding: 14px 18px;
    background: #fff;
    color: var(--text);
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.08);
    transition: border-color 180ms ease, box-shadow 180ms ease;
}

.search-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(255, 143, 2, 0.12);
}

.search-autocomplete {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 18px;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.12);
    overflow: hidden;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 180ms ease, transform 180ms ease;
    z-index: 20;
    pointer-events: none;
}

.search-autocomplete.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.search-suggestion {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    text-align: left;
    border: none;
    background: transparent;
    padding: 14px 18px;
    cursor: pointer;
    color: var(--text);
    font-size: 0.95rem;
    transition: background 120ms ease;
}

.search-suggestion:hover {
    background: #f1f5f9;
}

.search-suggestion .persona-ac-name {
    font-weight: 500;
}

.search-suggestion .persona-ac-cc {
    color: var(--muted);
    font-size: 0.82rem;
    white-space: nowrap;
}

.search-form button {
    border: none;
    background: var(--primary);
    color: white;
    border-radius: 16px;
    padding: 14px 22px;
    cursor: pointer;
    transition: background 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.search-form button:hover {
    transform: translateY(-1px);
}

.search-form button:hover,
.btn.primary:hover {
    background: var(--primary-dark);
}

.search-form button:focus-visible,
.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px var(--primary-shadow);
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.excel-btn {
    background: #21a366;
    color: #fff;
    border-color: transparent;
    white-space: nowrap;
    font-weight: 600;
    box-shadow: 0 8px 20px rgba(33, 163, 102, 0.32);
}

.excel-btn:hover {
    background: #1a8a55;
    color: #fff;
}

.excel-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px rgba(33, 163, 102, 0.35);
}

.summary {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.summary span {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
}

.table-card,
.form-card,
.detail-card,
.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.table-card {
    padding: 28px;
    margin: 0 auto;
    max-width: 100%;
    overflow-x: auto;
    background: var(--surface);
}

.table-card table {
    width: 100%;
    min-width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    background: white;
    border-radius: 20px;
    overflow: hidden;
}

thead th {
    text-align: left;
    padding: 16px 12px;
    font-weight: 700;
    color: var(--muted);
    border-bottom: 1px solid rgba(148, 163, 184, 0.24);
    background: rgba(248, 250, 252, 0.95);
}

tbody td {
    padding: 14px 12px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.9);
    font-size: 0.95rem;
    color: var(--text);
}

tbody tr:hover {
    background: var(--surface-strong);
}

tbody tr:last-child td {
    border-bottom: none;
}

.table-card {
    overflow-x: auto;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    font-weight: 500;
    text-decoration: none;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 180ms ease, border-color 180ms ease, box-shadow 180ms ease, color 180ms ease;
}

.btn:hover {
    background: var(--surface-strong);
    border-color: #c3d0e0;
}

.btn.primary {
    background: var(--primary);
    color: white;
    border-color: transparent;
}

.btn.primary:hover {
    background: var(--primary-dark);
    border-color: transparent;
}

.btn.primary:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px var(--primary-shadow);
}

.btn.small {
    padding: 8px 12px;
    font-size: 0.85rem;
}

.message {
    padding: 16px 18px;
    border-radius: 16px;
    margin-bottom: 16px;
}

.message.success { background: #ecfdf5; color: #166534; }
.message.error { background: #fee2e2; color: #991b1b; }
.message.info { background: #e0f2fe; color: #0369a1; }

.form-card {
    padding: 32px 36px 36px;
    max-width: 980px;
    margin: 0 auto;
}

.form-card-head {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 26px;
}

.form-card-icon {
    flex: none;
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 1.3rem;
}

.form-card h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text);
}

.form-intro {
    margin: 4px 0 0;
    color: var(--muted);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field-group:has(textarea) {
    grid-column: 1 / -1;
}

.field-group label {
    font-weight: 600;
    color: var(--muted);
}

.field-group input,
.field-group textarea,
.field-group select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 14px;
    background: #fff;
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 180ms ease, box-shadow 180ms ease;
}

.field-group textarea {
    resize: vertical;
    min-height: 96px;
}

.field-group input:focus,
.field-group textarea:focus,
.field-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-shadow);
}

.field-group.has-error input,
.field-group.has-error textarea,
.field-group.has-error select {
    border-color: var(--danger);
}

.field-error {
    color: var(--danger);
    font-size: 0.9rem;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-top: 1px solid var(--border);
    padding-top: 22px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-top: 20px;
}

.detail-actions {
    margin-top: 28px;
    display: flex;
    gap: 14px;
}

.login-card {
    max-width: 520px;
    width: 100%;
    margin: 0 auto;
    background: #ffffff;
    border-radius: 32px;
    box-shadow: 0 28px 90px rgba(15, 23, 42, 0.16);
    padding: 32px;
    color: var(--text);
}

.login-card h2 {
    margin: 0 0 20px;
    color: #111827;
    font-size: 2rem;
}

.login-card form {
    display: grid;
    gap: 16px;
    background: transparent;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
}

.login-card label {
    color: var(--muted);
}

.login-card input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 14px;
    background: white;
    color: var(--text);
}

.login-card button {
    width: 100%;
    margin-top: 8px;
}

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    background: radial-gradient(circle at top left, rgba(255, 143, 2, 0.14), transparent 28%),
                radial-gradient(circle at bottom right, rgba(15, 23, 42, 0.98), transparent 35%),
                linear-gradient(180deg, #0a1220 0%, #111827 100%);
}

.auth-page .page-content {
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    padding: 0;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
}

.auth-page .login-card {
    background: #ffffff;
    border-radius: 32px;
    padding: 34px 36px;
    box-shadow: 0 30px 90px rgba(15, 23, 42, 0.18);
}

@media (max-width: 960px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; max-height: none; flex-direction: row; align-items: center; justify-content: space-between; padding: 18px; }
    .sidebar nav { display: flex; gap: 8px; overflow-x: auto; }
    .sidebar-footer { display: none; }
    .search-form { width: 100%; }
    .form-grid, .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
    .topbar h1 { font-size: 1.6rem; }
    thead th, tbody td { padding: 12px 8px; }
    .sidebar { padding: 14px; }
}

/* --- Badges de estado --- */
.estado {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}
.estado-pendiente { background: #fef3c7; color: #92400e; }
.estado-aprobada { background: #dcfce7; color: #166534; }
.estado-rechazada { background: #fee2e2; color: #991b1b; }

/* --- Variantes de botón --- */
.btn.warning {
    background: #f59e0b;
    color: #fff;
    border-color: transparent;
}
.btn.warning:hover { background: #d97706; color: #fff; }
.btn.danger {
    background: #dc2626;
    color: #fff;
    border-color: transparent;
}
.btn.danger:hover { background: #b91c1c; color: #fff; }

/* --- Caja de rechazo en el detalle --- */
.reject-box {
    margin-top: 24px;
    padding: 20px;
    border: 1px solid rgba(220, 38, 38, 0.25);
    border-radius: 16px;
    background: #fff7f7;
}
.reject-box h3 {
    margin: 0 0 12px;
    color: #991b1b;
    font-size: 1.05rem;
}

/* --- Autocompletado de personal (buscable por nombre o cédula) --- */
.persona-ac-wrapper { position: relative; }
.persona-ac-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 14px;
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.14);
    overflow: hidden;
    z-index: 30;
    display: none;
    max-height: 280px;
    overflow-y: auto;
}
.persona-ac-dropdown.visible { display: block; }
.persona-ac-item {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    text-align: left;
    border: none;
    background: transparent;
    padding: 11px 16px;
    cursor: pointer;
    color: var(--text);
    font-size: 0.92rem;
}
.persona-ac-item:hover { background: #f1f5f9; }
.persona-ac-name { font-weight: 500; }
.persona-ac-cc {
    color: var(--muted);
    font-size: 0.82rem;
    white-space: nowrap;
}

/* --- Margen interno de la tarjeta de detalle --- */
.detail-card {
    padding: 28px 32px 32px;
}

/* --- Asterisco de campo obligatorio (estándar en rojo) --- */
.req {
    color: #dc2626;
    font-weight: 700;
    margin-left: 2px;
}

/* ===================================================================
   Barra de filtro del tablero (rediseño)
   =================================================================== */
.filterbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px 24px;
    flex-wrap: wrap;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 16px 18px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
}

.filterbar .search {
    display: flex;
    align-items: stretch;
    gap: 10px;
    flex: 1 1 360px;
    min-width: 260px;
    position: relative;
}

.search-box {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 4px;
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: 14px;
    padding: 0 8px 0 14px;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(255, 143, 2, 0.14);
}

.search-box-icon {
    color: var(--muted);
    font-size: 0.95rem;
    flex: none;
}

.search-box input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    padding: 13px 8px;
    font-size: 0.95rem;
    color: var(--text);
}

.search-box input::placeholder { color: #94a3b8; }

.search-box-clear {
    flex: none;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: var(--muted);
    text-decoration: none;
    transition: background 140ms ease, color 140ms ease;
}

.search-box-clear:hover {
    background: var(--surface-strong);
    color: var(--text);
}

.search-go {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: none;
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    padding: 0 22px;
    border-radius: 14px;
    cursor: pointer;
    transition: background 160ms ease, transform 160ms ease;
}

.search-go:hover { background: var(--primary-dark); transform: translateY(-1px); }
.search-go:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--primary-shadow); }

/* Dropdown de sugerencias */
.search-suggest {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 22px 48px rgba(15, 23, 42, 0.16);
    padding: 6px;
    z-index: 40;
    display: none;
    max-height: 340px;
    overflow-y: auto;
}

.search-suggest.visible { display: block; }

.search-suggest .search-suggestion {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    text-align: left;
    border: none;
    background: transparent;
    border-radius: 10px;
    padding: 11px 12px;
    cursor: pointer;
    color: var(--text);
    font-size: 0.93rem;
    transition: background 120ms ease;
}

.search-suggest .search-suggestion:hover { background: var(--surface-strong); }
.search-suggest .persona-ac-name { font-weight: 500; }

.search-suggest .persona-ac-cc {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    background: #eef2f7;
    border: 1px solid var(--border);
    padding: 3px 10px;
    border-radius: 999px;
    white-space: nowrap;
}

.filterbar-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.filterbar .summary span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.filterbar .summary span i { color: var(--primary); font-size: 0.8rem; }

/* Aviso de filtro activo */
.filter-active {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--primary-soft);
    color: var(--primary-muted);
    border: 1px solid rgba(255, 143, 2, 0.28);
    border-radius: 999px;
    padding: 8px 16px;
    font-size: 0.9rem;
    align-self: flex-start;
}

.filter-active strong { color: var(--text); }

.filter-active a {
    color: var(--primary-dark);
    font-weight: 600;
    text-decoration: none;
    margin-left: 2px;
}

.filter-active a:hover { text-decoration: underline; }

@media (max-width: 720px) {
    .filterbar .search { flex-basis: 100%; }
    .search-go { padding: 0 16px; }
}

/* --- Filtro rápido por estado (segmentado) --- */
.quick-filter {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.qf-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    transition: background 140ms ease, color 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.qf-chip i { font-size: 0.85rem; }

.qf-chip:not(.qf-active):hover {
    border-color: #c3d0e0;
    background: var(--surface-strong);
    color: var(--text);
}

.qf-count {
    display: inline-grid;
    place-items: center;
    min-width: 22px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--surface-strong);
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 700;
}

/* Estado activo (encendido) */
.qf-chip.qf-active {
    color: #fff;
    border-color: transparent;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.14);
}

.qf-chip.qf-active .qf-count {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

.qf-active:not(.qf-pendiente):not(.qf-aprobada):not(.qf-rechazada) { background: #334155; }
.qf-pendiente.qf-active { background: #f59e0b; }
.qf-aprobada.qf-active { background: #16a34a; }
.qf-rechazada.qf-active { background: #dc2626; }
