:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --bg: #f1f5f9;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #2563eb;
  --radius: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* Header */
.header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 56px;
}
.header-left { display: flex; align-items: center; gap: 32px; }
.header-right { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 18px; font-weight: 700; color: var(--primary); }
.nav { display: flex; gap: 4px; }
.nav-link {
  padding: 6px 14px;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 14px;
  transition: all .15s;
}
.nav-link:hover { background: var(--bg); color: var(--text); }
.nav-link.active { background: #eff6ff; color: var(--primary); }
.user-info { font-size: 14px; color: var(--text-muted); }
.role-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  text-transform: uppercase;
}
.role-admin { background: #fef3c7; color: #92400e; }
.role-staff { background: #dbeafe; color: #1e40af; }

/* Container */
.container { max-width: 1200px; margin: 0 auto; padding: 24px; }
.page-header { margin-bottom: 20px; }
.page-header h2 { font-size: 24px; font-weight: 600; }

/* Card */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.card h3 { font-size: 16px; margin-bottom: 16px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 4px 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; }
input[type="text"], input[type="date"], input[type="email"],
select, textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
textarea { resize: vertical; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form input, .inline-form select { width: auto; flex: 1; min-width: 150px; }

/* Filters */
.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}
.filters select, .filters input { width: auto; min-width: 140px; }

/* Table */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.table th {
  background: var(--bg);
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.table tbody tr:last-child td { border-bottom: none; }
.clickable-row { cursor: pointer; transition: background .1s; }
.clickable-row:hover { background: #f8fafc; }
.td-title { font-weight: 500; max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Status badges */
.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.status-em_aberto { background: #dbeafe; color: #1e40af; }
.status-em_andamento { background: #fef3c7; color: #92400e; }
.status-resolvido { background: #dcfce7; color: #166534; }
.status-fechado { background: #f1f5f9; color: #475569; }

.tipo-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}
.tipo-suporte { background: #ede9fe; color: #5b21b6; }
.tipo-erro { background: #fef2f2; color: #991b1b; }

/* Login */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}
.login-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,.07);
}
.login-header { text-align: center; margin-bottom: 32px; }
.login-header h1 { font-size: 24px; color: var(--primary); }
.login-header p { color: var(--text-muted); margin-top: 4px; }

/* Ticket detail */
.back-link {
  display: inline-block;
  color: var(--primary);
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 16px;
}
.back-link:hover { text-decoration: underline; }
.ticket-header-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.ticket-header-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.ticket-header-top h2 { font-size: 20px; }
.ticket-meta-badges { display: flex; gap: 8px; }
.ticket-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; margin-bottom: 16px; font-size: 14px; }
.meta-item { color: var(--text-muted); }
.meta-item strong { color: var(--text); }
.ticket-desc { font-size: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.ticket-desc p { margin-top: 4px; white-space: pre-wrap; }

.status-changer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 14px;
}
.status-changer select { width: auto; }
.status-changer label { font-weight: 500; }

/* Chat */
.chat-section { margin-bottom: 20px; }
.chat-section h3 { font-size: 16px; margin-bottom: 12px; }
.chat-timeline {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  max-height: 500px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chat-msg {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
}
.msg-client {
  align-self: flex-start;
  background: #f1f5f9;
  border-bottom-left-radius: 4px;
}
.msg-staff {
  align-self: flex-end;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-bottom-right-radius: 4px;
}
.msg-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.msg-sender { font-weight: 600; font-size: 12px; }
.msg-time { font-size: 11px; color: var(--text-muted); }
.msg-body { white-space: pre-wrap; word-break: break-word; }
.msg-attachment {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--primary);
}

/* Reply */
.reply-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.reply-section h3 { font-size: 16px; margin-bottom: 12px; }
.reply-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.reply-actions .btn-primary { margin-left: auto; }
.file-label input[type="file"] { display: none; }
.file-name-display { font-size: 13px; color: var(--text-muted); }
.closed-notice {
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* Misc */
.error-msg { color: var(--danger); font-size: 14px; margin-top: 8px; }
.empty-state { text-align: center; color: var(--text-muted); padding: 40px 20px; font-size: 14px; }
.loading { text-align: center; color: var(--text-muted); padding: 40px; }
.feedback { font-size: 13px; margin-left: 8px; }
.feedback.success { color: var(--success); }
.feedback.error { color: var(--danger); }
.text-muted { color: var(--text-muted); }
code { background: var(--bg); padding: 2px 6px; border-radius: 4px; font-size: 13px; }

/* Responsive */
@media (max-width: 768px) {
  .header-inner { height: auto; padding: 12px 0; flex-wrap: wrap; gap: 8px; }
  .header-left { flex-wrap: wrap; gap: 12px; }
  .ticket-meta { grid-template-columns: 1fr; }
  .chat-msg { max-width: 90%; }
  .table { font-size: 13px; }
  .table th, .table td { padding: 8px 10px; }
  .filters { flex-direction: column; }
  .filters select, .filters input { width: 100%; }
}
