/* ==========================================================================
   Lead Factory Retorno — Premium SaaS Stylesheet (Stripe / Linear / Notion)
   ========================================================================== */

:root {
  /* Core Neutral Palette */
  --bg-canvas: #F8FAFC;
  --bg-surface: #FFFFFF;
  --bg-subtle: #F1F5F9;
  --bg-hover: #F8FAFC;

  --border-color: #E2E8F0;
  --border-subtle: #F1F5F9;
  --border-strong: #CBD5E1;

  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-muted: #64748B;
  --text-faint: #94A3B8;

  /* Dynamic Brand Tokens (overridden by data-mode and JS user accent) */
  --brand-primary: #0F766E;
  --brand-primary-hover: #115E59;
  --brand-primary-soft: rgba(15, 118, 110, 0.08);
  --brand-primary-border: rgba(15, 118, 110, 0.24);
  --brand-accent: #D97706;
  --brand-accent-soft: #FFFBEB;

  /* Semantic Status Colors */
  --danger-text: #B91C1C;
  --danger-bg: #FEF2F2;
  --danger-border: #FECACA;
  --danger-dot: #EF4444;

  --warning-text: #B45309;
  --warning-bg: #FFF7ED;
  --warning-border: #FED7AA;
  --warning-dot: #F97316;

  --amber-text: #92400E;
  --amber-bg: #FFFBEB;
  --amber-border: #FCD34D;

  --success-text: #15803D;
  --success-bg: #F0FDF4;
  --success-border: #BBF7D0;
  --success-dot: #22C55E;

  --wa-green: #16A34A;
  --wa-green-hover: #15803D;

  /* Typography */
  --font-display: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Layout & Radii */
  --sidebar-w: 256px;
  --topbar-h: 72px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 6px 20px -4px rgba(15, 23, 42, 0.08), 0 2px 6px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 20px 44px -10px rgba(15, 23, 42, 0.16), 0 4px 12px -2px rgba(15, 23, 42, 0.06);

  --transition-fast: 150ms cubic-bezier(0.2, 0, 0, 1);
  --transition-theme: 220ms ease;
}

/* Mode Defaults */
html[data-mode="estetica"] {
  --brand-primary: #0F766E;
  --brand-primary-hover: #115E59;
  --brand-accent: #D97706;
}

html[data-mode="vet"] {
  --brand-primary: #14532D;
  --brand-primary-hover: #166534;
  --brand-accent: #EA580C;
}

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

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

svg {
  display: block;
  flex-shrink: 0;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   App Shell: Sidebar + Workspace
   ========================================================================== */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Fixed Desktop Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 20px 14px 16px;
  z-index: 30;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 20px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 14px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  color: var(--brand-primary);
  transition: color var(--transition-theme);
}

.brand-mark svg {
  width: 30px;
  height: 30px;
}

.brand-text {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.brand-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.brand-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
  letter-spacing: 0.01em;
  transition: background var(--transition-theme), color var(--transition-theme);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 13.5px;
  text-align: left;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.nav-item:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.nav-item.is-active {
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
  border-color: var(--brand-primary-border);
  font-weight: 600;
}

.nav-icon svg {
  width: 17px;
  height: 17px;
}

.nav-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-count {
  font-size: 11.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

.nav-item.is-active .nav-count {
  background: var(--brand-primary);
  color: #FFFFFF;
}

.nav-count.is-alert {
  background: var(--amber-bg);
  color: var(--amber-text);
  border: 1px solid var(--amber-border);
}

.sidebar-footer {
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-mode-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-canvas);
  border: 1px solid var(--border-color);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.mode-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--brand-primary-soft);
  transition: background var(--transition-theme);
}

.powered-by {
  font-size: 11.5px;
  color: var(--text-faint);
  padding: 0 4px;
  letter-spacing: 0.01em;
}

.powered-by strong {
  color: var(--text-muted);
  font-weight: 600;
}

/* Workspace Area */
.workspace {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Sticky Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: var(--topbar-h);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 28px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}

.topbar-left {
  min-width: 0;
}

.clinic-identity {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.clinic-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.meta-sep {
  opacity: 0.5;
}

.topbar-center {
  display: flex;
  justify-content: center;
}

/* Segmented Control */
.segmented-control {
  display: inline-flex;
  align-items: center;
  padding: 4px;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  gap: 2px;
}

.segment-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
}

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

.segment-btn.is-active {
  background: var(--bg-surface);
  color: var(--brand-primary);
  box-shadow: var(--shadow-sm);
}

.segment-icon svg {
  width: 15px;
  height: 15px;
}

.topbar-right {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

/* Main Content */
.main-content {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 28px 48px;
  flex: 1;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), transform 100ms ease, box-shadow var(--transition-fast);
}

.btn:active {
  transform: translateY(0.5px);
}

.btn-icon svg,
.btn svg {
  width: 16px;
  height: 16px;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12.5px;
  border-radius: 7px;
}

.btn-sm svg {
  width: 14px;
  height: 14px;
}

.btn-primary {
  background: var(--brand-primary);
  color: #FFFFFF;
  box-shadow: var(--shadow-xs);
}

.btn-primary:hover {
  background: var(--brand-primary-hover);
  box-shadow: var(--shadow-sm);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-color);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.btn-whatsapp {
  background: var(--wa-green);
  color: #FFFFFF;
  box-shadow: var(--shadow-xs);
}

.btn-whatsapp:hover {
  background: var(--wa-green-hover);
}

.btn-confirm {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: var(--success-border);
}

.btn-confirm:hover {
  background: #DCFCE7;
  border-color: #86EFAC;
}

.btn-danger-outline {
  background: var(--bg-surface);
  color: var(--danger-text);
  border-color: var(--danger-border);
}

.btn-danger-outline:hover {
  background: var(--danger-bg);
}

.btn-danger {
  background: #DC2626;
  color: #FFFFFF;
}

.btn-danger:hover {
  background: #B91C1C;
}

.btn-icon-only {
  padding: 6px;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
}

.btn-icon-only:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.btn-icon-only.is-danger:hover {
  background: var(--danger-bg);
  color: var(--danger-text);
  border-color: var(--danger-border);
}

/* ==========================================================================
   KPI Cards (4 Clickable Revenue-Focused Cards)
   ========================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.kpi-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 18px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-xs);
  text-align: left;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast), background var(--transition-fast);
}

.kpi-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.kpi-card.is-selected {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--brand-primary-soft), var(--shadow-sm);
}

.kpi-card.is-money-highlight {
  background: linear-gradient(180deg, #FFFFFF 0%, var(--brand-primary-soft) 100%);
  border-color: var(--brand-primary-border);
}

.kpi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.kpi-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.kpi-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}

.kpi-pill.is-danger {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.kpi-pill.is-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.kpi-pill.is-brand {
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
}

.kpi-pill.is-success {
  background: var(--success-bg);
  color: var(--success-text);
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.kpi-card.is-money-highlight .kpi-value {
  color: var(--brand-primary);
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

/* ==========================================================================
   Panel Card + Toolbar + Smart Table ("Chamar Hoje")
   ========================================================================== */
.panel-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.panel-toolbar {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.toolbar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 240px;
  max-width: 440px;
}

.search-box-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  pointer-events: none;
}

.search-box-icon svg {
  width: 16px;
  height: 16px;
}

.search-input {
  width: 100%;
  padding: 9px 34px 9px 36px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-canvas);
  font-size: 13.5px;
  color: var(--text-primary);
  transition: border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}

.search-input:focus {
  background: var(--bg-surface);
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--brand-primary-soft);
  outline: none;
}

.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--text-faint);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-clear:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.search-clear svg {
  width: 13px;
  height: 13px;
}

.toolbar-summary {
  font-size: 12.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Filter Tabs */
.filter-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  transition: all var(--transition-fast);
}

.filter-tab:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.filter-tab.is-active {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #FFFFFF;
}

.filter-tab-count {
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

.filter-tab.is-active .filter-tab-count {
  background: rgba(255, 255, 255, 0.22);
  color: #FFFFFF;
}

/* Smart Table (Desktop) */
.records-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.records-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.records-table th {
  padding: 11px 16px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: #F8FAFC;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

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

.records-table tbody tr {
  transition: background var(--transition-fast);
}

.records-table tbody tr:hover {
  background: #FAFCFF;
}

.records-table tbody tr:last-child td {
  border-bottom: 0;
}

/* Client / Pet Cell */
.client-cell {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 210px;
}

.avatar-badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.avatar-badge.is-pet {
  font-size: 17px;
  background: #FFF7ED;
}

.client-info {
  min-width: 0;
}

.client-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.client-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.service-cell {
  min-width: 170px;
}

.service-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 13.5px;
}

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

.dates-cell {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.date-main {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
}

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

.value-cell {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  color: var(--text-primary);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Status Badges */
.status-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-badge.is-danger {
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid var(--danger-border);
}

.status-badge.is-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid var(--warning-border);
}

.status-badge.is-neutral {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.status-badge.is-success {
  background: var(--success-bg);
  color: var(--success-text);
  border: 1px solid var(--success-border);
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  background: #EFF6FF;
  color: #1D4ED8;
  white-space: nowrap;
}

.meta-chip.is-returned {
  background: var(--success-bg);
  color: var(--success-text);
}

.meta-chip svg {
  width: 11px;
  height: 11px;
}

/* Row Actions */
.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  white-space: nowrap;
}

/* Mobile Record Cards (hidden on desktop, shown < 960px) */
.records-mobile-list {
  display: none;
  padding: 12px;
  gap: 12px;
  flex-direction: column;
}

.record-mobile-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rmc-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.rmc-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-canvas);
  font-size: 12.5px;
}

.rmc-meta-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

.rmc-meta-value {
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.rmc-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.rmc-actions .btn-whatsapp {
  flex: 1;
}

/* ==========================================================================
   View Header (Packages / Templates / Settings)
   ========================================================================== */
.view-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.view-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.view-subtitle {
  margin: 4px 0 0;
  font-size: 13.5px;
  color: var(--text-muted);
}

/* ==========================================================================
   Packages View (Bolinhas Visuais)
   ========================================================================== */
.packages-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.packages-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.package-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.package-card:hover {
  box-shadow: var(--shadow-sm);
}

.package-card.is-ending {
  border-color: var(--amber-border);
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.08);
}

.pkg-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.pkg-client {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.pkg-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.pkg-name-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-primary);
  background: var(--brand-primary-soft);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  align-self: flex-start;
}

/* Interactive Progress Dots */
.pkg-progress-box {
  background: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pkg-dots-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.pkg-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: var(--bg-surface);
  color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all var(--transition-fast);
}

.pkg-dot:hover {
  border-color: var(--brand-primary);
  transform: scale(1.08);
}

.pkg-dot.is-filled {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #FFFFFF;
}

.pkg-dot svg {
  width: 14px;
  height: 14px;
}

.pkg-progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.pkg-progress-meta strong {
  color: var(--text-primary);
}

/* Golden Renewal Alert Banner */
.pkg-renewal-alert {
  background: var(--amber-bg);
  border: 1px solid var(--amber-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pkg-renewal-text {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--amber-text);
  line-height: 1.4;
}

.pkg-renewal-text svg {
  width: 17px;
  height: 17px;
  color: #D97706;
  margin-top: 1px;
}

.pkg-renewal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pkg-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 4px;
}

/* ==========================================================================
   Templates View (Live WhatsApp Preview)
   ========================================================================== */
.templates-layout {
  display: grid;
  grid-template-columns: 1.25fr 0.95fr;
  gap: 20px;
  align-items: start;
}

.card-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-xs);
}

.template-tabs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}

.template-selector-btn {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-canvas);
  text-align: left;
  transition: all var(--transition-fast);
}

.template-selector-btn:hover {
  border-color: var(--border-strong);
  background: var(--bg-surface);
}

.template-selector-btn.is-active {
  background: var(--brand-primary-soft);
  border-color: var(--brand-primary);
}

.template-selector-title {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--text-primary);
}

.template-selector-btn.is-active .template-selector-title {
  color: var(--brand-primary);
}

.template-selector-desc {
  font-size: 12px;
  color: var(--text-muted);
}

.vars-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.var-chip {
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-canvas);
  color: var(--brand-primary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 600;
  transition: all var(--transition-fast);
}

.var-chip:hover {
  background: var(--brand-primary-soft);
  border-color: var(--brand-primary-border);
}

.template-textarea {
  width: 100%;
  min-height: 150px;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  resize: vertical;
  line-height: 1.55;
  font-size: 14px;
}

.template-textarea:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--brand-primary-soft);
  outline: none;
}

.template-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

/* WhatsApp Live Preview Phone Frame */
.wa-preview-shell {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  overflow: hidden;
  background: #EFEAE2;
  box-shadow: var(--shadow-sm);
}

.wa-preview-header {
  background: #075E54;
  color: #FFFFFF;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.wa-preview-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}

.wa-preview-name {
  font-weight: 600;
  font-size: 13.5px;
  line-height: 1.2;
}

.wa-preview-status {
  font-size: 11px;
  opacity: 0.82;
}

.wa-preview-body {
  padding: 18px 16px 22px;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.wa-bubble {
  align-self: flex-end;
  max-width: 92%;
  background: #D9FDD3;
  color: #111B21;
  padding: 10px 13px 8px;
  border-radius: 12px 12px 2px 12px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.1);
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.wa-bubble-time {
  display: block;
  text-align: right;
  font-size: 10.5px;
  color: #667781;
  margin-top: 5px;
}

/* ==========================================================================
   Settings View (White-Label + Backup + Demo Controls)
   ========================================================================== */
.settings-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 20px;
  align-items: start;
}

.settings-section-title {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.settings-section-desc {
  margin: 0 0 18px;
  font-size: 13px;
  color: var(--text-muted);
}

.swatch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.swatch-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid transparent;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  box-shadow: var(--shadow-xs);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.swatch-btn:hover {
  transform: scale(1.08);
}

.swatch-btn.is-active {
  box-shadow: 0 0 0 2px #FFFFFF, 0 0 0 4px var(--text-primary);
}

.swatch-btn svg {
  width: 15px;
  height: 15px;
}

.color-custom-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  background: var(--bg-canvas);
  font-size: 12px;
  color: var(--text-secondary);
}

.color-custom-input {
  width: 22px;
  height: 22px;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.settings-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ==========================================================================
   Forms & Inputs
   ========================================================================== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field.is-full {
  grid-column: 1 / -1;
}

.form-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  font-size: 13.5px;
  color: var(--text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--brand-primary-soft);
  outline: none;
}

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

/* Quick Presets Grid in Modal */
.presets-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.presets-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}

.preset-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-canvas);
  text-align: left;
  transition: all var(--transition-fast);
}

.preset-btn:hover {
  border-color: var(--brand-primary-border);
  background: var(--bg-surface);
}

.preset-btn.is-active {
  border-color: var(--brand-primary);
  background: var(--brand-primary-soft);
}

.preset-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.25;
}

.preset-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.species-toggle {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.species-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-canvas);
  font-weight: 600;
  font-size: 13px;
  color: var(--text-secondary);
}

.species-btn.is-active {
  border-color: var(--brand-primary);
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
}

.return-preview-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--brand-primary-soft);
  border: 1px solid var(--brand-primary-border);
  color: var(--brand-primary);
  font-size: 13px;
  font-weight: 600;
}

.return-preview-banner svg {
  width: 16px;
  height: 16px;
}

.checkbox-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border-strong);
  background: var(--bg-canvas);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.checkbox-card input {
  width: 16px;
  height: 16px;
  accent-color: var(--brand-primary);
}

.nested-package-box {
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-canvas);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

/* ==========================================================================
   Empty State
   ========================================================================== */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.empty-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-icon svg {
  width: 22px;
  height: 22px;
}

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

.empty-sub {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-muted);
  max-width: 360px;
}

/* ==========================================================================
   Modals & Toasts
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 140ms ease;
}

.modal-dialog {
  width: 100%;
  max-width: 580px;
  max-height: calc(100vh - 40px);
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: popIn 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-dialog.is-compact {
  max-width: 440px;
}

.modal-header {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.modal-body {
  padding: 18px 22px;
  overflow-y: auto;
}

.modal-footer {
  padding: 14px 22px 18px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  background: #FAFBFD;
}

.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast-item {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 15px;
  border-radius: 10px;
  background: #0F172A;
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  max-width: 360px;
  animation: slideUp 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-item.is-success {
  background: #14532D;
}

.toast-item.is-warning {
  background: #92400E;
}

.toast-item svg {
  width: 16px;
  height: 16px;
}

/* Mobile Bottom Nav (hidden on desktop) */
.mobile-nav {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

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

/* ==========================================================================
   Responsive Breakpoints (Tablet & Mobile)
   ========================================================================== */
@media (max-width: 1120px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .templates-layout,
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 960px) {
  .sidebar {
    display: none;
  }

  .workspace {
    margin-left: 0;
    padding-bottom: 72px;
  }

  .topbar {
    grid-template-columns: 1fr auto;
    padding: 12px 16px;
    gap: 10px;
  }

  .topbar-center {
    grid-column: 1 / -1;
    order: 3;
    justify-content: stretch;
  }

  .segmented-control {
    width: 100%;
  }

  .segment-btn {
    flex: 1;
    justify-content: center;
  }

  .main-content {
    padding: 16px 16px 32px;
  }

  .records-table-wrap {
    display: none;
  }

  .records-mobile-list {
    display: flex;
  }

  .packages-grid {
    grid-template-columns: 1fr;
  }

  .mobile-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 64px;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-color);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding: 6px 8px;
    z-index: 40;
  }

  .mobile-nav-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    border-radius: 10px;
  }

  .mobile-nav-item.is-active {
    color: var(--brand-primary);
    background: var(--brand-primary-soft);
  }

  .mobile-nav-icon svg {
    width: 19px;
    height: 19px;
  }

  .mobile-nav-dot {
    position: absolute;
    top: 5px;
    right: calc(50% - 16px);
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: var(--radius-pill);
    background: var(--brand-primary);
    color: #FFFFFF;
    font-size: 10px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-nav-dot:empty {
    display: none;
  }

  .toast-stack {
    left: 14px;
    right: 14px;
    bottom: 76px;
  }

  .toast-item {
    max-width: none;
  }
}

@media (max-width: 600px) {
  .kpi-grid {
    gap: 10px;
  }

  .kpi-card {
    padding: 14px 13px;
  }

  .kpi-value {
    font-size: 21px;
  }

  .btn-cta-label {
    display: none;
  }

  .btn-cta-new::after {
    content: 'Novo';
  }

  .presets-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid,
  .nested-package-box {
    grid-template-columns: 1fr;
  }

  .modal-backdrop {
    padding: 10px;
    align-items: flex-end;
  }

  .modal-dialog {
    max-height: calc(100vh - 20px);
    border-radius: 16px 16px 12px 12px;
  }
}
