/* ============================================
   DEVIXY STYLE — support-ticket-system
   Dark theme · purple accent · glassmorphism
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --bg-primary:    #1B1B1C;
    --bg-secondary:  #242426;
    --bg-overlay:    rgba(255,255,255,0.05);

    --text-primary:   #FFFFFF;
    --text-secondary: rgba(255,255,255,0.85);
    --text-muted:     #6B7280;

    --border-subtle: rgba(255,255,255,0.1);
    --border-medium: rgba(255,255,255,0.2);

    --brand-primary: #8B5CF6;
    --brand-hover:   rgba(139,92,246,0.2);
    --brand-active:  #7C3AED;
    --brand-glow:    rgba(139,92,246,0.3);

    --success: #22C55E;
    --warning: #F59E0B;
    --danger:  #EF4444;
    --info:    #3B82F6;

    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 9px;

    /* legacy compat */
    --bg:          var(--bg-primary);
    --card:        var(--bg-secondary);
    --card-elevated: #2a2a2c;
    --border:      rgba(255,255,255,0.1);
    --border-light: rgba(255,255,255,0.14);
    --text:        var(--text-primary);
    --text-sub:    rgba(255,255,255,0.65);
    --primary:     var(--brand-primary);
    --primary-hover: var(--brand-active);
    --primary-dim: rgba(139,92,246,0.12);
    --error:       #EF4444;
}

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ─── Body ─── */
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-primary);
    background-image: radial-gradient(circle, rgba(255,255,255,0.07) 1px, transparent 1px);
    background-size: 26px 26px;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.6;
    min-height: 100vh;
}

body::before {
    content: '';
    position: fixed;
    top: -200px;
    left: 50%;
    transform: translateX(-50%);
    width: 800px;
    height: 600px;
    background: radial-gradient(ellipse, rgba(139,92,246,0.12) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
    animation: bgPulse 8s ease-in-out infinite;
}

@keyframes bgPulse {
    0%,100% { opacity: 0.7; transform: translateX(-50%) scale(1); }
    50%      { opacity: 1;   transform: translateX(-50%) scale(1.1); }
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: rgba(139,92,246,0.35); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(139,92,246,0.6); }

/* old blob disabled */
.bg-animations { display: none; }

/* ─── Layout ─── */
.main-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem 3rem;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

/* ─── Navbar ─── */
.navbar {
    background: rgba(27,27,28,0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0 1.5rem;
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    margin-bottom: 0;
}

/* Reset main-wrapper top padding when navbar is sticky */
.main-wrapper { padding-top: 2rem; }

.logo {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.4px;
    text-decoration: none !important;
    background: linear-gradient(
        120deg,
        #ffffff 0%, #ffffff 20%,
        #c4b5fd 35%, #ffffff 50%,
        #ffffff 65%, #a78bfa 80%,
        #ffffff 100%
    );
    background-size: 300% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: logoShimmer 4s ease-in-out infinite;
}
.logo span { -webkit-text-fill-color: transparent; }

@keyframes logoShimmer {
    0%   { background-position: 200% center; filter: drop-shadow(0 0 0px rgba(139,92,246,0)); }
    45%  { background-position: 60% center;  filter: drop-shadow(0 0 8px rgba(139,92,246,0.55)); }
    55%  { background-position: 40% center;  filter: drop-shadow(0 0 16px rgba(139,92,246,0.85)); }
    100% { background-position: -100% center;filter: drop-shadow(0 0 0px rgba(139,92,246,0)); }
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-info span {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.logout-link {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.45rem 0.9rem;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
    background: rgba(255,255,255,0.04);
    transition: all 0.2s;
}
.logout-link:hover {
    background: rgba(239,68,68,0.1);
    border-color: rgba(239,68,68,0.25);
    color: #ef4444;
}

/* ─── Buttons ─── */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0.65rem 1.4rem;
    background: var(--brand-primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 2px 12px rgba(139,92,246,0.25);
    transition: all 0.25s ease;
    width: auto;
}
.btn-primary:hover {
    background: var(--brand-active);
    box-shadow: 0 4px 20px rgba(139,92,246,0.45);
    transform: translateY(-2px);
    color: #fff;
}
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.55rem 1rem;
    background: rgba(255,255,255,0.06);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 9px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}
.btn-ghost:hover {
    background: rgba(255,255,255,0.1);
    border-color: var(--border-medium);
    color: var(--text-primary);
    transform: translateY(-1px);
}

/* ─── Forms ─── */
.form-group { margin-bottom: 1.1rem; }

.form-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.4rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    padding: 0.7rem 1rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--text-muted); }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(139,92,246,0.15);
}
.form-group textarea { resize: vertical; min-height: 120px; }
.form-group select { cursor: pointer; -webkit-appearance: none; }

/* ─── Alerts ─── */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 10px;
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
    border: 1px solid;
}
.alert-error {
    background: rgba(239,68,68,0.08);
    color: #ef4444;
    border-color: rgba(239,68,68,0.25);
}
.alert-success {
    background: rgba(34,197,94,0.08);
    color: #22c55e;
    border-color: rgba(34,197,94,0.25);
}

/* ─── Auth Pages ─── */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}

.auth-card {
    background: linear-gradient(135deg, rgba(139,92,246,0.04) 0%, rgba(59,130,246,0.04) 100%);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.auth-card:hover {
    border-color: rgba(139,92,246,0.2);
    box-shadow: 0 8px 32px rgba(139,92,246,0.08);
}

.auth-card h2 {
    font-size: 1.55rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 1.75rem;
    text-align: center;
    color: var(--text-primary);
}

.auth-footer {
    margin-top: 1.5rem;
    padding-top: 1.4rem;
    border-top: 1px solid var(--border-subtle);
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.auth-footer a {
    color: var(--text-primary);
    font-weight: 600;
    text-decoration: none;
    margin-left: 4px;
}
.auth-footer a:hover { color: var(--brand-primary); }

/* ─── Dashboard header ─── */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.dashboard-header h1 {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.4px;
    color: var(--text-primary);
}

/* ─── Stats ─── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    position: relative;
    background: rgba(27,27,28,0.6);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px;
    padding: 1.25rem 1.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(139,92,246,0.06) 0%, transparent 60%);
    pointer-events: none;
}
.stat-card:hover {
    border-color: rgba(139,92,246,0.3);
    box-shadow: 0 4px 24px rgba(139,92,246,0.1);
}
.stat-card a { text-decoration: none; }

.stat-value {
    font-size: 1.9rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--brand-primary);
    line-height: 1;
    position: relative;
}

.stat-label {
    font-size: 0.73rem;
    color: var(--text-muted);
    font-weight: 500;
    position: relative;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

/* ─── Filters ─── */
.filters-area {
    background: rgba(27,27,28,0.55);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: flex-end;
}
.filters-area .form-group { margin-bottom: 0; flex: 1; min-width: 160px; }

/* ─── Ticket Grid ─── */
.ticket-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

.ticket-card {
    background: rgba(27,27,28,0.55);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-decoration: none;
    color: inherit;
    display: block;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
    position: relative;
    overflow: hidden;
}
.ticket-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(139,92,246,0.4), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}
.ticket-card:hover {
    border-color: rgba(139,92,246,0.3);
    box-shadow: 0 8px 32px rgba(139,92,246,0.12), 0 0 0 1px rgba(139,92,246,0.08);
    transform: translateY(-3px);
}
.ticket-card:hover::before { opacity: 1; }

.ticket-card h3 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0.5rem 0 0.4rem;
    color: var(--text-primary);
    letter-spacing: -0.2px;
}

.ticket-card p {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.5;
}

.ticket-meta {
    margin-top: 1rem;
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ─── Badges ─── */
.ticket-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    white-space: nowrap;
}
.ticket-badge::before {
    content: '';
    width: 5px; height: 5px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.badge-open             { background: rgba(59,130,246,0.1);  color: #60a5fa; }
.badge-in_progress      { background: rgba(245,158,11,0.1);  color: #fbbf24; }
.badge-awaiting_response{ background: rgba(139,92,246,0.12); color: #a78bfa; }
.badge-closed           { background: rgba(148,163,184,0.08);color: #64748b; }

/* ─── Ticket Detail ─── */
.ticket-layout {
    display: grid;
    grid-template-columns: 1fr 272px;
    gap: 1.5rem;
    align-items: start;
}

.ticket-detail-header { margin-bottom: 1.5rem; }

.ticket-detail-header h1 {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.4px;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.ticket-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ─── Ticket Actions ─── */
.ticket-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-subtle);
}

.action-btn {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 1rem;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid;
    transition: all 0.18s;
    text-decoration: none;
}
.action-btn-close { background: rgba(239,68,68,0.08); color: #ef4444; border-color: rgba(239,68,68,0.2); }
.action-btn-close:hover { background: rgba(239,68,68,0.15); }

/* ── Status dropdown ── */
.status-dropdown-wrap {
    position: relative;
    display: inline-block;
}
.action-btn-status {
    background: rgba(139,92,246,0.1);
    color: #a78bfa;
    border-color: rgba(139,92,246,0.25);
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 1rem;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid;
    transition: all 0.18s;
}
.action-btn-status:hover { background: rgba(139,92,246,0.18); }
.status-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 190px;
    background: #1e1e20;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    z-index: 100;
    overflow: hidden;
    flex-direction: column;
}
.status-dropdown.open { display: flex; }
.status-dropdown-item {
    background: none;
    border: none;
    padding: 0.65rem 1rem;
    text-align: left;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.status-dropdown-item:last-child { border-bottom: none; }
.item-progress { color: #fbbf24; }
.item-progress:hover { background: rgba(245,158,11,0.12); }
.item-await    { color: #a78bfa; }
.item-await:hover { background: rgba(139,92,246,0.12); }
.item-close    { color: #ef4444; }
.item-close:hover { background: rgba(239,68,68,0.1); }

/* ─── Chat ─── */
.chat-column { display: flex; flex-direction: column; }

.chat-box {
    position: relative;
    background: rgba(20, 20, 22, 0.72);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 260px);
    min-height: 520px;
    overflow: hidden;
    transition: border-color 0.2s;
    box-shadow: 0 8px 40px rgba(0,0,0,0.3);
}
.chat-box:focus-within {
    border-color: rgba(139,92,246,0.22);
    box-shadow: 0 8px 40px rgba(0,0,0,0.3), 0 0 0 3px rgba(139,92,246,0.06);
}

/* Subtle top accent line */
.chat-box::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, rgba(139,92,246,0.5) 40%, rgba(139,92,246,0.5) 60%, transparent 100%);
    z-index: 2;
}

/* ── Messages area ── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* Date separator */
.msg-date-sep {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1.25rem 0 1rem;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}
.msg-date-sep::before,
.msg-date-sep::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255,255,255,0.06);
}

/* Message rows */
.msg-row {
    display: flex;
    gap: 0.65rem;
    align-items: flex-end;
    padding: 0.15rem 0;
    animation: msgIn 0.22s cubic-bezier(0.22,1,0.36,1) both;
}
.msg-row.mine { flex-direction: row-reverse; }
.msg-row.msg-new { animation: msgIn 0.28s cubic-bezier(0.22,1,0.36,1) both; }

/* Group consecutive from same sender — hide avatar for middle messages */
.msg-row.grouped .msg-avatar { visibility: hidden; }
.msg-row.grouped { padding-top: 0.05rem; }

@keyframes msgIn {
    from { opacity: 0; transform: translateY(8px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Avatar */
.msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    border: 1.5px solid transparent;
    transition: transform 0.15s;
}
.msg-avatar:hover { transform: scale(1.1); }

/* Avatar color by role */
.avatar-user    { background: rgba(59,130,246,0.18);  color: #60a5fa; border-color: rgba(59,130,246,0.25); }
.avatar-helper  { background: rgba(139,92,246,0.18);  color: #a78bfa; border-color: rgba(139,92,246,0.3); }
.avatar-curator { background: rgba(167,139,250,0.22); color: #c4b5fd; border-color: rgba(167,139,250,0.35); }
.avatar-system  { background: rgba(100,116,139,0.15); color: #64748b; border-color: rgba(100,116,139,0.2); }

/* Message content wrapper */
.msg-content {
    max-width: 72%;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.msg-row.mine .msg-content { align-items: flex-end; }

/* Meta (name + role + time) */
.msg-meta {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.67rem;
    color: var(--text-muted);
    padding: 0 0.25rem;
    margin-bottom: 0.1rem;
}
.msg-row.grouped .msg-meta { display: none; }

.msg-name { font-weight: 600; color: rgba(255,255,255,0.5); }

/* Role badges */
.role-badge {
    padding: 0.08rem 0.42rem;
    border-radius: 999px;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.role-user    { background: rgba(59,130,246,0.12);  color: #60a5fa; }
.role-helper  { background: rgba(139,92,246,0.14);  color: #a78bfa; }
.role-curator { background: rgba(167,139,250,0.18); color: #c4b5fd; }
.role-system  { background: rgba(100,116,139,0.1);  color: #64748b; }

/* Bubble */
.msg-bubble {
    position: relative;
    padding: 0.65rem 0.9rem;
    border-radius: 16px;
    font-size: 0.875rem;
    line-height: 1.6;
    word-break: break-word;
    transition: opacity 0.15s;
}

/* ── My messages (right) ── */
.msg-row.mine .msg-bubble {
    background: var(--brand-primary);
    color: #fff;
    border-radius: 16px 16px 4px 16px;
    box-shadow: 0 2px 14px rgba(139,92,246,0.35), inset 0 1px 0 rgba(255,255,255,0.12);
}

/* ── Their messages (left) ── */
.msg-row.other .msg-bubble {
    background: rgba(255,255,255,0.06);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--text-primary);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px 16px 16px 4px;
}

/* Timestamp on hover */
.msg-bubble::after {
    content: attr(data-time);
    position: absolute;
    bottom: -1.1rem;
    font-size: 0.6rem;
    color: var(--text-muted);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.15s;
    pointer-events: none;
}
.msg-row.mine  .msg-bubble::after { right: 0.25rem; }
.msg-row.other .msg-bubble::after { left: 0.25rem; }
.msg-row:hover .msg-bubble::after { opacity: 1; }

/* ── System messages ── */
.msg-row.system-msg {
    justify-content: center;
    margin: 0.75rem 0;
}
.msg-row.system-msg .msg-content {
    max-width: 80%;
    align-items: center;
}
.msg-row.system-msg .msg-bubble {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 10px;
    color: var(--text-muted);
    font-size: 0.78rem;
    text-align: center;
    padding: 0.5rem 1rem;
    box-shadow: none;
}

/* File attachments */
.msg-file { margin-top: 0.45rem; }
.msg-file img {
    max-width: 100%;
    max-height: 260px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.08);
    display: block;
}
.msg-file-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.7rem;
    background: rgba(0,0,0,0.25);
    border-radius: 7px;
    color: inherit;
    text-decoration: none;
    font-size: 0.78rem;
    border: 1px solid rgba(255,255,255,0.08);
}

/* Markdown in bubbles */
.msg-bubble p { margin: 0 0 0.4em; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble strong { font-weight: 700; }
.msg-bubble em { font-style: italic; }
.msg-bubble code {
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 0.8em;
    background: rgba(0,0,0,0.3);
    border-radius: 4px;
    padding: 0.1em 0.35em;
}
.msg-bubble pre {
    background: rgba(0,0,0,0.38);
    border-radius: 8px;
    padding: 0.75em 1em;
    overflow-x: auto;
    margin: 0.5em 0;
    font-size: 0.78em;
    border: 1px solid rgba(255,255,255,0.06);
}
.msg-bubble pre code { background: none; padding: 0; }
.msg-bubble ul, .msg-bubble ol { padding-left: 1.4em; margin: 0.3em 0; }
.msg-bubble li { margin: 0.15em 0; }
.msg-bubble blockquote {
    border-left: 3px solid rgba(255,255,255,0.2);
    margin: 0.4em 0;
    padding: 0.1em 0.75em;
    opacity: 0.8;
}
.msg-row.mine .msg-bubble blockquote { border-color: rgba(255,255,255,0.4); }
.msg-bubble a { color: inherit; text-decoration: underline; opacity: 0.85; }

/* ─── Chat input ─── */
.chat-input-area {
    position: relative;
    padding: 0.875rem 1rem;
    border-top: 1px solid rgba(255,255,255,0.06);
    background: rgba(15,15,17,0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    display: flex;
    align-items: flex-end;
    gap: 0.625rem;
}

/* Inner input field wrapper — styled box */
.chat-form { display: contents; }

.chat-input-wrap {
    flex: 1;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 0.45rem 0.6rem 0.45rem 0.5rem;
    display: flex;
    align-items: flex-end;
    gap: 0.4rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.chat-input-wrap:focus-within {
    border-color: rgba(139,92,246,0.3);
    box-shadow: 0 0 0 3px rgba(139,92,246,0.07);
}

.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1.6;
    resize: none;
    min-height: 22px;
    max-height: 140px;
    overflow: hidden;
    overflow-y: auto;
    display: block;
    padding: 0.2rem 0;
}
.chat-input::placeholder { color: var(--text-muted); }

.chat-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.file-upload-btn {
    width: 28px; height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 7px;
    color: rgba(255,255,255,0.25);
    cursor: pointer;
    transition: color 0.15s;
    flex-shrink: 0;
    padding: 0;
}
.file-upload-btn:hover { color: var(--brand-primary); }

.chat-send-btn {
    width: 36px; height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--brand-primary);
    border: none;
    border-radius: 10px;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 2px 12px rgba(139,92,246,0.4);
    transition: background 0.15s, transform 0.12s, box-shadow 0.15s;
    flex-shrink: 0;
}
.chat-send-btn:hover {
    background: var(--brand-active);
    box-shadow: 0 4px 20px rgba(139,92,246,0.55);
    transform: translateY(-1px);
}
.chat-send-btn:active { transform: scale(0.93); box-shadow: none; }
.chat-send-btn svg { width: 14px; height: 14px; }

.chat-closed-notice {
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.78rem;
    border-top: 1px solid rgba(255,255,255,0.06);
    background: rgba(15,15,17,0.4);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ─── Ticket Sidebar ─── */
.ticket-sidebar {
    position: sticky;
    top: 84px;
    background: rgba(20,20,22,0.72);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.ticket-sidebar::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(139,92,246,0.5), transparent);
    z-index: 1;
}
.ticket-sidebar:hover {
    border-color: rgba(139,92,246,0.2);
    box-shadow: 0 8px 40px rgba(139,92,246,0.08), 0 0 0 1px rgba(139,92,246,0.06);
}

.sidebar-header {
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    background: rgba(255,255,255,0.02);
}

.sidebar-header-left { display: flex; align-items: center; gap: 0.75rem; }

.sidebar-icon {
    width: 34px; height: 34px;
    border-radius: 9px;
    background: rgba(139,92,246,0.14);
    border: 1px solid rgba(139,92,246,0.22);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.sidebar-header-title {
    font-weight: 700;
    font-size: 0.875rem;
    color: var(--text-primary);
    letter-spacing: -0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 130px;
}

.sidebar-closed-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.18rem 0.55rem;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: rgba(100,116,139,0.12);
    color: #64748b;
    white-space: nowrap;
    border: 1px solid rgba(100,116,139,0.2);
}

.sidebar-body { padding: 0; }

.sidebar-row {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    padding: 0.7rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    transition: background 0.15s;
}
.sidebar-row:last-child { border-bottom: none; }
.sidebar-row:hover { background: rgba(255,255,255,0.02); }

.sidebar-row-icon {
    color: rgba(255,255,255,0.2);
    flex-shrink: 0;
    margin-top: 1px;
    font-size: 0.8rem;
    width: 16px;
    text-align: center;
}

.sidebar-row-content { flex: 1; min-width: 0; }

.sidebar-row-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: 0.12rem;
}

.sidebar-row-value {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.55);
    font-weight: 500;
    word-break: break-all;
}
.sidebar-row-value.highlight { color: var(--text-primary); }

/* ─── Admin Panel ─── */
.table-wrap {
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    overflow: hidden;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.admin-table th {
    text-align: left;
    padding: 0.8rem 1.1rem;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(255,255,255,0.02);
}

.admin-table td {
    padding: 0.85rem 1.1rem;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    color: rgba(255,255,255,0.65);
    vertical-align: middle;
}

.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: rgba(255,255,255,0.025); }

.admin-table select {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-subtle);
    border-radius: 7px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.8rem;
    padding: 0.3rem 0.6rem;
    cursor: pointer;
    outline: none;
}
.admin-table select:focus { border-color: var(--brand-primary); }

/* ─── Modal ─── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    padding: 2rem;
    width: 90%;
    max-width: 480px;
    box-shadow: 0 24px 64px rgba(0,0,0,0.5), 0 0 0 1px rgba(139,92,246,0.1);
}

/* ─── Responsive ─── */
@media (max-width: 900px) {
    .ticket-layout { grid-template-columns: 1fr; }
    .ticket-sidebar { position: static; }
}
@media (max-width: 640px) {
    .main-wrapper { padding: 1rem 1rem 2rem; }
    .ticket-grid { grid-template-columns: 1fr; }
    .chat-box { height: calc(100vh - 320px); }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .navbar { padding: 0 1rem; }
}

/* ─── Unread badge on ticket cards ─── */
.unread-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--brand-primary);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
    flex-shrink: 0;
    box-shadow: 0 0 8px rgba(139,92,246,0.5);
    animation: pulseBadge 2s ease-in-out infinite;
}

@keyframes pulseBadge {
    0%, 100% { box-shadow: 0 0 8px rgba(139,92,246,0.5); }
    50%       { box-shadow: 0 0 16px rgba(139,92,246,0.9); }
}

.ticket-card--unread {
    border-color: rgba(139,92,246,0.35) !important;
    box-shadow: 0 0 0 1px rgba(139,92,246,0.2), 0 4px 20px rgba(139,92,246,0.1);
}

.ticket-card--unread::before {
    opacity: 1 !important;
}

/* ─── Unread message bubble highlight ─── */
.msg-bubble.msg-unread {
    border-left: 2px solid var(--brand-primary);
    background: rgba(139,92,246,0.13) !important;
    position: relative;
}

.msg-bubble.msg-unread::before {
    content: 'Новое';
    position: absolute;
    top: -18px;
    left: 0;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--brand-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.8;
}

.msg-row.mine .msg-bubble.msg-unread {
    border-left: none;
    border-right: 2px solid var(--brand-primary);
}

.msg-row.mine .msg-bubble.msg-unread::before {
    left: auto;
    right: 0;
}

/* ─── Pinned bar ─── */
#pinned-bar {
    border-bottom: 1px solid rgba(255,255,255,0.07);
    background: rgba(139,92,246,0.07);
    padding: 0.5rem 1rem;
    flex-shrink: 0;
    z-index: 2;
}
.pinned-bar-inner {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.pinned-bar-icon { font-size: 0.85rem; flex-shrink: 0; }
.pinned-bar-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pinned-bar-label {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--brand-primary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.pinned-bar-preview {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pinned-bar-goto {
    background: none;
    border: 1px solid rgba(139,92,246,0.3);
    border-radius: 6px;
    color: var(--brand-primary);
    padding: 0.2rem 0.5rem;
    font-size: 0.8rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
}
.pinned-bar-goto:hover { background: rgba(139,92,246,0.15); }

/* ─── Pin button on messages ─── */
.msg-pin-btn {
    background: none;
    border: none;
    padding: 2px 4px;
    cursor: pointer;
    color: rgba(255,255,255,0.25);
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
    vertical-align: middle;
    margin-left: 4px;
    line-height: 1;
}
.msg-pin-btn:hover { color: var(--brand-primary); background: rgba(139,92,246,0.12); }
.msg-pin-btn.pinned { color: var(--brand-primary); }

.msg-pinned-label {
    font-size: 0.65rem;
    color: var(--brand-primary);
    font-weight: 600;
    letter-spacing: 0.04em;
    margin-bottom: 2px;
    opacity: 0.85;
}

.msg-row--pinned .msg-bubble {
    border: 1px solid rgba(139,92,246,0.25) !important;
}

/* ─── File preview bar ─── */
#file-preview-bar {
    padding: 0.6rem 0.75rem;
    background: rgba(255,255,255,0.04);
    border-top: 1px solid rgba(255,255,255,0.07);
    border-radius: 0 0 0 0;
}
#file-preview-inner {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}
#file-preview-thumb {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    overflow: hidden;
    background: rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1px solid rgba(255,255,255,0.1);
}
.file-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.file-preview-icon {
    font-size: 0.6rem;
    font-weight: 800;
    color: var(--brand-primary);
    letter-spacing: 0.03em;
}
.file-preview-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(139,92,246,0.3);
    border-top-color: var(--brand-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#file-preview-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
#file-preview-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#file-preview-size {
    font-size: 0.7rem;
    color: var(--text-muted);
}
#file-preview-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    font-size: 0.85rem;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
}
#file-preview-remove:hover { color: var(--danger); background: rgba(239,68,68,0.1); }

/* ─── Send button disabled state ─── */
.chat-send-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

/* ─── Ticket card wrap (for pin button positioning) ─── */
.ticket-card-wrap {
    position: relative;
}

.ticket-pin-btn {
    position: absolute;
    top: 0.65rem;
    right: 0.65rem;
    background: rgba(20,20,22,0.85);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 0.25rem 0.4rem;
    font-size: 0.8rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, border-color 0.15s;
    z-index: 2;
    line-height: 1;
}

.ticket-card-wrap:hover .ticket-pin-btn {
    opacity: 1;
}

.ticket-pin-btn.is-pinned {
    opacity: 1;
    background: rgba(139,92,246,0.15);
    border-color: rgba(139,92,246,0.35);
}

.ticket-pin-btn:hover {
    background: rgba(139,92,246,0.2) !important;
    border-color: rgba(139,92,246,0.5) !important;
}

/* ─── Pinned ticket card style ─── */
.ticket-card--pinned {
    border-color: rgba(139,92,246,0.3) !important;
    background: rgba(139,92,246,0.05) !important;
}

.ticket-card--pinned::before {
    opacity: 1 !important;
}

/* ─── Section labels ─── */
.tickets-section-label {
    grid-column: 1 / -1;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 0.25rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    margin-bottom: 0.25rem;
}
