/* ════════════════════════════════════════════════════════════
   GRUPO MRX — mobile.css
   CSS dedicado para Tablet (≤ 1024px) e Mobile (≤ 640px)
   Carregado em adição ao style.css via <link media="...">
   Design system idêntico ao desktop, layout totalmente refeito
   ════════════════════════════════════════════════════════════ */

/* ── TABLET (≤ 1024px) ──────────────────────────────────────── */
@media (max-width: 1024px) {

  /* --- Topbar --- */
  .topbar {
    height: 56px;
    padding: 0 18px;
    gap: 10px;
  }

  .logo-text {
    font-size: 0.95rem;
  }

  .page-title {
    font-size: 0.75rem;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* --- KPI --- */
  .kpi-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 22px;
  }

  .kpi-card {
    padding: 16px 16px;
  }

  .kpi-card-value {
    font-size: 1.8rem;
  }

  /* --- Charts --- */
  .charts-grid-2 {
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }

  .charts-grid-3 {
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }

  /* --- Insight grid --- */
  .insight-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }

  /* --- Main padding --- */
  .main {
    padding: 22px 20px;
  }

  /* --- Table toolbar text sizes --- */
  .filter-chip {
    font-size: 0.71rem;
    padding: 4px 10px;
  }

  /* --- Modal width --- */
  .modal {
    width: 480px;
  }
}

/* ── SMALL TABLET  (≤ 768px) ────────────────────────────────── */
@media (max-width: 768px) {

  /* --- Topbar --- */
  .topbar {
    height: 54px;
    padding: 0 14px;
  }

  .topbar-divider {
    display: none;
  }

  .page-title {
    display: none;
  }

  /* --- KPI --- */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 18px;
  }

  .kpi-card {
    padding: 14px 14px;
  }

  .kpi-card-label {
    font-size: 0.65rem;
  }

  .kpi-card-value {
    font-size: 1.6rem;
  }

  .kpi-card-sub {
    font-size: 0.7rem;
  }

  /* --- Charts: 1 col --- */
  .charts-grid-2,
  .charts-grid-3 {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .chart-card {
    padding: 16px;
  }

  /* --- Insight grid --- */
  .insight-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .insight-card {
    padding: 16px;
  }

  /* --- Main --- */
  .main {
    padding: 14px;
  }

  /* --- Page header --- */
  .page-header {
    margin-bottom: 16px;
    padding-bottom: 12px;
  }

  .page-header h2 {
    font-size: 1.2rem;
  }

  .page-header p {
    font-size: 0.78rem;
  }

  /* --- Table toolbar --- */
  .table-toolbar {
    padding: 10px 12px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .table-filters {
    gap: 4px;
    flex-wrap: wrap;
  }

  .filter-chip {
    font-size: 0.68rem;
    padding: 4px 8px;
  }

  .search-box {
    width: 100%;
  }

  .search-box input {
    width: 100%;
  }

  .add-lead-btn {
    width: 100%;
    justify-content: center;
    padding: 9px 16px;
    font-size: 0.82rem;
  }

  /* --- Table rows --- */
  .leads-table thead th,
  .leads-table tbody td {
    padding: 9px 10px;
    font-size: 0.78rem;
  }

  /* --- Table footer --- */
  .table-footer {
    padding: 10px 12px;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    font-size: 0.72rem;
  }

  /* --- Modal --- */
  .modal {
    width: 100%;
    max-width: 480px;
    padding: 22px;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .form-group.full {
    grid-column: 1;
  }
}

/* ── MOBILE (≤ 480px) ───────────────────────────────────────── */
@media (max-width: 480px) {

  /* --- Topbar --- */
  .topbar {
    height: 52px;
    padding: 0 10px;
    gap: 8px;
  }

  .logo-img {
    width: 28px;
    height: 28px;
  }

  .logo-text {
    font-size: 0.88rem;
  }

  .theme-label {
    display: none;
  }

  .theme-toggle {
    padding: 2px 2px 2px 6px;
  }

  /* --- KPI: 2 cols, compacto --- */
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 14px;
  }

  .kpi-card {
    padding: 12px 10px;
    border-radius: 5px;
  }

  .kpi-accent {
    height: 20px;
    margin-right: 4px;
  }

  .kpi-card-label {
    font-size: 0.6rem;
    letter-spacing: 0.6px;
    margin-bottom: 6px;
  }

  .kpi-card-value {
    font-size: 1.5rem;
  }

  .kpi-card-sub {
    font-size: 0.65rem;
    margin-top: 4px;
  }

  /* --- Charts --- */
  .charts-grid-2,
  .charts-grid-3 {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 16px;
  }

  .chart-card {
    padding: 14px;
  }

  .chart-card-title {
    font-size: 0.68rem;
    margin-bottom: 12px;
  }

  /* --- Insight grid: 2 cols compactos no mobile --- */
  .insight-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 16px;
  }

  .insight-card {
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 88px;
  }

  .insight-card-label {
    font-size: 0.58rem;
    letter-spacing: 0.8px;
    margin-bottom: 8px;
    line-height: 1.3;
  }

  .insight-card-big {
    font-size: 1.5rem;
    line-height: 1.1;
    word-break: break-word;
  }

  .insight-card-desc {
    font-size: 0.62rem;
    margin-top: 6px;
    line-height: 1.3;
  }

  /* --- Main --- */
  .main {
    padding: 10px;
  }

  /* --- Page header --- */
  .page-header {
    margin-bottom: 12px;
    padding-bottom: 10px;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .page-header h2 {
    font-size: 1.1rem;
  }

  .page-header p {
    font-size: 0.74rem;
  }

  /* --- Toolbar chips pequeninhos --- */
  .filter-chip {
    font-size: 0.63rem;
    padding: 3px 7px;
    border-radius: 3px;
  }

  /* --- Table: sticky coluna #id e nome --- */
  .table-wrap {
    border-radius: 0;
    margin: 0 -10px;
    width: calc(100% + 20px);
  }

  .leads-table thead th:nth-child(1),
  .leads-table tbody td:nth-child(1) {
    position: sticky;
    left: 0;
    background: var(--card2);
    z-index: 3;
    border-right: 1px solid var(--border);
    min-width: 32px;
  }

  .leads-table thead th:nth-child(2),
  .leads-table tbody td:nth-child(2) {
    position: sticky;
    left: 44px;
    background: var(--card);
    z-index: 2;
    border-right: 1px solid var(--border);
    box-shadow: 2px 0 4px rgba(0,0,0,0.15);
  }

  [data-theme="light"] .leads-table thead th:nth-child(2),
  [data-theme="light"] .leads-table tbody td:nth-child(2) {
    background: var(--card2);
  }

  .leads-table thead th,
  .leads-table tbody td {
    padding: 8px 8px;
    font-size: 0.75rem;
  }

  .leads-table thead th {
    font-size: 0.62rem;
    letter-spacing: 0.5px;
  }

  /* Ação: só ícones */
  .action-btn {
    padding: 3px 6px;
    font-size: 0.68rem;
  }

  /* --- Status pills menores --- */
  .pill {
    font-size: 0.62rem;
    padding: 2px 7px;
  }

  /* --- Paginação compacta --- */
  .page-btn {
    padding: 3px 7px;
    font-size: 0.7rem;
  }

  /* --- Modal full screen quase --- */
  .modal-overlay {
    padding: 8px;
    align-items: flex-end;
  }

  .modal {
    width: 100%;
    max-height: 92vh;
    border-radius: 10px 10px 4px 4px;
    padding: 20px 16px;
  }

  .modal h3 {
    font-size: 1rem;
    margin-bottom: 16px;
    padding-bottom: 12px;
  }

  .form-input,
  .form-select {
    padding: 10px 12px;
    font-size: 0.88rem;
  }

  .form-label {
    font-size: 0.65rem;
  }

  .modal-footer {
    gap: 8px;
    margin-top: 16px;
  }

  .btn-cancel,
  .btn-save {
    flex: 1;
    text-align: center;
    padding: 10px;
    font-size: 0.82rem;
  }

  /* --- Funnel compacto --- */
  .funnel-step {
    gap: 8px;
    margin-bottom: 8px;
  }

  .funnel-outer {
    height: 36px;
  }

  .funnel-inner {
    font-size: 0.7rem;
    padding-left: 8px;
    min-width: 60px;
  }

  .funnel-count {
    font-size: 0.95rem;
  }

  .funnel-pct {
    font-size: 0.65rem;
  }

  .funnel-meta {
    min-width: 50px;
  }

  /* --- Bar rows --- */
  .bar-label {
    font-size: 0.72rem;
    min-width: 90px;
  }

  .bar-val {
    font-size: 0.68rem;
    min-width: 24px;
  }

  /* --- Toast bottom-center, largura total --- */
  .toast {
    bottom: 16px;
    left: 10px;
    right: 10px;
    transform: translateY(80px);
    white-space: normal;
    text-align: center;
    width: auto;
  }

  .toast.show {
    transform: translateY(0);
  }
}

/* ── TINY MOBILE (≤ 360px) ──────────────────────────────────── */
@media (max-width: 360px) {

  .kpi-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .kpi-card-value {
    font-size: 2rem;
  }

  .logo-text {
    display: none;
  }

  .filter-chip {
    font-size: 0.6rem;
    padding: 3px 5px;
  }

  .insight-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .insight-card {
    padding: 10px 8px;
    min-height: 76px;
  }

  .insight-card-label {
    font-size: 0.55rem;
    margin-bottom: 6px;
  }

  .insight-card-big {
    font-size: 1.25rem;
  }

  .insight-card-desc {
    font-size: 0.58rem;
    margin-top: 4px;
  }

  .modal {
    padding: 16px 12px;
  }

  .modal h3 {
    font-size: 0.95rem;
  }

  .topbar {
    padding: 0 8px;
  }

  .main {
    padding: 8px;
  }
}
