:root {
    --bg-primary: #202225;
    --bg-secondary: #2f3136;
    --bg-tertiary: #36393f;
    --bg-input: #40444b;
    --bg-hover: #393c43;
    --bg-card: #292b2f;
    --bg-danger: #4a1c1c;
    --bg-warning: #4a3c1c;
    --text-danger: #ff6b6b;
    --text-warning: #ffd700;
    --text-primary: #dcddde;
    --text-secondary: #b9bbbe;
    --text-muted: #72767d;
    --accent: #5865F2;
    --accent-hover: #4752C4;
    --accent-active: #3c45a5;
    --green: #3ba55c;
    --green-hover: #2d7d46;
    --red: #ed4245;
    --red-hover: #c03537;
    --yellow: #faa61a;
    --yellow-hover: #c8810f;
    --orange: #f26522;
    --border-color: #202225;
    --shadow: 0 2px 10px rgba(0,0,0,.2);
    --radius: 8px;
    --radius-sm: 5px;
    --radius-lg: 12px;
    --sidebar-width: 280px;
    --header-height: 60px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
input, textarea, select {
    background: var(--bg-input);
    color: var(--text-primary);
    border: none;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    outline: none;
    font-size: 14px;
    width: 100%;
    transition: background .15s;
}
input:focus, textarea:focus, select:focus {
    background: #484c52;
}
textarea { resize: vertical; min-height: 80px; font-family: inherit; }
button, .btn {
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all .15s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-green { background: var(--green); color: white; }
.btn-green:hover { background: var(--green-hover); }
.btn-red { background: var(--red); color: white; }
.btn-red:hover { background: var(--red-hover); }
.btn-yellow { background: var(--yellow); color: white; }
.btn-yellow:hover { background: var(--yellow-hover); }
.btn-ghost { background: transparent; color: var(--text-primary); border: 1px solid var(--bg-input); }
.btn-ghost:hover { background: var(--bg-hover); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 14px 24px; font-size: 16px; }
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.badge-new { background: var(--yellow); color: #1a1a2e; }
.badge-open { background: var(--green); color: white; }
.badge-pending { background: var(--accent); color: white; }
.badge-onhold { background: #fff; color: #1a1a2e; }
.badge-solved { background: var(--text-muted); color: white; }
.badge-archived { background: var(--text-muted); color: white; }
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-input);
    flex-shrink: 0;
    object-fit: cover;
}
.avatar-sm { width: 32px; height: 32px; }
.avatar-lg { width: 64px; height: 64px; }
.avatar-xl { width: 80px; height: 80px; }
.card {
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    padding: 20px;
}
.page-wrapper {
    display: flex;
    height: 100vh;
}
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    flex-shrink: 0;
}
.sidebar-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
}
.sidebar-header .server-select {
    flex: 1;
}
.server-select {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background .15s;
    position: relative;
}
.server-select:hover { background: var(--bg-hover); }
.server-select img { width: 28px; height: 28px; border-radius: 50%; }
.server-select .arrow { margin-left: auto; font-size: 10px; color: var(--text-muted); }
.server-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    z-index: 100;
    max-height: 300px;
    overflow-y: auto;
    margin-top: 4px;
}
.server-dropdown.show { display: block; }
.server-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    transition: background .15s;
}
.server-dropdown-item:hover { background: var(--bg-hover); }
.server-dropdown-item img { width: 24px; height: 24px; border-radius: 50%; }
.server-dropdown-item.active { background: var(--accent); color: white; }
.sidebar-nav {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
}
.nav-section {
    margin-bottom: 20px;
}
.nav-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    padding: 8px 12px;
    margin-bottom: 4px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    text-decoration: none;
    transition: background .15s;
    cursor: pointer;
    position: relative;
}
.nav-item:hover { background: var(--bg-hover); color: white; text-decoration: none; }
.nav-item.active { background: var(--bg-hover); color: white; }
.nav-item .count {
    margin-left: auto;
    background: var(--red);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}
.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-tertiary);
    min-width: 0;
}
.content-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: var(--header-height);
    flex-shrink: 0;
    background: var(--bg-tertiary);
}
.content-header h2 {
    font-size: 18px;
    font-weight: 600;
}
.content-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}
.ticket-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.ticket-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background .15s;
    border: 1px solid transparent;
}
.ticket-item:hover { background: var(--bg-hover); }
.ticket-item.selected { background: var(--bg-hover); border-color: var(--accent); }
.ticket-item .ticket-info { flex: 1; min-width: 0; }
.ticket-item .ticket-subject {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ticket-item .ticket-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}
.ticket-item .ticket-status { flex-shrink: 0; }
.ticket-detail {
    display: flex;
    flex-direction: column;
    height: 100%;
}
.ticket-detail-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-shrink: 0;
}
.ticket-detail-header .info h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}
.ticket-detail-header .info .meta {
    font-size: 12px;
    color: var(--text-muted);
}
.ticket-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.message {
    display: flex;
    gap: 12px;
    max-width: 85%;
}
.message.right { align-self: flex-end; flex-direction: row-reverse; }
.message .msg-body { display: flex; flex-direction: column; }
.message.right .msg-body { align-items: flex-end; }
.message .msg-author {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.message .msg-bubble {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 14px;
    line-height: 1.4;
    background: var(--bg-secondary);
    word-break: break-word;
}
.message.right .msg-bubble {
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 2px;
}
.message.left .msg-bubble {
    background: var(--bg-secondary);
    border-bottom-left-radius: 2px;
}
.message.staff-note .msg-bubble {
    border-left: 3px solid var(--yellow);
    background: rgba(250, 166, 26, 0.08);
}
.message.system {
    align-self: center;
}
.message.system .msg-bubble {
    background: var(--bg-card);
    font-size: 12px;
    color: var(--text-muted);
    padding: 6px 16px;
    border-radius: 20px;
    text-align: center;
}
.message-input-area {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    background: var(--bg-tertiary);
}
.message-input-area form {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}
.message-input-area textarea {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
    border-radius: var(--radius);
    padding: 12px;
}
.ticket-detail-sidebar {
    width: 280px;
    padding: 20px;
    border-left: 1px solid var(--border-color);
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    flex-shrink: 0;
}
.user-card {
    text-align: center;
    padding: 20px;
    background: var(--bg-primary);
    border-radius: var(--radius);
}
.user-card img { margin-bottom: 8px; }
.user-card h3 { font-size: 16px; font-weight: 600; }
.user-card .user-id { font-size: 11px; color: var(--text-muted); word-break: break-all; }
.status-select select {
    background: var(--bg-primary);
    padding: 8px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    width: 100%;
}
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-muted);
}
.loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid var(--text-muted);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
    margin-left: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.search-results .user-result {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-primary);
    border-radius: var(--radius);
    margin-bottom: 12px;
}
.search-results .user-result .user-info { flex: 1; }
.search-results .user-result .user-info h3 { font-size: 16px; }
.search-results .user-result .user-info .user-id { font-size: 12px; color: var(--text-muted); }
.search-results .roles-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.search-results .tickets-list {
    margin-top: 16px;
}
.search-results .tickets-list h4 {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.search-results .ticket-preview {
    padding: 10px 14px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background .15s;
}
.search-results .ticket-preview:hover { background: var(--bg-hover); }
.server-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    transition: background .15s;
}
.server-list-item:hover { background: var(--bg-hover); }
.server-list-item img { width: 36px; height: 36px; border-radius: 50%; }
.server-list-item .info { flex: 1; }
.server-list-item .info h4 { font-size: 14px; font-weight: 600; }
.server-list-item .info span { font-size: 12px; color: var(--text-muted); }
.tab-bar {
    display: flex;
    gap: 4px;
    padding: 0 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.tab-bar .tab {
    padding: 12px 20px;
    cursor: pointer;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 14px;
    border-bottom: 2px solid transparent;
    transition: all .15s;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}
.tab-bar .tab:hover { color: var(--text-primary); }
.tab-bar .tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}
.modal h2 { font-size: 18px; margin-bottom: 16px; }
.modal .modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.flex { display: flex; }
.flex-col { flex-direction: column; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.w-full { width: 100%; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.mt-sm { margin-top: 8px; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 16px; }
.truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
    text-align: center;
}
.empty-state .icon { font-size: 48px; margin-bottom: 16px; opacity: .5; }
.empty-state h3 { font-size: 18px; margin-bottom: 8px; }
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    border-radius: var(--radius);
    background: var(--bg-secondary);
    color: var(--text-primary);
    box-shadow: var(--shadow);
    z-index: 9999;
    animation: slideIn .3s ease;
    max-width: 400px;
}
.toast.success { border-left: 4px solid var(--green); }
.toast.error { border-left: 4px solid var(--red); }
.toast.info { border-left: 4px solid var(--accent); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
/* Badges */
.badge-dev { background: var(--yellow); color: #000; font-size: 11px; padding: 2px 8px; border-radius: 4px; font-weight: 700; letter-spacing: .5px; vertical-align: middle; margin-left: 6px; }

/* Buttons */
.btn-xs { font-size: 11px; padding: 2px 8px; height: auto; min-height: 0; line-height: 1.4; }
.btn-ghost { background: transparent; border: 1px solid var(--border-color); color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-content { background: var(--bg-tertiary); border-radius: var(--radius-lg); max-height: 90vh; overflow-y: auto; width: 100%; box-shadow: var(--shadow); }
.modal-sm { max-width: 480px; }
.modal-lg { max-width: 800px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border-color); }
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 20px; }
.btn-close { background: none; border: none; color: var(--text-muted); font-size: 18px; cursor: pointer; padding: 4px 8px; border-radius: 4px; }
.btn-close:hover { background: var(--bg-hover); color: var(--text-primary); }

/* Mobile */
@media (max-width: 768px) {
    .ticket-detail-sidebar { display: none; }
    .message { max-width: 95%; }
    .tickets-columns { flex-direction: column; }
    .tickets-column { max-height: 300px; min-width: 0; }
    .server-grid { grid-template-columns: repeat(auto-fill,minmax(140px,1fr)); }
    .settings-row { flex-direction: column; align-items: flex-start; gap: 8px; }
    .content-body { padding: 16px; }
    .modal-content { margin: 10px; max-height: 85vh; }
    .user-header { flex-wrap: wrap; }
    .ticket-info-bar { flex-wrap: wrap; }
    .form-group textarea { min-height: 80px; }
}
@media (max-width: 480px) {
    .server-grid { grid-template-columns: 1fr 1fr; }
    .content-header { padding: 12px 16px; }
    .content-header h2 { font-size: 16px; }
    .message-input-area { padding: 8px 12px; }
    .message-input-area textarea { min-height: 36px; font-size: 14px; }
    .btn { font-size: 13px; padding: 8px 14px; }
    .server-card { padding: 12px; }
    .server-card img { width: 48px; height: 48px; }
    .modal-body { padding: 12px; }
}
