/* Design System Tokens */
html {
    font-size: 15px;
}
:root {  /* CLARO (default) */
    --bg-main:      #f4f6f9;
    --bg-card:      #ffffff;
    --bg-header:    #ffffff;
    --bg-input:     #ffffff;
    --border:       #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary:#576575; /* WCAG AA contrast on both background and cards */
    --primary:      #4f46e5;
    --primary-hover:#4338ca;
    --accent:       #4f46e5;   /* aligned to primary, removing playful light blue */
    --success:      #059669;
    --warning:      #d97706;
    --danger:       #dc2626;
    --shadow: 0 1px 2px rgb(16 24 40 / 0.06), 0 1px 3px rgb(16 24 40 / 0.10);
    
    /* RGBA values for transparent colors */
    --primary-rgb: 79, 70, 229;
    --success-rgb: 5, 150, 105;
    --warning-rgb: 217, 119, 6;
    --danger-rgb: 220, 38, 38;
    --accent-rgb: 79, 70, 229;
    --text-secondary-rgb: 87, 101, 117;

    --bg-hover: rgba(0, 0, 0, 0.04);
    --bg-stripe: rgba(0, 0, 0, 0.015);
    --bg-th: rgba(0, 0, 0, 0.02);
    --bg-sla-cerrado: rgba(0, 0, 0, 0.05);

    --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: ui-monospace, 'SF Mono', 'Cascadia Code', 'Roboto Mono', Menlo, Consolas, monospace;
    --radius-card: 10px;
    --radius-ctrl: 8px;
    --transition: none; /* Fallback when reduced-motion matches */
}

:root[data-theme="dark"] {  /* OSCURO */
    --bg-main:      #0f172a;
    --bg-card:      #1e293b;
    --bg-header:    #1e293b;
    --bg-input:     #0f172a;
    --border:       #334155;
    --text-primary: #f1f5f9;
    --text-secondary:#94a3b8;
    --primary:      #6366f1;
    --primary-hover:#818cf8;
    --accent:       #6366f1;
    --success:      #10b981;
    --warning:      #f59e0b;
    --danger:       #ef4444;
    --shadow: 0 2px 4px rgb(0 0 0 / 0.3), 0 4px 12px rgb(0 0 0 / 0.25);

    --primary-rgb: 99, 102, 241;
    --success-rgb: 16, 185, 129;
    --warning-rgb: 245, 158, 11;
    --danger-rgb: 239, 68, 68;
    --accent-rgb: 99, 102, 241;
    --text-secondary-rgb: 148, 163, 184;

    --bg-hover: rgba(255, 255, 255, 0.04);
    --bg-stripe: rgba(255, 255, 255, 0.015);
    --bg-th: rgba(255, 255, 255, 0.02);
    --bg-sla-cerrado: rgba(255, 255, 255, 0.05);
}

/* Red de seguridad sin-JS: si no hay preferencia explícita, seguir al SO */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg-main:      #0f172a;
        --bg-card:      #1e293b;
        --bg-header:    #1e293b;
        --bg-input:     #0f172a;
        --border:       #334155;
        --text-primary: #f1f5f9;
        --text-secondary:#94a3b8;
        --primary:      #6366f1;
        --primary-hover:#818cf8;
        --accent:       #6366f1;
        --success:      #10b981;
        --warning:      #f59e0b;
        --danger:       #ef4444;
        --shadow: 0 2px 4px rgb(0 0 0 / 0.3), 0 4px 12px rgb(0 0 0 / 0.25);

        --primary-rgb: 99, 102, 241;
        --success-rgb: 16, 185, 129;
        --warning-rgb: 245, 158, 11;
        --danger-rgb: 239, 68, 68;
        --accent-rgb: 99, 102, 241;
        --text-secondary-rgb: 148, 163, 184;

        --bg-hover: rgba(255, 255, 255, 0.04);
        --bg-stripe: rgba(255, 255, 255, 0.015);
        --bg-th: rgba(255, 255, 255, 0.02);
        --bg-sla-cerrado: rgba(255, 255, 255, 0.05);
    }
}

/* Motion control */
@media (prefers-reduced-motion: no-preference) {
    :root {
        --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    }
}

@media (prefers-reduced-motion: reduce) {
    :root {
        --transition: none !important;
    }
    * {
        animation-delay: -1ms !important;
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
        background-attachment: initial !important;
        scroll-behavior: auto !important;
        transition-duration: 0s !important;
        transition-delay: 0s !important;
    }
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Monospace Class and Ticket ID */
.monospace {
    font-family: var(--font-mono);
}
.ticket-id {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--accent);
}
.tabular-nums {
    font-variant-numeric: tabular-nums;
    font-family: var(--font-mono);
}

/* Icon Support */
.icon {
    width: 1.1em;
    height: 1.1em;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
    display: inline-block;
    vertical-align: text-bottom;
}

/* Theme active icons style */
html[data-theme="light"] .sun-icon { display: block !important; }
html[data-theme="light"] .moon-icon { display: none !important; }
html[data-theme="dark"] .sun-icon { display: none !important; }
html[data-theme="dark"] .moon-icon { display: block !important; }

/* Accessibility Focus States */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: var(--transition);
}
a:hover {
    color: var(--primary);
}

/* Typography */
h1, h2, h3, h4 {
    font-weight: 700;
    letter-spacing: -0.025em;
    margin-bottom: 0.5rem;
}

/* Layout Framework */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

.sidebar {
    width: 260px;
    background-color: var(--bg-header);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
    flex-shrink: 0;
}

.main-content {
    flex-grow: 1;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    overflow-y: auto;
}

/* Header & Logo */
.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 3rem;
}
.logo-accent {
    color: var(--primary);
}
.logo-middle-t {
    color: #adb0f7;
}

/* Navigation Links */
.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-ctrl);
    color: var(--text-secondary);
    font-weight: 500;
    transition: var(--transition);
}

.nav-item a:hover, .nav-item.active a {
    background-color: rgba(var(--primary-rgb), 0.15);
    color: var(--text-primary);
    transform: translateX(4px);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

/* Profile Info in Sidebar */
.user-profile {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 1rem;
}
.user-name {
    font-size: 0.95rem;
    font-weight: 600;
}
.user-role {
    font-size: 0.8rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Premium Card Components */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: var(--transition);
}
.card:hover {
    border-color: rgba(var(--primary-rgb), 0.4);
}

.card-title {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-weight: 600;
}

/* Metrics Dashboard Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.metric-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 2rem;
}

.metric-value {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 0.5rem;
}

.metric-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Color Status Accents */
.border-abierto { border-left: 4px solid var(--accent); }
.border-en_progreso { border-left: 4px solid var(--primary); }
.border-en_espera { border-left: 4px solid var(--warning); }
.border-resuelto { border-left: 4px solid var(--success); }
.border-cerrado { border-left: 4px solid var(--text-secondary); }

/* Buttons & Inputs */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-ctrl);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    font-size: 0.95rem;
}

.btn-primary {
    background-color: var(--primary);
    color: #ffffff;
}
.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
}
.btn-secondary:hover {
    background-color: var(--bg-hover);
    border-color: var(--text-secondary);
}

.btn-danger {
    background-color: var(--danger);
    color: #ffffff;
}
.btn-danger:hover {
    filter: brightness(0.9);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-control {
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-ctrl);
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-family: inherit;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.2);
}

/* Modern Tables */
.table-container {
    width: 100%;
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.table th, .table td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.table th {
    background-color: var(--bg-th);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table tbody tr {
    transition: var(--transition);
}

.table tbody tr:hover {
    background-color: var(--bg-hover);
}

/* Badges */
.badge {
    display: inline-flex;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-abierto { background-color: rgba(var(--accent-rgb), 0.12); color: var(--primary); border: 1px solid rgba(var(--accent-rgb), 0.2); }
.badge-en_progreso { background-color: rgba(var(--primary-rgb), 0.12); color: var(--primary); border: 1px solid rgba(var(--primary-rgb), 0.2); }
.badge-en_espera { background-color: rgba(var(--warning-rgb), 0.12); color: #92400e; border: 1px solid rgba(var(--warning-rgb), 0.2); }
.badge-resuelto { background-color: rgba(var(--success-rgb), 0.12); color: #03543f; border: 1px solid rgba(var(--success-rgb), 0.2); }
.badge-cerrado { background-color: rgba(var(--text-secondary-rgb), 0.12); color: #334155; border: 1px solid rgba(var(--text-secondary-rgb), 0.2); }

.badge-baja { background-color: rgba(var(--success-rgb), 0.12); color: #03543f; border: 1px solid rgba(var(--success-rgb), 0.2); }
.badge-media { background-color: rgba(var(--accent-rgb), 0.12); color: var(--primary); border: 1px solid rgba(var(--accent-rgb), 0.2); }
.badge-alta { background-color: rgba(var(--warning-rgb), 0.12); color: #92400e; border: 1px solid rgba(var(--warning-rgb), 0.2); }
.badge-urgente { background-color: rgba(var(--danger-rgb), 0.12); color: #991b1b; border: 1px solid rgba(var(--danger-rgb), 0.2); }

/* Theme-override dark contrast for badges */
:root[data-theme="dark"] .badge-abierto { background-color: rgba(var(--accent-rgb), 0.15); color: var(--accent); border: none; }
:root[data-theme="dark"] .badge-en_progreso { background-color: rgba(var(--primary-rgb), 0.15); color: var(--primary); border: none; }
:root[data-theme="dark"] .badge-en_espera { background-color: rgba(var(--warning-rgb), 0.15); color: var(--warning); border: none; }
:root[data-theme="dark"] .badge-resuelto { background-color: rgba(var(--success-rgb), 0.15); color: var(--success); border: none; }
:root[data-theme="dark"] .badge-cerrado { background-color: rgba(var(--text-secondary-rgb), 0.15); color: #cbd5e1; border: none; }

:root[data-theme="dark"] .badge-baja { background-color: rgba(var(--success-rgb), 0.15); color: var(--success); border: none; }
:root[data-theme="dark"] .badge-media { background-color: rgba(var(--accent-rgb), 0.15); color: var(--accent); border: none; }
:root[data-theme="dark"] .badge-alta { background-color: rgba(var(--warning-rgb), 0.15); color: var(--warning); border: none; }
:root[data-theme="dark"] .badge-urgente { background-color: rgba(var(--danger-rgb), 0.15); color: var(--danger); border: none; }

/* Messages Alerts */
.messages-container {
    width: 100%;
}
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-ctrl);
    margin-bottom: 1rem;
    font-weight: 500;
    border: 1px solid transparent;
}
.alert-success { background-color: rgba(var(--success-rgb), 0.08); border-color: rgba(var(--success-rgb), 0.18); color: #065f46; }
.alert-error, .alert-danger { background-color: rgba(var(--danger-rgb), 0.08); border-color: rgba(var(--danger-rgb), 0.18); color: #991b1b; }
.alert-warning { background-color: rgba(var(--warning-rgb), 0.08); border-color: rgba(var(--warning-rgb), 0.18); color: #92400e; }

:root[data-theme="dark"] .alert-success { background-color: rgba(var(--success-rgb), 0.1); border-color: rgba(var(--success-rgb), 0.2); color: var(--success); }
:root[data-theme="dark"] .alert-error, :root[data-theme="dark"] .alert-danger { background-color: rgba(var(--danger-rgb), 0.1); border-color: rgba(var(--danger-rgb), 0.2); color: var(--danger); }
:root[data-theme="dark"] .alert-warning { background-color: rgba(var(--warning-rgb), 0.1); border-color: rgba(var(--warning-rgb), 0.2); color: var(--warning); }

/* Ticket Details Screen Styling */
.ticket-detail-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
}

@media (max-width: 900px) {
    .ticket-detail-grid {
        grid-template-columns: 1fr;
    }
}

.ticket-meta-block {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.meta-row {
    display: flex;
    justify-content: space-between;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}
.meta-row .label {
    color: var(--text-secondary);
    font-weight: 500;
}
.meta-row .val {
    font-weight: 600;
}

/* Timeline/History Audit */
.timeline {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: relative;
    padding-left: 1.5rem;
}
.timeline::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 4px;
    bottom: 4px;
    width: 2px;
    background-color: var(--border);
}
.timeline-item {
    position: relative;
}
.timeline-item::before {
    content: '';
    position: absolute;
    left: -22px;
    top: 4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--primary);
    border: 2px solid var(--bg-card);
}
.timeline-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}
.timeline-desc {
    font-size: 0.9rem;
    font-weight: 500;
}

/* Comments section */
.comments-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.comment-card {
    background-color: var(--bg-stripe);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 1rem;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 600;
}
.comment-author {
    color: var(--accent);
}
.comment-body {
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Login screen styles */
.login-container {
    max-width: 450px;
    margin: auto;
    padding: 3rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

/* Header in main view */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.main-title-block h1 {
    font-size: 1.75rem;
}
.main-title-block p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Utilities */
.text-muted { color: var(--text-secondary); }
.font-bold { font-weight: 700; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.d-flex { display: flex; }
.flex-column { flex-direction: column; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.w-full { width: 100%; }

/* Mobile Responsiveness (max-width: 768px) */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 1.25rem 1rem;
        gap: 1.25rem;
        margin-bottom: 0;
    }
    
    .logo {
        margin-bottom: 0.5rem;
        justify-content: center;
    }
    
    .nav-menu {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
    }
    
    .nav-item {
        width: auto;
    }
    
    .nav-item a {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }
    
    .sidebar-footer {
        margin-top: 0;
        padding-top: 1rem;
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        gap: 1rem;
    }
    
    .user-profile {
        margin-bottom: 0;
        flex-direction: row;
        align-items: center;
        gap: 0.5rem;
    }
    
    .sidebar-footer .btn {
        width: auto;
        margin-top: 0;
    }
    
    .main-content {
        padding: 1.25rem 1rem;
        gap: 1.5rem;
    }
    
    .main-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .main-title-block {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        width: 100% !important;
    }
    
    .main-header > div:not(.main-title-block) {
        width: 100%;
        display: flex;
        justify-content: flex-start;
        align-items: center;
        gap: 1rem;
    }
}

/* Notification Widget Styling */
.bell-btn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    position: relative;
    padding: 0.5rem;
    border-radius: 50%;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}
.bell-btn:hover {
    background-color: var(--bg-hover);
}
.unread-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background-color: var(--danger);
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 800;
    padding: 0.15rem 0.4rem;
    border-radius: 9999px;
    line-height: 1;
    border: 2px solid var(--bg-main);
}
.notif-dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    width: 320px;
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
    margin-top: 0.5rem;
    z-index: 100;
    overflow: hidden;
}
.notif-dropdown-content.show {
    display: block;
}
.notif-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}
.notif-title {
    font-weight: 700;
    font-size: 0.95rem;
}
.btn-text {
    background: transparent;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0;
}
.btn-text:hover {
    color: var(--primary);
    text-decoration: underline;
}
.notif-body {
    max-height: 350px;
    overflow-y: auto;
}
.notif-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}
.notif-item:last-child {
    border-bottom: none;
}
.notif-item:hover {
    background-color: var(--bg-hover);
}
.notif-item.unread {
    background-color: rgba(var(--primary-rgb), 0.05);
}
.notif-item.unread:hover {
    background-color: rgba(var(--primary-rgb), 0.08);
}
.notif-link {
    display: block;
    text-decoration: none;
    color: inherit;
}
.notif-msg {
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}
.notif-time {
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.mark-read-btn {
    background: rgba(var(--success-rgb), 0.1);
    color: var(--success);
    border: 1px solid rgba(var(--success-rgb), 0.2);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: bold;
    flex-shrink: 0;
    transition: var(--transition);
}
.mark-read-btn:hover {
    background-color: var(--success);
    color: var(--bg-card);
}
.notif-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Mobile Responsiveness & Hardening (max-width: 768px) */
@media (max-width: 768px) {
    /* App container and layout flow */
    .app-container {
        flex-direction: column !important;
        position: relative !important;
    }
    
    .sidebar {
        width: 100% !important;
        border-right: none !important;
        border-bottom: 1px solid var(--border) !important;
        padding: 1.25rem 1rem !important;
        margin-bottom: 0 !important;
        position: relative !important;
    }
    
    /* Topbar absolute positioning to align with sidebar logo */
    .main-topbar {
        position: absolute !important;
        top: 1rem !important;
        right: 1rem !important;
        border-bottom: none !important;
        margin-bottom: 0 !important;
        padding: 0 !important;
        z-index: 1000 !important;
        background: transparent !important;
        justify-content: flex-end !important;
    }
    
    /* Fixed viewport positioning for notification dropdown on mobile */
    .notif-dropdown-content {
        position: fixed !important;
        top: 65px !important;
        left: 10px !important;
        right: 10px !important;
        width: calc(100% - 20px) !important;
        max-width: none !important;
        z-index: 2000 !important;
        box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5) !important;
    }
    
    .notif-close-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        font-size: 1.75rem;
        color: var(--text-secondary);
        cursor: pointer;
        width: 44px;
        height: 44px;
        padding: 0;
        line-height: 1;
        transition: var(--transition);
    }
    .notif-close-btn:hover {
        color: var(--text-primary);
    }
    
    /* Ticket Details Screen apilamiento */
    .ticket-detail-grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }
    
    /* Comments wrapping on mobile */
    .comment-header {
        flex-direction: column !important;
        gap: 0.25rem !important;
    }
    .comment-author {
        word-break: break-all !important;
    }
    
    /* Table to Card layout transformation for tickets list */
    .tickets-table, 
    .tickets-table tbody, 
    .tickets-table tr, 
    .tickets-table td {
        display: block !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    .tickets-table thead {
        display: none !important;
    }
    .tickets-table tbody tr {
        background-color: var(--bg-card) !important;
        border: 1px solid var(--border) !important;
        border-radius: var(--radius-card) !important;
        padding: 1.25rem !important;
        margin-bottom: 1rem !important;
        position: relative !important;
        cursor: pointer;
    }
    .tickets-table tbody tr:hover {
        background-color: var(--bg-hover) !important;
        border-color: var(--primary) !important;
    }
    .tickets-table td {
        padding: 0.35rem 0 !important;
        border-bottom: none !important;
        text-align: left !important;
    }
    .tickets-table td:nth-child(1) {
        font-size: 0.85rem !important;
        color: var(--accent) !important;
        font-weight: 700 !important;
        margin-bottom: 0.25rem !important;
        display: inline-block !important;
        width: auto !important;
    }
    .tickets-table td:nth-child(2) {
        font-size: 1.1rem !important;
        font-weight: 700 !important;
        color: var(--text-primary) !important;
        margin-bottom: 0.5rem !important;
        display: block !important;
    }
    .tickets-table td:nth-child(3) {
        font-size: 0.85rem !important;
        color: var(--text-secondary) !important;
        display: inline-block !important;
        margin-right: 1rem !important;
    }
    .tickets-table td:nth-child(4), 
    .tickets-table td:nth-child(5) {
        display: inline-block !important;
        margin-right: 0.5rem !important;
        vertical-align: middle !important;
    }
    .tickets-table td:nth-child(6) {
        font-size: 0.85rem !important;
        color: var(--text-secondary) !important;
        display: block !important;
        margin-top: 0.5rem !important;
        word-break: break-all !important;
    }
    .tickets-table td:nth-child(7) {
        font-size: 0.8rem !important;
        color: var(--text-secondary) !important;
        display: block !important;
        margin-top: 0.25rem !important;
    }
    
    /* Filters and form layouts full-width apilados */
    .card form[hx-get*="tickets_list"] {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    .card form div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    /* Form fields and buttons height & touch comfort zone (>= 44px) */
    .form-control, .btn {
        min-height: 44px;
    }
    #archivo_input {
        padding: 0.75rem 1rem !important;
        font-size: 0.95rem !important;
        min-height: 44px !important;
    }
    .main-content form button[type="submit"] {
        padding: 0.75rem 1.5rem !important;
        font-size: 0.95rem !important;
        min-height: 44px !important;
    }
    .card select.form-control {
        min-height: 44px !important;
    }
    .main-title-block a[href*="tickets_list"] {
        display: inline-block !important;
        padding: 0.5rem 0 !important;
        min-height: 44px !important;
        line-height: 30px !important;
    }
    .attachment-item .btn {
        padding: 0.5rem 1rem !important;
        font-size: 0.9rem !important;
        min-height: 44px !important;
    }
    
    /* Dashboard metrics 2x2 responsive structure */
    .metrics-grid {
        grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)) !important;
        gap: 1rem !important;
    }
    .metric-card {
        padding: 1.25rem 1rem !important;
    }
    .main-content > div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }
    
    /* Mobile meta-row stacking and wrapping */
    .meta-row {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.25rem !important;
    }
    .meta-row .val {
        word-break: break-all !important;
        text-align: left !important;
    }
}
@media (min-width: 769px) {
    .notif-close-btn {
        display: none !important;
    }
}

/* Custom file upload styling */
.custom-file-upload {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 0.25rem;
}
.custom-file-label {
    min-height: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
}
.file-upload-status {
    font-size: 0.9rem;
    color: var(--text-secondary);
    word-break: break-all;
}
.file-input-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    border: 0 !important;
}

/* SLA metric card and badge styling */
.border-vencido {
    border-left: 4px solid var(--danger) !important;
}
.badge-sla {
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}
.badge-sla-plazo {
    background-color: rgba(var(--success-rgb), 0.12);
    color: #03543f;
    border: 1px solid rgba(var(--success-rgb), 0.2);
}
.badge-sla-vencido {
    background-color: rgba(var(--danger-rgb), 0.12);
    color: #991b1b;
    border: 1px solid rgba(var(--danger-rgb), 0.2);
}
.badge-sla-cerrado {
    background-color: var(--bg-sla-cerrado);
    color: #334155;
    border: 1px solid var(--border);
}

:root[data-theme="dark"] .badge-sla-plazo {
    color: var(--success);
}
:root[data-theme="dark"] .badge-sla-vencido {
    color: var(--danger);
}
:root[data-theme="dark"] .badge-sla-cerrado {
    color: var(--text-secondary);
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: no-preference) {
    .spin {
        animation: spin 1s linear infinite;
        display: inline-block;
    }
}

/* Tickets Table Compaction (Desktop and Tablet) */
@media (min-width: 769px) {
    .tickets-table th, 
    .tickets-table td {
        padding: 0.6rem 0.85rem !important; /* ~40% vertical padding reduction */
        line-height: 1.3 !important;
    }
    .tickets-table td {
        font-size: 0.87rem !important; /* ~13px */
    }
    .tickets-table th {
        font-size: 0.8rem !important; /* ~12px */
    }
}
