/* ============================================================
   Sala401 Design System
   Tokens + Base Components
   ============================================================ */

/* Poppins — self-hosted in /public/fonts to avoid a render-blocking
   round-trip to fonts.googleapis.com / fonts.gstatic.com on every
   page load. Only the Latin subset is bundled (the app is PT-BR). */
@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/poppins-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/poppins-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/poppins-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/poppins-700.woff2') format('woff2');
}

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

/* ── Tokens ──────────────────────────────────────────────────── */

:root {
  /* Colors */
  --accent:        #111111;
  --accent-hover:  #333333;
  --surface:       #ffffff;
  --surface-sub:   #F4F4F2;
  --border:        #E8E8E8;
  --border-strong: #CCCCCC;
  --text-primary:  #111111;
  --text-secondary:#6B6B6B;
  --text-muted:    #9B9B9B;
  --error:         #C0392B;
  --error-bg:      #FDEDEC;
  --success:       #27AE60;

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Typography */
  --font: 'Poppins', 'Helvetica Neue', Arial, sans-serif;

  /* Background & disabled */
  --bg:           var(--surface-sub);
  --text-disabled: #BBBBBB;

  /* Shadows */
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 2px 12px rgba(0, 0, 0, 0.08);

  /* Pipeline stage colours */
  --stage-enviada:   #3B82F6;
  --stage-aprovada:  #8B5CF6;
  --stage-contrato:  #F59E0B;
  --stage-cobranca:  #06B6D4;
  --stage-concluido: #10B981;
  --stage-perdido:   #9B9B9B;

  /* Legacy palette aliases (used by existing pages) */
  --black: #111111;
  --white: #ffffff;
  --gray-border: #E0E0E0;
  --gray-sub: #9B9B9B;
  --gray-footer: #AAAAAA;
  --gray-hover-btn: #333333;
  --red: #d32f2f;
  --green: #27ae60;
  --radius: 6px;
  --font-logo: 'Caveat', cursive;
  --color-gray-50: #f9f9f9;
  --color-gray-100: #f0f0f0;
  --color-gray-200: #e0e0e0;
  --color-gray-400: #a0a0a0;
  --color-gray-600: #666666;
  --color-gray-800: #222222;
  --color-black: #000000;
  --color-white: #ffffff;
  --color-error: #c0392b;
  --color-success: #27ae60;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);

  /* Layout */
  --sidebar-width: 220px;
  --sidebar-collapsed-width: 64px;
  --header-height: 60px;
  --content-padding: 32px;
  --content-max-width: 1200px;
}

html, body {
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

/* ── Typography utilities ─────────────────────────────────────── */

.text-label {
  font-size: 11px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.text-body {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-primary);
  line-height: 1.5;
}

.text-bold {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.text-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.text-secondary {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-secondary);
}

.text-kpi-number {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}

.text-kpi-currency {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}

/* ── Page Header ──────────────────────────────────────────────── */

.page-header {
  margin-bottom: 32px;
}

.page-header-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

/* ── Buttons ──────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 20px;
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: background 150ms ease, opacity 150ms ease;
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
}
.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
}
.btn-secondary:hover {
  background: #F9F9F9;
}

.btn-danger {
  background: var(--error);
  color: #ffffff;
}
.btn-danger:hover {
  background: #A93226;
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Inputs & Selects ─────────────────────────────────────────── */

.input,
.select {
  height: 40px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--surface);
  outline: none;
  width: 100%;
  transition: border-color 150ms ease;
  box-sizing: border-box;
}

.input::placeholder,
.select::placeholder {
  color: var(--text-secondary);
}

.input:hover,
.select:hover {
  border-color: var(--border-strong);
}

.input:focus,
.select:focus {
  border-color: var(--accent);
}

.select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B6B6B' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ── KPI Cards ────────────────────────────────────────────────── */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

@media (max-width: 880px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.kpi-card .kpi-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Help affordance with hover/focus tooltip on KPI labels.
   Renderiza um glifo "info" SVG outline — sutil, monocromático, sem
   poluir o card. Hover/foco escurece pra accent e exibe tooltip. */
.kpi-help {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: help;
  user-select: none;
  text-transform: none;
  letter-spacing: 0;
  flex-shrink: 0;
  outline: none;
  opacity: 0.55;
  transition: opacity 150ms ease, color 150ms ease, background-color 150ms ease;
  -webkit-tap-highlight-color: transparent;
}
.kpi-help svg {
  display: block;
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 1.6;
  fill: none;
}
.kpi-help:hover,
.kpi-help:focus-visible {
  opacity: 1;
  color: var(--text-primary);
}
.kpi-help:focus-visible {
  background: rgba(0, 0, 0, 0.04);
}
.kpi-help .kpi-tooltip {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--text-primary);
  color: #fff;
  font-family: 'Poppins', sans-serif;
  font-size: 12px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  line-height: 1.5;
  padding: 10px 14px;
  border-radius: 8px;
  width: max-content;
  max-width: 260px;
  text-align: left;
  white-space: normal;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 160ms ease, visibility 160ms ease, transform 160ms ease;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18), 0 2px 4px rgba(0, 0, 0, 0.08);
}
.kpi-help .kpi-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--text-primary);
}
.kpi-help:hover .kpi-tooltip,
.kpi-help:focus .kpi-tooltip,
.kpi-help:focus-visible .kpi-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* Em telas estreitas, alinha o tooltip ao card (não à viewport)
   pra evitar que vaze pro lado direito da tela. */
@media (max-width: 640px) {
  .kpi-help .kpi-tooltip {
    max-width: 220px;
    font-size: 11.5px;
  }
}

/* Help affordance para títulos de seção/tabela — espelha .kpi-help
   mas alinha o tooltip abaixo do ícone (bottom→top invert) e usa
   classe distinta para permitir overrides futuros sem afetar KPI cards. */
.section-help {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: help;
  user-select: none;
  flex-shrink: 0;
  outline: none;
  opacity: 0.55;
  transition: opacity 150ms ease, color 150ms ease;
  -webkit-tap-highlight-color: transparent;
  vertical-align: middle;
}
.section-help svg {
  display: block;
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 1.6;
  fill: none;
}
.section-help:hover,
.section-help:focus-visible {
  opacity: 1;
  color: var(--text-primary);
}
.section-help:focus-visible {
  background: rgba(0, 0, 0, 0.04);
}
.section-help .kpi-tooltip {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--text-primary);
  color: #fff;
  font-family: 'Poppins', sans-serif;
  font-size: 12px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  line-height: 1.5;
  padding: 10px 14px;
  border-radius: 8px;
  width: max-content;
  max-width: 260px;
  text-align: left;
  white-space: normal;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 160ms ease, visibility 160ms ease, transform 160ms ease;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18), 0 2px 4px rgba(0, 0, 0, 0.08);
}
.section-help .kpi-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--text-primary);
}
.section-help:hover .kpi-tooltip,
.section-help:focus .kpi-tooltip,
.section-help:focus-visible .kpi-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}
@media (max-width: 640px) {
  .section-help .kpi-tooltip {
    max-width: 220px;
    font-size: 11.5px;
  }
}

/* ── Propostas em Negociação (Início) ─────────────────────────── */
.propostas-card {
  padding: 4px 24px 0;
}
.propostas-table {
  display: flex;
  flex-direction: column;
}
.propostas-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px 160px;
  gap: 16px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.propostas-row:last-child {
  border-bottom: 0;
}
.propostas-row--header {
  padding: 10px 0;
}
.propostas-col-head {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.propostas-col-head--right {
  text-align: right;
}
.propostas-marca {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.propostas-valor {
  font-size: 14px;
  color: var(--text-primary);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.propostas-status {
  text-align: right;
  white-space: nowrap;
}
.propostas-empty {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 16px 0;
}
.propostas-footer {
  border-top: 1px solid var(--border);
  padding: 12px 0;
}
.propostas-footer .link-see-all {
  font-size: 13px;
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 500;
}
.propostas-footer .link-see-all:hover {
  text-decoration: underline;
}
@media (max-width: 560px) {
  .propostas-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "marca status" "valor valor";
    row-gap: 6px;
  }
  .propostas-marca { grid-area: marca; }
  .propostas-status { grid-area: status; }
  .propostas-valor { grid-area: valor; text-align: left; }
  .propostas-row--header { display: none; }
}

.kpi-card .kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.kpi-card .kpi-value--money {
  font-size: 22px;
}

/* Clickable KPI cards (used on Início page) */

.kpi-card.clickable {
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: border-color 150ms ease, box-shadow 150ms ease;
  box-shadow: 0 0 0 transparent;
}

.kpi-card.clickable:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

/* ── Generic Card ─────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 28px 32px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
}

/* ── Status Pills ─────────────────────────────────────────────── */

.pill {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 400;
  display: inline-block;
  white-space: nowrap;
}

.pill-enviada  { background: #EFF6FF; color: #1D4ED8; }
.pill-aprovada { background: #F5F3FF; color: #6D28D9; }
.pill-contrato { background: #FFFBEB; color: #B45309; }
.pill-cobranca { background: #ECFEFF; color: #0E7490; }
.pill-concluido{ background: #ECFDF5; color: #065F46; }
.pill-perdido  { background: #F3F4F6; color: #4B5563; }

/* ── Sidebar ──────────────────────────────────────────────────── */

:root {
  --sidebar-width:           220px;
  --sidebar-width-collapsed: 64px;
  --sidebar-active-bg:       #F4F4F2;
  --sidebar-transition:      0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow: hidden;
  font-family: var(--font);
  transition: width var(--sidebar-transition);
}

#sidebar.collapsed {
  width: var(--sidebar-width-collapsed);
}

/* Logo */
.sidebar-logo {
  padding: 0 24px;
  height: var(--header-height);
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-logo img {
  height: 28px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  transition: opacity var(--sidebar-transition), max-width var(--sidebar-transition);
  flex-shrink: 0;
}

#sidebar.collapsed .sidebar-logo img,
#sidebar.collapsed .sidebar-logo-text {
  opacity: 0;
  max-width: 0;
  width: 0;
  overflow: hidden;
}

/* Nav */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: 40px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  color: var(--text-secondary);
  transition: background 150ms ease;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
}

.sidebar-item:hover {
  background: #F9F9F9;
}

.sidebar-item.active {
  background: var(--sidebar-active-bg);
  border-left: 2px solid var(--accent);
}

.sidebar-item.active .sidebar-label {
  font-weight: 700;
  color: var(--text-primary);
}

.sidebar-item.active .sidebar-icon {
  color: var(--text-primary);
}

.sidebar-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-icon svg {
  width: 18px;
  height: 18px;
}

.sidebar-label {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-secondary);
  transition: opacity 200ms ease;
  overflow: hidden;
}

#sidebar.collapsed .sidebar-label {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

/* Divider */
.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

/* Footer */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  flex-shrink: 0;
  overflow: hidden;
  padding-bottom: 52px;
}

.sidebar-user-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
  transition: opacity 200ms ease, max-width 200ms ease;
  max-width: 120px;
}

#sidebar.collapsed .sidebar-user-name {
  opacity: 0;
  max-width: 0;
  overflow: hidden;
}

.sidebar-logout {
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  background: none;
  border: none;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 4px;
  font-family: var(--font);
  transition: color 150ms ease;
  flex-shrink: 0;
  text-decoration: none;
}

.sidebar-logout:hover {
  color: var(--error);
}

.sidebar-logout-label {
  font-size: 12px;
  transition: opacity 200ms ease, max-width 200ms ease;
  max-width: 60px;
  overflow: hidden;
  white-space: nowrap;
}

#sidebar.collapsed .sidebar-logout-label {
  opacity: 0;
  max-width: 0;
  overflow: hidden;
}

/* Toggle */
.sidebar-toggle {
  position: absolute;
  bottom: 16px;
  right: 12px;
  cursor: pointer;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 150ms ease, box-shadow 150ms ease, right var(--sidebar-transition), left var(--sidebar-transition);
  z-index: 10;
}

.sidebar-toggle:hover {
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

#sidebar.collapsed .sidebar-toggle {
  right: auto;
  left: 50%;
  transform: translateX(-50%);
}

/* Page body offset */
.sb-page-body {
  margin-left: var(--sidebar-width);
  transition: margin-left var(--sidebar-transition);
}

.sb-page-body.collapsed {
  margin-left: var(--sidebar-width-collapsed);
}

/* ── Base Layout Classes ──────────────────────────────────────── */

.app-layout {
  display: flex;
  min-height: 100vh;
  background: var(--surface-sub);
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.main-area {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  transition: margin-left 0.2s ease;
}

.sidebar.collapsed ~ .main-area {
  margin-left: var(--sidebar-collapsed-width);
}

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

.page-content {
  padding: var(--content-padding);
  max-width: var(--content-max-width);
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
  flex: 1;
}
/* ── Tables ───────────────────────────────────────────────────── */

.table-wrapper {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  color: var(--text-primary);
}

.data-table th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--surface-sub);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr {
  background: var(--surface);
  transition: background 100ms ease;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: var(--surface-sub);
}

.table-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Form Inputs & Selects ────────────────────────────────────── */

.form-input,
.form-select {
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 13px;
  color: var(--text-primary);
  background: var(--surface);
  outline: none;
  transition: border-color 150ms ease;
  box-sizing: border-box;
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-input:hover,
.form-select:hover {
  border-color: var(--border-strong);
}

.form-input:focus,
.form-select:focus {
  border-color: var(--accent);
}

.form-select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B6B6B' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.load-more-btn {
  display: block;
  width: 100%;
  padding: 12px;
  border: none;
  background: var(--surface-sub);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  transition: background 150ms ease, color 150ms ease;
}

.load-more-btn:hover {
  background: var(--border);
  color: var(--text-primary);
}

/* ── Skeleton Loading ─────────────────────────────────────────── */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-sub) 25%,
    #e8e8e8 50%,
    var(--surface-sub) 75%
  );
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: var(--radius-sm);
  display: block;
}

.skeleton-text-sm {
  height: 12px;
  width: 60%;
}

.skeleton-text-md {
  height: 14px;
  width: 80%;
}

.skeleton-value {
  height: 28px;
  width: 50%;
  border-radius: var(--radius-sm);
}

.skeleton-card {
  height: 100px;
  width: 100%;
  border-radius: var(--radius-md);
}

.skeleton-table-row {
  height: 44px;
  width: 100%;
  border-radius: 0;
  border-bottom: 1px solid var(--border);
}

.content-loaded {
  animation: fadeIn 150ms ease both;
}

/* ── Empty States ─────────────────────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 14px;
}

.empty-state svg {
  opacity: 0.4;
}

.empty-state-icon {
  font-size: 36px;
  line-height: 1;
  margin-bottom: 8px;
  color: var(--text-muted);
}

.empty-state--error .empty-state-icon {
  color: var(--error);
}

.empty-state-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.empty-state-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
  max-width: 320px;
}

.empty-state-text {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.5;
  max-width: 400px;
  margin: 0;
}

/* ── Section Error States ─────────────────────────────────────── */

.error-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
  gap: 8px;
  background: var(--error-bg);
  border: 1px solid #F1948A;
  border-radius: var(--radius-md);
}

.error-section-icon {
  font-size: 28px;
  line-height: 1;
  margin-bottom: 4px;
  color: var(--error);
}

.error-section-message {
  font-size: 13px;
  color: var(--error);
  font-weight: 600;
  margin: 0;
  max-width: 360px;
}

.error-retry-btn {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--error);
  background: transparent;
  color: var(--error);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}

.error-retry-btn:hover {
  background: var(--error);
  color: #ffffff;
}

/* ── Error Banner (inline section error) ─────────────────────── */

.error-banner {
  background: #fdf0ef;
  border: 1px solid var(--color-error);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--color-error);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 16px;
}

/* ── Timestamp & Refresh ──────────────────────────────────────── */

.update-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.update-timestamp {
  font-size: 12px;
  color: var(--text-muted);
}

.update-timestamp.stale {
  color: var(--error);
  font-weight: 600;
}

.refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease;
}

.refresh-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
  background: var(--surface-sub);
}

.refresh-btn.spinning {
  pointer-events: none;
  opacity: 0.7;
  animation: spin-refresh 0.6s linear infinite;
}

@keyframes spin-refresh {
  to { transform: rotate(360deg); }
}

/* ── Update Info (timestamp + refresh button, right-aligned in page header) ── */

.update-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.update-info .timestamp {
  font-size: 12px;
  color: #9B9B9B;
}

.btn-refresh {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 6px;
  border: 1px solid #E8E8E8;
  background: #FFFFFF;
  color: #6B6B6B;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
  flex-shrink: 0;
}

.btn-refresh:hover {
  background: #F4F4F2;
  color: #111111;
  border-color: #D0D0D0;
}

.btn-refresh:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Skeleton Loading States ─────────────────────────────────────── */

.skeleton-card,
.skeleton-table-row {
  background: linear-gradient(90deg, #EBEBEB 25%, #F5F5F5 50%, #EBEBEB 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: var(--radius-md);
}

.skeleton-card {
  min-height: 96px;
}

.skeleton-table-row {
  height: 44px;
  margin-bottom: 8px;
}

.skeleton-table-row:last-child {
  margin-bottom: 0;
}

/* ── Content Loaded (fade-in trigger) ────────────────────────────── */

.content-loaded {
  animation: fadeIn 0.3s ease;
}

/* ── Data Table ──────────────────────────────────────────────────── */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: 12px 24px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 13px 24px;
  color: var(--text-primary);
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table td.td-bold {
  font-weight: 700;
}

.data-table td.td-muted {
  color: var(--text-muted);
}

.data-table th.td-right,
.data-table td.td-right {
  text-align: right;
}

.data-table td.td-valor {
  font-weight: 700;
}

/* ── See-all Link ────────────────────────────────────────────────── */

.link-see-all {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
}

.link-see-all:hover {
  text-decoration: underline;
}

/* ── KPI Grid column variants ─────────────────────────────────── */

.kpi-grid--cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 640px) {
  .kpi-grid--cols-3 { grid-template-columns: 1fr; }
}

/* ── Marca Cards ──────────────────────────────────────────────── */

.marca-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 720px) {
  .marca-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .marca-grid { grid-template-columns: 1fr; }
}

.marca-card {
  padding: 20px;
  cursor: pointer;
  text-decoration: none;
  display: block;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.marca-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.marca-card-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.marca-card-valor {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
  line-height: 1.2;
}

.marca-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
}

/* Soft variant: used when the card has no monetary value to show
   (e.g. "Em negociação" for andamento, "Sem negócios ativos" for perdidos). */
.marca-card-valor--soft {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-secondary);
}

/* Em andamento — no extra treatment beyond the soft value above. */
.marca-card--andamento {
  opacity: 0.95;
}

/* Negócios perdidos — visually demoted so they don't compete with
   parcerias and propostas ativas. The whole card is dimmed and the
   pill is rendered with a softer tone. */
.marca-card--perdido {
  opacity: 0.7;
  background: var(--surface-sub, #FAFAFA);
}

.marca-card--perdido:hover {
  opacity: 0.95;
}

.marca-card--perdido .marca-card-name {
  color: var(--text-secondary);
  font-weight: 600;
}

.marca-card--perdido .pill {
  background: #F3F4F6;
  color: #9CA3AF;
}

.marca-section-header--muted {
  color: var(--text-muted);
  opacity: 0.85;
}

/* Per-block empty state: shown when a search query keeps a block visible
   but matches none of its cards. Visually subtle so other blocks dominate. */
.marca-grid-empty {
  padding: 18px 4px 24px;
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Breadcrumb ───────────────────────────────────────────────── */

.breadcrumb {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 20px;
}

.breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 150ms ease;
}

.breadcrumb a:hover {
  color: var(--text-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.breadcrumb-sep {
  color: var(--border-strong);
}

.breadcrumb-current {
  color: var(--text-primary);
  font-weight: 700;
}

/* ── Tab Navigation ───────────────────────────────────────────── */

.tab-nav {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
}

.tab-btn {
  padding: 10px 20px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 400;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn--active {
  font-weight: 700;
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}

.tab-panel {
  display: none;
}

.tab-panel--active {
  display: block;
}

/* ── Select width utility ─────────────────────────────────────── */

.select-auto {
  width: auto;
}

/* ── Page Layout Helpers ──────────────────────────────────────── */

.page-header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.chart-canvas-wrapper {
  position: relative;
  width: 100%;
  height: 260px;
}

.chart-canvas-wrapper .skeleton {
  position: absolute;
  inset: 0;
}

.chart-label {
  margin-bottom: 20px;
}

.section-mb {
  margin-bottom: 24px;
}

.label-mb {
  margin-bottom: 16px;
}

/* ── Keyframe Animations ──────────────────────────────────────── */

@keyframes shimmer {
  from { background-position: -800px 0; }
  to   { background-position: 800px 0; }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
