@font-face {
  font-family: "Archivo";
  src: url("fonts/archivo-latin.woff2") format("woff2");
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Geist";
  src: url("fonts/geist-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --canvas: #f5f7fa;
  --surface: #ffffff;
  --surface-tint: #edf2f6;
  --ink: #102033;
  --muted: #4b5d70;
  --accent: #0c5c7a;
  --accent-dark: #084359;
  --copper: #b85c28;
  --line: #d6dfe8;
  --line-strong: #b6c5d4;
  --ok-bg: #e6f5ee;
  --ok-fg: #145b42;
  --warn-bg: #fff3e6;
  --warn-fg: #994d12;
  --danger-bg: #fbeceb;
  --danger-fg: #9f2d1e;
  --info-bg: #e9f2f9;
  --info-fg: #0c4d73;
  --radius: 6px;
  --font-display: "Archivo", system-ui, -apple-system, sans-serif;
  --font-sans: "Geist", system-ui, -apple-system, sans-serif;
}

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

body.dash-body {
  margin: 0;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font: inherit;
}

:focus-visible {
  outline: 3px solid var(--copper) !important;
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 100;
  background: var(--surface);
  color: var(--ink);
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  transform: translateY(-160%);
}
.skip-link:focus {
  transform: translateY(0);
}

/* Barra superior de aviso */
.demo-strip {
  background: var(--ink);
  color: #e6eef5;
  font-size: 12px;
}
.demo-strip-inner {
  min-height: 36px;
  padding: 6px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.demo-strip-credit {
  color: #b7c6d6;
}

/* Layout principal */
.dash-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: calc(100vh - 36px);
}

.dash-sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.dash-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.dash-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #ffffff;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 17px;
  border-radius: 4px;
}
.dash-brand strong {
  display: block;
  font-family: var(--font-display);
  font-size: 17px;
  line-height: 1.1;
}
.dash-brand small {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.sidebar-nav {
  display: grid;
  gap: 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 4px;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
}
.nav-item:hover {
  background: var(--surface-tint);
  color: var(--ink);
}
.nav-item.active {
  background: var(--info-bg);
  color: var(--accent-dark);
}
.nav-badge {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink);
}

.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 14px;
}
.conn-box {
  padding: 12px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--canvas);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.conn-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-top: 5px;
  flex: none;
  background: var(--copper);
}
.conn-box[data-state="online"] .conn-dot {
  background: #1b8a5a;
}
.conn-box strong {
  display: block;
  font-size: 12px;
}
.conn-box small {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.demo-profile {
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
}
.profile-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-tint);
  color: var(--accent-dark);
  font-weight: 700;
  font-size: 12px;
  display: grid;
  place-items: center;
}
.demo-profile strong {
  display: block;
  font-size: 13px;
}
.demo-profile small {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

/* Conteúdo principal */
.dash-main {
  min-width: 0;
  padding: 24px clamp(16px, 2.4vw, 32px) 32px;
  max-width: 1440px;
  width: 100%;
}

.dash-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.dash-kicker {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--muted);
}
.dash-header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(24px, 2.8vw, 32px);
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.dash-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 4px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.btn-primary {
  background: var(--accent);
  color: #ffffff;
}
.btn-primary:hover {
  background: var(--accent-dark);
}
.btn-outline {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn-outline:hover {
  background: var(--surface-tint);
}
.btn-whatsapp {
  background: #145b42;
  color: #ffffff;
}
.btn-whatsapp:hover {
  background: #0e4431;
}

/* 7 KPIs */
.metrics-section {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.kpi-card {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}
.kpi-positive {
  border-top: 3px solid #1b8a5a;
}
.kpi-alert {
  border-top: 3px solid var(--copper);
}
.kpi-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}
.kpi-value {
  display: block;
  margin: 6px 0 2px;
  font-family: var(--font-display);
  font-size: 28px;
  line-height: 1.1;
  color: var(--ink);
}
.kpi-card small {
  font-size: 11px;
  color: var(--muted);
}

/* Funil */
.funnel-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 18px;
}
.funnel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.funnel-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 15px;
}
.funnel-head span {
  font-size: 12px;
  color: var(--muted);
}
.funnel-bar {
  display: flex;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-tint);
  gap: 2px;
}
.funnel-seg {
  height: 100%;
  min-width: 4px;
}
.funnel-seg[data-status="new"], .legend-swatch[data-status="new"] { background: #0c5c7a; }
.funnel-seg[data-status="contacted"], .legend-swatch[data-status="contacted"] { background: #3b7ea1; }
.funnel-seg[data-status="proposal_sent"], .legend-swatch[data-status="proposal_sent"] { background: #c4742a; }
.funnel-seg[data-status="won"], .legend-swatch[data-status="won"] { background: #1c7c54; }
.funnel-seg[data-status="lost"], .legend-swatch[data-status="lost"] { background: #9aa7b4; }
.funnel-legend {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 12px;
  color: var(--muted);
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

/* Área de trabalho */
.workspace-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
.workspace-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.workspace-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 19px;
}
.workspace-head p {
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.view-switch {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  overflow: hidden;
}
.switch-btn {
  border: 0;
  background: var(--surface);
  color: var(--muted);
  padding: 8px 14px;
  min-height: 38px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.switch-btn.active {
  background: var(--ink);
  color: #ffffff;
}

.controls-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.search-wrap {
  flex: 1 1 240px;
}
.search-wrap input {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fbfcfd;
  color: var(--ink);
}
.filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.filter-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.filter-group select {
  min-height: 40px;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
}

.state-box {
  padding: 16px;
  border-radius: 4px;
  background: var(--canvas);
  border: 1px solid var(--line);
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--muted);
}
.state-box[data-state="error"] {
  background: var(--danger-bg);
  border-color: #e4b6af;
  color: var(--danger-fg);
}
.empty-box {
  text-align: center;
  padding: 20px 10px;
}
.empty-box strong {
  display: block;
  color: var(--ink);
  margin-bottom: 4px;
}

/* Tabela */
.table-wrap {
  overflow-x: auto;
}
.orders-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
.orders-table th {
  padding: 10px 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}
.orders-table td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.cell-primary {
  display: block;
  font-weight: 700;
  color: var(--ink);
}
.cell-sub {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.late-badge {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 7px;
  border-radius: 3px;
  background: var(--danger-bg);
  color: var(--danger-fg);
  font-size: 11px;
  font-weight: 700;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  background: var(--info-bg);
  color: var(--info-fg);
}
.status-pill[data-status="contacted"] { background: #e8eef9; color: #244a85; }
.status-pill[data-status="proposal_sent"] { background: var(--warn-bg); color: var(--warn-fg); }
.status-pill[data-status="won"] { background: var(--ok-bg); color: var(--ok-fg); }
.status-pill[data-status="lost"] { background: var(--danger-bg); color: var(--danger-fg); }

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.action-btn {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.action-btn:hover {
  background: var(--surface-tint);
}
.action-wa {
  border-color: #a9d0bf;
  color: #145b42;
}

/* Kanban */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(210px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 6px;
}
.kanban-col {
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 240px;
}
.kanban-col-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.kanban-col-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 14px;
}
.kanban-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.kanban-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 12px;
  display: grid;
  gap: 6px;
}
.kanban-card strong {
  font-size: 14px;
}
.kanban-card p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

/* Cards mobile */
.mobile-leads {
  display: none;
}
.lead-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--surface);
  display: grid;
  gap: 8px;
}
.lead-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.lead-card-top h3 {
  margin: 0;
  font-size: 15px;
}
.lead-card-meta {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}
.lead-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.workspace-foot {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}

.dash-footer {
  margin-top: 20px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}
.dash-footer a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Modal de detalhes */
.order-dialog {
  width: min(620px, calc(100% - 24px));
  max-height: 90vh;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  box-shadow: 0 24px 64px rgba(16, 32, 51, 0.25);
}
.order-dialog::backdrop {
  background: rgba(16, 32, 51, 0.52);
  backdrop-filter: blur(2px);
}
.dialog-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.dialog-kicker {
  margin: 0 0 2px;
  font-size: 12px;
  color: var(--muted);
}
.dialog-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 21px;
}
.dialog-close {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
  font-size: 22px;
  cursor: pointer;
}
.dialog-body {
  padding: 20px 22px 24px;
  display: grid;
  gap: 18px;
}
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.detail-item {
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px 12px;
}
.detail-item-wide {
  grid-column: 1 / -1;
}
.detail-item small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 2px;
}
.detail-item strong {
  font-size: 13px;
}

.edit-form {
  display: grid;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.edit-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.edit-field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
}
.edit-field input,
.edit-field select,
.edit-field textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
}
.dialog-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.history-block {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.history-block h3 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 14px;
}
.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  max-width: 360px;
  padding: 12px 16px;
  background: var(--ink);
  color: #ffffff;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Responsividade */
@media (max-width: 1200px) {
  .metrics-section {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 920px) {
  .dash-layout {
    grid-template-columns: 1fr;
  }
  .dash-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 14px 16px;
    gap: 12px;
  }
  .sidebar-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .sidebar-foot {
    display: none;
  }
  .metrics-section {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 680px) {
  .demo-strip-inner {
    padding: 6px 14px;
  }
  .dash-main {
    padding: 18px 14px 28px;
  }
  .metrics-section {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .kpi-card {
    padding: 12px;
  }
  .kpi-value {
    font-size: 24px;
  }
  .workspace-card {
    padding: 14px;
  }
  .table-wrap {
    display: none !important;
  }
  .mobile-leads {
    display: grid;
    gap: 10px;
  }
  .mobile-leads[hidden] {
    display: none;
  }
  .detail-grid,
  .edit-row {
    grid-template-columns: 1fr;
  }
  .filter-group {
    width: 100%;
    justify-content: space-between;
  }
  .filter-group select {
    flex: 1;
    max-width: 210px;
  }
}
