:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #dde1e7;
  --text: #1a1d23;
  --text-muted: #6b7280;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }

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

.sidebar {
  width: 224px; background: #1e2a3a; color: #c9d3e0;
  display: flex; flex-direction: column; flex-shrink: 0;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
  transition: transform .25s;
}
.sidebar-logo { padding: 16px 14px 12px; border-bottom: 1px solid #2d3d50; }
.gde-logo-frame { background: #fff; border-radius: 6px; overflow: hidden; box-shadow: 0 1px 6px rgba(0,0,0,.35); line-height: 0; }
.sidebar-logo h1 { color: #fff; font-size: 14px; font-weight: 700; margin-top: 10px; }
.sidebar-logo small { color: #8a9ab0; font-size: 11px; }
.sidebar nav { flex: 1; padding: 10px 0; overflow-y: auto; }
.nav-section { padding: 10px 16px 4px; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: #5a7090; font-weight: 600; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 9px 16px;
  color: #c9d3e0; text-decoration: none; font-size: 13.5px;
  cursor: pointer; border: none; background: none; width: 100%; text-align: left;
  transition: background .15s;
}
.nav-link:hover { background: #2d3d50; color: #fff; }
.nav-link.active { background: #1d4ed8; color: #fff; }
.nav-link .icon { font-size: 16px; width: 20px; text-align: center; }
.sidebar-user { padding: 12px 14px; border-top: 1px solid #2d3d50; font-size: 12px; }
.sidebar-user-name { color: #fff; font-weight: 600; }
.sidebar-user-email { color: #8a9ab0; font-size: 11px; margin-top: 1px; }
.sidebar-user-role { display: inline-block; margin-top: 6px; padding: 1px 8px; border-radius: 10px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; background: #2d3d50; color: #8ab0d8; }
.btn-logout { margin-top: 8px; width: 100%; padding: 6px; background: #2d3d50; border: none; color: #c9d3e0; border-radius: 4px; cursor: pointer; font-size: 12px; text-align: center; }
.btn-logout:hover { background: #dc2626; color: #fff; }

.main { margin-left: 224px; flex: 1; padding: 24px; min-width: 0; }
.page { display: none; }
.page.active { display: block; }

/* ── HAMBURGER ── */
.hamburger { display: none; position: fixed; top: 14px; left: 14px; z-index: 200; background: #1e2a3a; border: none; color: #fff; width: 36px; height: 36px; border-radius: 6px; cursor: pointer; font-size: 18px; }
#sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 99; }
#sidebar-overlay.show { display: block; }

/* ── PÁGINA HEADER ── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.page-title { font-size: 20px; font-weight: 700; color: var(--text); }
.page-sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ── BOTÕES ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius); font-size: 13px; font-weight: 600; cursor: pointer; border: none; transition: background .15s, opacity .15s; text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: #fee2e2; color: var(--danger); border: 1px solid #fca5a5; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── KPI CARDS ── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi-card { background: var(--surface); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.kpi-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.kpi-value { font-size: 32px; font-weight: 800; color: var(--text); margin: 4px 0 2px; line-height: 1; }
.kpi-card.danger .kpi-value { color: var(--danger); }
.kpi-card.warning .kpi-value { color: var(--warning); }
.kpi-card.success .kpi-value { color: var(--success); }
.kpi-card.primary .kpi-value { color: var(--primary); }

/* ── CARD ── */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.card-title { font-size: 14px; font-weight: 700; }
.card-body { padding: 20px; }

/* ── FILTROS ── */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: flex-end; }
.filter-bar select, .filter-bar input { height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; background: var(--surface); color: var(--text); }
.filter-bar input[type=text] { min-width: 220px; }
.filter-bar select { min-width: 140px; }

/* ── TABELA ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); background: #f8fafc; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid #f0f2f5; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }
.clickable { cursor: pointer; }
.empty-row td { text-align: center; color: var(--text-muted); padding: 40px; }

/* ── BADGES PRIORIDADE ── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.p-critica  { background: #fef2f2; color: #dc2626; }
.p-alta     { background: #fff7ed; color: #ea580c; }
.p-media    { background: #fffbeb; color: #d97706; }
.p-baixa    { background: #f0fdf4; color: #16a34a; }

/* ── BADGES STATUS ── */
.s-novo                { background: #eff6ff; color: #1d4ed8; }
.s-em_atendimento      { background: #fff7ed; color: #c2410c; }
.s-aguardando_usuario  { background: #faf5ff; color: #7e22ce; }
.s-aguardando_agente   { background: #fffbeb; color: #b45309; }
.s-resolvido           { background: #f0fdf4; color: #15803d; }
.s-fechado             { background: #f9fafb; color: #6b7280; }

/* ── SLA ── */
.sla-ok      { color: var(--success); font-size: 11px; font-weight: 600; }
.sla-warn    { color: var(--warning); font-size: 11px; font-weight: 600; }
.sla-viol    { color: var(--danger);  font-size: 11px; font-weight: 700; }
.sla-na      { color: var(--text-muted); font-size: 11px; }

/* ── TICKET DETALHE ── */
.ticket-detail-header { margin-bottom: 20px; }
.ticket-detail-header .back-link { color: var(--primary); cursor: pointer; font-size: 13px; margin-bottom: 8px; display: inline-flex; align-items: center; gap: 4px; }
.ticket-detail-header h2 { font-size: 18px; font-weight: 700; margin: 8px 0 6px; }
.ticket-detail-header .badges { display: flex; gap: 6px; flex-wrap: wrap; }

.ticket-detail-grid { display: grid; grid-template-columns: 1fr 280px; gap: 20px; align-items: start; }

.ticket-desc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; white-space: pre-wrap; font-size: 13.5px; line-height: 1.7; }

/* ── TIMELINE ── */
.timeline { display: flex; flex-direction: column; gap: 1px; }
.timeline-item { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid #f0f2f5; }
.timeline-item:last-child { border-bottom: none; }
.timeline-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.timeline-avatar.history { background: #e5e7eb; color: #6b7280; font-size: 14px; }
.timeline-content { flex: 1; min-width: 0; }
.timeline-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.timeline-meta strong { color: var(--text); }
.timeline-body { font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; }
.timeline-item.interno .timeline-content { background: #fffbeb; border: 1px solid #fde68a; border-radius: var(--radius); padding: 8px 12px; }
.badge-interno { background: #fef3c7; color: #92400e; padding: 1px 7px; border-radius: 10px; font-size: 10px; font-weight: 700; }
.timeline-section { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin: 16px 0 8px; display: flex; align-items: center; gap: 8px; }
.timeline-section::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── PAINEL DE DETALHES ── */
.detail-panel { position: sticky; top: 20px; }
.detail-row { display: flex; flex-direction: column; gap: 2px; padding: 12px 0; border-bottom: 1px solid #f0f2f5; }
.detail-row:last-child { border-bottom: none; }
.detail-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.detail-value { font-size: 13.5px; color: var(--text); }

/* ── FORMULÁRIO ── */
.form-grid { display: grid; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.form-control { padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13.5px; color: var(--text); background: var(--surface); font-family: inherit; transition: border-color .15s; width: 100%; }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29,78,216,.12); }
textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control { cursor: pointer; }

/* ── COMMENT BOX ── */
.comment-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-top: 16px; }
.comment-box-title { font-size: 13px; font-weight: 700; margin-bottom: 12px; }
.comment-box textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13.5px; font-family: inherit; resize: vertical; min-height: 80px; }
.comment-box textarea:focus { outline: none; border-color: var(--primary); }
.comment-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; flex-wrap: wrap; gap: 8px; }
.check-interno { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); cursor: pointer; }

/* ── AÇÕES DO TICKET ── */
.ticket-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.ticket-actions select { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; }

/* ── MODAL ── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 300; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.show { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius); box-shadow: 0 8px 32px rgba(0,0,0,.18); width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; }
.modal-header { padding: 18px 20px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 15px; font-weight: 700; }
.modal-close { background: none; border: none; cursor: pointer; font-size: 20px; color: var(--text-muted); line-height: 1; }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ── TOAST ── */
.toast { position: fixed; bottom: 24px; right: 24px; background: #1e2a3a; color: #fff; padding: 12px 20px; border-radius: var(--radius); font-size: 13px; font-weight: 500; box-shadow: 0 4px 16px rgba(0,0,0,.2); opacity: 0; transform: translateY(8px); transition: opacity .25s, transform .25s; pointer-events: none; z-index: 999; max-width: 340px; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* ── LOGIN ── */
.lg-root { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #0f1923; }
.lg-card { background: var(--surface); border-radius: 12px; padding: 36px; width: 100%; max-width: 380px; box-shadow: 0 8px 32px rgba(0,0,0,.3); }
.lg-logo-wrap { text-align: center; margin-bottom: 24px; }
.lg-title { font-size: 22px; font-weight: 800; color: var(--text); margin-top: 14px; }
.lg-sub { font-size: 13px; color: var(--text-muted); margin-top: 4px; text-align: center; }
.lg-form { display: flex; flex-direction: column; gap: 14px; margin-top: 24px; }
.lg-field label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); display: block; margin-bottom: 5px; }
.lg-field input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; transition: border-color .15s; }
.lg-field input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29,78,216,.12); }
.lg-btn { width: 100%; padding: 11px; background: var(--primary); color: #fff; border: none; border-radius: var(--radius); font-size: 14px; font-weight: 700; cursor: pointer; transition: background .15s; margin-top: 4px; }
.lg-btn:hover { background: var(--primary-hover); }
.lg-error { background: #fee2e2; color: var(--danger); border-radius: 6px; padding: 10px 14px; font-size: 13px; display: none; }

/* ── ABAS LOGIN/CADASTRO ── */
.lg-tabs { display: flex; border-bottom: 2px solid var(--border); margin: 20px 0 0; }
.lg-tab { flex: 1; padding: 10px; background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -2px; font-size: 14px; font-weight: 600; color: var(--text-muted); cursor: pointer; transition: color .15s, border-color .15s; }
.lg-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.lg-tab:hover:not(.active) { color: var(--text); }
.lg-success { background: #f0fdf4; color: #15803d; border-radius: 6px; padding: 10px 14px; font-size: 13px; margin-bottom: 4px; }
.lg-toggle-link { text-align: center; font-size: 12.5px; color: var(--text-muted); margin-top: 14px; }
.lg-toggle-link a { color: var(--primary); text-decoration: none; font-weight: 600; }
.lg-toggle-link a:hover { text-decoration: underline; }
.lg-info { text-align: center; font-size: 12px; color: var(--text-muted); margin-top: 8px; background: #f8fafc; border-radius: 6px; padding: 8px 12px; }

/* ── SETUP ── */
#setup-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #0f1923; }

/* ── PAGINATION ── */
.pagination { display: flex; gap: 6px; align-items: center; justify-content: center; margin-top: 16px; }
.pagination button { padding: 5px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); cursor: pointer; font-size: 12px; }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .hamburger { display: flex; align-items: center; justify-content: center; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; padding: 16px; padding-top: 56px; }
  .ticket-detail-grid { grid-template-columns: 1fr; }
  .detail-panel { position: static; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .filter-bar input[type=text] { min-width: 140px; }
}
