:root {
    --sidebar-bg: #0F2A1F;
    --sidebar-bg-hover: #1B3D2C;
    --sidebar-text: #A8C3B4;
    --sidebar-text-active: #FFFFFF;
    --accent: #16A34A;
    --accent-light: #4ADE80;
    --accent-dark: #15803D;
    --bg-page: #F5F7F5;
    --bg-card: #FFFFFF;
    --border: #E2E8E4;
    --text-primary: #14211A;
    --text-secondary: #5B6B62;
    --estado-abierto: #F59E0B;
    --estado-proceso: #0D9488;
    --estado-pausa: #94A3B8;
    --estado-cerrado: #16A34A;
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    margin: 0;
    background-color: var(--bg-page);
    color: var(--text-primary);
    font-size: 14px;
}

/* ---------- Layout general ---------- */

.app-shell {
    display: flex;
    min-height: 100vh;
}

.content {
    flex: 1;
    padding: 32px 40px;
}

/* ---------- Sidebar ---------- */

.sidebar {
    width: 240px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}


.sidebar-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand-logo {
    width: 78px;
    height: 78px;
    object-fit: contain;
}

.brand-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    line-height: 3.5;
}

.brand-name-main {
    color: var(--sidebar-text-active);
    font-weight: 700;
    font-size: 15px;
}

.brand-name-sub {
    color: var(--sidebar-text);
    font-weight: 500;
    font-size: 11.5px;
    margin-left: -15px;
}


.brand-mark {
    color: var(--accent-light);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-group {
    margin-bottom: 22px;
}

.nav-group-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(168, 195, 180, 0.55);
    padding: 0 12px 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius);
    color: var(--sidebar-text);
    text-decoration: none;
    font-weight: 500;
    font-size: 13.5px;
    margin-bottom: 2px;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-link:hover {
    background-color: var(--sidebar-bg-hover);
    color: var(--sidebar-text-active);
}

.nav-link.active {
    background-color: var(--accent-dark);
    color: #FFFFFF;
}

.nav-icon {
    width: 16px;
    text-align: center;
    opacity: 0.85;
}

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

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
    text-transform: uppercase;
}

.user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
    overflow: hidden;
}

.user-name {
    color: var(--sidebar-text-active);
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 11.5px;
    color: rgba(168, 195, 180, 0.7);
    text-transform: capitalize;
}

.logout-link {
    display: block;
    font-size: 12.5px;
    color: rgba(168, 195, 180, 0.7);
    text-decoration: none;
}

.logout-link:hover {
    color: var(--sidebar-text-active);
}

/* ---------- Tipografía general de contenido ---------- */

h1, h2, h3 {
    color: var(--text-primary);
    font-weight: 700;
}

h2 {
    font-size: 22px;
    margin-bottom: 20px;
}

/* ---------- Tarjetas ---------- */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

/* ---------- Botones ---------- */

button, .btn {
    background-color: var(--accent);
    color: white;
    border: none;
    padding: 9px 16px;
    border-radius: var(--radius);
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 13.5px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

button:hover, .btn:hover {
    background-color: var(--accent-dark);
}

.btn-light {
    background-color: #DCFCE7;
    color: var(--accent-dark);
}

.btn-light:hover {
    background-color: #BBF7D0;
}

/* ---------- Formularios ---------- */

input, textarea, select {
    font-family: 'Inter', sans-serif;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    font-size: 13.5px;
    width: 100%;
    background: white;
    color: var(--text-primary);
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.12);
}

label {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 6px;
}

/* ---------- Tablas ---------- */

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

th {
    background-color: #FAFBFA;
    color: var(--text-secondary);
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
    color: var(--text-primary);
}

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

tr:hover td {
    background-color: #FAFBFA;
}

table a {
    color: var(--accent-dark);
    font-weight: 600;
    text-decoration: none;
}

table a:hover {
    text-decoration: underline;
}

/* ---------- Badges de estado ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.badge-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.badge-abierto { background: #FEF3C7; color: #92400E; }
.badge-abierto .badge-dot { background: var(--estado-abierto); }

.badge-en-proceso { background: #CCFBF1; color: #115E59; }
.badge-en-proceso .badge-dot { background: var(--estado-proceso); }

.badge-en-pausa { background: #F1F5F9; color: #475569; }
.badge-en-pausa .badge-dot { background: var(--estado-pausa); }

.badge-cerrado { background: #DCFCE7; color: #166534; }
.badge-cerrado .badge-dot { background: var(--estado-cerrado); }

/* ---------- Login ---------- */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--sidebar-bg);
}

.login-container {
    max-width: 380px;
    width: 100%;
    background: var(--bg-card);
    padding: 36px;
    border-radius: 12px;
    text-align: center;
}

.login-container h1 {
    font-size: 18px;
    margin-bottom: 4px;
}

.login-container h2 {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.login-container form {
    text-align: left;
}

.login-container input {
    max-width: 100%;
}

.login-container button {
    width: 100%;
    margin-top: 6px;
}

.flash-messages {
    color: #DC2626;
    background: #FEF2F2;
    border-radius: var(--radius);
    list-style: none;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 16px;
}

/* ---------- Dashboard ---------- */

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
}

.grafica-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.grafica-card h3 {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 0;
}
.grafica-card canvas {
    max-height: 260px;
}

/* ---------- Detalle de ticket / notas ---------- */

.ticket-detalle, .ticket-acciones, .ticket-notas, .usuario-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.nota {
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
}

.nota:last-child {
    border-bottom: none;
}

.nota small {
    color: var(--text-secondary);
}

/* ---------- Formularios modernos ---------- */

.form-card {
    max-width: 100%;
}

.field-group {
    margin-bottom: 22px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* Select con flecha personalizada */

.select-wrap {
    position: relative;
}

.select-wrap select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 36px;
    cursor: pointer;
}

.select-wrap::after {
    content: '⌄';
    position: absolute;
    right: 14px;
    top: 38px;
    color: var(--text-secondary);
    pointer-events: none;
    font-size: 15px;
}

/* Selector de prioridad tipo chips */

.priority-picker {
    display: flex;
    gap: 8px;
}

.priority-picker input[type="radio"] {
    display: none;
}

.priority-picker label {
    flex: 1;
    text-align: center;
    padding: 10px 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-secondary);
    background: white;
    margin-bottom: 0;
    transition: all 0.15s ease;
}

.priority-picker input[type="radio"]:checked + label {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* Toggle switches para permisos */

.permiso-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 0;
    border-bottom: 1px solid var(--border);
}

.permiso-row:last-of-type {
    border-bottom: none;
}

.permiso-nombre {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-primary);
}

.switch {
    position: relative;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch .slider {
    position: absolute;
    inset: 0;
    background: #D3DCD6;
    border-radius: 999px;
    cursor: pointer;
    transition: 0.2s;
}

.switch .slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    top: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.switch input:checked + .slider {
    background: var(--accent);
}

.switch input:checked + .slider::before {
    transform: translateX(18px);
}

/* Cabecera de tarjeta de usuario en administración */

.usuario-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.usuario-card-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
    text-transform: uppercase;
}

.usuario-card-header h3 {
    margin: 0;
    font-size: 14.5px;
}

.usuario-card-header .rol-tag {
    font-size: 11.5px;
    color: var(--text-secondary);
    text-transform: capitalize;
}

/* ---------- Modal de ticket ---------- */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 42, 31, 0.55);
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-overlay.open {
    display: flex;
}

.modal-box {
    background: white;
    width: 840px;
    max-width: 92vw;
    max-height: 85vh;
    overflow-y: auto;
    border-radius: 12px;
    padding: 28px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 18px;
}

.modal-header h3 {
    margin: 0 0 6px 0;
    font-size: 17px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    background: none;
    color: var(--text-primary);
}

.modal-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.modal-meta span.tag {
    background: #F1F5F0;
    color: var(--text-secondary);
    font-size: 11.5px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 999px;
}

.modal-descripcion {
    font-size: 13.5px;
    color: var(--text-primary);
    line-height: 1.6;
    margin-bottom: 20px;
}

.modal-section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.modal-nota {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.modal-nota small {
    display: block;
    color: var(--text-secondary);
    margin-top: 3px;
    font-size: 11.5px;
}

.modal-nota-form textarea {
    max-width: 100%;
    margin-bottom: 10px;
}

.clickable-row {
    cursor: pointer;
}

.ver-link {
    background: none;
    border: none;
    padding: 0;
    color: var(--accent-dark);
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
}

.ver-link:hover {
    text-decoration: underline;
    background: none;
}

/* ---------- Acordeón de usuarios ---------- */

.usuario-accordion {
    padding: 0;
    overflow: hidden;
}

.usuario-accordion summary {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    cursor: pointer;
    list-style: none;
}

.usuario-accordion summary::-webkit-details-marker {
    display: none;
}

.usuario-accordion summary::after {
    content: '⌄';
    margin-left: auto;
    color: var(--text-secondary);
    font-size: 16px;
    transition: transform 0.2s ease;
}

.usuario-accordion[open] summary::after {
    transform: rotate(180deg);
}

.usuario-accordion summary:hover {
    background: #FAFBFA;
}

.usuario-accordion-body {
    padding: 4px 20px 20px;
    border-top: 1px solid var(--border);
}

/* ---------- Tabla de usuarios ---------- */

.estado-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.estado-badge.activo {
    background: #DCFCE7;
    color: #166534;
}

.estado-badge.suspendido {
    background: #FEE2E2;
    color: #991B1B;
}

.usuario-nombre-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.usuario-nombre-cell .avatar-sm {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 11px;
    flex-shrink: 0;
    text-transform: uppercase;
}

/* ---------- Modal de usuario ---------- */

.modal-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 18px;
}

.modal-tab {
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.modal-tab.active {
    color: var(--accent-dark);
    border-bottom-color: var(--accent);
}

.modal-tab-panel {
    display: none;
}

.modal-tab-panel.active {
    display: block;
}

.modal-inline-form {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.modal-inline-form input {
    max-width: none;
    flex: 1;
}

.action-message {
    font-size: 12.5px;
    padding: 8px 12px;
    border-radius: var(--radius);
    margin-bottom: 12px;
    display: none;
}

.action-message.show.ok {
    display: block;
    background: #DCFCE7;
    color: #166534;
}

.action-message.show.error {
    display: block;
    background: #FEE2E2;
    color: #991B1B;
}

/* ---------- Página de formulario centrada ---------- */

.form-page {
    max-width: 640px;
    margin: 0 auto;
}

.form-page-header {
    background: var(--sidebar-bg);
    color: white;
    padding: 20px 28px;
    border-radius: var(--radius) var(--radius) 0 0;
}

.form-page-header h2 {
    color: white;
    margin: 0;
    font-size: 19px;
}

.form-page-header p {
    color: var(--sidebar-text);
    font-size: 13px;
    margin: 4px 0 0;
}

.form-card-attached {
    border-radius: 0 0 var(--radius) var(--radius);
    border-top: none;
    margin-bottom: 0;
}
.badge-pendiente { background: #EDE9FE; color: #5B21B6; }
.badge-pendiente .badge-dot { background: #8B5CF6; }

.badge-rechazado { background: #FEE2E2; color: #991B1B; }
.badge-rechazado .badge-dot { background: #DC2626; }


/* ---------- Modal rediseñado ---------- */

.modal-box-v2 {
    padding: 0;
    overflow: hidden;
}

.modal-header-v2 {
    background: var(--sidebar-bg);
    color: white;
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.modal-header-v2 h3 {
    color: white;
    margin: 0 0 4px 0;
    font-size: 17px;
}

.modal-header-v2 span {
    color: var(--sidebar-text);
    font-size: 12.5px;
}

.modal-header-v2 .modal-close {
    color: rgba(255,255,255,0.7);
}

.modal-header-v2 .modal-close:hover {
    color: white;
}

.modal-body-v2 {
    padding: 22px 24px;
    max-height: 70vh;
    overflow-y: auto;
}

.modal-block {
    padding-bottom: 18px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--border);
}

.modal-block:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.modal-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 20px;
    font-size: 13px;
}

.modal-info-grid .label {
    color: var(--text-secondary);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    display: block;
    margin-bottom: 2px;
}

.modal-info-grid .value {
    font-weight: 600;
    color: var(--text-primary);
}


.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 28px;
    text-align: center;
    cursor: pointer;
    background: #FAFBFA;
    transition: all 0.15s ease;
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--accent);
    background: #F0FDF4;
}

.drop-zone p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 13px;
}

.archivo-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #F1F5F0;
    border-radius: 999px;
    padding: 5px 10px 5px 12px;
    font-size: 12.5px;
    margin: 8px 8px 0 0;
}

.archivo-chip img {
    width: 24px;
    height: 24px;
    object-fit: cover;
    border-radius: 4px;
}

.archivo-chip .quitar {
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 700;
}

/* ---------- Dashboard con filtros ---------- */

.dashboard-filtros {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.dashboard-filtros .field-group {
    margin-bottom: 0;
}

.dashboard-filtros input, .dashboard-filtros select {
    max-width: 180px;
}

.kpi-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    padding: 20px;
}

.kpi-box {
    background: #F0FDF4;
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}

.kpi-box .kpi-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--accent-dark);
}

.kpi-box .kpi-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.dashboard-grid-v2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 16px;
    padding: 0 20px 20px;
}

.dashboard-grid-v2 .grafica-card {
    height: 320px;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.dashboard-grid-v2 .grafica-card canvas {
    flex: 1;
    max-height: none;
    min-height: 0;
}

/* ---------- Alerta de pendientes de aprobación ---------- */

.alerta-aprobacion {
    background: #FFFBEB;
    border: 1px solid #FDE68A;
    border-left: 4px solid #F59E0B;
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 24px;
}

.alerta-aprobacion .alerta-titulo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    color: #92400E;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 12px;
}

.alerta-aprobacion table {
    border: 1px solid #FDE68A;
}

.alerta-aprobacion th {
    background-color: #FEF3C7;
    color: #92400E;
}

.alerta-aprobacion tr:hover td {
    background-color: #FFFBEB;
}

/* ---------- Badges de auditoría ---------- */

.accion-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
}

.accion-aprobado { background: #DCFCE7; color: #166534; }
.accion-rechazado { background: #FEE2E2; color: #991B1B; }
.accion-asignado { background: #DBEAFE; color: #1E40AF; }
.accion-estado { background: #EDE9FE; color: #5B21B6; }
.accion-permisos { background: #FEF3C7; color: #92400E; }
.accion-otro { background: #F1F5F0; color: var(--text-secondary); }

.filtros-tickets {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.filtros-tickets .field-group {
    margin-bottom: 0;
}

.filtros-tickets input, .filtros-tickets select {
    max-width: 200px;
}