
/* ── UX Sprint: toasts, loading, a11y, mobile ── */
.auth-body #main-content { display: contents; }
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 9999;
    padding: 0.65rem 1rem;
    background: var(--primary);
    color: #fff;
    border-radius: 0 0 var(--radius) 0;
    font-weight: 600;
}
.skip-link:focus {
    left: 0;
}

.toast-host {
    position: fixed;
    bottom: max(1rem, env(safe-area-inset-bottom));
    right: max(1rem, env(safe-area-inset-right));
    z-index: 9000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: min(420px, calc(100vw - 2rem));
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.85rem 2.25rem 0.85rem 1rem;
    border-radius: var(--radius);
    background: var(--card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    color: var(--text);
    font-size: 0.9rem;
    line-height: 1.45;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.25s var(--ease-out), transform 0.25s var(--ease-out);
    pointer-events: auto;
}
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-info { border-left: 4px solid var(--info); }
.toast-close {
    position: absolute;
    top: 0.35rem;
    right: 0.35rem;
    width: 1.75rem;
    height: 1.75rem;
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    border-radius: 6px;
    font-size: 1.1rem;
    line-height: 1;
}
.toast-close:hover { background: var(--surface-soft); color: var(--text); }

.btn.is-loading { position: relative; pointer-events: none; opacity: 0.92; }
.btn-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgb(255 255 255 / 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btn-spin 0.65s linear infinite;
    flex-shrink: 0;
}
.btn-outline .btn-spinner { border-color: rgb(79 70 229 / 0.25); border-top-color: var(--primary); }
@keyframes btn-spin { to { transform: rotate(360deg); } }

.form-control.is-invalid, .auth-input.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgb(220 38 38 / 0.12); }
.field-error { display: block; margin-top: 0.35rem; font-size: 0.82rem; color: var(--danger); }

.offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9500;
    padding: 0.55rem 1rem;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    background: #991b1b;
    color: #fff;
}

.stat-card-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}
.stat-card-link:hover { text-decoration: none; color: inherit; }
.stats-section-title { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 0.65rem; }
.stats-secondary-wrap { margin-bottom: 1.5rem; }
.stats-toggle-btn { margin-bottom: 0.75rem; }
.stats-grid-secondary { margin-bottom: 0; }

.chart-wrap.is-loading canvas { opacity: 0; }
.chart-skeleton {
    position: absolute;
    inset: 0;
    border-radius: var(--radius);
    background: linear-gradient(90deg, var(--surface-soft) 25%, var(--border) 50%, var(--surface-soft) 75%);
    background-size: 200% 100%;
    animation: chart-shimmer 1.2s ease-in-out infinite;
}
.chart-wrap.is-loading .chart-skeleton { display: block; }
.chart-wrap:not(.is-loading) .chart-skeleton { display: none; }
@keyframes chart-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.filter-active-hint { font-size: 0.85rem; color: var(--muted); margin: -0.5rem 0 1rem; }
.saved-filters-select { min-width: 140px; }

.tickets-grid tbody tr.row-critical { box-shadow: inset 3px 0 0 #dc2626; }
.tickets-grid tbody tr.row-sla-breached { background: rgb(220 38 38 / 0.06); }
.tickets-grid tbody tr.row-sla-warning { background: rgb(217 119 6 / 0.06); }
[data-theme="dark"] .tickets-grid tbody tr.row-sla-breached { background: rgb(248 113 113 / 0.08); }
[data-theme="dark"] .tickets-grid tbody tr.row-sla-warning { background: rgb(251 191 36 / 0.08); }

.empty-state { padding: 2rem; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 0.75rem; }
.empty-state .empty { padding: 0; margin: 0; }
.empty-state-icon { width: 3rem; height: 3rem; color: var(--muted); opacity: 0.65; }
.empty-state-icon svg { width: 100%; height: 100%; }

.chart-card-clickable .chart-wrap { cursor: pointer; }
.chart-hint { font-size: 0.72rem; font-weight: 500; color: var(--muted); margin-left: 0.35rem; }

.offline-page { text-align: center; }
.offline-page-icon { width: 3.5rem; height: 3.5rem; margin: 0 auto 1rem; color: var(--muted); }
.offline-page-icon svg { width: 100%; height: 100%; }
.offline-banner a { color: inherit; font-weight: 700; text-decoration: underline; margin-left: 0.35rem; }

.chat-messages-wrap { position: relative; }
.chat-new-messages-pill {
    position: absolute;
    bottom: 0.75rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    padding: 0.4rem 0.85rem;
    border: none;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
}
.chat-header-icon, .alert-icon, .inline-icon { width: 1.1rem; height: 1.1rem; vertical-align: -0.15em; margin-right: 0.35rem; flex-shrink: 0; }
.chat-header { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
.sla-alert { display: flex; align-items: flex-start; gap: 0.35rem; }

.ticket-sticky-actions {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 800;
    padding: 0.65rem 1rem max(0.65rem, env(safe-area-inset-bottom));
    background: var(--card);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 20px rgb(15 23 42 / 0.08);
    gap: 0.5rem;
    justify-content: stretch;
}
.ticket-sticky-actions .btn { flex: 1; justify-content: center; }

.urgency-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.65rem; }
.urgency-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 0.85rem 0.5rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color var(--duration-fast), background var(--duration-fast);
}
.urgency-card:has(input:checked) { border-color: var(--primary); background: rgb(79 70 229 / 0.06); }
.urgency-card input { position: absolute; opacity: 0; pointer-events: none; }
.urgency-card span { font-weight: 700; font-size: 0.92rem; }
.urgency-card small { font-size: 0.72rem; color: var(--muted); margin-top: 0.2rem; }

#itilFields.is-collapsed {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.attachment-preview-list { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.65rem; }
.attachment-preview-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-soft);
    font-size: 0.85rem;
}
.attachment-preview-item small { color: var(--muted); margin-right: auto; }

.auth-mobile-tagline {
    display: none;
    margin: 0 0 1rem;
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius);
    background: rgb(79 70 229 / 0.08);
    border: 1px solid rgb(79 70 229 / 0.18);
    font-size: 0.88rem;
    color: var(--text);
    text-align: center;
}

.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 850;
    padding: 0.35rem 0.5rem max(0.35rem, env(safe-area-inset-bottom));
    background: var(--card);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 16px rgb(15 23 42 / 0.06);
    justify-content: space-around;
    align-items: stretch;
    gap: 0.25rem;
}
.mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    padding: 0.35rem 0.25rem;
    border: none;
    background: transparent;
    color: var(--muted);
    text-decoration: none;
    font-size: 0.65rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    min-height: 52px;
}
.mobile-nav-item svg { width: 22px; height: 22px; }
.mobile-nav-item.active, .mobile-nav-item:hover { color: var(--primary); background: rgb(79 70 229 / 0.06); }
.mobile-nav-item-primary.active { color: var(--primary); }

[data-theme="dark"] .sla-warning { background: rgb(251 191 36 / 0.22); color: #fde68a; }
[data-theme="dark"] .sla-breached { background: rgb(248 113 113 / 0.22); color: #fecaca; }
[data-theme="dark"] .sla-met { background: rgb(129 140 248 / 0.22); color: #e0e7ff; }
[data-theme="dark"] .sla-ok { background: rgb(52 211 153 / 0.2); color: #a7f3d0; }

.chat-tab-panel { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat-tab-panel[hidden] { display: none !important; }

.chat-panel-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    padding: 0 0.5rem;
}
.chat-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.85rem 1rem;
    border: none;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    margin-bottom: -1px;
    transition: color var(--duration-fast), border-color var(--duration-fast);
}
.chat-tab:hover { color: var(--text); }
.chat-tab.is-active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}
.chat-tab .live { margin-left: 0.25rem; }

.timeline-scroll {
    flex: 1;
    overflow-y: auto;
    max-height: 400px;
    padding: 1rem 1rem 1rem 0.5rem;
}
.ticket-timeline {
    list-style: none;
    margin: 0;
    padding: 0 0 0 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0;
}
.timeline-item {
    position: relative;
    display: grid;
    grid-template-columns: 28px 1fr;
    gap: 0.85rem;
    padding-bottom: 1.25rem;
}
.timeline-item:not(:last-child)::before {
    content: "";
    position: absolute;
    left: 13px;
    top: 28px;
    bottom: 0;
    width: 2px;
    background: var(--border);
}
.timeline-marker {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--card);
    position: relative;
    z-index: 1;
    flex-shrink: 0;
}
.timeline-icon-created { background: rgb(79 70 229 / 0.15); border-color: var(--primary); }
.timeline-icon-status { background: rgb(217 119 6 / 0.15); border-color: var(--warning); }
.timeline-icon-sla { background: rgb(8 145 178 / 0.12); border-color: #0891b2; }
.timeline-icon-message { background: rgb(5 150 105 / 0.12); border-color: var(--success); }
.timeline-icon-internal { background: rgb(234 179 8 / 0.15); border-color: #eab308; }
.timeline-icon-attachment { background: rgb(124 58 237 / 0.12); border-color: var(--accent); }
.timeline-sla-breached .timeline-marker,
.timeline-sla-first_breached .timeline-marker { border-color: var(--danger); background: rgb(220 38 38 / 0.12); }
.timeline-sla-warning .timeline-marker { border-color: var(--warning); }
.timeline-sla-paused .timeline-marker { border-color: #0891b2; }
.timeline-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.35rem 0.75rem;
    margin-bottom: 0.25rem;
}
.timeline-head strong { font-size: 0.92rem; }
.timeline-head time { font-size: 0.75rem; color: var(--muted); white-space: nowrap; }
.timeline-actor { font-size: 0.78rem; color: var(--muted); margin: 0 0 0.35rem; }
.timeline-body { font-size: 0.88rem; line-height: 1.55; color: var(--text); }
.timeline-notes { font-size: 0.82rem; color: var(--muted); margin: 0.45rem 0 0; }
.timeline-link { display: inline-block; margin-top: 0.45rem; font-size: 0.82rem; font-weight: 600; }
.timeline-internal .timeline-body { border-left: 3px solid #eab308; padding-left: 0.65rem; }

@media (max-width: 900px) {
    .auth-mobile-tagline { display: block; }
    .mobile-bottom-nav { display: flex; }
    .main-content { padding-bottom: calc(4.5rem + env(safe-area-inset-bottom)); }
    .ticket-sticky-actions { display: flex; bottom: calc(3.75rem + env(safe-area-inset-bottom)); }
    .toast-host { bottom: calc(4.5rem + env(safe-area-inset-bottom)); left: 1rem; right: 1rem; max-width: none; }
    .urgency-cards { grid-template-columns: 1fr; }
    .filters-card { flex-wrap: wrap; }
    .saved-filters-select { width: 100%; max-width: none; }
    .timeline-scroll { max-height: 320px; }
}

/* Language switcher (matches theme-toggle) */
.topbar-end {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}
.lang-switcher {
    position: relative;
}
.lang-switcher-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-width: 42px;
    height: 42px;
    padding: 0 0.65rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out), transform var(--duration-fast) var(--ease-out);
    flex-shrink: 0;
    font-size: 0.82rem;
    font-weight: 500;
}
.lang-switcher-btn:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
}
.lang-switcher-btn svg {
    width: 18px;
    height: 18px;
    display: block;
    flex-shrink: 0;
}
.lang-switcher-current {
    max-width: 5.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.lang-switcher-menu {
    position: absolute;
    top: calc(100% + 0.35rem);
    right: 0;
    z-index: 200;
    min-width: 10.5rem;
    padding: 0.35rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card);
    box-shadow: var(--shadow-lg);
}
.lang-switcher-item {
    display: block;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    transition: background var(--duration-fast) var(--ease-out);
}
.lang-switcher-item:hover {
    background: var(--surface-soft);
    color: var(--text);
}
.lang-switcher-item.is-active {
    background: rgb(79 70 229 / 0.1);
    color: var(--primary);
    font-weight: 600;
}
.auth-lang-bar {
    position: fixed;
    top: max(0.75rem, env(safe-area-inset-top));
    right: max(0.75rem, env(safe-area-inset-right));
    z-index: 100;
}
.auth-brand-row {
    justify-content: space-between;
}
.auth-brand-main {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-width: 0;
}
.auth-brand-row .lang-switcher-current {
    display: none;
}
@media (min-width: 480px) {
    .auth-brand-row .lang-switcher-current {
        display: inline;
    }
}

@media (prefers-reduced-motion: reduce) {
    .toast, .btn-spinner, .chart-skeleton { animation: none; transition: none; }
}
