/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --red:      #C8102E;
  --red-dark: #9e0c24;
  --bg:       #0f0f0f;
  --bg2:      #1a1a1a;
  --bg3:      #222;
  --border:   #2e2e2e;
  --text:     #e8e8e8;
  --muted:    #888;
  --success:  #22c55e;
  --error:    #ef4444;
  --bnav-h:   64px;
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5;
  padding-bottom: var(--bnav-h); }
a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, textarea { background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: 10px 14px; width: 100%; font-size: 16px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--red); }
hr { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }
.capitalize { text-transform: capitalize; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 13px; }
.required { color: var(--red); }

/* ── Top Bar ── */
.topbar { background: var(--bg2); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100; }
.topbar-inner { display: flex; align-items: center; gap: 1.25rem; height: 54px;
  max-width: 1200px; margin: 0 auto; padding: 0 1.25rem; }
.topbar-brand { display: flex; align-items: center; gap: 8px; font-weight: 700;
  font-size: 1rem; white-space: nowrap; color: var(--text); }
.nav-logo { font-size: 1.2rem; }
.nav-sub { font-weight: 400; color: var(--muted); font-size: 0.8rem; }
.desktop-nav { display: flex; gap: 0.2rem; flex: 1; }
.desktop-nav a { padding: 6px 13px; border-radius: 6px; color: var(--muted);
  font-size: 14px; transition: .15s; }
.desktop-nav a:hover, .desktop-nav a.active { background: var(--bg3); color: var(--text); text-decoration: none; }
.topbar-user { display: flex; align-items: center; gap: 8px; margin-left: auto; white-space: nowrap; }
.nav-name { font-size: 13px; color: var(--muted); }
.btn-logout { background: none; border: 1px solid var(--border); color: var(--muted);
  padding: 5px 10px; border-radius: 6px; cursor: pointer; font-size: 12px; transition: .15s; }
.btn-logout:hover { border-color: var(--red); color: var(--red); }

/* ── Bottom Nav (mobile) ── */
.bottom-nav { display: none; position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--bnav-h); background: var(--bg2); border-top: 1px solid var(--border);
  z-index: 200; padding-bottom: env(safe-area-inset-bottom); }
.bnav-item { display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex: 1; gap: 3px; color: var(--muted); font-size: 10px; font-weight: 500;
  text-decoration: none; transition: .15s; padding: 6px 4px; min-width: 0; }
.bnav-item.active { color: var(--red); }
.bnav-item:hover { text-decoration: none; color: var(--text); }
.bnav-icon { font-size: 1.3rem; line-height: 1; }
.bnav-label { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Page ── */
.page { max-width: 1200px; margin: 0 auto; padding: 1.25rem 1rem; }
.page-narrow { max-width: 860px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 1.25rem; gap: 0.75rem; flex-wrap: wrap; }
.page-header h2 { font-size: 1.25rem; font-weight: 700; }
.month-nav { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Cards ── */
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  padding: 1rem; margin-bottom: 1rem; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.85rem; }
.card-header h3 { font-size: 0.95rem; font-weight: 600; }

/* ── KPI Grid ── */
.kpi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; margin-bottom: 1rem; }
.kpi-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  padding: 0.85rem; text-align: center; }
.kpi-card.kpi-highlight { border-color: var(--red); background: rgba(200,16,46,0.07); }
.kpi-icon { font-size: 1.3rem; margin-bottom: 0.25rem; }
.kpi-value { font-size: 1.2rem; font-weight: 800; line-height: 1.1; margin-bottom: 0.2rem; }
.kpi-label { font-size: 11px; color: var(--muted); }

/* ── Meta Bar ── */
.meta-bar-wrap { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  padding: 0.9rem 1rem; margin-bottom: 1rem; }
.meta-bar-header { display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.5rem; font-size: 13px; flex-wrap: wrap; gap: 4px; }
.meta-values { color: var(--muted); font-size: 13px; }
.meta-values strong { color: var(--text); }
.meta-pct { color: var(--red); font-weight: 700; }
.meta-bar { height: 10px; background: var(--bg3); border-radius: 99px; overflow: hidden; }
.meta-bar-fill { height: 100%; background: var(--red); border-radius: 99px; transition: width .6s ease; min-width: 2px; }

/* ── Funnel ── */
.funnel-section { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  padding: 1rem; margin-bottom: 1rem; }
.funnel-section h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.85rem; }
.funnel-steps { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.funnel-step { text-align: center; background: var(--bg3); border-radius: 8px; padding: 0.6rem 1rem; flex: 1; min-width: 60px; }
.funnel-num { font-size: 1.5rem; font-weight: 800; color: var(--red); }
.funnel-name { font-size: 11px; color: var(--muted); }
.funnel-arrow { color: var(--muted); font-size: 1rem; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.funnel-rate { font-size: 11px; font-weight: 700; color: var(--success); }

/* ── Two col ── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; padding: 8px 10px; color: var(--muted); font-weight: 600;
  font-size: 11px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: rgba(255,255,255,.02); }
.table-full { min-width: 900px; }
.row-inactive { opacity: .45; }
.rank-pos { display: inline-block; width: 20px; height: 20px; background: var(--bg3);
  border-radius: 50%; text-align: center; line-height: 20px; font-size: 11px; margin-right: 6px; }

/* ── Mobile card list (replaces table on small screens) ── */
.mobile-list { display: none; }
.m-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
  padding: 0.9rem; margin-bottom: 0.65rem; }
.m-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.5rem; }
.m-card-title { font-weight: 700; font-size: 14px; }
.m-card-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.m-card-value { font-weight: 800; color: var(--red); font-size: 15px; white-space: nowrap; }
.m-card-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 0.5rem; }
.m-card-actions { display: flex; gap: 6px; margin-top: 0.65rem; flex-wrap: wrap; }

/* ── Forms ── */
.form-group { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.form-group label { font-size: 13px; color: var(--muted); font-weight: 500; }
.form-row { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.85rem; }
.form-section-title { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 0.65rem; text-transform: uppercase; letter-spacing: .04em; }
.form-divider { margin: 1rem 0; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 1rem; flex-wrap: wrap; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: 8px; font-size: 14px; font-weight: 600;
  cursor: pointer; border: 1px solid transparent; transition: .15s;
  text-decoration: none; white-space: nowrap; -webkit-tap-highlight-color: transparent; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--red); color: #fff; border-color: var(--red); }
.btn-primary:hover { background: var(--red-dark); }
.btn-secondary { background: var(--bg3); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--muted); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-xs { padding: 4px 8px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; }

/* ── Badges ── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px;
  font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.badge-admin { background: rgba(200,16,46,.2); color: #ff6b6b; }
.badge-vendas { background: rgba(34,197,94,.15); color: #22c55e; }
.badge-atendimento { background: rgba(59,130,246,.15); color: #60a5fa; }
.badge-active { background: rgba(34,197,94,.15); color: #22c55e; }
.badge-inactive { background: rgba(100,100,100,.2); color: var(--muted); }

/* ── Alerts ── */
.alert { padding: 10px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 0.85rem; }
.alert-success { background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.3); color: #22c55e; }
.alert-error   { background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.3); color: #f87171; }
.alert-followup { background:rgba(251,191,36,.1); border:1px solid rgba(251,191,36,.3); color:#fbbf24;
  padding:10px 14px; border-radius:8px; font-size:14px; margin-bottom:0.85rem; }
.alert-danger { background:rgba(239,68,68,.1); border:1px solid rgba(239,68,68,.35); color:#f87171;
  padding:10px 14px; border-radius:8px; font-size:14px; margin-bottom:0.85rem; }

/* ── Login ── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 1rem; }
.login-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 16px;
  padding: 2rem; width: 100%; max-width: 380px; }
.login-brand { text-align: center; margin-bottom: 1.75rem; }
.login-logo { font-size: 2.5rem; margin-bottom: 0.5rem; }
.login-brand h1 { font-size: 1.6rem; font-weight: 800; }
.login-brand p { color: var(--muted); font-size: 14px; }
.login-card .form-group { margin-bottom: 1rem; }

/* ── User tag ── */
.user-tag { display:inline-block; padding:2px 10px; border-radius:99px; font-size:12px; font-weight:600;
  background:rgba(200,16,46,.12); color:#ff6b6b; border:1px solid rgba(200,16,46,.25); white-space:nowrap; }

/* ── Footer ── */
.site-footer { text-align: center; padding: 1.5rem; font-size: 12px; color: #444;
  border-top: 1px solid var(--border); margin-top: 1.5rem; }
.site-footer a { color: #555; }
.site-footer a:hover { color: var(--red); }

/* ── Empty ── */
.empty-state { color: var(--muted); text-align: center; padding: 2rem; font-size: 14px; }

/* ── Appointments ── */
.status-badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.status-agendado  { background: rgba(59,130,246,.15); color: #60a5fa; }
.status-visitou   { background: rgba(251,191,36,.15); color: #fbbf24; }
.status-fechou    { background: rgba(34,197,94,.15);  color: #22c55e; }
.status-cancelado { background: rgba(100,100,100,.2); color: var(--muted); }
.badge-count { display: inline-block; padding: 4px 12px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.badge-count.badge-agendado  { background: rgba(59,130,246,.12); color: #60a5fa; }
.badge-count.badge-visitou   { background: rgba(251,191,36,.12); color: #fbbf24; }
.badge-count.badge-fechou    { background: rgba(34,197,94,.12);  color: #22c55e; }
.badge-count.badge-cancelado { background: rgba(100,100,100,.15); color: var(--muted); }
.whatsapp-link { color: #22c55e; font-size: 13px; }
.whatsapp-link:hover { text-decoration: underline; }
.text-warning { color: #fbbf24; }
.notes-row td { background: rgba(255,255,255,.01); }

/* ── Quote Badges ── */
.qstatus-badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.qstatus-enviado       { background: rgba(59,130,246,.15); color: #60a5fa; }
.qstatus-em_negociacao { background: rgba(251,191,36,.15); color: #fbbf24; }
.qstatus-aprovado      { background: rgba(34,197,94,.15);  color: #22c55e; }
.qstatus-perdido       { background: rgba(100,100,100,.2); color: var(--muted); }
.stale-tag { display:inline-block; padding:1px 6px; border-radius:99px; font-size:11px;
  background:rgba(251,191,36,.15); color:#fbbf24; }

/* ── Projection ── */
.projection-line { font-size:13px; color:var(--muted); margin-top:0.5rem; }
.projection-line strong { color:var(--text); }

/* ── Mini bars ── */
.mini-bar-row { display:flex; justify-content:space-between; align-items:center;
  padding:7px 0; border-bottom:1px solid var(--border); }
.mini-bar-row:last-child { border-bottom:none; }
.mini-bar-count { font-weight:700; font-size:14px; }

/* ── Kanban ── */
.kanban-board { display:grid; grid-template-columns:repeat(4,1fr); gap:1rem; align-items:start; }
.kanban-col { background:var(--bg2); border:1px solid var(--border); border-radius:12px; padding:0.85rem; }
.kanban-col-header { display:flex; justify-content:space-between; align-items:center;
  font-weight:600; font-size:14px; margin-bottom:0.75rem; padding-bottom:0.5rem; border-bottom:2px solid; }
.kanban-count { background:var(--bg3); border-radius:99px; padding:2px 8px; font-size:12px; font-weight:700; }
.kanban-cards { min-height:80px; display:flex; flex-direction:column; gap:8px; transition:.15s; }
.kanban-cards.kanban-drop-target { background:rgba(200,16,46,.07); border-radius:8px; }
.kanban-card { background:var(--bg3); border:1px solid var(--border); border-radius:8px;
  padding:10px 12px; cursor:grab; transition:.15s; }
.kanban-card:hover { border-color:var(--muted); }
.kanban-card-stale { border-color:#fbbf2455; }
.kanban-card-name { font-weight:600; font-size:14px; margin-bottom:2px; }
.kanban-card-product { margin-bottom:4px; }
.kanban-card-value { font-weight:800; color:var(--red); font-size:15px; margin-bottom:6px; }
.kanban-card-footer { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.kanban-empty { color:var(--muted); text-align:center; font-size:13px; padding:1rem 0; }

/* ════════════════════════════════════════
   MOBILE — app layout
   ════════════════════════════════════════ */
@media (max-width: 768px) {
  /* body already has padding-bottom via var(--bnav-h) */

  /* Show bottom nav, hide desktop nav */
  .bottom-nav { display: flex; }
  .desktop-nav { display: none; }
  .topbar-user .nav-name { display: none; }
  .topbar-user .badge { display: none; }

  /* Page */
  .page { padding: 0.85rem 0.75rem; }

  /* KPIs: 2 col */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }
  .kpi-value { font-size: 1.1rem; }
  .kpi-icon { font-size: 1.1rem; }

  /* Two-col → single */
  .two-col { grid-template-columns: 1fr; }

  /* Kanban → 1 col */
  .kanban-board { grid-template-columns: 1fr; }

  /* Page header */
  .page-header { margin-bottom: 0.85rem; }
  .page-header h2 { font-size: 1.1rem; }

  /* Show mobile card list, hide table */
  .desktop-table { display: none !important; }
  .mobile-list { display: block; }

  /* Forms: single col */
  .form-row { flex-direction: column; gap: 0.65rem; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }

  /* Buttons bigger tap targets */
  .btn { min-height: 44px; }
  .btn-sm { min-height: 36px; }

  /* Footer hidden on mobile (bottom nav serves this purpose) */
  .site-footer { display: none; }

  /* Meta bar */
  .meta-bar-header { flex-direction: column; align-items: flex-start; gap: 2px; }
}

@media (min-width: 769px) {
  /* Desktop: no bottom nav padding */
  body { padding-bottom: 0; }
  .bottom-nav { display: none !important; }
}
