@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg:        #F0F2F5;
  --bg-2:      #FFFFFF;
  --bg-3:      #F8F9FA;
  --bg-4:      #E9ECEF;
  --green:     #16A34A;
  --green-lt:  #22C55E;
  --green-bg:  rgba(22,163,74,0.08);
  --green-glow:rgba(22,163,74,0.2);
  --amber:     #D97706;
  --amber-lt:  #F59E0B;
  --blue:      #2563EB;
  --blue-lt:   #3B82F6;
  --red:       #DC2626;
  --red-lt:    #EF4444;
  --text:      #111827;
  --text-2:    #374151;
  --text-3:    #6B7280;
  --text-4:    #9CA3AF;
  --border:    #E5E7EB;
  --border-hl: rgba(22,163,74,0.3);
  --radius:    10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:    0 4px 16px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06);
  --font:      'Plus Jakarta Sans', system-ui, sans-serif;
  --transition:200ms cubic-bezier(0.4,0,0.2,1);
  --sidebar-w: 260px;
  --pix:       #059669;
  --din:       #2563EB;
  --cart:      #D97706;
  --fiado:     #DC2626;
}

*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

/* ── UTILITIES ──────────────────────── */
.flex-gap     { display: flex; gap: 12px; }
.flex-1       { flex: 1; }
.align-end    { align-items: flex-end; }
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.text-muted   { color: var(--text-3); }
.mb-2 { margin-bottom: .5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.p-3  { padding: 1rem; }
.border-radius { border-radius: var(--radius); }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── SCROLLBAR ──────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg-3); }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-4); }

/* ── BUTTONS ────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 10px 20px; border-radius: var(--radius);
  font-family: var(--font); font-size: 14px; font-weight: 600;
  cursor: pointer; border: 1px solid transparent;
  transition: all var(--transition); white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, #16A34A, #15803D);
  color: #fff;
  box-shadow: 0 2px 8px rgba(22,163,74,0.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(22,163,74,0.35); }
.btn-primary:active { transform: none; }

.btn-outline {
  background: var(--bg-2);
  color: var(--text-2);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.btn-outline:hover { background: var(--bg-3); border-color: var(--text-4); }

.btn-danger {
  background: linear-gradient(135deg, #DC2626, #B91C1C);
  color: #fff;
  box-shadow: 0 2px 8px rgba(220,38,38,0.25);
}
.btn-danger:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(220,38,38,0.35); }

.btn-sm { padding: 6px 14px; font-size: 12px; }

.btn-icon {
  padding: 7px; border-radius: var(--radius);
  background: var(--bg-2); color: var(--text-3);
  border: 1px solid var(--border); cursor: pointer;
  transition: all var(--transition);
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
}
.btn-icon:hover { color: var(--text); background: var(--bg-3); border-color: var(--text-4); }

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

/* ── SIDEBAR ────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 100;
  box-shadow: 2px 0 16px rgba(0,0,0,0.06);
}
.sidebar-header {
  padding: 24px 20px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--border);
}
.logo-mark {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
}
.logo-text strong { display: block; font-size: 17px; font-weight: 800; color: var(--text); letter-spacing: -0.02em; }
.logo-text span { font-size: 11px; font-weight: 600; color: var(--green); text-transform: uppercase; letter-spacing: 0.12em; }

.sidebar-nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; color: var(--text-3);
  text-decoration: none; font-weight: 600; font-size: 14px;
  transition: all var(--transition); border-radius: var(--radius);
  position: relative;
}
.nav-item:hover { color: var(--text); background: var(--bg-3); }
.nav-item.active { color: var(--green); background: var(--green-bg); }
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 60%;
  background: var(--green); border-radius: 0 3px 3px 0;
}
.nav-item i { font-size: 19px; }

.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); }

/* ── MAIN ───────────────────────────── */
.main-content { flex: 1; margin-left: var(--sidebar-w); height: 100vh; overflow-y: auto; background: var(--bg); }

.view { display: none; padding: 36px 44px; animation: viewIn 0.3s ease both; }
.view.active { display: block; }
@keyframes viewIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

.view-header {
  display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 32px;
}
.view-header h1 { font-size: 1.8rem; font-weight: 800; color: var(--text); line-height: 1.1; letter-spacing: -0.03em; }
.view-header p { color: var(--text-3); margin-top: 4px; font-size: 14px; }
.header-actions { display: flex; gap: 10px; align-items: center; }

/* ── PANEL ──────────────────────────── */
.panel {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}
.panel h3 { font-size: 14px; font-weight: 700; margin-bottom: 18px; color: var(--text); }

/* ── KANBAN ─────────────────────────── */
.kanban-board {
  display: flex; gap: 14px; overflow-x: auto;
  padding-bottom: 20px; min-height: calc(100vh - 180px);
}
.kanban-col {
  flex: 0 0 272px;
  background: var(--bg-3);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: border-color var(--transition);
}
.kanban-col.drag-over { border-color: var(--green); box-shadow: 0 0 0 2px var(--green-bg); }
.kanban-col h3 {
  padding: 14px 16px 12px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.badge-count {
  background: var(--bg-4); border: 1px solid var(--border);
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; color: var(--text-3);
}
.kanban-cards { flex: 1; padding: 10px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }

/* ── KANBAN CARD ────────────────────── */
.k-card {
  background: var(--bg-2); border-radius: var(--radius);
  padding: 14px; border: 1px solid var(--border);
  cursor: grab; transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}
.k-card:hover { border-color: var(--green); transform: translateY(-2px); box-shadow: var(--shadow); }
.k-card:active { cursor: grabbing; }

.k-card-header { display: flex; justify-content: space-between; margin-bottom: 8px; }
.k-card-id { font-size: 11px; font-weight: 700; color: var(--green); letter-spacing: 0.05em; }
.k-card-client { font-weight: 700; color: var(--text); font-size: 14px; margin-bottom: 6px; }
.k-card-items { font-size: 12px; color: var(--text-3); line-height: 1.6; margin-bottom: 10px; }
.k-card-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding-top: 10px; border-top: 1px solid var(--border);
}
.k-card-total { font-weight: 700; color: var(--text); font-size: 14px; }
.k-card-actions { display: flex; gap: 4px; margin-top: 8px; justify-content: flex-end; }

/* Payment badges */
.badge-pay { font-size: 10px; font-weight: 700; padding: 3px 10px; border-radius: 20px; text-transform: uppercase; letter-spacing: 0.06em; }
.pay-PIX      { background: #D1FAE5; color: #065F46; border: 1px solid #A7F3D0; }
.pay-Dinheiro { background: #DBEAFE; color: #1E40AF; border: 1px solid #BFDBFE; }
.pay-Cartão   { background: #FEF3C7; color: #92400E; border: 1px solid #FDE68A; }
.pay-Fiado    { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }

/* Attention notes */
.attention-note { margin-top: 6px; padding: 5px 10px; border-radius: 6px; font-size: 11px; font-weight: 600; line-height: 1.4; }
.note-urgencia { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }
.note-alerta   { background: #FEF3C7; color: #92400E; border: 1px solid #FDE68A; }

/* ── TABLES ─────────────────────────── */
.table-container {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.data-table { width: 100%; border-collapse: collapse; text-align: left; }
.data-table th {
  padding: 13px 18px; font-size: 11px; font-weight: 700;
  color: var(--text-3); text-transform: uppercase; letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border); background: var(--bg-3);
}
.data-table td {
  padding: 14px 18px; font-size: 14px;
  border-bottom: 1px solid var(--bg-4);
  color: var(--text-2); vertical-align: middle;
  transition: background var(--transition);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--bg-3); }

/* ── TABS ───────────────────────────── */
.tabs { display: flex; gap: 2px; margin-bottom: 24px; border-bottom: 2px solid var(--border); }
.tab-btn {
  background: transparent; border: none;
  padding: 10px 22px; color: var(--text-3);
  font-family: var(--font); font-size: 14px; font-weight: 600;
  cursor: pointer; position: relative; transition: color var(--transition);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--green); }
.tab-btn.active::after {
  content: ''; position: absolute;
  bottom: -2px; left: 0; right: 0; height: 2px;
  background: var(--green); border-radius: 2px 2px 0 0;
}
.tab-content { display: none; animation: viewIn 0.2s ease; }
.tab-content.active { display: block; }

/* ── FINANCEIRO ─────────────────────── */
.dashboard-cards {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 14px; margin-bottom: 20px;
}
.dash-card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}
.dash-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.dash-card h4 { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 8px; }
.dash-card h2 { font-size: 1.8rem; font-weight: 800; color: var(--text); letter-spacing: -0.03em; }
.dash-card.primary { border-color: rgba(22,163,74,0.25); background: linear-gradient(135deg, var(--green-bg) 0%, var(--bg-2) 100%); }
.dash-card.primary h2 { color: var(--green); }
.dash-card.success { border-color: rgba(37,99,235,0.2); background: linear-gradient(135deg, rgba(37,99,235,0.06) 0%, var(--bg-2) 100%); }
.dash-card.success h2 { color: var(--blue); }

.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.chart-container { position: relative; }
.chart-container canvas { max-height: 220px; }

.comissao-control { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.comissao-control input { width: 100px; }

.ranking-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.ranking-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 14px; background: var(--bg-3);
  border-radius: var(--radius); border: 1px solid var(--border);
  transition: all var(--transition);
}
.ranking-list li:hover { background: var(--bg-4); }
.ranking-name { font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 8px; font-size: 13px; }
.ranking-val { font-size: 13px; color: var(--text-3); text-align: right; }

/* ── CONVERSÃO ──────────────────────── */
.conv-bar-wrap { background: var(--bg-4); border-radius: 99px; height: 10px; overflow: hidden; margin: 8px 0 4px; }
.conv-bar { height: 100%; border-radius: 99px; background: linear-gradient(90deg, #16A34A, #22C55E); transition: width 0.6s ease; }

/* ── TAREFAS ────────────────────────── */
.tarefa-card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  display: flex; align-items: flex-start; gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
}
.tarefa-card:hover { box-shadow: var(--shadow); border-color: var(--text-4); }
.tarefa-card.concluida { opacity: 0.5; }
.tarefa-card.concluida .tarefa-nome { text-decoration: line-through; color: var(--text-3); }

.tarefa-check {
  width: 20px; height: 20px; border-radius: 6px;
  border: 2px solid var(--border); cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition); margin-top: 2px;
  background: var(--bg-2);
}
.tarefa-check:hover { border-color: var(--green); background: var(--green-bg); }
.tarefa-check.checked { background: var(--green); border-color: var(--green); color: white; }

.tarefa-nome { font-weight: 600; font-size: 14px; color: var(--text); }
.tarefa-desc { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.tarefa-prazo {
  font-size: 11px; font-weight: 700; padding: 3px 10px;
  border-radius: 20px; white-space: nowrap; flex-shrink: 0;
  display: flex; align-items: center; gap: 4px;
}
.prazo-ok      { background: #D1FAE5; color: #065F46; border: 1px solid #A7F3D0; }
.prazo-alerta  { background: #FEF3C7; color: #92400E; border: 1px solid #FDE68A; }
.prazo-vencido { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }
.prazo-sem     { background: var(--bg-3); color: var(--text-3); border: 1px solid var(--border); }

.tipo-badge {
  font-size: 10px; font-weight: 700; padding: 2px 8px;
  border-radius: 20px; text-transform: uppercase; letter-spacing: 0.06em;
  flex-shrink: 0;
}
.tipo-montar   { background: #EDE9FE; color: #5B21B6; border: 1px solid #DDD6FE; }
.tipo-entrega  { background: #DBEAFE; color: #1E40AF; border: 1px solid #BFDBFE; }
.tipo-outro    { background: var(--bg-3); color: var(--text-3); border: 1px solid var(--border); }

.tarefas-grid { display: flex; flex-direction: column; gap: 8px; }
.tarefas-section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--text-3); margin: 20px 0 10px;
  display: flex; align-items: center; gap: 8px;
}
.tarefas-section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── MODALS ─────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 1000; display: none;
  align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.active { display: flex; animation: modalBg 0.2s ease; }
@keyframes modalBg { from { opacity: 0; } to { opacity: 1; } }

.modal-content {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%; max-width: 520px;
  box-shadow: var(--shadow-lg);
  max-height: 90vh; display: flex; flex-direction: column;
  animation: modalIn 0.25s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(12px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes sheetUp  { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-lg { max-width: 820px; }

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-header h2 { font-size: 1.1rem; font-weight: 700; color: var(--text); }

.btn-close {
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-3);
  width: 32px; height: 32px; font-size: 16px; cursor: pointer;
  transition: all var(--transition);
  display: flex; align-items: center; justify-content: center;
}
.btn-close:hover { color: var(--text); background: var(--bg-4); }

.modal-body { padding: 24px; overflow-y: auto; }
.modal-actions {
  display: flex; justify-content: flex-end; gap: 10px;
  margin-top: 20px; padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ── FORMS ──────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.07em; }
.form-group small { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.form-input, .form-select {
  background: var(--bg-2); border: 1px solid var(--border);
  color: var(--text); padding: 10px 13px;
  border-radius: var(--radius); font-family: var(--font); font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}
.form-input::placeholder { color: var(--text-4); }
.form-input:focus, .form-select:focus {
  outline: none; border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(22,163,74,0.1);
}
.form-select option { background: var(--bg-2); color: var(--text); }
textarea.form-input { resize: vertical; }

/* ── RESPONSIVE ─────────────────────── */
@media (max-width: 1280px) {
  .dashboard-cards { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid  { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .view { padding: 20px 16px; }
  .view-header { flex-direction: column; align-items: flex-start; gap: 14px; }
}

/* ── MOBILE (iPhone) ─────────────────── */
@media (max-width: 768px) {

  /* Sidebar vira nav bar inferior */
  .sidebar {
    width: 100%; height: auto;
    position: fixed; bottom: 0; left: 0; right: 0; top: auto;
    border-right: none;
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
    z-index: 200;
    flex-direction: row;
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .sidebar-header { display: none; }
  .sidebar-footer  { display: none; }

  .sidebar-nav {
    flex-direction: row;
    flex: 1;
    padding: 6px 4px;
    gap: 0;
    overflow: visible;
    justify-content: space-around;
  }
  .nav-item {
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 10px;
    font-size: 10px;
    font-weight: 700;
    flex: 1;
    border-radius: 10px;
    white-space: nowrap;
  }
  .nav-item::before { display: none; }
  .nav-item i { font-size: 22px; }

  /* Conteúdo principal ocupa tudo com espaço pro nav bar */
  .main-content {
    margin-left: 0;
    height: auto;
    min-height: 100vh;
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }

  /* View */
  .view { padding: 16px 14px; }
  .view-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .view-header h1 { font-size: 1.4rem; }
  .header-actions { width: 100%; }
  .header-actions .btn { flex: 1; justify-content: center; }

  /* Dashboard cards - 1 coluna */
  .dashboard-cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .dashboard-cards .dash-card { padding: 14px; }
  .dash-card h2 { font-size: 1.3rem; }

  /* Conversão - empilha */
  .dashboard-grid { grid-template-columns: 1fr; gap: 12px; }

  /* Kanban - scroll horizontal com colunas menores */
  .kanban-board {
    gap: 10px;
    padding-bottom: 16px;
    min-height: 50vh;
  }
  .kanban-col { flex: 0 0 240px; }

  /* Formulários */
  .grid-form { grid-template-columns: 1fr; }
  .flex-gap { flex-wrap: wrap; }

  /* Modais - sheet que sobe de baixo */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal-content {
    max-width: 100%;
    width: 100%;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 92vh;
    padding-bottom: env(safe-area-inset-bottom);
    animation: sheetUp 0.3s cubic-bezier(0.34,1.2,0.64,1);
  }
  .modal-lg { max-width: 100%; }

  /* Tabelas */
  .table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table th, .data-table td { padding: 10px 12px; font-size: 13px; }

  /* Tarefas */
  .tarefa-card { flex-wrap: wrap; gap: 8px; }
  .tarefa-prazo { order: -1; }

  /* Conversão blocks */
  [style*="grid-template-columns:1fr 1fr 1fr"] {
    display: grid !important;
    grid-template-columns: 1fr !important;
  }

  /* Tabs */
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab-btn { white-space: nowrap; padding: 10px 16px; }

  /* Botão novo pedido full width no header */
  .view-header .btn-primary { width: 100%; }
}
