/* ═══════════════════════════════════════════════════════
   TICKET MODULE — Design System v2
   Aesthetic: Refined editorial — warm neutral tones,
   precision typography, subtle depth
   ═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    /* Core palette */
    --tk-primary: #1a3a5c;
    --tk-primary-light: #2a5a8c;
    --tk-primary-dark: #0f2440;
    --tk-accent: #2d9cdb;
    --tk-accent-light: #56b3e6;
    --tk-accent-glow: rgba(45, 156, 219, 0.12);

    /* Surfaces */
    --tk-surface: #ffffff;
    --tk-surface-raised: #ffffff;
    --tk-bg: #f5f6f8;
    --tk-bg-warm: #fafafa;

    /* Borders & dividers */
    --tk-border: #e8ecf1;
    --tk-border-light: #f0f2f5;
    --tk-divider: #eaedf2;

    /* Text */
    --tk-text: #1c2b3a;
    --tk-text-secondary: #4a5e73;
    --tk-text-muted: #8295a8;
    --tk-text-faint: #b0bec5;

    /* Status colors */
    --tk-status-new: #3b82f6;
    --tk-status-progress: #f59e0b;
    --tk-status-resolved: #10b981;
    --tk-status-closed: #8b5cf6;
    --tk-status-cancelled: #dc3545;

    /* Priority colors */
    --tk-prio-low: #10b981;
    --tk-prio-medium: #f59e0b;
    --tk-prio-high: #f97316;
    --tk-prio-critical: #ef4444;

    /* Spacing & shape */
    --tk-radius: 14px;
    --tk-radius-sm: 8px;
    --tk-radius-xs: 6px;
    --tk-radius-pill: 100px;

    /* Shadows (layered for depth) */
    --tk-shadow-xs: 0 1px 2px rgba(28,43,58,0.04);
    --tk-shadow: 0 1px 3px rgba(28,43,58,0.06), 0 1px 2px rgba(28,43,58,0.04);
    --tk-shadow-md: 0 4px 12px rgba(28,43,58,0.07), 0 1px 3px rgba(28,43,58,0.04);
    --tk-shadow-lg: 0 12px 24px rgba(28,43,58,0.08), 0 4px 8px rgba(28,43,58,0.04);
    --tk-shadow-focus: 0 0 0 3px var(--tk-accent-glow);

    /* Motion */
    --tk-ease: cubic-bezier(0.4, 0, 0.2, 1);
    --tk-transition: all 0.2s var(--tk-ease);
    --tk-transition-slow: all 0.35s var(--tk-ease);
}

/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--tk-bg);
    color: var(--tk-text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 0.9375rem;
    line-height: 1.5;
}

/* ─── Utility: Monospace numbers ─── */
.tk-mono {
    font-family: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
}

/* ═══════════════════════════════════════════════════════
   NAVBAR
   ═══════════════════════════════════════════════════════ */
.tk-navbar {
    background: var(--tk-primary-dark);
    box-shadow: 0 1px 0 rgba(0,0,0,0.1);
    padding: 0 1.25rem;
    height: 52px;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.tk-navbar .container-fluid {
    height: 100%;
}

.tk-navbar-logo {
    height: 26px;
    width: auto;
}

.tk-brand-separator {
    width: 1px;
    height: 20px;
    background: rgba(255,255,255,0.2);
}

.tk-navbar .navbar-brand {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: #fff !important;
}

.tk-navbar .nav-link {
    color: rgba(255,255,255,0.65) !important;
    font-weight: 500;
    font-size: 0.82rem;
    padding: 0.35rem 0.7rem;
    border-radius: var(--tk-radius-xs);
    transition: var(--tk-transition);
    position: relative;
}

.tk-navbar .nav-link:hover {
    color: rgba(255,255,255,0.95) !important;
    background: rgba(255,255,255,0.08);
}

.tk-navbar .nav-link.active {
    color: #fff !important;
    background: rgba(45, 156, 219, 0.2);
}

.tk-navbar .nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 2px;
    background: var(--tk-accent);
    border-radius: 1px;
}

/* ─── Avatar ─── */
.tk-avatar-sm {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--tk-accent), var(--tk-primary-light));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    flex-shrink: 0;
    letter-spacing: 0.02em;
}

/* ═══════════════════════════════════════════════════════
   GLASS CARD (elevated panels)
   ═══════════════════════════════════════════════════════ */
.tk-glass-card {
    background: var(--tk-surface);
    border-radius: var(--tk-radius);
    padding: 1.25rem;
    box-shadow: var(--tk-shadow);
    border: 1px solid var(--tk-border);
    transition: var(--tk-transition);
}

.tk-glass-card:hover {
    box-shadow: var(--tk-shadow-md);
}

/* ═══════════════════════════════════════════════════════
   WELCOME BANNER
   ═══════════════════════════════════════════════════════ */
.tk-welcome-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, var(--tk-primary-dark) 0%, var(--tk-primary) 60%, var(--tk-primary-light) 100%);
    border-radius: var(--tk-radius);
    padding: 2rem 2.5rem;
    margin-bottom: 1.75rem;
    position: relative;
    overflow: hidden;
    color: #fff;
    animation: tkFadeIn 0.4s var(--tk-ease);
}

.tk-welcome-banner::before {
    content: '';
    position: absolute;
    top: -40%;
    right: -5%;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: rgba(45, 156, 219, 0.1);
    pointer-events: none;
}

.tk-welcome-banner::after {
    content: '';
    position: absolute;
    bottom: -50%;
    right: 25%;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.04);
    pointer-events: none;
}

.tk-welcome-left {
    position: relative;
    z-index: 1;
}

.tk-welcome-title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0 0 0.3rem;
    line-height: 1.3;
}

.tk-welcome-subtitle {
    font-size: 0.88rem;
    color: rgba(255, 255, 255, 0.65);
    margin: 0 0 1.25rem;
}

.tk-welcome-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1.25rem;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: 'DM Sans', sans-serif;
    color: var(--tk-primary-dark);
    background: #fff;
    border: none;
    border-radius: var(--tk-radius-sm);
    cursor: pointer;
    transition: var(--tk-transition);
}

.tk-welcome-cta:hover {
    background: rgba(255, 255, 255, 0.9);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.tk-welcome-stats {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    position: relative;
    z-index: 1;
}

.tk-mini-stat {
    text-align: center;
}

.tk-mini-stat-number {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.25rem;
}

.tk-mini-stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.55);
    font-weight: 600;
}

.tk-mini-stat-sep {
    width: 1px;
    height: 36px;
    background: rgba(255, 255, 255, 0.15);
}

@media (max-width: 768px) {
    .tk-welcome-banner {
        flex-direction: column;
        gap: 1.5rem;
        padding: 1.5rem;
        text-align: center;
    }
    .tk-welcome-stats {
        width: 100%;
        justify-content: center;
    }
    .tk-welcome-title { font-size: 1.2rem; }
}

/* ═══════════════════════════════════════════════════════
   PAGE HEADERS
   ═══════════════════════════════════════════════════════ */
.tk-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--tk-border-light);
}

.tk-page-header h4,
.tk-page-header h5 {
    font-weight: 700;
    font-size: 1.3rem;
    letter-spacing: -0.02em;
    color: var(--tk-text);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.tk-page-header .tk-header-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--tk-primary) 0%, var(--tk-accent) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.tk-page-header p {
    margin: 0.25rem 0 0;
    font-size: 0.82rem;
    color: var(--tk-text-muted);
}

/* ─── Breadcrumb link ─── */
.tk-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--tk-text-muted);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    padding: 0.3rem 0.6rem;
    border-radius: var(--tk-radius-xs);
    transition: var(--tk-transition);
    margin-bottom: 0.75rem;
}

.tk-back-link:hover {
    color: var(--tk-primary);
    background: var(--tk-accent-glow);
}

/* ═══════════════════════════════════════════════════════
   STAT CARDS (for index page)
   ═══════════════════════════════════════════════════════ */
.tk-stat-card {
    background: var(--tk-surface);
    border-radius: var(--tk-radius);
    padding: 1rem 1.25rem;
    text-align: center;
    box-shadow: var(--tk-shadow);
    border: 1px solid var(--tk-border);
    cursor: pointer;
    transition: var(--tk-transition);
    position: relative;
    overflow: hidden;
}

.tk-stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--stat-color, var(--tk-accent));
    opacity: 0;
    transition: opacity 0.25s var(--tk-ease);
}

.tk-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--tk-shadow-lg);
    border-color: transparent;
}

.tk-stat-card:hover::before {
    opacity: 1;
}

.tk-stat-card.active {
    border-color: var(--stat-color, var(--tk-accent));
    box-shadow: var(--tk-shadow-focus);
}

.tk-stat-number {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
}

.tk-stat-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--tk-text-muted);
    font-weight: 600;
    margin-top: 0.35rem;
}

/* ═══════════════════════════════════════════════════════
   TICKET LIST & CARDS
   ═══════════════════════════════════════════════════════ */
.tk-ticket-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Row ticket (used in list views) */
.tk-ticket-row {
    display: flex;
    background: var(--tk-surface);
    border-radius: var(--tk-radius);
    box-shadow: var(--tk-shadow-xs);
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: var(--tk-transition);
    border: 1px solid var(--tk-border);
    animation: tkFadeIn 0.3s var(--tk-ease) forwards;
}

.tk-ticket-row:hover {
    transform: translateX(3px);
    box-shadow: var(--tk-shadow-md);
    border-color: var(--tk-accent-light);
    color: inherit;
}

.tk-ticket-priority {
    width: 4px;
    flex-shrink: 0;
}

.tk-ticket-body {
    flex: 1;
    padding: 0.75rem 1rem;
}

.tk-ticket-ref {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--tk-primary);
    background: rgba(26, 58, 92, 0.06);
    padding: 2px 8px;
    border-radius: 4px;
}

.tk-ticket-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin: 0;
    line-height: 1.35;
}

.tk-ticket-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--tk-text-muted);
}

/* Card style tickets (index "Mes tickets") */
.tk-ticket-card {
    background: var(--tk-surface);
    border-radius: var(--tk-radius);
    border: 1px solid var(--tk-border);
    box-shadow: var(--tk-shadow-xs);
    padding: 1.1rem 1.25rem;
    transition: var(--tk-transition);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.tk-ticket-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--card-accent, var(--tk-border));
    border-radius: var(--tk-radius) 0 0 var(--tk-radius);
}

.tk-ticket-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--tk-shadow-md);
    border-color: var(--tk-accent-light);
}

.tk-ticket-card .tk-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.6rem;
}

.tk-ticket-card .tk-card-title {
    font-weight: 600;
    font-size: 0.92rem;
    line-height: 1.35;
    color: var(--tk-text);
    margin: 0 0 0.35rem;
}

.tk-ticket-card .tk-card-title a {
    color: inherit;
    text-decoration: none;
}

.tk-ticket-card .tk-card-title a:hover {
    color: var(--tk-primary);
}

.tk-ticket-card .tk-card-footer {
    margin-top: auto;
    padding-top: 0.75rem;
    border-top: 1px solid var(--tk-border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.78rem;
}

/* ─── Badge/Chip styles ─── */
.tk-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.55rem;
    border-radius: var(--tk-radius-pill);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.tk-badge-status {
    color: #fff;
}

.tk-badge-outline {
    background: color-mix(in srgb, var(--badge-color, #6c757d) 8%, transparent);
    color: var(--badge-color, #6c757d);
    border: 1px solid color-mix(in srgb, var(--badge-color, #6c757d) 20%, transparent);
}

.tk-badge-cat {
    background: var(--tk-bg-warm);
    color: var(--tk-text-secondary);
    border: 1px solid var(--tk-border);
}

/* ═══════════════════════════════════════════════════════
   CUSTOM TABS (segmented control)
   ═══════════════════════════════════════════════════════ */
.tk-tabs {
    display: inline-flex;
    background: var(--tk-bg);
    border-radius: 10px;
    padding: 3px;
    gap: 0;
    border: 1px solid var(--tk-border);
}

.tk-tab {
    padding: 0.45rem 1rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--tk-text-muted);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--tk-transition);
    border: none;
    background: none;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.tk-tab:hover {
    color: var(--tk-text);
}

.tk-tab.active {
    background: var(--tk-surface);
    color: var(--tk-primary);
    box-shadow: var(--tk-shadow-xs);
}

.tk-tab .tk-tab-count {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.68rem;
    padding: 1px 6px;
    border-radius: var(--tk-radius-pill);
    background: var(--tk-bg);
    color: var(--tk-text-muted);
}

.tk-tab.active .tk-tab-count {
    background: var(--tk-accent-glow);
    color: var(--tk-accent);
}

/* ═══════════════════════════════════════════════════════
   WIZARD BREADCRUMB
   ═══════════════════════════════════════════════════════ */
.tk-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
    padding: 0.55rem 0.75rem;
    background: var(--tk-bg-warm);
    border-radius: var(--tk-radius-sm);
    border: 1px solid var(--tk-border-light);
    margin-bottom: 1.25rem;
}

.tk-breadcrumb-item {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--tk-text-muted);
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.tk-breadcrumb-item.active {
    color: var(--tk-text);
    font-weight: 700;
}

.tk-breadcrumb-item.clickable {
    color: var(--tk-accent);
    cursor: pointer;
    transition: var(--tk-transition);
}

.tk-breadcrumb-item.clickable:hover {
    text-decoration: underline;
    color: var(--tk-primary-light);
}

.tk-breadcrumb-sep {
    font-size: 0.55rem;
    color: var(--tk-text-faint);
}

/* ─── Category & Type Cards ─── */
.tk-category-card,
.tk-type-card {
    padding: 1rem;
    border: 1px solid var(--tk-border);
    border-radius: var(--tk-radius-sm);
    cursor: pointer;
    transition: var(--tk-transition);
    text-align: center;
    background: var(--tk-surface);
}

.tk-category-card:hover,
.tk-type-card:hover {
    border-color: var(--tk-accent-light);
    transform: translateY(-2px);
    box-shadow: var(--tk-shadow-md);
}

.tk-category-card.selected,
.tk-type-card.selected {
    border-color: var(--tk-accent);
    background: var(--tk-accent-glow);
    box-shadow: var(--tk-shadow-focus);
}

.tk-category-card i {
    font-size: 1.3rem;
    display: block;
    margin-bottom: 0.5rem;
}

/* ─── Priority Radio ─── */
.tk-priority-radio input { display: none; }

.tk-priority-radio span {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.35rem 0.7rem;
    border: 1.5px solid var(--tk-border);
    border-radius: var(--tk-radius-pill);
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    transition: var(--tk-transition);
    background: var(--tk-surface);
}

.tk-priority-radio span:hover {
    border-color: var(--prio-color);
    background: color-mix(in srgb, var(--prio-color) 5%, transparent);
}

.tk-priority-radio input:checked + span {
    border-color: var(--prio-color);
    background: color-mix(in srgb, var(--prio-color) 10%, transparent);
    color: var(--prio-color);
}

/* ═══════════════════════════════════════════════════════
   TICKET DETAIL HEADER
   ═══════════════════════════════════════════════════════ */
.tk-detail-header {
    background: var(--tk-surface);
    border: 1px solid var(--tk-border);
    border-radius: var(--tk-radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 0;
    box-shadow: var(--tk-shadow);
}

.tk-detail-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.65rem;
}

.tk-detail-dates {
    display: flex;
    gap: 1rem;
    font-size: 0.72rem;
    color: var(--tk-text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.tk-detail-title {
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -0.015em;
    margin: 0;
    color: var(--tk-text);
}

/* People row in header */
.tk-detail-people {
    display: flex;
    gap: 1.25rem;
    margin-top: 0.75rem;
    padding-top: 0.65rem;
    border-top: 1px solid var(--tk-border-light);
}

.tk-detail-person {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.tk-detail-person-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--tk-text-faint);
    margin-right: 0.15rem;
}

.tk-detail-person-name {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--tk-text);
}

/* Header meta tokens */
.tk-header-sep {
    width: 1px;
    height: 14px;
    background: var(--tk-border);
    display: inline-block;
    vertical-align: middle;
}

.tk-header-meta {
    font-size: 0.72rem;
    color: var(--tk-text-muted);
    font-weight: 500;
}

/* Actions inline in header */
.tk-detail-actions-inline {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-left: auto;
    flex-wrap: wrap;
}

/* ═══════════════════════════════════════════════════════
   SECTION TITLES
   ═══════════════════════════════════════════════════════ */
.tk-section-title {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--tk-text-muted);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.tk-section-title i {
    font-size: 0.72rem;
    color: var(--tk-accent);
}

/* ═══════════════════════════════════════════════════════
   PEOPLE ROWS (sidebar)
   ═══════════════════════════════════════════════════════ */
.tk-person-row {
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--tk-border-light);
}

.tk-person-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--tk-text-faint);
    margin-bottom: 0.3rem;
}

.tk-person-value {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.84rem;
    font-weight: 500;
}

/* ═══════════════════════════════════════════════════════
   SIDEBAR META
   ═══════════════════════════════════════════════════════ */
.tk-sidebar-meta {
    display: flex;
    flex-direction: column;
}

.tk-sidebar-meta > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0;
    font-size: 0.82rem;
    border-bottom: 1px solid var(--tk-border-light);
}

.tk-sidebar-meta > div:last-child { border-bottom: none; }

.tk-sidebar-meta > div > span:first-child {
    color: var(--tk-text-muted);
    font-size: 0.76rem;
    font-weight: 500;
}

.tk-sidebar-meta > div > strong,
.tk-sidebar-meta > div > .tk-mono {
    font-size: 0.78rem;
}

.tk-sidebar-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--tk-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.35rem;
    display: block;
}

/* ═══════════════════════════════════════════════════════
   CUSTOM FIELDS GRID
   ═══════════════════════════════════════════════════════ */
.tk-custom-fields-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.65rem;
}

.tk-custom-field {
    padding: 0.55rem 0.65rem;
    background: var(--tk-bg-warm);
    border-radius: var(--tk-radius-sm);
    border: 1px solid var(--tk-border-light);
}

.tk-custom-field-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--tk-text-muted);
    margin-bottom: 0.2rem;
}

.tk-custom-field-value {
    font-size: 0.84rem;
    font-weight: 500;
}

/* ═══════════════════════════════════════════════════════
   ATTACHMENTS GRID
   ═══════════════════════════════════════════════════════ */
.tk-attachments-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tk-attachment-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.65rem;
    background: var(--tk-bg-warm);
    border: 1px solid var(--tk-border-light);
    border-radius: var(--tk-radius-sm);
    text-decoration: none;
    color: var(--tk-text);
    transition: var(--tk-transition);
    max-width: 260px;
}

.tk-attachment-item:hover {
    border-color: var(--tk-accent);
    box-shadow: var(--tk-shadow);
    color: var(--tk-text);
}

.tk-attachment-icon {
    font-size: 1rem;
    color: var(--tk-text-muted);
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.tk-attachment-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.tk-attachment-name {
    font-size: 0.78rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tk-attachment-size {
    font-size: 0.65rem;
    color: var(--tk-text-faint);
}

/* ═══════════════════════════════════════════════════════
   CHAT PANEL (sidebar)
   ═══════════════════════════════════════════════════════ */
.tk-chat-panel {
    background: var(--tk-surface);
    border: 1px solid var(--tk-border);
    border-radius: var(--tk-radius);
    box-shadow: var(--tk-shadow);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 70px;
    max-height: calc(100vh - 90px);
    overflow: hidden;
}

.tk-chat-panel-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--tk-border-light);
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--tk-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    flex-shrink: 0;
}

.tk-chat-panel-header i {
    color: var(--tk-accent);
    font-size: 0.72rem;
}

.tk-chat-panel-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.55rem 0.7rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-height: 200px;
}

.tk-chat-panel-input {
    border-top: 1px solid var(--tk-border-light);
    padding: 0.55rem 0.7rem;
    flex-shrink: 0;
}

.tk-chat-msg {
    display: flex;
    gap: 0.35rem;
    align-items: flex-start;
    max-width: 92%;
    animation: tkFadeIn 0.2s var(--tk-ease) forwards;
}

.tk-chat-msg.own {
    margin-left: auto;
    flex-direction: row-reverse;
}

.tk-chat-bubble {
    background: var(--tk-bg);
    padding: 0.35rem 0.6rem;
    border-radius: 10px 10px 10px 3px;
    max-width: 100%;
    word-break: break-word;
    border: 1px solid var(--tk-border-light);
}

.tk-chat-msg.own .tk-chat-bubble {
    background: var(--tk-primary);
    color: #fff;
    border-radius: 10px 10px 3px 10px;
    border-color: transparent;
}

.tk-chat-msg.internal .tk-chat-bubble {
    background: #fffbeb;
    border: 1px dashed #fbbf24;
}

.tk-chat-msg.own.internal .tk-chat-bubble {
    background: #fffbeb;
    color: #92400e;
}

.tk-chat-author {
    font-size: 0.62rem;
    font-weight: 700;
    color: var(--tk-primary);
    margin-bottom: 1px;
}

.tk-chat-msg.own .tk-chat-author { display: none; }

.tk-chat-text {
    font-size: 0.8rem;
    line-height: 1.35;
}

.tk-chat-time {
    font-size: 0.56rem;
    opacity: 0.4;
    margin-top: 1px;
    text-align: right;
    font-family: 'JetBrains Mono', monospace;
}

.tk-chat-internal-badge {
    font-size: 0.56rem;
    font-weight: 700;
    color: #92400e;
    margin-bottom: 1px;
}

.tk-chat-system {
    text-align: center;
    font-size: 0.66rem;
    color: var(--tk-text-muted);
    padding: 0.1rem 0;
    font-style: italic;
}

/* ═══════════════════════════════════════════════════════
   TABLE view
   ═══════════════════════════════════════════════════════ */
.tk-data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.82rem;
}

.tk-data-table thead th {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--tk-text-muted);
    padding: 0.65rem 0.75rem;
    border-bottom: 2px solid var(--tk-border);
    white-space: nowrap;
    background: var(--tk-bg-warm);
    position: sticky;
    top: 0;
    z-index: 1;
}

.tk-data-table tbody td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--tk-border-light);
    vertical-align: middle;
}

.tk-data-table tbody tr {
    transition: background 0.15s var(--tk-ease);
}

.tk-data-table tbody tr:hover td {
    background: color-mix(in srgb, var(--tk-accent) 3%, #fff);
}

.tk-data-table tbody tr:last-child td {
    border-bottom: none;
}

/* ─── Status filter pills ─── */
.tk-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
    background: var(--tk-surface);
    padding: 0.5rem 0.75rem;
    border-radius: var(--tk-radius);
    border: 1px solid var(--tk-border);
    margin-bottom: 1rem;
}

.tk-filter-pill {
    padding: 0.3rem 0.7rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--tk-radius-pill);
    cursor: pointer;
    transition: var(--tk-transition);
    border: 1.5px solid var(--tk-border);
    background: var(--tk-surface);
    color: var(--tk-text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.tk-filter-pill:hover {
    border-color: var(--pill-color, var(--tk-text-muted));
    background: color-mix(in srgb, var(--pill-color, var(--tk-accent)) 6%, transparent);
}

.tk-filter-pill.active {
    background: var(--pill-color, var(--tk-primary));
    border-color: var(--pill-color, var(--tk-primary));
    color: #fff;
}

/* ─── Search input ─── */
.tk-search-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--tk-surface);
    border: 1px solid var(--tk-border);
    border-radius: var(--tk-radius-sm);
    padding: 0 0.75rem;
    transition: var(--tk-transition);
}

.tk-search-box:focus-within {
    border-color: var(--tk-accent);
    box-shadow: var(--tk-shadow-focus);
}

.tk-search-box i {
    color: var(--tk-text-faint);
    font-size: 0.82rem;
}

.tk-search-box input {
    border: none;
    outline: none;
    background: none;
    font-size: 0.82rem;
    padding: 0.4rem 0;
    width: 100%;
    color: var(--tk-text);
    font-family: inherit;
}

.tk-search-box input::placeholder {
    color: var(--tk-text-faint);
}

/* ═══════════════════════════════════════════════════════
   FIELD BUILDER
   ═══════════════════════════════════════════════════════ */
.tk-field-card {
    background: var(--tk-bg-warm);
    border: 1px solid var(--tk-border);
    border-radius: var(--tk-radius-sm);
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    transition: var(--tk-transition);
}

.tk-field-card:hover {
    border-color: var(--tk-accent-light);
}

.tk-field-card.dragging {
    opacity: 0.5;
}

.cursor-grab { cursor: grab; }

/* ─── Admin Tabs ─── */
.tk-admin-tabs .nav-link {
    font-weight: 600;
    font-size: 0.82rem;
    border-radius: var(--tk-radius-sm) var(--tk-radius-sm) 0 0;
    color: var(--tk-text-muted);
}

.tk-admin-tabs .nav-link.active {
    color: var(--tk-primary);
    border-color: var(--tk-border) var(--tk-border) #fff;
}

/* ─── Hover bg ─── */
.hover-bg { transition: var(--tk-transition); border-radius: var(--tk-radius-xs); }
.hover-bg:hover { background: var(--tk-bg-warm); }

/* ═══════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════ */
.btn {
    font-family: 'DM Sans', sans-serif;
    font-weight: 600;
    letter-spacing: -0.01em;
    border-radius: var(--tk-radius-sm);
    transition: var(--tk-transition);
}

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

.btn-primary:hover {
    background: var(--tk-primary-light);
    border-color: var(--tk-primary-light);
    transform: translateY(-1px);
    box-shadow: var(--tk-shadow-md);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-outline-primary {
    color: var(--tk-primary);
    border-color: var(--tk-primary);
}

.btn-outline-primary:hover {
    background: var(--tk-primary);
    border-color: var(--tk-primary);
}

.text-primary { color: var(--tk-primary) !important; }

/* ─── Form controls ─── */
.form-control, .form-select {
    border-radius: var(--tk-radius-sm);
    border-color: var(--tk-border);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.85rem;
    transition: var(--tk-transition);
}

.form-control:focus, .form-select:focus {
    border-color: var(--tk-accent);
    box-shadow: var(--tk-shadow-focus);
}

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

/* ═══════════════════════════════════════════════════════
   LOGIN PAGE
   ═══════════════════════════════════════════════════════ */
.tk-login-wrapper {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: #fafbfc;
}

/* ─── Left branded panel ─── */
.tk-login-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, var(--tk-primary-dark) 0%, var(--tk-primary) 50%, var(--tk-primary-light) 100%);
    position: relative;
    overflow: hidden;
    padding: 3rem;
}

.tk-login-brand::before {
    content: '';
    position: absolute;
    top: -15%;
    right: -15%;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background: rgba(45, 156, 219, 0.1);
    pointer-events: none;
}

.tk-login-brand::after {
    content: '';
    position: absolute;
    bottom: -20%;
    left: -10%;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: rgba(45, 156, 219, 0.07);
    pointer-events: none;
}

.tk-login-brand-content {
    position: relative;
    z-index: 1;
    text-align: center;
    color: #fff;
    max-width: 360px;
}

.tk-login-brand-content img {
    max-height: 72px;
    max-width: 240px;
    margin-bottom: 2rem;
}

.tk-login-brand-content h2 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.75rem;
    line-height: 1.3;
}

.tk-login-brand-content p {
    font-size: 0.9rem;
    color: rgba(255,255,255,0.7);
    line-height: 1.6;
    margin: 0;
}

/* ─── Right form panel ─── */
.tk-login-form-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.tk-login-card {
    width: 100%;
    max-width: 380px;
    animation: tkSlideUp 0.5s var(--tk-ease);
}

.tk-login-card .tk-login-logo-mobile {
    display: none;
    margin-bottom: 1.5rem;
}

.tk-login-card .tk-login-logo-mobile img {
    max-height: 48px;
}

.tk-login-card h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--tk-text);
    margin-bottom: 0.35rem;
}

.tk-login-card .tk-login-subtitle {
    font-size: 0.88rem;
    color: var(--tk-text-muted);
    margin-bottom: 2rem;
    line-height: 1.4;
}

.tk-login-card .form-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--tk-text-secondary);
    margin-bottom: 0.4rem;
}

.tk-login-card .form-control {
    padding: 0.65rem 0.85rem;
    border-radius: 10px;
    border: 1.5px solid var(--tk-border);
    font-size: 0.88rem;
    background: #fff;
    transition: var(--tk-transition);
}

.tk-login-card .form-control:focus {
    border-color: var(--tk-accent);
    box-shadow: 0 0 0 4px rgba(45, 156, 219, 0.08);
}

.tk-login-card .form-control::placeholder {
    color: var(--tk-text-faint);
}

.tk-login-card .input-group .btn {
    border-radius: 0 10px 10px 0;
    border: 1.5px solid var(--tk-border);
    border-left: none;
    background: #fff;
}

.tk-login-card .input-group .form-control {
    border-radius: 10px 0 0 10px;
}

.tk-login-btn {
    width: 100%;
    padding: 0.7rem;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    background: var(--tk-primary);
    color: #fff;
    cursor: pointer;
    transition: var(--tk-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    letter-spacing: -0.01em;
}

.tk-login-btn:hover {
    background: var(--tk-primary-light);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(26, 58, 92, 0.2);
}

.tk-login-btn:active {
    transform: translateY(0);
}

.tk-login-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.tk-login-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--tk-border-light);
}

.tk-login-footer a {
    color: var(--tk-text-muted);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    transition: var(--tk-transition);
}

.tk-login-footer a:hover {
    color: var(--tk-accent);
}

/* ─── Login alerts ─── */
.tk-login-alert {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.85rem;
    border-radius: 10px;
    font-size: 0.83rem;
    font-weight: 500;
    margin-bottom: 1.25rem;
    animation: tkFadeIn 0.3s var(--tk-ease);
}

.tk-login-alert-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.tk-login-alert-success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

/* ─── Responsive: stack on mobile ─── */
@media (max-width: 768px) {
    .tk-login-wrapper {
        grid-template-columns: 1fr;
    }

    .tk-login-brand {
        display: none;
    }

    .tk-login-card .tk-login-logo-mobile {
        display: block;
    }

    .tk-login-form-panel {
        min-height: 100vh;
    }
}

/* ═══════════════════════════════════════════════════════
   ERROR PAGES
   ═══════════════════════════════════════════════════════ */
.tk-error-page {
    text-align: center;
    padding: 4rem 1rem;
    max-width: 480px;
    margin: 0 auto;
}

.tk-error-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin-bottom: 1.5rem;
}

.tk-error-page h3 {
    font-weight: 700;
    font-size: 1.4rem;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

.tk-error-page p {
    color: var(--tk-text-muted);
    font-size: 0.9rem;
}

/* ═══════════════════════════════════════════════════════
   EMPTY STATES
   ═══════════════════════════════════════════════════════ */
.tk-empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    background: var(--tk-bg-warm);
    border-radius: var(--tk-radius);
    border: 1px dashed var(--tk-border);
}

.tk-empty-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--tk-bg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--tk-text-faint);
    margin-bottom: 1rem;
}

.tk-empty-state h5 {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 0.35rem;
}

.tk-empty-state p {
    color: var(--tk-text-muted);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

/* ═══════════════════════════════════════════════════════
   VIEW SWITCHER (table / kanban)
   ═══════════════════════════════════════════════════════ */
.tk-view-switch {
    display: inline-flex;
    border-radius: var(--tk-radius-sm);
    overflow: hidden;
    border: 1px solid var(--tk-border);
}

.tk-view-switch a {
    padding: 0.35rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--tk-text-muted);
    background: var(--tk-surface);
    transition: var(--tk-transition);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.tk-view-switch a:first-child {
    border-right: 1px solid var(--tk-border);
}

.tk-view-switch a.active {
    background: var(--tk-primary);
    color: #fff;
    border-color: var(--tk-primary);
}

.tk-view-switch a:hover:not(.active) {
    background: var(--tk-bg);
    color: var(--tk-text);
}

/* ═══════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════ */
@keyframes tkFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes tkSlideUp {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes tkSlideIn {
    from { opacity: 0; transform: translateX(-8px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Staggered animation helper */
.tk-stagger > * {
    opacity: 0;
    animation: tkFadeIn 0.35s var(--tk-ease) forwards;
}
.tk-stagger > *:nth-child(1) { animation-delay: 0s; }
.tk-stagger > *:nth-child(2) { animation-delay: 0.04s; }
.tk-stagger > *:nth-child(3) { animation-delay: 0.08s; }
.tk-stagger > *:nth-child(4) { animation-delay: 0.12s; }
.tk-stagger > *:nth-child(5) { animation-delay: 0.16s; }
.tk-stagger > *:nth-child(6) { animation-delay: 0.20s; }
.tk-stagger > *:nth-child(7) { animation-delay: 0.24s; }
.tk-stagger > *:nth-child(8) { animation-delay: 0.28s; }
.tk-stagger > *:nth-child(9) { animation-delay: 0.32s; }
.tk-stagger > *:nth-child(10) { animation-delay: 0.36s; }

/* ═══════════════════════════════════════════════════════
   SCROLLBAR (subtle)
   ═══════════════════════════════════════════════════════ */
.tk-chat-panel-messages::-webkit-scrollbar { width: 4px; }
.tk-chat-panel-messages::-webkit-scrollbar-track { background: transparent; }
.tk-chat-panel-messages::-webkit-scrollbar-thumb { background: var(--tk-text-faint); border-radius: 3px; }
.tk-chat-panel-messages::-webkit-scrollbar-thumb:hover { background: var(--tk-text-muted); }

/* ═══════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .tk-stat-card { padding: 0.5rem; }
    .tk-stat-number { font-size: 1.25rem; }
    .tk-ticket-meta { flex-wrap: wrap; gap: 0.5rem; }
    .tk-chat-msg { max-width: 95%; }
    .tk-chat-panel { position: static; max-height: none; }
    .tk-chat-panel-messages { min-height: 150px; max-height: 250px; }
    .tk-navbar-logo { height: 22px; }
    .tk-navbar { padding: 0 0.75rem; }
    .tk-page-header { flex-direction: column; gap: 0.75rem; align-items: flex-start; }
    .tk-page-header h4, .tk-page-header h5 { font-size: 1.1rem; }
    .tk-detail-header-top { flex-direction: column; align-items: flex-start; }
    .tk-detail-title { font-size: 1rem; }
    .tk-detail-people { flex-direction: column; gap: 0.5rem; }
    .tk-header-sep { display: none; }
    .tk-custom-fields-grid { grid-template-columns: 1fr; }
}
