/* === DESIGN SYSTEM — Livre Intelligence Dashboard v3 === */
:root {
  --livre-blue: #1a56db;
  --livre-blue-hover: #1545b5;
  --livre-red: #ff3b30;
  --livre-orange: #ff9500;
  --livre-yellow: #ffcc00;
  --livre-green: #30d158;
  --livre-purple: #5856d6;

  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e3e8ee;
  --border-strong: #cdd4dd;
  --text: #1a1f36;
  --text-muted: #697386;
  --text-dim: #8a94a6;

  --sidebar-bg: #0f1629;
  --sidebar-text: #c7cad1;
  --sidebar-active: #1a2340;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(17,24,39,.04);
  --shadow: 0 4px 12px rgba(17,24,39,.06);
}

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

/* === SIDEBAR FIXA === */
.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  display: flex;
  flex-direction: column;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }
.sidebar-brand {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand-logo {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #3b82f6, #1a56db);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; font-size: 18px;
}
.sidebar-brand-text { font-weight: 600; font-size: 15px; color: #fff; }
.sidebar-brand-sub { font-size: 11px; color: var(--sidebar-text); opacity: 0.7; }

.sidebar-group { padding: 14px 0 2px; }
.sidebar-group-label {
  padding: 0 20px 8px;
  font-size: 10px;
  font-weight: 600;
  color: var(--sidebar-text);
  opacity: 0.55;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s, color .12s;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--sidebar-active); color: #fff; }
.nav-item.active {
  background: var(--sidebar-active);
  color: #fff;
  border-left-color: #3b82f6;
}
.nav-item-badge {
  margin-left: auto;
  background: var(--livre-red);
  color: #fff;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.sidebar-bottom { margin-top: auto; padding: 16px 0 8px; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar-status {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 20px 4px;
  font-size: 12px; color: var(--sidebar-text); opacity: 0.85;
}
.sidebar-status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--livre-green);
  box-shadow: 0 0 6px rgba(48,209,88,0.55);
  animation: sidebar-pulse 2.4s ease-in-out infinite;
}
@keyframes sidebar-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}
.sidebar-status-text { font-size: 12px; }
.sidebar-version {
  padding: 0 20px 8px;
  font-size: 11px; color: var(--sidebar-text); opacity: 0.55;
  letter-spacing: 0.2px;
}

/* === MAIN === */
.main {
  margin-left: 240px;
  padding: 24px 32px;
  max-width: 1400px;
  min-height: 100vh;
  box-sizing: border-box;
}
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-title { font-size: 24px; font-weight: 700; }
.page-subtitle { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.page-header-actions { display: flex; gap: 8px; align-items: center; }

/* === CARDS === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.stat-card.urgent { border-left: 4px solid var(--livre-red); }
.stat-card.warn   { border-left: 4px solid var(--livre-orange); }
.stat-card-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.stat-card-value {
  font-size: 28px;
  font-weight: 700;
  margin-top: 6px;
}
.stat-card-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* === CHARTS === */
.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
.chart-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.chart-card h3 { font-size: 14px; font-weight: 600; margin-bottom: 16px; }
.chart-container { position: relative; height: 280px; }

/* === TABELAS === */
.data-table {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.data-table table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: top;
}
.data-table tbody tr:hover { background: #fafbfc; cursor: pointer; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .truncate { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* === BADGES === */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
}
.badge-critico { background: var(--livre-red); color: #fff; }
.badge-grave   { background: var(--livre-orange); color: #fff; }
.badge-medio   { background: var(--livre-yellow); color: var(--text); }
.badge-leve    { background: var(--livre-green); color: #fff; }
.badge-elite   { background: var(--livre-purple); color: #fff; }
.badge-bom     { background: var(--livre-green); color: #fff; }
.badge-regular { background: #8e8e93; color: #fff; }
.badge-alerta  { background: var(--livre-orange); color: #fff; }
.badge-inactive{ background: #d2d2d7; color: var(--text-muted); }
.badge-ghost   { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

/* === FILTROS === */
.filters-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-select, .filter-input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--surface);
  font-family: inherit;
  color: var(--text);
}
.filter-input { min-width: 200px; }
.filter-label { font-size: 12px; color: var(--text-muted); margin-right: 4px; }

/* === BOTÕES === */
.btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
}
.btn:hover { opacity: 0.9; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary   { background: var(--livre-blue); color: #fff; }
.btn-success   { background: var(--livre-green); color: #fff; }
.btn-danger    { background: var(--livre-red); color: #fff; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* === FORMS === */
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; font-weight: 500; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  resize: vertical;
}

/* === MODAL === */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow);
}
.modal-close {
  position: absolute; top: 12px; right: 12px;
  border: none; background: transparent;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}

/* === UTILITIES === */
.empty-state { text-align: center; padding: 48px; color: var(--text-muted); }
.loading     { text-align: center; padding: 24px; color: var(--text-muted); }
.result-msg  { padding: 12px; border-radius: var(--radius-sm); margin-top: 12px; font-size: 14px; }
.result-msg.success { background: #d1f5d1; color: #1d7f1d; }
.result-msg.error   { background: #ffd1d1; color: #a3181b; }
.result-msg.info    { background: #dee9ff; color: #1a56db; }

.pagination { display: flex; gap: 8px; justify-content: center; margin-top: 16px; align-items: center; font-size: 14px; color: var(--text-muted); }
.pagination .btn { padding: 6px 12px; }

.mono { font-family: 'SF Mono', Consolas, Menlo, monospace; font-size: 12px; }
.hint { font-size: 12px; color: var(--text-muted); }

/* === LOGIN (standalone) === */
body.login {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f1629 0%, #1a2340 100%);
  min-height: 100vh;
  padding: 20px;
}
.login-box {
  background: var(--surface);
  padding: 32px;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  width: 100%;
  max-width: 380px;
}
.login-box h1 { font-size: 22px; margin-bottom: 4px; }
.login-box p.hint { margin-bottom: 24px; }
.login-box button { width: 100%; padding: 12px; margin-top: 4px; }

/* === HAMBURGER MENU + BACKDROP (sempre presentes; só visíveis em mobile) === */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px; left: 12px;
  z-index: 1100;
  width: 44px; height: 44px;
  background: var(--sidebar-bg);
  border: none;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  cursor: pointer;
  padding: 0;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
}
.sidebar-toggle span {
  display: block;
  width: 22px; height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: transform .2s, opacity .2s;
}
.sidebar-toggle.active span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.sidebar-toggle.active span:nth-child(2) { opacity: 0; }
.sidebar-toggle.active span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 999;
  opacity: 0;
  transition: opacity .2s;
}
.sidebar-backdrop.backdrop-visible {
  display: block;
  opacity: 1;
}

/* === TOOLTIP popover (criado via JS no mobile, ou via :hover em desktop) === */
[data-tooltip] {
  position: relative;
}
@media (hover: hover) and (pointer: fine) {
  [data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15,22,41,0.95);
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.35;
    max-width: 250px;
    width: max-content;
    white-space: normal;
    z-index: 1500;
    box-shadow: var(--shadow);
    pointer-events: none;
  }
  [data-tooltip]:hover::before {
    content: "";
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(15,22,41,0.95);
    z-index: 1500;
    pointer-events: none;
  }
}
.tooltip-popover {
  position: absolute;
  background: rgba(15,22,41,0.95);
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12.5px;
  line-height: 1.4;
  max-width: 250px;
  z-index: 2000;
  box-shadow: var(--shadow);
  pointer-events: none;
}

/* === BOTÃO (?) AJUDA INLINE === */
.help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, color .15s;
  font-family: inherit;
  padding: 0;
  vertical-align: middle;
  margin-left: 6px;
  line-height: 1;
}
.help-btn:hover { background: var(--livre-blue); color: #fff; border-color: var(--livre-blue); }

/* === HELP MODAL === */
.help-modal { position: fixed; inset: 0; z-index: 2000; }
.help-modal[hidden] { display: none; }
.help-modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.55); }
.help-modal-content {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  max-width: 560px;
  width: calc(100% - 32px);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 24px 24px 20px;
}
.help-modal-close {
  position: absolute; top: 8px; right: 8px;
  width: 32px; height: 32px;
  border: none; background: transparent;
  font-size: 24px; line-height: 1;
  cursor: pointer; color: var(--text-muted);
  border-radius: 50%;
}
.help-modal-close:hover { background: var(--bg); color: var(--text); }
.help-modal-title { font-size: 18px; font-weight: 700; margin-bottom: 12px; padding-right: 24px; }
.help-modal-body { font-size: 14px; line-height: 1.55; color: var(--text); }
.help-modal-body p { margin-bottom: 10px; }
.help-modal-body ul { padding-left: 20px; margin-bottom: 10px; }
.help-modal-body li { margin-bottom: 6px; }
.help-modal-body strong { color: var(--text); }
.help-modal-body code {
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12.5px;
}

/* === RESPONSIVE — TABLET (768px – 1024px) === */
@media (max-width: 1024px) and (min-width: 769px) {
  .main { padding: 18px 22px; max-width: 100%; }
  .chart-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
}

/* === RESPONSIVE — MOBILE (≤768px) === */
@media (max-width: 768px) {
  /* HAMBURGER visível */
  .sidebar-toggle { display: flex; }

  /* SIDEBAR vira overlay */
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease;
    width: 260px;
    max-width: 80vw;
    z-index: 1000;
    box-shadow: 4px 0 20px rgba(0,0,0,0.25);
  }
  .sidebar.sidebar-open { transform: translateX(0); }

  /* MAIN ocupa 100% */
  .main {
    margin-left: 0;
    padding: 60px 14px 18px;
    max-width: 100%;
  }

  /* PAGE HEADER vertical */
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 18px;
  }
  .page-title { font-size: 20px; }
  .page-subtitle { font-size: 12px; }
  .page-header-actions { flex-wrap: wrap; gap: 6px; }

  /* CARDS: 1 coluna */
  .stats-grid { grid-template-columns: 1fr; gap: 10px; margin-bottom: 18px; }
  .stat-card { padding: 14px; }
  .stat-card-value { font-size: 22px; }
  .kpi-row { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi-card { padding: 10px 12px; }
  .kpi-value { font-size: 20px; }
  .kpi-label { font-size: 10px; }

  /* CHARTS: 1 coluna, altura menor */
  .chart-grid { grid-template-columns: 1fr; gap: 12px; }
  .chart-card { padding: 14px; }
  .chart-container { height: 200px; }

  /* TABELAS: scroll horizontal */
  .data-table { overflow-x: auto; }
  .data-table table { min-width: 600px; }
  .data-table th, .data-table td { padding: 8px 10px; font-size: 12px; }
  .data-table .truncate { max-width: 180px; }

  /* FILTROS: empilhar verticalmente */
  .filters-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .filter-select, .filter-input {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 10px 12px;
    font-size: 15px;
  }

  /* BOTÕES: área de toque maior */
  .btn {
    min-height: 44px;
    padding: 10px 16px;
    font-size: 15px;
  }
  .btn-sm { min-height: 32px; padding: 6px 12px; font-size: 13px; }

  /* FORMS */
  .form-group input, .form-group textarea, .form-group select {
    min-height: 44px;
    padding: 10px 12px;
    font-size: 15px;
  }

  /* MODAL */
  .modal-content { padding: 18px 14px; }

  /* SLIDE PANELS — full screen */
  .slide-panel,
  .slideover,
  .conversation-panel,
  .drawer,
  .side-panel {
    width: 100vw !important;
    max-width: 100vw !important;
    left: 0 !important;
    right: 0 !important;
  }

  /* TABS empilhar com scroll horizontal se muitos */
  .tabs-bar {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  .tab-btn {
    flex-shrink: 0;
    min-height: 44px;
    padding: 10px 14px;
  }

  /* BADGES e tags um pouco maiores */
  .badge { padding: 3px 9px; font-size: 11px; }

  /* PROFILE / DETAIL */
  .profile-name { font-size: 20px; }
  .profile-cards-grid { grid-template-columns: 1fr; gap: 8px; }
  .profile-stats-mini { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .profile-mini-num { font-size: 18px; }
  .profile-behavior-grid { grid-template-columns: 1fr; }

  /* HELP BUTTON inline com título */
  .help-btn { width: 32px; height: 32px; }

  /* PAGINATION com toque */
  .pagination .btn { min-height: 36px; padding: 8px 12px; }

  /* HELP MODAL: padding menor */
  .help-modal-content { padding: 18px 16px 14px; }

  /* KANBAN com scroll horizontal */
  .kanban-board, .kanban-cols, .tickets-board {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* === PROFILE V3 (driver_detail / passenger_detail) === */
.profile-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 18px;
}
.profile-header-main { min-width: 0; flex: 1 1 320px; }
.profile-back { color: var(--livre-blue); font-size: 13px; }
.profile-name { font-size: 26px; font-weight: 700; margin: 4px 0 6px 0; line-height: 1.1; }
.profile-meta { color: var(--text-muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.profile-header-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.profile-cards-grid {
  display: grid; gap: 10px; margin-bottom: 18px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
@media (max-width: 900px) { .profile-cards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .profile-cards-grid { grid-template-columns: 1fr; } }
.profile-card {
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px;
}
.profile-card-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.profile-card-value { font-size: 18px; font-weight: 600; line-height: 1.25; }
.profile-card-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.loading-inline::after { content: '…'; color: var(--text-muted); }

.profile-rep-bar { background: #f0f0f3; border-radius: 4px; height: 6px; margin-top: 6px; overflow: hidden; }
.profile-rep-fill { background: linear-gradient(90deg, #ff9500 0%, #ffcc00 50%, #30d158 100%); height: 100%; }

.badge-tier-big { font-size: 13px; padding: 4px 12px; }

.profile-section { margin-bottom: 18px; }

.profile-behavior-grid {
  display: grid; grid-template-columns: minmax(220px, 280px) 1fr; gap: 18px; align-items: start;
}
@media (max-width: 700px) { .profile-behavior-grid { grid-template-columns: 1fr; } }
.profile-gauge {
  background: #f9fafb; border-radius: 10px; padding: 14px;
}
.profile-gauge-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; }
.profile-gauge-value { font-size: 32px; font-weight: 700; margin: 6px 0 8px 0; }
.profile-gauge-bar { background: #e5e5ea; border-radius: 4px; height: 8px; overflow: hidden; }
.profile-gauge-fill { height: 100%; transition: width 0.3s; }

.profile-stats-mini {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.profile-mini-stat {
  background: #f9fafb; border-radius: 8px; padding: 10px; text-align: center;
}
.profile-mini-num { font-size: 22px; font-weight: 700; line-height: 1; }
.profile-mini-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; margin-top: 4px; }

.profile-rate-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; background: #f9fafb; border-radius: 8px;
}
.profile-rate-label { font-size: 12px; }
.profile-rate-value { font-weight: 700; font-size: 14px; }
.text-muted { color: var(--text-muted); font-weight: 400; font-size: 11px; }

/* Timeline */
.profile-tl-filters { display: flex; flex-wrap: wrap; gap: 4px; }
.profile-tl-btn {
  background: #f0f0f3; border: 0; padding: 5px 10px; border-radius: 14px;
  font-size: 11px; cursor: pointer; transition: all 0.15s; color: var(--text-muted);
}
.profile-tl-btn:hover { background: #e5e5ea; }
.profile-tl-btn.active { background: var(--livre-blue); color: #fff; }

.profile-timeline { display: flex; flex-direction: column; gap: 6px; }
.tl-row {
  display: flex; gap: 12px; padding: 10px 12px;
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  border-left-width: 3px;
}
.tl-row.tl-ride       { border-left-color: #1a56db; }
.tl-row.tl-incident   { border-left-color: #ff9500; }
.tl-row.tl-edu        { border-left-color: #30d158; }
.tl-row.tl-conv       { border-left-color: #af52de; }
.tl-row.tl-action     { border-left-color: #ff3b30; }
.tl-icon { font-size: 18px; line-height: 1.2; flex-shrink: 0; }
.tl-content { flex: 1; min-width: 0; font-size: 13px; }
.tl-head { font-weight: 500; }
.tl-time { color: var(--text-muted); font-size: 11px; font-weight: 400; }
.tl-desc { font-size: 13px; color: var(--text); margin-top: 4px; }
.tl-extra { font-size: 12px; color: var(--text-muted); margin-top: 4px; word-break: break-word; }
.tl-link { color: var(--livre-blue); font-size: 11px; text-decoration: none; margin-left: 6px; }
.tl-link:hover { text-decoration: underline; }
.tl-toggle { color: var(--livre-blue); font-size: 11px; cursor: pointer; }
.tl-raw {
  display: none; background: #f5f5f7; padding: 8px; border-radius: 6px;
  font-size: 11px; margin-top: 4px; max-height: 200px; overflow: auto;
  white-space: pre-wrap; word-break: break-word;
}
.tl-raw.open { display: block; }
.tl-ok  { color: #30d158; font-weight: 600; }
.tl-bad { color: #ff3b30; font-weight: 600; }
.tl-warn{ color: #ff9500; font-weight: 600; }
.badge-perm { background: #f59e0b; color: #fff; font-size: 10px; }

/* === MENSAGENS V3 (Fase 2A) === */
.tabs-bar { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab-btn {
  background: transparent; border: 0; padding: 10px 16px; cursor: pointer;
  font-size: 14px; color: var(--text-muted); border-bottom: 2px solid transparent;
  font-weight: 500;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--livre-blue); border-bottom-color: var(--livre-blue); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

.kpi-row {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
.kpi-card {
  background: var(--surface); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.kpi-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.kpi-value { font-size: 26px; font-weight: 700; margin-top: 4px; }

.form-row { margin-bottom: 14px; position: relative; }
.form-label { display: block; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; font-weight: 600; }

.suggest-box {
  position: absolute; top: 100%; left: 0; right: 0;
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  margin-top: 4px; max-height: 240px; overflow-y: auto; z-index: 10;
  box-shadow: var(--shadow-sm);
}
.suggest-item { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--border); font-size: 13px; }
.suggest-item:hover { background: #f5f5f7; }
.suggest-item:last-child { border-bottom: 0; }

.preview-box { border: 1px solid var(--border); border-radius: 8px; padding: 14px; background: var(--bg); }

/* === CAMPANHAS V3 (Fase 2B) === */
.campaign-cards {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}
.campaign-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 12px;
}
.campaign-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.campaign-card-head h3 { font-size: 16px; margin: 0; line-height: 1.2; }
.campaign-card-meta { font-size: 12px; color: var(--text-muted); }
.campaign-card-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  background: #f9fafb; border-radius: 8px; padding: 10px; text-align: center;
}
.campaign-card-stats > div { font-size: 11px; color: var(--text-muted); }
.campaign-card-stats strong { display: block; font-size: 16px; color: var(--text); margin-bottom: 2px; }
.campaign-card-actions { display: flex; flex-wrap: wrap; gap: 6px; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 22, 41, 0.5); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 32px 16px;
  overflow-y: auto;
}
/* CRITICO: HTML [hidden] precisa sobrescrever display:flex acima.
   Sem essa regra, modais ficam EMPILHADOS na tela porque display:flex
   tem maior especificidade que o atributo [hidden]. */
.modal-overlay[hidden] { display: none !important; }
.modal-box {
  background: var(--surface); border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  max-width: 640px; width: 100%; max-height: 90vh; overflow-y: auto;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 18px; }
.modal-body { padding: 20px; }

/* Fix defensivo Commit 38: garantir que conteudo do modal seja visivel.
   Marcos relatou: ao clicar editar/criar, "apenas uma linha com o nome
   do campo eh mostrada" — labels e inputs colapsando. Forca display +
   altura minima dentro de .modal-box pra garantir renderizacao. */
.modal-box .form-group { display: block !important; margin-bottom: 14px !important; }
.modal-box .form-group label {
  display: block !important; visibility: visible !important;
  font-size: 13px !important; color: var(--text) !important;
  margin-bottom: 6px !important; font-weight: 500 !important;
  height: auto !important; line-height: 1.4 !important;
}
.modal-box .form-group input,
.modal-box .form-group textarea,
.modal-box .form-group select {
  display: block !important; visibility: visible !important;
  width: 100% !important; min-height: 38px !important;
  padding: 8px 12px !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  font-family: inherit !important; font-size: 14px !important;
  background: var(--surface) !important; color: var(--text) !important;
  box-sizing: border-box !important;
}
.modal-box .form-group input[type="checkbox"] {
  display: inline-block !important; width: auto !important;
  min-height: auto !important; margin-right: 8px !important;
}

.reward-table { width: 100%; border-collapse: collapse; }
.reward-table th { text-align: left; padding: 6px 4px; font-size: 11px; color: var(--text-muted); text-transform: uppercase; }
.reward-table td { padding: 4px; }

/* === ATENDIMENTO V3 (Fase 3) === */
.view-toggle { display: inline-flex; background: var(--bg); border-radius: 8px; padding: 3px; gap: 2px; }
.view-btn {
  background: transparent; border: 0; padding: 6px 12px; border-radius: 6px;
  cursor: pointer; font-size: 13px; color: var(--text-muted); font-weight: 500;
}
.view-btn:hover { color: var(--text); }
.view-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* Severity badges reuse */
.badge-grave { background: #ff9500; color: #fff; }

/* Kanban */
.kanban-board {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px;
}
@media (max-width: 1100px) { .kanban-board { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px)  { .kanban-board { grid-template-columns: 1fr; } }
.kanban-col {
  background: var(--bg); border-radius: 12px; padding: 10px;
  display: flex; flex-direction: column; min-height: 200px;
}
.kanban-col-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 8px 10px 8px; font-size: 13px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.4px;
}
.kanban-count {
  background: var(--surface); padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600; color: var(--text);
}
.kanban-cards { display: flex; flex-direction: column; gap: 8px; }
.kanban-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; cursor: pointer; transition: box-shadow 0.15s;
}
.kanban-card:hover { box-shadow: var(--shadow-sm); border-color: var(--border-strong); }
.kanban-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; gap: 6px; }
.kanban-card-title { font-size: 13px; font-weight: 500; line-height: 1.3; margin-bottom: 6px; }
.kanban-card-foot { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); }

/* Slide panel */
.slide-panel-overlay { position: fixed; inset: 0; background: rgba(15,22,41,0.5); z-index: 90; }
.slide-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: 520px; max-width: 100vw;
  background: var(--surface); box-shadow: -4px 0 20px rgba(0,0,0,0.15);
  z-index: 95; transform: translateX(100%); transition: transform 0.2s ease-out;
  display: flex; flex-direction: column;
}
.slide-panel.open { transform: translateX(0); }
.slide-panel-head {
  display: flex; align-items: center; gap: 8px; padding: 14px 18px;
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.slide-panel-body { padding: 18px; overflow-y: auto; flex: 1; }

.ticket-meta-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; font-size: 13px;
}
.ticket-meta-grid .form-label { margin-bottom: 2px; }

.comments-list { display: flex; flex-direction: column; gap: 8px; }
.comment-bubble {
  background: #f5f5f7; border-radius: 8px; padding: 10px 12px; font-size: 13px;
  border-left: 3px solid var(--livre-blue);
}
.comment-bubble.internal { background: #fff8e1; border-left-color: #ff9500; }
.comment-head { display: flex; align-items: center; font-size: 11px; margin-bottom: 4px; }
.comment-body { white-space: pre-wrap; }

.ticket-actions .form-row { margin-bottom: 10px; }

/* Badge inactive (estilo "fechado") */
.badge-inactive { background: #cdd4dd; color: #495057; }

/* === AUDITORIA (Fase 5) === */
.compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}
.compare-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--border);
  display: flex; flex-direction: column; gap: 4px;
}
.compare-card.compare-up   { border-left-color: var(--livre-green); }
.compare-card.compare-down { border-left-color: var(--livre-red); }
.compare-card.compare-flat { border-left-color: var(--text-dim); }

.compare-label {
  font-size: 11px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600;
}
.compare-value { font-size: 22px; font-weight: 700; line-height: 1.1; }

.compare-delta {
  font-size: 12px; display: flex; align-items: center; gap: 6px;
  color: var(--text-muted);
}
.compare-up   .compare-delta { color: var(--livre-green); font-weight: 600; }
.compare-down .compare-delta { color: var(--livre-red);   font-weight: 600; }
.compare-flat .compare-delta { color: var(--text-dim); }

.compare-chip {
  background: var(--bg);
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.compare-up   .compare-chip { background: rgba(48,209,88,0.12); color: var(--livre-green); }
.compare-down .compare-chip { background: rgba(255,59,48,0.10); color: var(--livre-red); }
.compare-sub { font-weight: 400; color: var(--text-muted); font-size: 11px; }

/* ──────────────────────────────────────────────────────────────────────
   Tabs: badge de contagem dentro de .tab-btn
   ────────────────────────────────────────────────────────────────────── */
.tab-btn .badge {
  background: var(--livre-red);
  color: #fff;
  margin-left: 6px;
  vertical-align: middle;
}
.tab-btn.active .badge {
  background: var(--livre-blue);
}

/* ──────────────────────────────────────────────────────────────────────
   Utilitários — spacing
   ────────────────────────────────────────────────────────────────────── */
.mt-1{margin-top:4px}   .mb-1{margin-bottom:4px}
.mt-2{margin-top:8px}   .mb-2{margin-bottom:8px}
.mt-3{margin-top:12px}  .mb-3{margin-bottom:12px}
.mt-4{margin-top:16px}  .mb-4{margin-bottom:16px}
.mt-6{margin-top:24px}  .mb-6{margin-bottom:24px}
.mt-8{margin-top:32px}  .mb-8{margin-bottom:32px}

/* ──────────────────────────────────────────────────────────────────────
   Utilitários — flex
   ────────────────────────────────────────────────────────────────────── */
.flex{display:flex}
.flex-col{display:flex;flex-direction:column}
.flex-wrap{flex-wrap:wrap}
.items-center{align-items:center}
.items-start{align-items:flex-start}
.items-end{align-items:flex-end}
.justify-between{justify-content:space-between}
.justify-center{justify-content:center}
.justify-end{justify-content:flex-end}
.gap-1{gap:4px}  .gap-2{gap:8px}  .gap-3{gap:12px}  .gap-4{gap:16px}  .gap-6{gap:24px}

/* ──────────────────────────────────────────────────────────────────────
   Utilitários — text (text-muted já existe em linha 728)
   ────────────────────────────────────────────────────────────────────── */
.text-dim     { color: var(--text-dim); }
.text-danger  { color: var(--livre-red); }
.text-success { color: var(--livre-green); }
.text-warning { color: var(--livre-orange); }
.text-primary { color: var(--livre-blue); }

.text-xs{font-size:11px}
.text-sm{font-size:13px}
.text-base{font-size:14px}
.text-lg{font-size:16px}

.font-medium{font-weight:500}
.font-semibold{font-weight:600}
.font-bold{font-weight:700}

/* ──────────────────────────────────────────────────────────────────────
   Utilitários — width/visibility
   ────────────────────────────────────────────────────────────────────── */
.w-full{width:100%}
.hidden{display:none}
.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%}
