* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

:root {
    --bg-0: #0b1120;
    --bg-1: #131c2e;
    --bg-2: #1a2540;
    --border: #24304a;
    --text: #e6edf7;
    --text-dim: #8b97ad;
    --primary: #3ab5fe;
    --primary-dark: #1c587a;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
}

body {
    background: var(--bg-0);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    font-size: 15px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: #5cc5ff; }

/* ============ LOGIN ============ */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top left, #10203a 0%, var(--bg-0) 60%);
    padding: 20px;
}

.login-card {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.login-logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo h1 {
    font-size: 26px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 5px;
}

.login-logo p {
    color: var(--text-dim);
    font-size: 14px;
}

/* ============ LAYOUT ============ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: var(--bg-1);
    border-right: 1px solid var(--border);
    padding: 24px 16px;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    overflow-y: auto;
}

.sidebar-logo {
    padding: 0 12px 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.sidebar-logo h2 {
    font-size: 18px;
    color: var(--primary);
    font-weight: 700;
}

.sidebar-logo span {
    display: block;
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 2px;
}

.sidebar-menu {
    list-style: none;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 8px;
    color: var(--text-dim);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    margin-bottom: 4px;
}

.sidebar-menu li a:hover {
    background: var(--bg-2);
    color: var(--text);
}

.sidebar-menu li a.active {
    background: rgba(58, 181, 254, 0.12);
    color: var(--primary);
    border-left: 3px solid var(--primary);
}

.sidebar-menu .icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-1);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 8px;
    background: var(--bg-2);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-info .name {
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-info .role {
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
}

.main-content {
    margin-left: 240px;
    flex: 1;
    padding: 32px 40px;
    min-height: 100vh;
}

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

.page-header h1 {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 4px;
}

.page-header p {
    color: var(--text-dim);
    font-size: 14px;
}

/* ============ CARDS ============ */
.card {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
}

.stat-card .label {
    font-size: 12px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.stat-card .value {
    font-size: 30px;
    font-weight: 700;
    color: var(--primary);
}

.stat-card .sub {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 4px;
}

/* ============ FORM ============ */
.form-group {
    margin-bottom: 16px;
}

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

.form-control,
.form-select {
    width: 100%;
    background: var(--bg-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 11px 14px;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s;
}

.form-control:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(58, 181, 254, 0.15);
}

textarea.form-control {
    resize: vertical;
    min-height: 120px;
}

/* ============ BOTÕES ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    text-decoration: none;
}

.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary {
    background: var(--primary);
    color: #0b1120;
}
.btn-primary:hover:not(:disabled) {
    background: #5cc5ff;
    color: #0b1120;
}

.btn-secondary {
    background: var(--bg-2);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) {
    background: #223055;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-danger:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.25);
}

.btn-sm {
    padding: 7px 12px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
}

/* ============ TABELAS ============ */
.table-wrap {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-1);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

thead th {
    background: var(--bg-2);
    color: var(--text-dim);
    text-align: left;
    padding: 14px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

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

tbody tr:hover { background: rgba(58, 181, 254, 0.04); }

/* ============ BADGES ============ */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-open { background: rgba(58, 181, 254, 0.15); color: #7dd3fc; }
.badge-in_progress { background: rgba(245, 158, 11, 0.15); color: #fcd34d; }
.badge-waiting_client { background: rgba(168, 85, 247, 0.15); color: #d8b4fe; }
.badge-resolved { background: rgba(34, 197, 94, 0.15); color: #86efac; }
.badge-closed { background: rgba(107, 114, 128, 0.2); color: #9ca3af; }

.badge-low { background: rgba(148, 163, 184, 0.15); color: #cbd5e1; }
.badge-medium { background: rgba(58, 181, 254, 0.15); color: #7dd3fc; }
.badge-high { background: rgba(245, 158, 11, 0.15); color: #fcd34d; }
.badge-critical { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }

/* ============ MODAL ============ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 28px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover { color: var(--text); }

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* ============ ALERTS ============ */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
    display: none;
}

.alert.show { display: block; }

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.alert-success {
    background: rgba(34, 197, 94, 0.1);
    color: #86efac;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

/* ============ TICKET DETAIL ============ */
.ticket-header {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.ticket-meta {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
}

.ticket-meta .row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.ticket-meta .row:last-child { border-bottom: none; }

.ticket-meta .row .key {
    color: var(--text-dim);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
}

.timeline {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.comment {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
}

.comment.internal {
    border-left: 3px solid var(--warning);
    background: rgba(245, 158, 11, 0.05);
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 12px;
    color: var(--text-dim);
}

.comment-header .author {
    font-weight: 600;
    color: var(--text);
    font-size: 13px;
}

.comment-body {
    font-size: 14px;
    white-space: pre-wrap;
    word-break: break-word;
}

.comment-form {
    margin-top: 20px;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
}

/* ============ UTILS ============ */
.text-dim { color: var(--text-dim); }
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.gap-2 { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }

.filters {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filters input,
.filters select {
    max-width: 220px;
}

.empty-state {
    padding: 60px 20px;
    text-align: center;
    color: var(--text-dim);
}

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.4;
}

/* Responsivo */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
    .sidebar.active { transform: translateX(0); }
    .main-content { margin-left: 0; padding: 20px; }
    .ticket-header { grid-template-columns: 1fr; }
}
