/* ==========================================
   SupportDesk - Complete Stylesheet
   ========================================== */

:root {
    /* Dark theme (default) */
    --bg-primary:   #0d0d1f;
    --bg-secondary: #13132b;
    --bg-card:      #191934;
    --bg-input:     #1f1f44;
    --bg-hover:     #242452;
    --border:       #2e2e60;
    --text-primary:   #eeeef5;
    --text-secondary: #9090bb;
    --text-muted:     #5e5e90;
    --accent:       #00d4aa;
    --accent-hover: #00f0c2;
    --accent-dim:   rgba(0, 212, 170, 0.14);
    --red:    #ff4466;
    --orange: #ff8c42;
    --yellow: #ffc444;
    --green:  #00d4aa;
    --blue:   #4d94ff;
    --purple: #9b72ff;
    --radius:    12px;
    --radius-sm:  8px;
    --shadow:     0 4px 20px rgba(0,0,0,0.4);
    --shadow-lg:  0 8px 40px rgba(0,0,0,0.5);
    --font: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

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

/* ==========================================
   Navbar
   ========================================== */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    height: 62px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 12px rgba(0,0,0,0.25);
}

.nav-brand a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 18px;
    letter-spacing: -0.3px;
}

.logo-icon {
    color: var(--accent);
    font-size: 20px;
}

.nav-links {
    display: flex;
    gap: 2px;
}

.nav-link {
    padding: 7px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 14px;
    transition: all 0.18s;
}

.nav-link:hover  { color: var(--text-primary); background: var(--bg-hover); }
.nav-link.active {
    color: var(--accent);
    background: var(--accent-dim);
    font-weight: 600;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-dim);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.user-name {
    font-weight: 500;
    font-size: 14px;
}

.user-role-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--accent-dim);
    color: var(--accent);
}

.role-admin { background: rgba(136, 102, 255, 0.15); color: var(--purple); }
.role-agent { background: rgba(68, 136, 255, 0.15); color: var(--blue); }

/* ==========================================
   Main Content
   ========================================== */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
}

.page-header h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.back-link {
    display: inline-block;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 14px;
}

/* ==========================================
   Cards
   ========================================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 22px;
    border-bottom: 1px solid var(--border);
    background: rgba(255,255,255,0.02);
}

.card-header h3 {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.2px;
}

.card-body {
    padding: 22px;
}

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

.stats-small { grid-template-columns: repeat(3, 1fr); }

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
    display: flex;
    align-items: center;
    gap: 18px;
    transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

/* Colored left accent bar per card */
.stat-card::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    border-radius: 3px 0 0 3px;
}
.stat-card:nth-child(1)::before { background: var(--blue); }
.stat-card:nth-child(2)::before { background: var(--orange); }
.stat-card:nth-child(3)::before { background: var(--yellow); }
.stat-card:nth-child(4)::before { background: var(--green); }
.stat-card:nth-child(5)::before { background: var(--purple); }

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

.stat-icon {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    flex-shrink: 0;
}

.stat-blue   { background: rgba(77,148,255,0.14);  color: var(--blue); }
.stat-orange { background: rgba(255,140,66,0.14);  color: var(--orange); }
.stat-yellow { background: rgba(255,196,68,0.14);  color: var(--yellow); }
.stat-green  { background: rgba(0,212,170,0.14);   color: var(--green); }
.stat-purple { background: rgba(155,114,255,0.14); color: var(--purple); }

/* Make inline SVGs inside stat icons scale correctly */
.stat-icon svg { width: 26px; height: 26px; display: block; }

.stat-info { display: flex; flex-direction: column; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }

/* ==========================================
   Dashboard Grid
   ========================================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

/* Priority Bars */
.priority-bars { display: flex; flex-direction: column; gap: 14px; }
.priority-row { display: flex; align-items: center; gap: 12px; }
.priority-label { width: 70px; font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.priority-bar-track { flex: 1; height: 10px; background: var(--bg-input); border-radius: 5px; overflow: hidden; }
.priority-bar-fill { height: 100%; border-radius: 5px; transition: width 0.6s ease; min-width: 4px; }
.priority-count { width: 30px; text-align: right; font-weight: 600; font-size: 14px; font-family: var(--mono); }

/* Category List */
.category-list { display: flex; flex-direction: column; gap: 10px; }
.category-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
}
.category-name { font-size: 14px; font-weight: 500; }
.category-badge {
    background: var(--accent-dim);
    color: var(--accent);
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    font-family: var(--mono);
}

/* ==========================================
   Tables
   ========================================== */
.table-responsive { overflow-x: auto; }

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

.table thead th {
    text-align: left;
    padding: 12px 14px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.table tbody td {
    padding: 14px;
    border-bottom: 1px solid rgba(42, 42, 90, 0.5);
    font-size: 14px;
}

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

.clickable-row { cursor: pointer; transition: background 0.15s; }
.clickable-row:hover { background: var(--bg-hover); }

.ticket-code {
    font-family: var(--mono);
    font-size: 12px;
    background: var(--accent-dim);
    color: var(--accent);
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.ticket-subject {
    font-weight: 500;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ==========================================
   Status & Priority Badges
   ========================================== */
.status-badge, .priority-badge, .category-tag {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.status-open { background: rgba(68,136,255,0.15); color: var(--blue); }
.status-in_progress { background: rgba(255,187,51,0.15); color: var(--yellow); }
.status-waiting { background: rgba(255,136,68,0.15); color: var(--orange); }
.status-resolved { background: rgba(0,212,170,0.15); color: var(--green); }
.status-closed { background: rgba(104,104,160,0.15); color: var(--text-muted); }

.priority-critical { background: rgba(255,68,102,0.15); color: var(--red); }
.priority-high { background: rgba(255,136,68,0.15); color: var(--orange); }
.priority-medium { background: rgba(255,187,51,0.15); color: var(--yellow); }
.priority-low { background: rgba(0,212,170,0.15); color: var(--green); }

.category-tag { background: var(--bg-input); color: var(--text-secondary); font-weight: 500; text-transform: none; }

/* ==========================================
   Forms
   ========================================== */
.form-group {
    margin-bottom: 18px;
}

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-group textarea { resize: vertical; min-height: 100px; }

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

.form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

.form-inline-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 120px auto;
    gap: 16px;
    align-items: end;
}

.select-sm {
    padding: 6px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
}

/* ==========================================
   Buttons
   ========================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: #07211c;
    font-weight: 700;
    box-shadow: 0 2px 10px rgba(0,212,170,0.3);
}
.btn-primary:hover {
    background: var(--accent-hover);
    color: #07211c;
    transform: translateY(-1px);
    box-shadow: 0 4px 18px rgba(0,212,170,0.4);
}

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

.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-hover); }

.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-full { width: 100%; }

/* ==========================================
   Alerts
   ========================================== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-success { background: rgba(0,212,170,0.1); border: 1px solid rgba(0,212,170,0.3); color: var(--green); }
.alert-error { background: rgba(255,68,102,0.1); border: 1px solid rgba(255,68,102,0.3); color: var(--red); }
.alert-info { background: rgba(68,136,255,0.1); border: 1px solid rgba(68,136,255,0.3); color: var(--blue); }

/* ==========================================
   Auth Page
   ========================================== */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(ellipse at 50% 0%, #161635 0%, var(--bg-primary) 70%);
}

.auth-container { width: 100%; max-width: 420px; padding: 20px; }

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

.auth-header {
    text-align: center;
    margin-bottom: 28px;
}

.auth-header .logo { font-size: 28px; margin-bottom: 8px; }
.auth-header .logo .logo-text {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}
.auth-subtitle { color: var(--text-muted); font-size: 14px; }

.auth-switch {
    text-align: center;
    margin-top: 18px;
    font-size: 14px;
    color: var(--text-muted);
}

.guest-option { margin-top: 24px; }

.divider {
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--text-muted);
    font-size: 12px;
    margin-bottom: 16px;
}

.divider::before, .divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ==========================================
   Ticket View Layout
   ========================================== */
.ticket-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
    align-items: start;
}

.ticket-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    flex-wrap: wrap;
}

/* Response Cards */
.response-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
    overflow: hidden;
}

.response-card.original { border-left: 3px solid var(--accent); }
.response-card.internal-note { border-left: 3px solid var(--yellow); background: rgba(255,187,51,0.04); }

.response-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
}

.response-author {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-input);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.avatar-agent { background: var(--accent-dim); color: var(--accent); }

.response-time { color: var(--text-muted); font-size: 12px; margin-left: 4px; }

.response-body {
    padding: 16px 20px;
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-secondary);
}

.agent-badge {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--accent-dim);
    color: var(--accent);
    font-weight: 700;
    text-transform: uppercase;
}

.internal-badge {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(255,187,51,0.15);
    color: var(--yellow);
    font-weight: 700;
    text-transform: uppercase;
}

/* System Messages */
.system-response { background: transparent; border-color: transparent; }
.system-message {
    padding: 12px 20px;
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.system-icon { font-size: 16px; }

/* Sidebar */
.sidebar-details { display: flex; flex-direction: column; gap: 14px; }
.detail-row { display: flex; justify-content: space-between; font-size: 14px; }
.detail-label { color: var(--text-muted); font-weight: 500; }

.sidebar-form .form-group { margin-bottom: 10px; }
.sidebar-form label { font-size: 12px; }

/* Timeline */
.timeline { position: relative; padding-left: 20px; }
.timeline::before {
    content: '';
    position: absolute;
    left: 6px;
    top: 4px;
    bottom: 4px;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    margin-bottom: 18px;
}

.timeline-dot {
    position: absolute;
    left: -17px;
    top: 6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg-card);
}

.timeline-content { display: flex; flex-direction: column; gap: 3px; }
.timeline-time { font-size: 12px; color: var(--text-muted); }
.timeline-user { font-size: 12px; color: var(--text-muted); }

/* Reply Card */
.reply-card { border: 1px dashed var(--border); }

/* Checkbox */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
}

/* ==========================================
   Empty State
   ========================================== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

/* ==========================================
   Pagination
   ========================================== */
.pagination {
    display: flex;
    gap: 6px;
    justify-content: center;
    padding-top: 20px;
}

.page-link {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-input);
}

.page-link.active {
    background: var(--accent);
    color: #0a0a1a;
}

/* ==========================================
   Filter Bar
   ========================================== */
.filter-card { padding: 16px 20px; margin-bottom: 20px; }
.filter-form {
    display: flex;
    gap: 12px;
    align-items: end;
}

.filter-form .form-group { margin-bottom: 0; flex: 1; }
.filter-form .btn { height: 40px; }

/* ==========================================
   Utility
   ========================================== */
.text-muted { color: var(--text-muted); }

/* ==========================================
   Attachments
   ========================================== */
.file-upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 24px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    background: var(--bg-input);
    user-select: none;
}
.file-upload-area:hover,
.file-upload-area.drag-over {
    border-color: var(--accent);
    background: var(--accent-dim);
}
.file-upload-area input[type="file"] { display: none; }
.file-upload-icon { font-size: 28px; margin-bottom: 6px; }
.file-upload-text { font-size: 14px; color: var(--text-secondary); font-weight: 500; }
.file-upload-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.file-preview-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}
.file-preview-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 5px 10px;
    font-size: 12px;
    color: var(--text-secondary);
}
.file-preview-size { color: var(--text-muted); }

.file-remove-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    padding: 0 0 0 4px;
    margin-left: auto;
    display: flex;
    align-items: center;
    transition: color 0.15s;
}
.file-remove-btn:hover { color: var(--red); }

/* Make label inside upload area fill the whole area so the click target is correct */
.file-upload-area label {
    display: block;
    cursor: pointer;
    padding: 24px 20px;
    text-align: center;
}
.file-upload-area { padding: 0; }

.attachments-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 20px 14px;
    border-top: 1px solid var(--border);
    background: var(--bg-input);
}
.attachments-label {
    width: 100%;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.attachment-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 5px 12px;
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: border-color 0.2s, color 0.2s;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.attachment-item:hover { border-color: var(--accent); color: var(--accent); }
.attachment-item-icon { flex-shrink: 0; }
.attachment-img-thumb {
    display: block;
    width: 80px;
    height: 60px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    transition: opacity 0.2s;
}
.attachment-img-thumb:hover { opacity: 0.85; }
.attachment-img-wrap {
    display: inline-block;
    text-decoration: none;
}

/* ==========================================
   Theme Toggle — Pill / Slider (button-based, no checkbox)
   The thumb & track change via [data-theme="light"] on <html>
   ========================================== */
.theme-switch {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    border-radius: 20px;
    transition: background 0.15s;
}
.theme-switch:hover { background: var(--bg-hover); }

.switch-track {
    display: inline-block;  /* REQUIRED: span is inline by default, width/height ignored otherwise */
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--bg-input);
    border: 1.5px solid var(--border);
    border-radius: 12px;
    transition: background 0.3s, border-color 0.3s;
    pointer-events: none;   /* button handles click */
    vertical-align: middle;
}

.switch-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: var(--text-muted);
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0,0,0,0.35);
    transition: transform 0.25s ease, background 0.25s;
    pointer-events: none;
}

/* Light mode — CSS reads data-theme on <html> directly, no JS class needed */
[data-theme="light"] .switch-track {
    background: var(--accent-dim);
    border-color: var(--accent);
}
[data-theme="light"] .switch-thumb {
    transform: translateX(20px);
    background: var(--accent);
}

.switch-icon {
    font-size: 14px;
    line-height: 1;
    user-select: none;
}

/* Nav avatar button (profile link) */
.nav-avatar-btn {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    border-radius: 50%;
    transition: box-shadow 0.2s;
}
.nav-avatar-btn:hover .user-avatar,
.nav-avatar-btn.active .user-avatar {
    box-shadow: 0 0 0 2px var(--accent);
}

/* ==========================================
   Light Theme Variables
   ========================================== */
[data-theme="light"] {
    --bg-primary:    #f2f4f9;
    --bg-secondary:  #ffffff;
    --bg-card:       #ffffff;
    --bg-input:      #f6f8fd;
    --bg-hover:      #ebeef8;
    --border:        #d0d7ec;
    --text-primary:  #141625;
    --text-secondary:#424a6a;
    --text-muted:    #7080a8;
    --accent:        #008f6f;
    --accent-hover:  #00a880;
    --accent-dim:    rgba(0, 143, 111, 0.10);
    --shadow:        0 2px 12px rgba(0,0,0,0.07);
    --shadow-lg:     0 6px 28px rgba(0,0,0,0.10);
    --red:    #e03250;
    --orange: #d96c28;
    --yellow: #c98a00;
    --green:  #008f6f;
    --blue:   #2b72e8;
    --purple: #6b44dc;
}

[data-theme="light"] body {
    background: var(--bg-primary);
}

[data-theme="light"] .auth-page {
    background: linear-gradient(135deg, #eef1fa 0%, #f8f9fd 100%);
}

[data-theme="light"] .navbar {
    box-shadow: 0 1px 0 var(--border), 0 2px 8px rgba(0,0,0,0.05);
}

[data-theme="light"] .card-header {
    background: rgba(0,0,0,0.01);
}

/* Fix portal page background in light mode */
[data-theme="light"] .portal-page {
    background: radial-gradient(ellipse at 50% 0%, #dde6f5 0%, var(--bg-primary) 60%);
}

/* Fix portal card shadows in light mode */
[data-theme="light"] .portal-card {
    box-shadow: 0 2px 12px rgba(0,0,0,0.07);
}

/* Light mode button primary keeps dark text readable on teal */
[data-theme="light"] .btn-primary { color: #ffffff; box-shadow: 0 2px 10px rgba(0,143,111,0.25); }
[data-theme="light"] .btn-primary:hover { color: #ffffff; }

/* Fix select option colors in light mode */
[data-theme="light"] .form-group select option { background: #ffffff; color: #141625; }

/* Fix table row borders */
[data-theme="light"] .table tbody td { border-bottom: 1px solid var(--border); }

[data-theme="light"] .timeline::before { background: var(--border); }

/* Status badges look better in light mode */
[data-theme="light"] .status-open      { background: rgba(43,114,232,0.1); color: var(--blue); }
[data-theme="light"] .status-in_progress { background: rgba(201,138,0,0.1); color: var(--yellow); }
[data-theme="light"] .status-resolved  { background: rgba(0,143,111,0.1);  color: var(--green); }
[data-theme="light"] .status-closed    { background: rgba(112,128,168,0.1); color: var(--text-muted); }
[data-theme="light"] .priority-critical { background: rgba(224,50,80,0.1);  color: var(--red); }
[data-theme="light"] .priority-high    { background: rgba(217,108,40,0.1);  color: var(--orange); }
[data-theme="light"] .priority-medium  { background: rgba(201,138,0,0.1);   color: var(--yellow); }
[data-theme="light"] .priority-low     { background: rgba(0,143,111,0.1);   color: var(--green); }

/* Stat card accent bars visible in light mode */
[data-theme="light"] .stat-blue   { background: rgba(43,114,232,0.08);  }
[data-theme="light"] .stat-orange { background: rgba(217,108,40,0.08);  }
[data-theme="light"] .stat-yellow { background: rgba(201,138,0,0.08);   }
[data-theme="light"] .stat-green  { background: rgba(0,143,111,0.08);   }
[data-theme="light"] .stat-purple { background: rgba(107,68,220,0.08);  }

/* ==========================================
   Professional UI Polish
   ========================================== */

/* Elevated cards */
.card {
    box-shadow: var(--shadow);
}
.stat-card {
    box-shadow: var(--shadow);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.22);
}

/* Better navbar */
.navbar {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 1px 0 var(--border);
}

/* Nav links pill style */
.nav-link {
    border-radius: 8px;
}
.nav-link.active {
    background: var(--accent-dim);
    color: var(--accent);
    font-weight: 600;
}

/* Better buttons */
.btn-primary {
    box-shadow: 0 2px 8px rgba(0, 212, 170, 0.25);
}
.btn-primary:hover {
    box-shadow: 0 4px 16px rgba(0, 212, 170, 0.35);
    transform: translateY(-1px);
}
.btn-outline:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Better form inputs */
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    box-shadow: 0 0 0 3px var(--accent-dim), 0 1px 4px rgba(0,0,0,0.1);
}

/* Auth card polish */
.auth-card {
    box-shadow: 0 8px 48px rgba(0,0,0,0.28);
}

/* Closure note card highlight */
.response-card.closure-note {
    border-left: 3px solid var(--green);
}

/* Better table row hover */
.clickable-row:hover {
    background: var(--bg-hover);
    transform: none;
}

/* Badge refinements */
.status-badge, .priority-badge {
    font-size: 11px;
    letter-spacing: 0.4px;
    font-weight: 700;
}

/* ==========================================
   Responsive — Mobile First
   ========================================== */
@media (max-width: 768px) {
    /* Navbar collapses gracefully */
    .navbar {
        flex-wrap: wrap;
        height: auto;
        padding: 10px 16px;
        gap: 8px;
    }
    .nav-brand { order: 1; }
    .nav-user  { order: 2; margin-left: auto; }
    .nav-links {
        order: 3;
        width: 100%;
        overflow-x: auto;
        padding-bottom: 2px;
        gap: 2px;
        /* Hide scrollbar but keep scrollable */
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
    .nav-links::-webkit-scrollbar { display: none; }
    .nav-link { padding: 7px 12px; font-size: 13px; white-space: nowrap; }

    /* Content spacing */
    .main-content { padding: 14px 12px; }
    .page-header  { flex-direction: column; align-items: flex-start; gap: 10px; }
    .page-header h1 { font-size: 22px; }

    /* Stats: 2 columns on mobile */
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stats-small { grid-template-columns: 1fr 1fr; }
    .stat-card { padding: 14px; gap: 10px; }
    .stat-value { font-size: 22px; }
    .stat-icon { width: 40px; height: 40px; font-size: 22px; }

    /* Dashboard / layout grids */
    .dashboard-grid  { grid-template-columns: 1fr; }
    .ticket-layout   { grid-template-columns: 1fr; }
    .form-row        { grid-template-columns: 1fr; }
    .form-inline-grid{ grid-template-columns: 1fr; }
    .filter-form     { flex-direction: column; }
    .filter-form .form-group { flex: none; }

    /* Sidebar goes below main content on mobile */
    .ticket-sidebar { order: -1; }

    /* Auth card full width */
    .auth-container { padding: 12px; }
    .auth-card      { padding: 24px 20px; }

    /* Table: hide less important columns */
    .table thead th:nth-child(4),
    .table tbody td:nth-child(4) { display: none; }

    /* Hide user name text in nav on mobile, show only avatar */
    .user-name, .user-role-badge { display: none; }

    /* Card padding reduction */
    .card-body { padding: 14px; }
    .card-header { padding: 12px 14px; }
}

@media (max-width: 480px) {
    /* Single column stats on very small screens */
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .ticket-code { font-size: 10px; }
    .btn { padding: 9px 14px; font-size: 13px; }
    .btn-sm { padding: 5px 10px; font-size: 11px; }
}

/* ==========================================================================
   MODERN UI OVERHAUL — v2
   ClickUp / Jira / Linear inspired refinements.
   Appended last so it overrides everything above.
   ========================================================================== */

:root {
    --radius:        10px;
    --radius-sm:     7px;
    --radius-lg:     14px;
    --shadow-xs:     0 1px 2px rgba(0,0,0,0.18);
    --shadow:        0 2px 6px rgba(0,0,0,0.22), 0 1px 2px rgba(0,0,0,0.15);
    --shadow-lg:     0 10px 32px rgba(0,0,0,0.30);
    --content-max:   1480px;
    --gutter:        32px;
}

[data-theme="light"] {
    --shadow-xs:     0 1px 2px rgba(20, 22, 37, 0.05);
    --shadow:        0 1px 3px rgba(20, 22, 37, 0.06), 0 1px 2px rgba(20, 22, 37, 0.04);
    --shadow-lg:     0 12px 32px rgba(20, 22, 37, 0.10), 0 2px 6px rgba(20, 22, 37, 0.05);
}

body {
    font-feature-settings: "cv11", "ss01", "ss03";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.01em;
}

/* ---------- Layout: kill the empty side gaps ---------- */
.navbar {
    padding: 0 var(--gutter);
    height: 60px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    box-shadow: none;
}

.main-content {
    max-width: var(--content-max);
    padding: 28px var(--gutter) 56px;
}

@media (max-width: 1100px) {
    :root { --gutter: 20px; }
}
@media (max-width: 640px) {
    :root { --gutter: 14px; }
    .navbar { height: auto; }
    .main-content { padding-top: 18px; padding-bottom: 36px; }
}

/* ---------- Navbar polish ---------- */
.nav-brand a { gap: 12px; font-size: 15.5px; }
.nav-links { gap: 4px; }
.nav-link {
    padding: 8px 14px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: 8px;
    transition: background 0.15s ease, color 0.15s ease;
}
.nav-link:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-link.active {
    background: var(--accent-dim);
    color: var(--accent);
    font-weight: 600;
}

.nav-user { gap: 12px; }
.user-avatar {
    width: 30px; height: 30px;
    font-size: 13px;
    font-weight: 600;
}

/* ---------- Page header ---------- */
.page-header { margin-bottom: 22px; align-items: flex-end; }
.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

/* ---------- Cards ---------- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    margin-bottom: 18px;
}
.card-header {
    padding: 14px 20px;
    background: transparent;
    border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.card-body { padding: 20px; }

/* ---------- Stat cards ---------- */
.stats-grid { gap: 14px; margin-bottom: 24px; }
.stat-card {
    padding: 18px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    gap: 14px;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.stat-card::before { width: 0; } /* drop the colored left bar — cleaner */
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--border);
}
.stat-icon {
    width: 44px; height: 44px;
    border-radius: 10px;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-value { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.stat-label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }

/* ---------- Filter bar ---------- */
.filter-card {
    padding: 14px 18px;
    margin-bottom: 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
}
.filter-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    align-items: end;
}
.filter-form .form-group { margin-bottom: 0; }

/* ---------- Forms ---------- */
.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: none;
    letter-spacing: 0;
    margin-bottom: 5px;
}
.form-group input,
.form-group select,
.form-group textarea {
    padding: 9px 12px;
    font-size: 13.5px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover { border-color: var(--text-muted); }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
    background: var(--bg-card);
}

/* ---------- Buttons ---------- */
.btn {
    padding: 9px 16px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 600;
    letter-spacing: 0;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}
.btn:active { transform: translateY(0.5px); }
.btn-primary {
    background: var(--accent);
    color: #ffffff;
    box-shadow: var(--shadow-xs);
}
.btn-primary:hover {
    background: var(--accent-hover);
    color: #ffffff;
    box-shadow: var(--shadow);
    transform: none;
}
.btn-outline {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
}
.btn-outline:hover {
    background: var(--bg-hover);
    border-color: var(--border);
    color: var(--text-primary);
}
.btn-ghost { color: var(--text-secondary); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }

/* ---------- Tables ---------- */
.table thead th {
    padding: 11px 16px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    background: transparent;
    border-bottom: 1px solid var(--border);
}
.table tbody td {
    padding: 14px 16px;
    font-size: 13.5px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table tbody tr { transition: background 0.12s ease; }
.clickable-row:hover { background: var(--bg-hover); }

.ticket-code {
    font-family: var(--mono);
    font-size: 11.5px;
    font-weight: 600;
    background: var(--accent-dim);
    color: var(--accent);
    padding: 3px 8px;
    border-radius: 5px;
    letter-spacing: 0.3px;
}

.ticket-subject {
    font-weight: 500;
    color: var(--text-primary);
    max-width: 360px;
}

/* ---------- Badges ---------- */
.status-badge, .priority-badge {
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    line-height: 1.6;
    display: inline-block;
}
.category-tag {
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    background: var(--bg-input);
    color: var(--text-secondary);
    text-transform: none;
    letter-spacing: 0;
}

/* ---------- Ticket view layout ---------- */
.ticket-layout { gap: 24px; grid-template-columns: 1fr 360px; }

/* ---------- Response cards ---------- */
.response-card {
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    margin-bottom: 14px;
}
.response-header { padding: 14px 18px; }
.response-body { padding: 16px 18px; color: var(--text-primary); }
.avatar { width: 34px; height: 34px; font-size: 13px; }

/* ---------- Auth page ---------- */
.auth-card {
    padding: 32px 32px 28px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

/* ---------- Pagination ---------- */
.page-link {
    padding: 7px 12px;
    border-radius: 7px;
    font-size: 12.5px;
    background: var(--bg-card);
    border: 1px solid var(--border);
}
.page-link:hover { background: var(--bg-hover); color: var(--text-primary); }
.page-link.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
}

/* ---------- Scrollbar polish ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--text-muted); background-clip: padding-box; border: 2px solid transparent; }

/* ---------- Light-mode specific refinements ---------- */
[data-theme="light"] {
    --bg-primary:    #f7f8fb;
    --bg-secondary:  #ffffff;
    --bg-card:       #ffffff;
    --bg-input:      #f4f6fa;
    --bg-hover:      #f0f2f7;
    --border:        #e4e7ee;
    --text-primary:  #1a1d29;
    --text-secondary:#4a5169;
    --text-muted:    #7a8299;
}

[data-theme="light"] body { background: var(--bg-primary); }
[data-theme="light"] .navbar {
    background: rgba(255,255,255,0.85);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    box-shadow: 0 1px 0 var(--border);
}
[data-theme="light"] .card,
[data-theme="light"] .stat-card,
[data-theme="light"] .response-card,
[data-theme="light"] .filter-card {
    box-shadow: var(--shadow-xs);
}
[data-theme="light"] .card:hover,
[data-theme="light"] .stat-card:hover { box-shadow: var(--shadow); }
[data-theme="light"] .ticket-code {
    background: rgba(0,143,111,0.10);
    color: var(--accent);
}

/* ---------- Dark-mode subtle tweaks ---------- */
:root:not([data-theme="light"]) {
    --bg-primary:    #0b0d1a;
    --bg-secondary:  #11142a;
    --bg-card:       #161937;
    --bg-input:      #1c1f44;
    --bg-hover:      #1f2350;
    --border:        #262a5a;
}
:root:not([data-theme="light"]) .navbar {
    background: rgba(17, 20, 42, 0.88);
    backdrop-filter: saturate(160%) blur(10px);
    -webkit-backdrop-filter: saturate(160%) blur(10px);
}

/* ---------- Mobile final touches ---------- */
@media (max-width: 768px) {
    .navbar { padding: 10px var(--gutter); }
    .page-header h1 { font-size: 20px; }
    .stat-value { font-size: 20px; }
    .filter-form { grid-template-columns: 1fr 1fr; }
    .ticket-layout { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
    .filter-form { grid-template-columns: 1fr; }
}

/* ==========================================================================
   MODERN UI OVERHAUL — v3  (Tickets page rich layout)
   ========================================================================== */

.tickets-page .page-header { margin-bottom: 18px; align-items: flex-start; }
.tickets-page .page-header h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
.muted-count {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-input);
    border: 1px solid var(--border);
    padding: 2px 8px;
    border-radius: 6px;
}
.page-subtitle { margin-top: 4px; font-size: 13px; color: var(--text-muted); }
.header-actions { display: flex; gap: 8px; align-items: center; }

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
    margin-bottom: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-xs);
}
.toolbar-search { position: relative; flex: 1 1 240px; min-width: 220px; max-width: 320px; }
.toolbar-search svg {
    position: absolute; left: 11px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}
.toolbar-search input {
    width: 100%;
    height: 34px;
    padding: 0 12px 0 32px;
    font-size: 13px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: var(--font);
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.toolbar-search input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--bg-card);
    box-shadow: 0 0 0 3px var(--accent-dim);
}
.tb-select {
    height: 34px;
    padding: 0 28px 0 10px;
    font-size: 13px;
    font-family: var(--font);
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='gray' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 9px center;
    transition: border-color 0.15s, background-color 0.15s;
}
.tb-select:hover { background-color: var(--bg-hover); }
.tb-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

.tb-date-group { display: inline-flex; align-items: center; gap: 6px; }
.tb-date-group input[type="date"] {
    height: 34px;
    padding: 0 10px;
    font-size: 13px;
    font-family: var(--font);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
}
.tb-date-group input[type="date"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.tb-sep { font-size: 12px; color: var(--text-muted); }

.toolbar-right { margin-left: auto; display: inline-flex; align-items: center; gap: 10px; }
.tb-link {
    font-size: 12.5px;
    color: var(--text-muted);
    font-weight: 500;
    text-decoration: none;
    padding: 6px 8px;
    border-radius: 6px;
}
.tb-link:hover { color: var(--accent); background: var(--accent-dim); }
.tb-count {
    font-size: 12.5px;
    color: var(--text-muted);
    padding-left: 10px;
    border-left: 1px solid var(--border);
    margin-left: 2px;
}

input[type="date"]::-webkit-calendar-picker-indicator { cursor: pointer; opacity: 0.5; }
input[type="date"]::-webkit-calendar-picker-indicator:hover { opacity: 1; }

/* Data table */
.data-table {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow-xs);
}
.tickets-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.tickets-table thead th {
    background: var(--bg-card);
    padding: 12px 16px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    text-align: left;
}
.tickets-table tbody td {
    padding: 14px 16px;
    font-size: 13.5px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
    transition: background 0.12s ease;
}
.tickets-table tbody tr:last-child td { border-bottom: none; }
.tickets-table tbody tr:hover td { background: var(--bg-hover); }

.subject-link {
    display: block;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    margin-bottom: 3px;
    max-width: 460px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.subject-link:hover { color: var(--accent); }
.subject-date { font-size: 11.5px; color: var(--text-muted); font-family: var(--mono); }

/* Pills with dot indicator */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px 3px 8px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.7;
    letter-spacing: 0;
    text-transform: none;
    border: 1px solid transparent;
    white-space: nowrap;
}
.pill-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

.pill.pill-cat { background: rgba(139,92,246,0.08); color: #8b5cf6; border-color: rgba(139,92,246,0.20); }
.pill.status-open        { background: rgba(59,130,246,0.10); color: #3b82f6; border-color: rgba(59,130,246,0.22); }
.pill.status-in_progress { background: rgba(99,102,241,0.10); color: #6366f1; border-color: rgba(99,102,241,0.22); }
.pill.status-waiting     { background: rgba(249,115,22,0.10); color: #f97316; border-color: rgba(249,115,22,0.22); }
.pill.status-resolved    { background: rgba(34,197,94,0.10);  color: #22c55e; border-color: rgba(34,197,94,0.22); }
.pill.status-closed      { background: rgba(148,163,184,0.12); color: #94a3b8; border-color: rgba(148,163,184,0.22); }
.pill.priority-critical { background: rgba(244,63,94,0.10);   color: #f43f5e; border-color: rgba(244,63,94,0.25); }
.pill.priority-high     { background: rgba(249,115,22,0.10);  color: #f97316; border-color: rgba(249,115,22,0.25); }
.pill.priority-medium   { background: rgba(59,130,246,0.10);  color: #3b82f6; border-color: rgba(59,130,246,0.22); }
.pill.priority-low      { background: rgba(34,197,94,0.10);   color: #22c55e; border-color: rgba(34,197,94,0.22); }

/* Avatars */
.user-cell { display: inline-flex; align-items: center; gap: 9px; min-width: 0; }
.av {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18);
}
.av-empty { background: var(--bg-input); color: var(--text-muted); box-shadow: inset 0 0 0 1px var(--border); }
.user-meta { display: flex; flex-direction: column; min-width: 0; }
.user-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}
.user-sub {
    font-size: 11.5px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}
.unassigned { font-style: italic; font-size: 12.5px; }

.updated-cell { white-space: nowrap; }
.updated-date { display: block; font-size: 13px; color: var(--text-primary); font-weight: 500; }
.updated-time { display: block; font-size: 11.5px; color: var(--text-muted); font-family: var(--mono); }

.row-actions { text-align: right; padding-right: 14px !important; }
.row-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.tickets-table tbody tr:hover .row-action { opacity: 1; }
.row-action:hover { background: var(--bg-hover); color: var(--accent); }

.tickets-table .ticket-code {
    display: inline-block;
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    padding: 3px 8px;
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 5px;
}

.data-table .pagination {
    padding: 14px;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
    margin: 0;
}

@media (max-width: 1100px) {
    .toolbar-search { flex: 1 1 100%; max-width: none; }
    .tb-count { display: none; }
}
@media (max-width: 768px) {
    .toolbar { padding: 10px; gap: 6px; }
    .tb-select { flex: 1 1 calc(50% - 6px); min-width: 0; }
    .tb-date-group { flex: 1 1 100%; }
    .tb-date-group input[type="date"] { flex: 1; }
    .toolbar-right { width: 100%; justify-content: flex-end; }
    .subject-link { max-width: 240px; }
    .row-action { opacity: 1; }
}

/* ==========================================================================
   MODERN UI OVERHAUL — v4
   Site-wide uniform polish. Upgrades the SHARED badge classes used on every
   page (dashboard, admin, view ticket) to the rich pill+dot look — no markup
   changes needed — plus auth-page and generic-table refinements.
   ========================================================================== */

/* ---- Global badge -> pill (dot via ::before, so markup is untouched) ---- */
.status-badge,
.priority-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 11px 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.7;
    letter-spacing: 0;
    text-transform: none;
    border: 1px solid transparent;
    white-space: nowrap;
    vertical-align: middle;
}
.status-badge::before,
.priority-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

/* Unified palette (matches the tickets-page pills) */
.status-open        { background: rgba(59,130,246,0.10); color: #3b82f6; border-color: rgba(59,130,246,0.22); }
.status-in_progress { background: rgba(99,102,241,0.10); color: #6366f1; border-color: rgba(99,102,241,0.22); }
.status-waiting     { background: rgba(249,115,22,0.10); color: #f97316; border-color: rgba(249,115,22,0.22); }
.status-resolved    { background: rgba(34,197,94,0.10);  color: #22c55e; border-color: rgba(34,197,94,0.22); }
.status-closed      { background: rgba(148,163,184,0.12); color: #94a3b8; border-color: rgba(148,163,184,0.22); }

.priority-critical { background: rgba(244,63,94,0.10);   color: #f43f5e; border-color: rgba(244,63,94,0.25); }
.priority-high     { background: rgba(249,115,22,0.10);  color: #f97316; border-color: rgba(249,115,22,0.25); }
.priority-medium   { background: rgba(59,130,246,0.10);  color: #3b82f6; border-color: rgba(59,130,246,0.22); }
.priority-low      { background: rgba(34,197,94,0.10);   color: #22c55e; border-color: rgba(34,197,94,0.22); }

/* Category tag as a soft pill */
.category-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 11px 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    background: rgba(139,92,246,0.08);
    color: #8b5cf6;
    border: 1px solid rgba(139,92,246,0.20);
    text-transform: none;
    letter-spacing: 0;
}
.category-tag::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

/* Role badges (admin / users table) */
.user-role-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    border: 1px solid transparent;
}
.role-admin { background: rgba(139,92,246,0.10); color: #8b5cf6; border-color: rgba(139,92,246,0.22); }
.role-agent { background: rgba(59,130,246,0.10); color: #3b82f6; border-color: rgba(59,130,246,0.22); }

/* ---- Generic tables (dashboard, admin) get the polished feel too ---- */
.card .table thead th {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 12px 14px;
}
.card .table tbody td { padding: 13px 14px; font-size: 13.5px; }
.card .table tbody tr { transition: background 0.12s ease; }
.card .table tbody tr.clickable-row:hover td { background: var(--bg-hover); }

/* ---- Dashboard stat cards: a touch more refined ---- */
.stat-card { border-radius: 12px; }
.stat-icon { border-radius: 11px; }

/* ---- Category list / priority bars subtle polish ---- */
.category-item { border: 1px solid var(--border); background: var(--bg-input); border-radius: 8px; }
.category-badge { background: var(--accent-dim); color: var(--accent); }

/* ==========================================================================
   AUTH PAGE — premium centered card
   ========================================================================== */
.auth-page {
    background:
        radial-gradient(900px 500px at 50% -10%, rgba(0,212,170,0.10), transparent 60%),
        var(--bg-primary);
}
[data-theme="light"] .auth-page {
    background:
        radial-gradient(900px 500px at 50% -10%, rgba(0,143,111,0.10), transparent 60%),
        linear-gradient(180deg, #eef2f9 0%, var(--bg-primary) 60%);
}
.auth-container { max-width: 410px; }
.auth-card {
    padding: 36px 34px 30px;
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
}
.auth-header { margin-bottom: 22px; }
.auth-subtitle { font-size: 13.5px; color: var(--text-muted); }
.auth-card .form-group input { height: 42px; font-size: 14px; }
.auth-card .btn-full { height: 44px; font-size: 14px; margin-top: 4px; }
.auth-switch { font-size: 13.5px; }

/* ==========================================================================
   ADMIN — harmonize the custom filter bar & danger button with the new look
   ========================================================================== */
.ticket-filter-bar { gap: 8px !important; padding: 12px 16px !important; }
.ticket-filter-bar input[type="text"],
.ticket-filter-bar select {
    height: 34px !important;
    border-radius: 8px !important;
}
.ticket-filter-bar input[type="text"]:focus,
.ticket-filter-bar select:focus {
    outline: none;
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px var(--accent-dim);
}
.btn-danger {
    border-radius: 8px !important;
    font-size: 12.5px !important;
    padding: 6px 12px !important;
    color: #f43f5e !important;
    border: 1px solid rgba(244,63,94,0.35) !important;
    background: rgba(244,63,94,0.06) !important;
}
.btn-danger:hover { background: #f43f5e !important; color: #fff !important; border-color: #f43f5e !important; }

/* Admin: stats-small cards without icon look balanced */
.stats-small .stat-card { padding: 18px 20px; }

/* Select dropdown chevron for native selects across forms (subtle) */
.select-sm { border-radius: 8px; height: 32px; }

/* ==========================================================================
   MODERN UI OVERHAUL — v5
   Wider layout (less wasted margin), reliable horizontal table scroll,
   rich pagination with prev/next arrows, highlighted Export & Logout buttons.
   ========================================================================== */

/* ---- Use the screen: much smaller side margins ---- */
:root {
    --content-max: 1760px;
    --gutter: 28px;
}
@media (max-width: 1400px) { :root { --gutter: 22px; } }
@media (max-width: 1100px) { :root { --gutter: 18px; } }
@media (max-width: 640px)  { :root { --gutter: 14px; } }

.main-content { max-width: var(--content-max); }

/* ---- Reliable horizontal scrolling so EVERY column is reachable ---- */
.data-table { overflow: hidden; }            /* keeps rounded corners */
.data-table .table-responsive {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
}
/* Force the table to keep its natural column widths and scroll when needed */
.tickets-table { min-width: 1200px; }

/* Make the horizontal scrollbar clearly visible under the table */
.data-table .table-responsive::-webkit-scrollbar { height: 10px; }
.data-table .table-responsive::-webkit-scrollbar-track { background: var(--bg-input); border-radius: 8px; }
.data-table .table-responsive::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 8px;
    border: 2px solid var(--bg-card);
    background-clip: padding-box;
}

/* Generic responsive tables (dashboard/admin) also scroll, never clip */
.table-responsive { overflow-x: auto; }

/* ---- Rich pagination: prev / numbers / next ---- */
.pagination {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
}
.pagination .page-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    justify-content: center;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-card);
    border: 1px solid var(--border);
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.pagination .page-link:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--text-muted); }
.pagination .page-link.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 2px 8px var(--accent-dim);
}
.pagination .page-nav { padding: 0 14px; color: var(--text-primary); }
.pagination .page-nav.disabled {
    opacity: 0.4;
    pointer-events: none;
    cursor: default;
}
.pagination .page-nav svg { display: block; }

/* ---- Highlighted action buttons ---- */
/* Export — accent-tinted "soft" button */
.btn-soft {
    background: var(--accent-dim);
    color: var(--accent);
    border: 1px solid transparent;
    font-weight: 600;
}
.btn-soft:hover {
    background: var(--accent);
    color: #fff;
    box-shadow: var(--shadow);
}
.btn-soft svg { stroke: currentColor; }

/* Logout — red-tinted, clearly visible in navbar */
.btn-logout {
    background: rgba(244,63,94,0.10);
    color: #f43f5e;
    border: 1px solid rgba(244,63,94,0.22);
    font-weight: 600;
}
.btn-logout:hover {
    background: #f43f5e;
    color: #fff;
    border-color: #f43f5e;
}

/* Keep Sign In button consistent in navbar */
.nav-user .btn-sm { height: 32px; }

/* Make the New Ticket / primary button pop a touch more */
.btn-primary svg { stroke: currentColor; }

/* ==========================================================================
   EXPENSE MODULE — v5
   ========================================================================== */

.text-green  { color: #22c55e !important; }
.text-orange { color: #f97316 !important; }

.filter-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px; height: 18px;
    padding: 0 5px;
    background: rgba(255,255,255,0.25);
    color: inherit;
    font-size: 10.5px;
    font-weight: 700;
    border-radius: 9px;
    margin-left: 4px;
}

/* ---- Tabs ---- */
.exp-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 18px;
}
.exp-tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s;
}
.exp-tab:hover { color: var(--text-primary); }
.exp-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.exp-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px; height: 18px;
    padding: 0 5px;
    background: #f43f5e;
    color: #fff;
    font-size: 10.5px;
    font-weight: 700;
    border-radius: 9px;
}

/* ---- Summary cards ---- */
.exp-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 18px;
}
.exp-sum-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 16px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-xs);
}
.exp-sum-label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.exp-sum-value { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }

/* ---- Expense status pills ---- */
.pill.exp-open       { background: rgba(59,130,246,0.10); color: #3b82f6; border-color: rgba(59,130,246,0.22); }
.pill.exp-in_review  { background: rgba(99,102,241,0.10); color: #6366f1; border-color: rgba(99,102,241,0.22); }
.pill.exp-approved   { background: rgba(34,197,94,0.10);  color: #22c55e; border-color: rgba(34,197,94,0.22); }
.pill.exp-rejected   { background: rgba(244,63,94,0.10);  color: #f43f5e; border-color: rgba(244,63,94,0.25); }
.pill.exp-closed     { background: rgba(148,163,184,0.12); color: #94a3b8; border-color: rgba(148,163,184,0.22); }

.pill.item-pending   { background: rgba(249,115,22,0.10); color: #f97316; border-color: rgba(249,115,22,0.22); }
.pill.item-approved  { background: rgba(34,197,94,0.10);  color: #22c55e; border-color: rgba(34,197,94,0.22); }
.pill.item-rejected  { background: rgba(244,63,94,0.10);  color: #f43f5e; border-color: rgba(244,63,94,0.25); }

.exp-amt { font-family: var(--mono); font-size: 13px; font-weight: 600; white-space: nowrap; }

/* ---- Item table (new + view) ---- */
.exp-item-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.exp-item-table th {
    text-align: left;
    padding: 9px 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}
.exp-item-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.exp-item-table tfoot td { border-bottom: none; padding-top: 12px; }
.exp-item-table input,
.exp-item-table select {
    width: 100%;
    height: 36px;
    padding: 0 10px;
    font-size: 13px;
    font-family: var(--font);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--text-primary);
}
.exp-item-table input:focus,
.exp-item-table select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.exp-item-table input[type="file"] { padding: 6px; height: auto; font-size: 11px; }
.exp-item-table .row-file { font-size: 11px; }
.row-del {
    width: 30px; height: 30px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-muted);
    border-radius: 7px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.row-del:hover { background: rgba(244,63,94,0.10); color: #f43f5e; border-color: rgba(244,63,94,0.3); }

/* View-mode item table (read-only, more padding) */
.exp-item-table.view td { padding: 12px 10px; }

/* Per-item approve / reject buttons */
.item-actions { display: inline-flex; gap: 6px; }
.item-btn {
    width: 30px; height: 30px;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    transition: all 0.15s;
}
.item-btn.approve { color: #22c55e; }
.item-btn.approve:hover { background: #22c55e; color: #fff; border-color: #22c55e; }
.item-btn.reject { color: #f43f5e; }
.item-btn.reject:hover { background: #f43f5e; color: #fff; border-color: #f43f5e; }

.bill-link {
    display: inline-flex;
    align-items: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
}
.bill-link:hover { text-decoration: underline; }

/* ---- Admin approvals banner ---- */
.exp-approval-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    margin-bottom: 20px;
    background: var(--accent-dim);
    border: 1px solid var(--accent);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
    text-decoration: none;
    transition: box-shadow 0.15s;
}
.exp-approval-banner:hover { box-shadow: var(--shadow); color: var(--text-primary); }
.exp-approval-icon { font-size: 20px; }
.exp-approval-cta { margin-left: auto; font-weight: 700; color: var(--accent); }

/* Sidebar order on mobile (claim view reuses ticket-layout) */
@media (max-width: 768px) {
    .exp-summary { grid-template-columns: 1fr 1fr; }
    .ticket-sidebar { order: -1; }
}
@media (max-width: 480px) {
    .exp-summary { grid-template-columns: 1fr 1fr; }
}

/* ==========================================================================
   SETTINGS / CMS — v5
   ========================================================================== */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}
.toggle-row:last-of-type { border-bottom: none; }
.toggle-title { display: block; font-size: 14px; font-weight: 600; color: var(--text-primary); }
.toggle-desc  { display: block; font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

/* iOS-style switch built on the checkbox */
.toggle-row input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    width: 42px;
    height: 24px;
    flex-shrink: 0;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}
.toggle-row input[type="checkbox"]::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: transform 0.2s, background 0.2s;
}
.toggle-row input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
}
.toggle-row input[type="checkbox"]:checked::after {
    transform: translateX(18px);
    background: #fff;
}
