/* ============================================================
   RETLED EXPANSÃO - Estilos v1.1 (Responsivo)
   ============================================================ */
:root {
  --bg:        #0d1117;
  --bg2:       #161b22;
  --bg3:       #1c2230;
  --border:    #30363d;
  --text:      #e6edf3;
  --text2:     #8b949e;
  --led:       #00d4ff;
  --led2:      #0099cc;
  --success:   #3fb950;
  --warn:      #d29922;
  --danger:    #f85149;
  --purple:    #bc8cff;
  --radius:    8px;
  --shadow:    0 2px 16px rgba(0,0,0,.4);
  --font:      'Inter', 'Segoe UI', system-ui, sans-serif;
  --sidebar-w: 230px;
  --sidebar-w-collapsed: 0px;
}

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

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

a { color: var(--led); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* ---- OVERLAY mobile ---- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 90;
}
.sidebar-overlay.open { display: block; }

/* ---- SIDEBAR ---- */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s ease;
}

.sidebar-logo {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-logo .brand {
  font-size: 18px;
  font-weight: 700;
  color: var(--led);
  letter-spacing: -.3px;
}

.sidebar-logo .sub {
  font-size: 11px;
  color: var(--text2);
  margin-top: 2px;
}

.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--text2);
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.sidebar-nav { flex: 1; padding: 10px 0; overflow-y: auto; }

.nav-section {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text2);
  padding: 10px 16px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--text2);
  border-left: 3px solid transparent;
  transition: all .15s;
  font-size: 13.5px;
}

.nav-item:hover, .nav-item.active {
  background: var(--bg3);
  color: var(--text);
  border-left-color: var(--led);
  text-decoration: none;
}

.nav-item.active { color: var(--led); }
.nav-icon { font-size: 17px; width: 22px; text-align: center; flex-shrink: 0; }

.sidebar-user {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--led), var(--led2));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; color: var(--bg);
  flex-shrink: 0;
}

.user-info .name { font-size: 13px; font-weight: 600; }
.user-info .role { font-size: 11px; color: var(--text2); }

/* ---- MAIN ---- */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

/* ---- TOPBAR ---- */
.topbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky; top: 0; z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 12px; }

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text2);
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  flex-shrink: 0;
}

.page-title { font-size: 15px; font-weight: 600; }
.topbar-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

.content { padding: 20px; flex: 1; }

/* ============================================================
   CARDS / STATS
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.stat-label { font-size: 11px; color: var(--text2); margin-bottom: 5px; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-sub { font-size: 11px; color: var(--text2); margin-top: 4px; }
.stat-card.led .stat-value { color: var(--led); }
.stat-card.success .stat-value { color: var(--success); }
.stat-card.warn .stat-value { color: var(--warn); }
.stat-card.danger .stat-value { color: var(--danger); }

/* ============================================================
   CARDS GERAIS
   ============================================================ */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 18px;
}

.card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.card-title { font-size: 13px; font-weight: 600; }

/* ============================================================
   TABELAS — responsivas via scroll
   ============================================================ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table { width: 100%; border-collapse: collapse; min-width: 480px; }

th {
  background: var(--bg3);
  text-align: left;
  padding: 9px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg3); }

/* ============================================================
   PIPELINE BAR
   ============================================================ */
.pipeline-bar {
  display: flex;
  border-radius: 6px;
  overflow: hidden;
  height: 36px;
  border: 1px solid var(--border);
}

.pipeline-step {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg3);
  color: var(--text2);
  transition: all .2s;
  cursor: default;
  min-width: 0;
}

.pipeline-step.done    { background: var(--led2); color: #fff; }
.pipeline-step.current { background: var(--led);  color: var(--bg); }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-ativo         { background: rgba(63,185,80,.18);  color: var(--success); }
.badge-contratado    { background: rgba(0,212,255,.18);  color: var(--led); }
.badge-aguardando    { background: rgba(188,140,255,.18);color: var(--purple); }
.badge-negociacao    { background: rgba(210,153,34,.18); color: var(--warn); }
.badge-analisar      { background: rgba(139,148,158,.18);color: var(--text2); }
.badge-aprovado      { background: rgba(63,185,80,.18);  color: var(--success); }
.badge-reprovado     { background: rgba(248,81,73,.18);  color: var(--danger); }
.badge-pendente      { background: rgba(210,153,34,.18); color: var(--warn); }

/* ============================================================
   ESTRELAS
   ============================================================ */
.stars { color: var(--warn); letter-spacing: 1px; font-size: 13px; }

/* ============================================================
   BOTÕES
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
  font-family: var(--font);
}

.btn-primary  { background: var(--led);     color: var(--bg); }
.btn-primary:hover  { background: var(--led2); color: #fff; text-decoration: none; }

.btn-ghost    { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover    { background: var(--bg3); color: var(--text); text-decoration: none; }

.btn-danger   { background: var(--danger);  color: #fff; }
.btn-danger:hover   { background: #c0392b; text-decoration: none; }

.btn-success  { background: var(--success); color: var(--bg); }
.btn-success:hover  { background: #2ea043; text-decoration: none; }

.btn-sm  { padding: 5px 10px; font-size: 12px; }
.btn-xs  { padding: 3px 8px;  font-size: 11px; }
.w-100   { width: 100%; }

/* ============================================================
   FORMULÁRIOS
   ============================================================ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }

label { font-size: 12px; font-weight: 600; color: var(--text2); }

input, select, textarea {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 9px 12px;
  font-size: 13px;
  width: 100%;
  transition: border-color .15s;
  font-family: var(--font);
  -webkit-appearance: none;
  appearance: none;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--led);
}

textarea { min-height: 80px; resize: vertical; }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238b949e' d='M1 1l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }
select option { background: var(--bg2); }

/* ============================================================
   FILTROS
   ============================================================ */
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}

.search-input { max-width: 260px; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}

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

.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 680px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  margin: auto;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0;
  background: var(--bg2);
  z-index: 10;
}

.modal-title  { font-size: 15px; font-weight: 700; }
.modal-close  { background: none; border: none; color: var(--text2); font-size: 22px; cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body   { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* ============================================================
   TOAST
   ============================================================ */
.toast-area {
  position: fixed;
  bottom: 20px; right: 20px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: calc(100vw - 40px);
}

.toast {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  min-width: 220px;
  box-shadow: var(--shadow);
  animation: slideIn .25s ease;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }

@keyframes slideIn {
  from { transform: translateX(60px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ============================================================
   HISTÓRICO / TIMELINE
   ============================================================ */
.timeline { display: flex; flex-direction: column; }

.timeline-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.timeline-item:last-child { border-bottom: none; }

.tl-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--led); margin-top: 5px; flex-shrink: 0; }
.tl-info { flex: 1; min-width: 0; }
.tl-header { font-size: 11px; color: var(--text2); margin-bottom: 3px; }
.tl-text { font-size: 13px; }

/* ============================================================
   AVALIAÇÃO / ESTRELAS
   ============================================================ */
.score-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 14px 0;
}

.score-item { display: flex; flex-direction: column; gap: 4px; }
.score-label { font-size: 11px; color: var(--text2); }
.score-stars { display: flex; gap: 2px; }

.star-btn {
  background: none; border: none; cursor: pointer;
  font-size: 22px; color: var(--border); padding: 0;
  transition: color .1s; line-height: 1;
  touch-action: manipulation;
}
.star-btn.active { color: var(--warn); }
.score-stars:hover .star-btn { color: var(--warn); }
.score-stars .star-btn:hover ~ .star-btn { color: var(--border); }

/* ============================================================
   LOGIN
   ============================================================ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}

.login-logo { text-align: center; margin-bottom: 26px; }
.login-logo .brand { font-size: 24px; font-weight: 800; color: var(--led); }
.login-logo .sub   { font-size: 12px; color: var(--text2); margin-top: 2px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.form-error { color: var(--danger); font-size: 12px; text-align: center; padding: 6px 0; }

/* ============================================================
   UTILITÁRIOS
   ============================================================ */
.text-muted   { color: var(--text2); }
.text-sm      { font-size: 12px; }
.text-xs      { font-size: 11px; }
.text-led     { color: var(--led); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warn    { color: var(--warn); }
.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; }
.d-flex       { display: flex; }
.gap-1        { gap: 8px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap    { flex-wrap: wrap; }
.empty-state  { text-align: center; padding: 40px 20px; color: var(--text2); }
.empty-state .icon { font-size: 36px; margin-bottom: 10px; }
.empty-state p { font-size: 13px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

/* ============================================================
   CARDS MOBILE — tabela vira cards empilhados
   ============================================================ */
.mobile-cards { display: none; }

.m-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}

.m-card-title { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.m-card-row   { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; font-size: 12px; }
.m-card-label { color: var(--text2); }
.m-card-actions { display: flex; gap: 6px; margin-top: 10px; }

/* ============================================================
   RESPONSIVO — BREAKPOINTS
   ============================================================ */

/* Tablet e mobile */
@media (max-width: 900px) {

  /* Sidebar vira drawer lateral */
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-close { display: block; }

  /* Main ocupa tudo */
  .main { margin-left: 0; }

  /* Botão hambúrguer */
  .menu-toggle { display: block; }

  /* Score grid 2 colunas */
  .score-grid { grid-template-columns: repeat(2, 1fr); }

  /* Stats 2 colunas */
  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  /* Grids de 2 colunas viram 1 */
  .grid-2col { grid-template-columns: 1fr !important; }
}

/* Mobile puro */
@media (max-width: 600px) {

  .content { padding: 14px; }

  /* Stats em 2 colunas compactas */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .stat-value { font-size: 22px; }

  /* Score grid 1 coluna */
  .score-grid { grid-template-columns: 1fr 1fr; }

  /* Formulário sempre 1 coluna */
  .form-grid { grid-template-columns: 1fr; }

  /* Tabelas somem, cards aparecem */
  .table-desktop { display: none !important; }
  .mobile-cards  { display: block; }

  /* Pipeline labels ocultos */
  .pipeline-labels { display: none; }
  .pipeline-step   { font-size: 10px; }

  /* Botões empilham */
  .btn-group-mobile { flex-direction: column; }
  .btn-group-mobile .btn { justify-content: center; }

  /* Modal full width */
  .modal { border-radius: 10px 10px 0 0; max-height: 85vh; }
  .modal-overlay { align-items: flex-end; padding: 0; }

  /* Topbar compacta */
  .topbar { padding: 10px 14px; }
  .topbar-actions .text-muted { display: none; }

  /* Card header flex-col em telas pequenas */
  .card-header { gap: 8px; }

  /* Ocultar colunas menos importantes na tabela */
  .hide-mobile { display: none; }

  /* Search full width */
  .search-input { max-width: 100%; }

  /* Login box sem borda no mobile */
  .login-box { border: none; padding: 24px 20px; box-shadow: none; }
}

/* Landscape mobile */
@media (max-width: 600px) and (orientation: landscape) {
  .modal { max-height: 92vh; }
  .modal-overlay { align-items: center; padding: 16px; }
  .modal { border-radius: 10px; }
}
