/* =============================================
   TicketSystem – Haupt-Stylesheet
   Dark Mode • Modern Design • Premium UI
   ============================================= */

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

/* ========================
   CSS Custom Properties
   ======================== */
:root {
    --bg:           #0f172a;
    --bg2:          #111827;
    --surface:      #1e293b;
    --surface2:     #253347;
    --surface3:     #2d3f55;
    --border:       #334155;
    --border2:      #3d4f66;

    --accent:       #6366f1;
    --accent-hover: #4f46e5;
    --accent-light: rgba(99,102,241,0.12);
    --accent-glow:  rgba(99,102,241,0.35);

    --success:      #10b981;
    --success-bg:   rgba(16,185,129,0.1);
    --warning:      #f59e0b;
    --warning-bg:   rgba(245,158,11,0.1);
    --error:        #ef4444;
    --error-bg:     rgba(239,68,68,0.1);
    --info:         #06b6d4;
    --info-bg:      rgba(6,182,212,0.1);

    --text:         #f1f5f9;
    --text-muted:   #94a3b8;
    --text-dim:     #64748b;

    --sidebar-width: 260px;
    --topbar-height: 64px;

    --radius-sm:    6px;
    --radius:       10px;
    --radius-lg:    16px;
    --radius-xl:    24px;

    --shadow-sm:    0 1px 3px rgba(0,0,0,0.3);
    --shadow:       0 4px 16px rgba(0,0,0,0.35);
    --shadow-lg:    0 20px 60px rgba(0,0,0,0.4);
    --shadow-accent:0 0 40px rgba(99,102,241,0.25);

    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { scroll-behavior: smooth; font-size: 16px; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

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

img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }

/* ========================
   Scrollbar
   ======================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ========================
   App Layout
   ======================== */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 200;
    transition: transform var(--transition);
}

.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ========================
   Sidebar
   ======================== */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.25rem;
    border-bottom: 1px solid var(--border);
    min-height: var(--topbar-height);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text);
    font-weight: 700;
    font-size: 1rem;
}

.logo-icon {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
    box-shadow: var(--shadow-accent);
    flex-shrink: 0;
}

.sidebar-toggle { display: none; background: none; border: none; color: var(--text-muted); font-size: 1.2rem; cursor: pointer; padding: 0.25rem; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 1rem 0.75rem; }

.nav-section { margin-bottom: 1.5rem; }

.nav-section-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    text-transform: uppercase;
    padding: 0 0.5rem;
    margin-bottom: 0.4rem;
    display: block;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition);
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--accent-light);
    color: var(--text);
}

.nav-item.active {
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 600;
}

.nav-icon { font-size: 1.1rem; width: 20px; text-align: center; }

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

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
}

.user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.9rem; color: #fff;
    flex-shrink: 0;
}

.user-details { flex: 1; min-width: 0; }
.user-name { font-size: 0.875rem; font-weight: 600; truncate: true; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.75rem; color: var(--text-muted); }

.logout-btn {
    color: var(--text-muted);
    font-size: 1.2rem;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    display: flex; align-items: center;
}
.logout-btn:hover { color: var(--error); background: var(--error-bg); }

/* ========================
   Topbar
   ======================== */
.topbar {
    position: sticky; top: 0;
    height: var(--topbar-height);
    background: rgba(30,41,59,0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    z-index: 100;
}

.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.4rem;
}
.menu-toggle span {
    display: block; width: 22px; height: 2px;
    background: var(--text-muted); border-radius: 2px;
    transition: all var(--transition);
}

.topbar-title { flex: 1; font-size: 1rem; font-weight: 600; color: var(--text-muted); }
.topbar-actions { display: flex; align-items: center; gap: 0.75rem; }

/* ========================
   Content Area
   ======================== */
.content { flex: 1; padding: 2rem 1.75rem; max-width: 1280px; width: 100%; }
.main-footer { padding: 1rem 1.75rem; color: var(--text-dim); font-size: 0.8rem; border-top: 1px solid var(--border); }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 199; backdrop-filter: blur(2px); }

/* ========================
   Page Headers
   ======================== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.75rem;
    gap: 1rem;
}

.page-title { font-size: 1.75rem; font-weight: 800; color: var(--text); line-height: 1.2; }
.page-subtitle { color: var(--text-muted); font-size: 0.9rem; margin-top: 0.25rem; }
.breadcrumb { font-size: 0.85rem; color: var(--text-muted); display: inline-block; margin-bottom: 0.5rem; }
.breadcrumb:hover { color: var(--accent); }
.date-badge { background: var(--surface); border: 1px solid var(--border); padding: 0.4rem 0.875rem; border-radius: var(--radius); font-size: 0.85rem; color: var(--text-muted); }

/* ========================
   Cards
   ======================== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.card-header h3 { font-size: 0.95rem; font-weight: 600; }
.card-body { padding: 1.25rem 1.5rem; }

/* ========================
   Buttons
   ======================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent) 0%, #8b5cf6 100%);
    color: #fff;
    box-shadow: 0 4px 14px rgba(99,102,241,0.35);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(99,102,241,0.45); color: #fff; }

.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface3); color: var(--text); }

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

.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }

.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover { background: #dc2626; }

.btn-sm { padding: 0.4rem 0.875rem; font-size: 0.8rem; }
.btn-lg { padding: 0.85rem 1.75rem; font-size: 0.95rem; }
.btn-xs { padding: 0.25rem 0.6rem; font-size: 0.75rem; border-radius: 4px; }
.btn-block { width: 100%; }

/* ========================
   Forms
   ======================== */
.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; font-size: 0.875rem; font-weight: 500; color: var(--text-muted); margin-bottom: 0.4rem; }
.required { color: var(--error); }
.label-link { float: right; font-size: 0.8rem; font-weight: 400; color: var(--accent); }

.form-control {
    width: 100%;
    padding: 0.7rem 1rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
    -webkit-appearance: none;
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.2);
}

.form-control::placeholder { color: var(--text-dim); }

.form-textarea { resize: vertical; min-height: 120px; }
.form-select { cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.75rem center; padding-right: 2.5rem; }

.form-hint { font-size: 0.78rem; color: var(--text-dim); margin-top: 0.3rem; }
.char-count { font-size: 0.78rem; color: var(--text-dim); text-align: right; margin-top: 0.25rem; }

.input-wrapper { position: relative; }
.input-icon { position: absolute; left: 0.875rem; top: 50%; transform: translateY(-50%); color: var(--text-dim); font-size: 0.95rem; pointer-events: none; }
.input-wrapper .form-control { padding-left: 2.5rem; }
.password-toggle { position: absolute; right: 0.875rem; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 1rem; padding: 0; }

.form-check { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1rem; }
.checkbox { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.checkbox-label { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; cursor: pointer; }

/* Password strength */
.password-strength { margin-top: 0.5rem; }
.strength-bar { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; margin-bottom: 0.25rem; }
#strengthIndicator { height: 100%; border-radius: 2px; transition: width 0.3s, background 0.3s; width: 0; }

/* Form layouts */
.form-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 2rem; }
.form-grid { display: grid; grid-template-columns: 1fr 320px; gap: 2rem; }
.form-col-main {}
.form-col-side {}

.side-panel { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.side-panel-title { font-size: 0.875rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 1rem; }
.info-box { background: rgba(99,102,241,0.06); border: 1px solid rgba(99,102,241,0.2); border-radius: var(--radius-sm); padding: 0.875rem; font-size: 0.85rem; color: var(--text-muted); margin-top: 1rem; }
.info-box code { background: rgba(99,102,241,0.2); padding: 0.15rem 0.35rem; border-radius: 3px; font-size: 0.8rem; }

/* ========================
   Alerts & Flash Messages
   ======================== */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown { from { opacity:0; transform: translateY(-10px); } to { opacity:1; transform: translateY(0); } }

.alert-success { background: var(--success-bg); border: 1px solid rgba(16,185,129,0.3); color: #6ee7b7; }
.alert-error   { background: var(--error-bg);   border: 1px solid rgba(239,68,68,0.3);  color: #fca5a5; }
.alert-warning { background: var(--warning-bg); border: 1px solid rgba(245,158,11,0.3); color: #fde68a; }
.alert-info    { background: var(--info-bg);    border: 1px solid rgba(6,182,212,0.3);  color: #67e8f9; }

.alert-dismissible { position: relative; }
.alert-close { background: none; border: none; color: inherit; cursor: pointer; margin-left: auto; opacity: 0.7; font-size: 0.9rem; padding: 0; }
.alert-close:hover { opacity: 1; }

/* ========================
   Status & Priority Badges
   ======================== */
.status-badge, .priority-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.status-open        { background: rgba(239,68,68,0.12);  color: #fca5a5; }
.status-in_progress { background: rgba(245,158,11,0.12); color: #fde68a; }
.status-waiting     { background: rgba(139,92,246,0.12); color: #c4b5fd; }
.status-resolved    { background: rgba(16,185,129,0.12); color: #6ee7b7; }
.status-closed      { background: rgba(100,116,139,0.12);color: #94a3b8; }

.priority-text-low    { background: rgba(100,116,139,0.1);  color: #94a3b8; }
.priority-text-medium { background: rgba(99,102,241,0.12);  color: #a5b4fc; }
.priority-text-high   { background: rgba(245,158,11,0.12);  color: #fde68a; }
.priority-text-urgent { background: rgba(239,68,68,0.12);   color: #fca5a5; }

.category-badge {
    display: inline-flex; align-items: center;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
}

/* ========================
   Ticket Cards (List)
   ======================== */
.ticket-list { display: flex; flex-direction: column; gap: 0.5rem; }

.ticket-card {
    display: flex;
    align-items: stretch;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all var(--transition);
    color: var(--text);
}

.ticket-card:hover {
    border-color: var(--accent);
    transform: translateX(3px);
    box-shadow: var(--shadow);
}

.ticket-card-left { width: 4px; flex-shrink: 0; }
.ticket-card-left.priority-urgent { background: var(--error); }
.ticket-card-left.priority-high { background: var(--warning); }
.ticket-card-left.priority-medium { background: var(--accent); }
.ticket-card-left.priority-low { background: var(--text-dim); }

.ticket-priority { width: 100%; height: 100%; }
.priority-urgent .ticket-priority { background: var(--error); }
.priority-high   .ticket-priority { background: var(--warning); }
.priority-medium .ticket-priority { background: var(--accent); }
.priority-low    .ticket-priority { background: var(--text-dim); }

.ticket-card-body { flex: 1; padding: 1rem 1.25rem; }
.ticket-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; gap: 0.5rem; flex-wrap: wrap; }
.ticket-meta { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.ticket-badges { display: flex; align-items: center; gap: 0.5rem; }
.ticket-number { font-size: 0.75rem; color: var(--text-dim); font-family: monospace; background: var(--surface2); padding: 0.2rem 0.5rem; border-radius: 4px; }
.ticket-title { font-size: 0.95rem; font-weight: 600; color: var(--text); margin-bottom: 0.5rem; }
.ticket-footer { display: flex; justify-content: space-between; align-items: center; }
.ticket-info { font-size: 0.78rem; color: var(--text-dim); }
.ticket-agent { font-size: 0.78rem; color: var(--text-muted); }
.ticket-card-arrow { display: flex; align-items: center; padding: 0 1rem; color: var(--text-dim); font-size: 1.5rem; }

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

.message-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    overflow: hidden;
}

.message-original { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(99,102,241,0.1); }
.message-agent { border-color: rgba(139,92,246,0.3); background: rgba(139,92,246,0.04); }
.message-internal { border-left: 3px solid var(--warning); background: rgba(245,158,11,0.03); }
.internal-badge { background: rgba(245,158,11,0.12); color: var(--warning); font-size: 0.75rem; font-weight: 600; padding: 0.3rem 1rem; }

.message-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.message-author { display: flex; align-items: center; gap: 0.75rem; }
.author-name { font-size: 0.9rem; font-weight: 600; display: flex; align-items: center; gap: 0.5rem; }
.author-meta { font-size: 0.78rem; color: var(--text-dim); }
.message-body { padding: 1.25rem; font-size: 0.9rem; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }

.avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.9rem; color: #fff;
    flex-shrink: 0;
}
.avatar-agent { background: linear-gradient(135deg, #8b5cf6, #6366f1); }
.avatar-admin { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.avatar-sm { width: 32px; height: 32px; font-size: 0.8rem; }

.role-chip { background: var(--accent-light); color: var(--accent); font-size: 0.7rem; font-weight: 600; padding: 0.1rem 0.4rem; border-radius: 3px; }

/* Attachments */
.message-attachments { padding: 1rem 1.25rem; border-top: 1px solid var(--border); background: rgba(0,0,0,0.1); }
.attachments-title { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.75rem; }
.attachment-grid { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.attachment-item { }
.attachment-preview img { width: 120px; height: 90px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); transition: transform var(--transition); }
.attachment-preview:hover img { transform: scale(1.05); }
.attachment-file { display: flex; align-items: center; gap: 0.5rem; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.5rem 0.75rem; font-size: 0.8rem; }
.file-icon { font-size: 1.2rem; }
.file-name { color: var(--text); max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { color: var(--text-dim); font-size: 0.7rem; }

/* Reply form */
.reply-form { margin-top: 1.5rem; }
.reply-title { font-size: 1rem; font-weight: 600; padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); }
.reply-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 0.75rem; }

/* Ticket closed */
.closed-notice { display: flex; align-items: center; gap: 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem 1.5rem; margin-top: 1rem; font-size: 0.9rem; }
.closed-notice strong { color: var(--text); display: block; }
.closed-notice p { color: var(--text-muted); font-size: 0.85rem; }

/* Info list */
.info-list { display: grid; grid-template-columns: auto 1fr; gap: 0.5rem 1rem; font-size: 0.875rem; }
.info-list dt { color: var(--text-muted); font-weight: 500; white-space: nowrap; }
.info-list dd { color: var(--text); }

/* ========================
   File Upload
   ======================== */
.upload-area {
    position: relative;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--surface2);
}
.upload-area:hover, .upload-area.dragover {
    border-color: var(--accent);
    background: var(--accent-light);
}
.upload-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.upload-text { font-size: 0.9rem; font-weight: 500; color: var(--text); }
.upload-hint { font-size: 0.78rem; color: var(--text-dim); margin-top: 0.25rem; }
.upload-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }

.upload-area-sm { padding: 0.75rem 1rem; display: flex; align-items: center; gap: 0.5rem; justify-content: center; }
.upload-icon-sm { font-size: 1.1rem; }

.file-preview-list { margin-top: 0.75rem; display: flex; flex-direction: column; gap: 0.4rem; }
.file-preview-item { display: flex; align-items: center; gap: 0.5rem; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.5rem 0.75rem; font-size: 0.8rem; }
.file-preview-remove { margin-left: auto; background: none; border: none; color: var(--error); cursor: pointer; font-size: 1rem; padding: 0; }

/* ========================
   Filter Bar
   ======================== */
.filter-bar { margin-bottom: 1.25rem; }
.filter-form { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.filter-search { max-width: 280px; }
.filter-group { display: flex; align-items: center; gap: 0.5rem; }

/* ========================
   Empty State
   ======================== */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
.empty-icon { font-size: 3.5rem; margin-bottom: 1rem; }
.empty-state h3 { font-size: 1.25rem; font-weight: 700; margin-bottom: 0.5rem; }
.empty-state p { color: var(--text-muted); margin-bottom: 1.5rem; }

/* ========================
   Pagination
   ======================== */
.pagination { display: flex; align-items: center; justify-content: center; gap: 0.5rem; margin-top: 1.5rem; }
.pagination-btn { padding: 0.5rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 0.875rem; color: var(--text-muted); transition: all var(--transition); }
.pagination-btn:hover { border-color: var(--accent); color: var(--accent); }
.pagination-pages { display: flex; gap: 0.25rem; }
.pagination-page { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); font-size: 0.875rem; color: var(--text-muted); border: 1px solid transparent; transition: all var(--transition); }
.pagination-page:hover { background: var(--surface2); color: var(--text); }
.pagination-page.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ========================
   Auth Pages
   ======================== */
.auth-body {
    background: var(--bg);
    background-image: radial-gradient(ellipse at 20% 50%, rgba(99,102,241,0.12) 0%, transparent 50%), radial-gradient(ellipse at 80% 50%, rgba(139,92,246,0.08) 0%, transparent 50%);
    min-height: 100vh;
    display: flex;
    align-items: center;
}

.auth-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 100vh;
    width: 100%;
}

.auth-wrapper.auth-centered {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    min-height: 100vh;
}

.auth-left {
    background: linear-gradient(135deg, rgba(99,102,241,0.1) 0%, rgba(139,92,246,0.08) 100%);
    border-right: 1px solid var(--border);
    padding: 3rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2rem;
}

.auth-brand { }
.auth-logo { font-size: 3.5rem; margin-bottom: 1rem; display: block; }
.auth-brand h1 { font-size: 1.75rem; font-weight: 800; margin-bottom: 0.75rem; background: linear-gradient(135deg, var(--text), var(--text-muted)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.auth-brand p { color: var(--text-muted); line-height: 1.6; }

.auth-features { display: flex; flex-direction: column; gap: 0.75rem; }
.auth-feature { display: flex; align-items: center; gap: 0.75rem; font-size: 0.9rem; color: var(--text-muted); }
.auth-feature span { font-size: 1.2rem; width: 28px; text-align: center; }

.auth-right { display: flex; align-items: center; justify-content: center; padding: 3rem; }

.auth-card { width: 100%; max-width: 420px; }

.auth-card-header { margin-bottom: 2rem; }
.auth-card-header h2 { font-size: 1.5rem; font-weight: 800; margin-bottom: 0.25rem; }
.auth-card-header p { color: var(--text-muted); font-size: 0.9rem; }

.auth-divider { text-align: center; margin: 1.25rem 0; position: relative; color: var(--text-dim); font-size: 0.85rem; }
.auth-divider::before { content: ''; position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: var(--border); z-index: -1; }
.auth-divider span { background: var(--bg); padding: 0 0.75rem; }

/* ========================
   Modals (dialog element)
   ======================== */
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); max-width: 520px; width: 100%; padding: 0; box-shadow: var(--shadow-lg); color: var(--text); }
.modal::backdrop { background: rgba(0,0,0,0.65); backdrop-filter: blur(4px); }

.modal-content { }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 1rem; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 1.2rem; cursor: pointer; padding: 0.25rem; border-radius: 4px; transition: all var(--transition); }
.modal-close:hover { color: var(--error); background: var(--error-bg); }
.modal form { padding: 1.5rem; }
.modal-footer { display: flex; gap: 0.75rem; justify-content: flex-end; padding-top: 1rem; border-top: 1px solid var(--border); margin-top: 1rem; }

/* ========================
   Tables
   ======================== */
.table-wrapper { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th { text-align: left; padding: 0.875rem 1rem; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); border-bottom: 1px solid var(--border); white-space: nowrap; background: rgba(0,0,0,0.1); }
.data-table td { padding: 0.875rem 1rem; border-bottom: 1px solid rgba(51,65,85,0.5); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: rgba(99,102,241,0.04); }
.clickable-row { cursor: pointer; }
.empty-cell { text-align: center; color: var(--text-dim); padding: 2rem !important; }
.ticket-number-sm { font-family: monospace; font-size: 0.8rem; background: var(--surface2); padding: 0.2rem 0.4rem; border-radius: 4px; color: var(--text-muted); }
.ticket-number-link { font-family: monospace; font-size: 0.85rem; color: var(--accent); }
.ticket-title-cell { max-width: 250px; }
.ticket-title-cell a { color: var(--text); font-weight: 500; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; }
.ticket-title-cell a:hover { color: var(--accent); }
.reply-badge { background: var(--surface2); color: var(--text-dim); font-size: 0.7rem; padding: 0.1rem 0.4rem; border-radius: 3px; margin-left: 0.5rem; }
.action-btns { display: flex; align-items: center; gap: 0.4rem; }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--error); }

/* ========================
   User & Role Badges
   ======================== */
.role-badge { display: inline-flex; align-items: center; padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.role-customer { background: var(--surface3); color: var(--text-muted); }
.role-agent { background: rgba(99,102,241,0.12); color: #a5b4fc; }
.role-admin { background: rgba(245,158,11,0.12); color: #fde68a; }
.you-badge { background: var(--accent-light); color: var(--accent); font-size: 0.7rem; padding: 0.1rem 0.4rem; border-radius: 3px; }
.status-dot { font-size: 0.8rem; font-weight: 500; }
.status-dot.active { color: var(--success); }
.status-dot.inactive { color: var(--error); }
.user-cell { display: flex; align-items: center; gap: 0.5rem; }
.version-badge { background: var(--surface2); border: 1px solid var(--border); padding: 0.25rem 0.75rem; border-radius: 999px; font-size: 0.75rem; color: var(--text-muted); }

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

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; }
.stat-open::before { background: var(--error); }
.stat-progress::before { background: var(--warning); }
.stat-resolved::before { background: var(--success); }
.stat-users::before { background: var(--info); }
.stat-total::before { background: var(--accent); }
.stat-customers::before { background: #8b5cf6; }

.stat-icon { font-size: 1.75rem; }
.stat-body { flex: 1; min-width: 0; }
.stat-value { font-size: 1.75rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.2rem; }
.stat-trend { font-size: 0.72rem; color: var(--text-dim); margin-top: 0.25rem; }

.dashboard-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem; }
.dashboard-col { }

.progress-row { margin-bottom: 0.875rem; }
.progress-label { display: flex; justify-content: space-between; font-size: 0.8rem; margin-bottom: 0.3rem; color: var(--text-muted); }
.progress-count { font-weight: 600; color: var(--text); }
.progress-bar { height: 6px; background: var(--surface2); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; transition: width 0.6s cubic-bezier(0.4,0,0.2,1); }

.category-row { display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 0; border-bottom: 1px solid rgba(51,65,85,0.3); font-size: 0.875rem; }
.category-row:last-child { border-bottom: none; }
.category-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.category-name { flex: 1; color: var(--text); }
.category-count { font-weight: 600; color: var(--text-muted); }

/* Admin categories grid */
.categories-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
.category-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.category-card-header { display: flex; align-items: center; gap: 1rem; padding: 1.25rem; }
.category-card-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; flex-shrink: 0; }
.category-card-info { flex: 1; min-width: 0; }
.category-card-info h3 { font-size: 0.95rem; font-weight: 700; }
.category-card-info p { font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.category-card-count { text-align: center; }
.big-number { font-size: 1.75rem; font-weight: 800; display: block; }
.category-card-actions { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 1.25rem; background: rgba(0,0,0,0.1); border-top: 1px solid var(--border); }
.color-swatch { font-size: 0.75rem; padding: 0.2rem 0.5rem; border-radius: 4px; color: #fff; font-family: monospace; }

/* Color picker */
.color-picker-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.color-input { width: 44px; height: 36px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; background: none; padding: 2px; }
.preset-colors { display: flex; gap: 0.4rem; }
.color-preset { width: 22px; height: 22px; border-radius: 4px; cursor: pointer; transition: transform var(--transition); }
.color-preset:hover { transform: scale(1.2); }

/* Settings */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.settings-card { }
.settings-actions { margin-top: 1.5rem; display: flex; justify-content: flex-end; }

.setting-toggle { display: flex; align-items: center; justify-content: space-between; cursor: pointer; gap: 1rem; }
.toggle-wrapper { position: relative; }
.toggle-input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track { width: 42px; height: 22px; background: var(--border); border-radius: 11px; transition: background var(--transition); position: relative; cursor: pointer; }
.toggle-input:checked ~ .toggle-track { background: var(--accent); }
.toggle-thumb { width: 18px; height: 18px; background: #fff; border-radius: 50%; position: absolute; top: 2px; left: 2px; transition: transform var(--transition); box-shadow: var(--shadow-sm); }
.toggle-input:checked ~ .toggle-track .toggle-thumb { transform: translateX(20px); }

/* ========================
   Responsive
   ======================== */
@media (max-width: 1024px) {
    .form-grid { grid-template-columns: 1fr; }
    .form-col-side { order: -1; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .settings-grid { grid-template-columns: 1fr; }
    .ticket-detail-grid { grid-template-columns: 1fr; }
    .ticket-detail-side { order: -1; }
}

@media (max-width: 768px) {
    :root { --sidebar-width: 0px; }

    .sidebar {
        transform: translateX(-260px);
        width: 260px;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.show { display: block; }
    .main-wrapper { margin-left: 0; }
    .menu-toggle { display: flex; }
    .sidebar-toggle { display: block; }
    .topbar { padding: 0 1rem; }
    .content { padding: 1.25rem 1rem; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .auth-wrapper { grid-template-columns: 1fr; }
    .auth-left { display: none; }
    .auth-right { padding: 2rem 1rem; }
    .filter-form { flex-direction: column; align-items: stretch; }
    .filter-search { max-width: none; }
    .categories-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .page-title { font-size: 1.35rem; }
}
