/* ═══════════════════════════════════════════════════════════
   BAGY CUPONS — Design System
   Light Mode | Clean Fintech | Inter Font
   Referência: Gestão de Pagamentos (Loy/Bagy)
═══════════════════════════════════════════════════════════ */

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

:root {
  /* Backgrounds */
  --bg-base:       #f5f5f5;
  --bg-surface:    #ffffff;
  --bg-card:       #ffffff;
  --bg-hover:      #fafafa;

  /* Charcoal Primary */
  --navy-900:      #0a0a0a;
  --navy-800:      #1a1a1a;
  --navy-700:      #2a2a2a;
  --navy-600:      #3a3a3a;
  --navy-50:       #f5f5f5;

  /* Accent */
  --indigo:        #1a1a1a;
  --indigo-light:  #f0f0f0;

  /* Status */
  --green:         #16a34a;
  --green-light:   #dcfce7;
  --orange:        #ea580c;
  --orange-light:  #fff7ed;
  --red:           #dc2626;
  --red-light:     #fef2f2;
  --blue:          #2563eb;
  --blue-light:    #eff6ff;

  /* Text */
  --text-primary:   #111111;
  --text-secondary: #444444;
  --text-muted:     #999999;
  --text-placeholder: #c0c0c0;

  /* Borders */
  --border:         #e0e0e0;
  --border-strong:  #cccccc;
  --border-focus:   #1a1a1a;

  /* Shadows */
  --shadow-xs:  0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:  0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg:  0 10px 24px rgba(0,0,0,0.08), 0 4px 8px rgba(0,0,0,0.04);
  --shadow-xl:  0 20px 48px rgba(0,0,0,0.12);

  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  14px;
  --radius-xl:  20px;
  --radius-pill: 100px;
  --transition: 0.18s cubic-bezier(0.4,0,0.2,1);

  /* Typography Scale */
  --fs-xs:   0.6875rem;  /* 11px — micro captions, table subs, tiny labels */
  --fs-sm:   0.75rem;    /* 12px — labels, badges, table headers, code */
  --fs-base: 0.825rem;   /* 13.2px — body text, table cells */
  --fs-md:   0.875rem;   /* 14px — buttons, secondary titles */
  --fs-lg:   1rem;       /* 16px — emphasis, large body */
  --fs-xl:   1.2rem;     /* 19.2px — card values, stats */
  --fs-2xl:  1.5rem;     /* 24px — section titles */
  --fs-3xl:  2rem;       /* 32px — page titles */

  /* Font Weights */
  --fw-regular:   400;
  --fw-medium:    500;
  --fw-semibold:  600;
  --fw-bold:      700;
  --fw-extrabold: 800;

  /* Spacing Scale (4px grid) */
  --sp-1:  2px;
  --sp-2:  4px;
  --sp-3:  6px;
  --sp-4:  8px;
  --sp-5:  10px;
  --sp-6:  12px;
  --sp-7:  16px;
  --sp-8:  20px;
  --sp-9:  24px;
  --sp-10: 32px;
  --sp-11: 40px;
  --sp-12: 48px;
  --sp-13: 60px;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ═══════════════════════════════════════════════════════════
   HEADER
═══════════════════════════════════════════════════════════ */
.header {
  position: sticky; top: 0; z-index: 100;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  padding: 0 32px;
}

.header-inner {
  max-width: 1360px;
  margin: 0 auto;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-icon {
  width: 40px; height: 40px;
  background: var(--navy-900);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.brand-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy-900);
  line-height: 1.2;
}

.brand-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
}

.header-actions { display: flex; align-items: center; gap: 10px; }

/* ═══════════════════════════════════════════════════════════
   CONNECTION BADGE
═══════════════════════════════════════════════════════════ */
.badge {
  display: flex; align-items: center; gap: 6px;
  padding: 0;
  border-radius: 0;
  font-size: 0.73rem;
  font-weight: 500;
  border: none;
  background: transparent;
  transition: var(--transition);
}

.badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
}

.badge-checking {
  color: var(--orange);
}
.badge-checking .badge-dot { background: var(--orange); animation: pulse 1.5s infinite; }

.badge-ok {
  color: var(--green);
}
.badge-ok .badge-dot { background: var(--green); }

.badge-error {
  color: var(--red);
}
.badge-error .badge-dot { background: var(--red); }

@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.35; } }

/* ═══════════════════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-7);
  border-radius: var(--radius-sm);
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  font-family: inherit;
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.btn-primary {
  background: var(--navy-900);
  color: white;
  border-color: var(--navy-900);
}
.btn-primary:hover {
  background: var(--navy-700);
  border-color: var(--navy-700);
  box-shadow: var(--shadow-md);
}
.btn-primary:active { transform: translateY(1px); }

.btn-secondary {
  background: #ffffff;
  color: var(--text-secondary);
  border-color: var(--border-strong);
}
.btn-secondary:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

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

.btn-danger {
  background: var(--red);
  color: white;
  border-color: var(--red);
}
.btn-danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
}

/* ═══════════════════════════════════════════════════════════
   MAIN LAYOUT
═══════════════════════════════════════════════════════════ */
.main {
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 var(--sp-10) var(--sp-13);
}

/* ═══════════════════════════════════════════════════════════
   PAGE TITLE AREA
════════════════════════════════════════════════════════════ */
.page-title-area {
  position: sticky;
  top: 64px;
  z-index: 90;
  background: var(--bg-base);
  padding: var(--sp-9) 0;
  margin-bottom: 0;
}

.page-title {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  color: var(--text-primary);
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: var(--sp-2);
}

.page-subtitle {
  font-size: var(--fs-md);
  color: var(--text-secondary);
  max-width: 560px;
  line-height: 1.6;
}

/* ═══════════════════════════════════════════════════════════
   BALANCE STRIP (inspired by reference top section)
═══════════════════════════════════════════════════════════ */
.balance-strip {
  display: flex;
  align-items: center;
  gap: 0;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.balance-item {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 18px 28px;
  flex: 1;
  border-right: 1px solid var(--border);
}

.balance-item:last-child { border-right: none; }

.balance-info {}
.balance-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 2px;
}
.balance-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

/* ═══════════════════════════════════════════════════════════
   METRICS CARDS
═══════════════════════════════════════════════════════════ */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  animation: fadeUp 0.4s ease both;
}

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

.metric-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.metric-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.metric-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
}

.metric-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -0.04em;
}

/* ═══════════════════════════════════════════════════════════
   COUPON TABLE AREA (inspired by reference's table section)
═══════════════════════════════════════════════════════════ */
.table-container {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

/* ── TABLE HEADER (dark navy — like "Carteira" in reference) */
.table-header-bar {
  background: var(--navy-900);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.table-header-title {
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.01em;
}

.table-header-sub {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.55);
  margin-top: 2px;
}

.table-header-bar .btn-primary {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.25);
  color: white;
  font-size: 0.82rem;
  padding: 7px 14px;
}
.table-header-bar .btn-primary:hover {
  background: rgba(255,255,255,0.25);
  border-color: rgba(255,255,255,0.4);
  box-shadow: none;
}

/* ── TOOLBAR */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  background: var(--bg-card);
}

.search-box {
  flex: 1;
  min-width: 200px;
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  transition: var(--transition);
  color: var(--text-muted);
}

.search-box:focus-within {
  border-color: var(--border-focus);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(26,26,26,0.08);
  color: var(--text-secondary);
}

.search-box input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.86rem;
  width: 100%;
}

.search-box input::placeholder { color: var(--text-placeholder); }

.filter-group {
  display: flex;
  gap: 4px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.filter-btn {
  padding: 6px 14px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

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

.filter-btn.active {
  background: #ffffff;
  color: var(--navy-900);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

/* ── COUPON TABLE */
.coupon-table {
  width: 100%;
  border-collapse: collapse;
}

.coupon-table thead tr {
  background: #f9fafb;
  border-bottom: 1px solid var(--border);
}

.coupon-table th {
  padding: 11px 20px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  white-space: nowrap;
}

.coupon-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
  animation: fadeIn 0.3s ease both;
}

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

.coupon-table tbody tr:hover { background: #f9fafb; }

.coupon-table td {
  padding: 14px 20px;
  font-size: 0.86rem;
  color: var(--text-primary);
  vertical-align: middle;
}

.coupon-table th:nth-child(6),
.coupon-table td:nth-child(6),
.coupon-table th:nth-child(7),
.coupon-table td:nth-child(7) { text-align: center; }

/* Coupon name cell */
.coupon-name-cell {}
.coupon-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.88rem;
  line-height: 1.3;
}
.coupon-id {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 1px;
}

/* Type badge */
.type-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid;
}

.type-badge.percentage {
  background: var(--indigo-light);
  color: var(--indigo);
  border-color: #dddddd;
}
.type-badge.fixed {
  background: var(--green-light);
  color: var(--green);
  border-color: #86efac;
}
.type-badge.freight {
  background: var(--orange-light);
  color: var(--orange);
  border-color: #fed7aa;
}

/* Status badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid;
}
.status-badge.active {
  background: var(--green-light);
  color: var(--green);
  border-color: #86efac;
}
.status-badge.inactive {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fca5a5;
}

/* Discount value in table */
.coupon-discount-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--navy-900);
  letter-spacing: -0.02em;
}
.coupon-discount-suffix {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
  margin-top: 1px;
  font-weight: 400;
}

/* Codes */
.coupon-codes {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.code-chip {
  background: var(--bg-base);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 3px 9px;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', monospace;
  color: var(--navy-900);
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.code-chip:hover {
  background: var(--indigo-light);
  border-color: #888;
  color: var(--indigo);
}

/* Tags */
.coupon-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.7rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Actions cell */
.coupon-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}

.action-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.action-btn:hover { color: var(--text-primary); border-color: var(--border-strong); background: var(--bg-hover); }
.action-btn.edit:hover { border-color: #888; color: var(--indigo); background: var(--indigo-light); }
.action-btn.delete:hover { border-color: #fca5a5; color: var(--red); background: var(--red-light); }

/* ─── GRID FALLBACK (for the coupon-grid used in loading/empty state) */
.coupon-grid {
  padding: 0;
}

/* ─── LOADING STATE */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 64px 24px;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.spinner {
  width: 54px; height: 54px;
  display: flex; align-items: center; justify-content: center;
  background: url('hubble-loader.png') no-repeat center / contain;
  border: none;
  border-radius: 0;
  animation: hubblePulse 1.8s ease-in-out infinite;
}

@keyframes hubblePulse {
  0%, 100% { opacity: 0.6; transform: scale(0.95); }
  50%      { opacity: 1;   transform: scale(1.05); }
}

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

/* ─── EMPTY STATE */
.empty-state {
  text-align: center;
  padding: 72px 24px;
  color: var(--text-secondary);
  animation: fadeUp 0.3s ease;
}

.empty-icon { font-size: 3rem; margin-bottom: 14px; opacity: 0.4; }
.empty-state h3 { font-size: 1.1rem; font-weight: 600; color: var(--text-primary); margin-bottom: 8px; }
.empty-state p { font-size: 0.87rem; color: var(--text-muted); margin-bottom: 22px; }

/* ═══════════════════════════════════════════════════════════
   MODAL
═══════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(17,24,39,0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 580px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  transform: translateY(16px) scale(0.98);
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1);
}

.modal-sm { max-width: 400px; }

.modal-overlay.open .modal {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.modal-close {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* ═══════════════════════════════════════════════════════════
   FORM
═══════════════════════════════════════════════════════════ */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  padding: 22px 24px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }
.full-width { grid-column: 1 / -1; }

.form-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: -0.01em;
}

.required { color: var(--red); margin-left: 2px; }

.form-group input,
.form-group select {
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.87rem;
  outline: none;
  transition: var(--transition);
  width: 100%;
}

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

.form-group input:focus,
.form-group select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(26,26,26,0.1);
  background: #ffffff;
}

.form-group select {
  -webkit-appearance: none;
  cursor: pointer;
  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='%239ca3af' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 36px;
}

.form-group select option { background: #ffffff; color: var(--text-primary); }

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

/* Chip checkbox group (multi-select) */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
}
.chip-option {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.chip-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.chip-option span {
  display: inline-flex;
  align-items: center;
  padding: var(--sp-2) var(--sp-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  transition: background .15s ease, border-color .15s ease, color .15s ease;
  cursor: pointer;
  user-select: none;
}
.chip-option:hover span {
  border-color: var(--indigo);
  color: var(--indigo);
}
.chip-option input:checked + span {
  background: var(--indigo);
  border-color: var(--indigo);
  color: #ffffff;
}
.chip-option input:focus-visible + span {
  outline: 2px solid var(--indigo);
  outline-offset: 2px;
}

/* Input with prefix */
.input-prefix-wrapper { position: relative; }
.input-prefix {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.87rem;
  pointer-events: none;
  z-index: 1;
}
.input-prefix-wrapper input { padding-left: 38px; }

/* Toggle */
.toggle-group {
  flex-direction: row !important;
  align-items: center;
  gap: 10px !important;
}

.toggle-group > label:first-child {
  flex: 1;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.toggle { display: inline-flex; cursor: pointer; flex-shrink: 0; }
.toggle input { display: none; }

.toggle-slider {
  width: 38px; height: 21px;
  background: var(--border-strong);
  border-radius: 100px;
  position: relative;
  transition: var(--transition);
}

.toggle-slider::after {
  content: '';
  position: absolute;
  width: 15px; height: 15px;
  background: white;
  border-radius: 50%;
  top: 3px; left: 3px;
  transition: var(--transition);
  box-shadow: var(--shadow-xs);
}

.toggle input:checked + .toggle-slider {
  background: var(--navy-900);
}

.toggle input:checked + .toggle-slider::after {
  transform: translateX(17px);
}

.toggle-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  min-width: 22px;
}

/* ── MODAL FOOTER */
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* ── MODAL TABS (Informações Gerais | Dados de Comissão) */
.modal-tabs {
  display: flex;
  gap: var(--sp-1);
  padding: var(--sp-5) var(--sp-9) 0;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
}

.modal-tab-btn {
  padding: var(--sp-5) var(--sp-7);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

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

.modal-tab-btn.active {
  color: var(--navy-900);
  font-weight: var(--fw-semibold);
  border-bottom-color: var(--navy-900);
}

.modal-tab-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.modal-tab-btn:disabled:hover { color: var(--text-muted); }

/* Tab panels */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Section title inside form grid */
.form-section-title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  color: var(--navy-900);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--border);
}

/* CEP search row */
.cep-row { display: flex; gap: var(--sp-4); align-items: center; }
.cep-row input { flex: 1; }

/* Hint under commission form */
.commission-hint { padding: 0 var(--sp-9) var(--sp-6); }

/* Indicator dot when commission data is saved */
.commission-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: var(--sp-2);
  border-radius: 50%;
  background: var(--green);
  vertical-align: middle;
  flex-shrink: 0;
}

/* ── INFORMAÇÕES DETALHADAS MODAL ── */
.detail-modal { max-width: 800px; }

.detail-coupon-pick {
  padding: var(--sp-6) var(--sp-9);
  border-bottom: 1px solid var(--border);
  background: var(--bg-hover);
}

.detail-coupon-pick select {
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: var(--fs-base);
  outline: none;
  cursor: pointer;
  transition: var(--transition);
}

.detail-coupon-pick select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(26,26,26,0.1);
}

.detail-body { padding: var(--sp-8) var(--sp-9); }

.detail-empty {
  text-align: center;
  padding: var(--sp-11) var(--sp-8);
  color: var(--text-muted);
  font-size: var(--fs-base);
  line-height: 1.7;
}

.detail-coupon-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-6);
  margin-bottom: var(--sp-7);
  padding-bottom: var(--sp-6);
  border-bottom: 1px solid var(--border);
}

.detail-coupon-name {
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.detail-coupon-sub {
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  white-space: nowrap;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-7) var(--sp-9);
}

.detail-item { display: flex; flex-direction: column; gap: var(--sp-1); }
.detail-item.full { grid-column: 1 / -1; }

.detail-label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.detail-value {
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  color: var(--text-primary);
  word-break: break-word;
}

.detail-value.muted { color: var(--text-muted); font-weight: var(--fw-regular); }

/* ── DETAILS SESSION COUPON LIST (table) ── */
.details-coupon-table th:first-child,
.details-coupon-table td:first-child { min-width: 160px; }
.details-coupon-table th:nth-child(2),
.details-coupon-table td:nth-child(2),
.details-coupon-table th:nth-child(3),
.details-coupon-table td:nth-child(3) { white-space: nowrap; }
.details-coupon-table th:last-child,
.details-coupon-table td:last-child { text-align: right; }

.details-coupon-table tr.highlight { background: #fff; box-shadow: inset 3px 0 0 var(--indigo); }
.details-coupon-table tr.highlight:hover { background: #fff; }

.details-coupon-table .details-subrow td {
  padding: 0 20px 18px;
  background: var(--bg-hover);
  border-bottom: 1px solid var(--border);
}
.details-coupon-table .details-subrow td:last-child { text-align: left; }

.details-subrow .partner-details {
  margin: 0;
  padding: var(--sp-6) var(--sp-7);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.origin-pill {
  display: inline-flex;
  align-items: center;
  padding: var(--sp-2) var(--sp-5);
  border-radius: var(--radius-pill);
  background: var(--blue-light);
  color: var(--blue);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  white-space: nowrap;
}

.detail-muted { color: var(--text-muted); font-size: var(--fs-sm); }

.info-chip { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }

/* ── PARTNER CARDS ── */
.detail-summary {
  padding: var(--sp-6) var(--sp-9);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--text-secondary);
}

.partner-list { display: flex; flex-direction: column; gap: var(--sp-7); }

/* ── PARTNER EDIT (TRIAGEM) MODAL ── */
.partner-edit-modal { max-width: 760px; }

.partner-edit-body { padding: var(--sp-8) var(--sp-9); max-height: 68vh; overflow-y: auto; }

.partner-edit-sub {
  margin-bottom: var(--sp-8);
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  line-height: 1.6;
}

.partner-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-8);
  transition: var(--transition);
}
.partner-card.open { border-color: var(--border-strong); }
.partner-card.highlight {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(26,26,26,0.08);
}

.partner-head { display: flex; align-items: flex-start; gap: var(--sp-6); }

.partner-avatar {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--indigo);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  letter-spacing: 0.03em;
}

.partner-id { flex: 1; min-width: 0; }
.partner-name {
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  color: var(--text-primary);
  letter-spacing: -0.01em;
  word-break: break-word;
}
.partner-meta {
  margin-top: var(--sp-2);
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  word-break: break-word;
}
.partner-meta.muted { color: var(--text-muted); }

.partner-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--sp-3);
  flex-shrink: 0;
}

.partner-status,
.partner-count {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-5);
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  white-space: nowrap;
}

.partner-status.active { background: var(--green-light); color: var(--green); }
.partner-status.origin { background: var(--blue-light); color: var(--blue); }
.partner-status.inactive { background: var(--red-light); color: var(--red); }

.partner-count { background: var(--indigo-light); color: var(--text-secondary); }

/* Coupon entry current info chips */
.coupon-current-info { display: flex; flex-wrap: wrap; gap: var(--sp-4); }

.coupon-info-chip {
  display: inline-flex;
  align-items: center;
  padding: var(--sp-3) var(--sp-6);
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  white-space: nowrap;
}

.partner-coupons {
  margin-top: var(--sp-7);
  padding-top: var(--sp-7);
  border-top: 1px solid var(--border);
}

.partner-coupons-label {
  display: block;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: var(--sp-5);
}

.partner-coupon-chips { display: flex; flex-wrap: wrap; gap: var(--sp-4); }

.partner-coupon-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--sp-1);
  padding: var(--sp-5) var(--sp-7);
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
}
.partner-coupon-chip:hover {
  border-color: var(--border-strong);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.chip-label { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-primary); }
.chip-code { font-size: var(--fs-xs); color: var(--text-muted); }

.partner-actions {
  margin-top: var(--sp-7);
  display: flex;
  gap: var(--sp-4);
  flex-wrap: wrap;
}

.partner-details {
  margin-top: var(--sp-7);
  padding-top: var(--sp-7);
  border-top: 1px solid var(--border);
}

.partner-details .detail-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

/* ── CONFIRM MODAL */
.confirm-body {
  padding: 28px 24px;
  text-align: center;
}

.confirm-icon { font-size: 2.4rem; margin-bottom: 14px; }

.confirm-body p {
  font-size: 0.93rem;
  color: var(--text-primary);
  font-weight: 600;
  margin-bottom: 6px;
}

.confirm-sub { font-size: 0.82rem !important; color: var(--text-muted) !important; font-weight: 400 !important; }

/* ═══════════════════════════════════════════════════════════
   TOAST
═══════════════════════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 500;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  max-width: 340px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.25s cubic-bezier(0.34,1.56,0.64,1);
  border: 1px solid;
  box-shadow: var(--shadow-lg);
}

.toast.show { opacity: 1; transform: translateY(0); }

.toast.success { background: var(--green-light); border-color: #86efac; color: #15803d; }
.toast.error   { background: var(--red-light); border-color: #fca5a5; color: var(--red); }
.toast.info    { background: var(--indigo-light); border-color: #888; color: var(--indigo); }

/* ═══════════════════════════════════════════════════════════
   UTILITIES
═══════════════════════════════════════════════════════════ */
.spinning { animation: spin 0.6s linear infinite; }

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

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

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 100px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .header { padding: 0 16px; }
  .main { padding: 20px 16px 64px; }
  .coupon-table th:nth-child(4),
  .coupon-table td:nth-child(4) { display: none; } /* hide tags col on mobile */
}

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .full-width { grid-column: 1; }
  .filter-group { display: none; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric-value { font-size: 1.5rem; }
  .balance-strip { flex-direction: column; }
  .balance-item { border-right: none; border-bottom: 1px solid var(--border); }
  .balance-item:last-child { border-bottom: none; }
  .coupon-table th:nth-child(3),
  .coupon-table td:nth-child(3) { display: none; }
}

/* ═══════════════════════════════════════════════════════════
   APP SHELL & SIDEBAR
═══════════════════════════════════════════════════════════ */

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar (collapsed by default, toggles via class) */
.sidebar {
  width: 60px;
  min-width: 60px;
  background: var(--navy-900);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow: visible;
  z-index: 300;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border-right: 1px solid rgba(255,255,255,0.07);
}
.sidebar.sidebar-expanded {
  width: 224px;
  min-width: 224px;
  overflow: visible;
}

/* Aplica tamanho expandido ANTES do JS inicializar (evita flicker ao navegar) */
html.sidebar-preload-expanded .sidebar {
  width: 224px;
  min-width: 224px;
  transition: none !important;
}
html.sidebar-preload-expanded .sidebar ~ .content-area {
  margin-left: 224px;
  transition: none !important;
}

/* ── Sidebar Inner Wrapper ── */
.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 11px;
  height: 64px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  white-space: nowrap;
  flex-shrink: 0;
  background: var(--navy-900);
  position: relative;
  z-index: 5;
  overflow: visible;
}
.sidebar:not(.sidebar-expanded) .sidebar-brand {
  border-radius: 0 8px 8px 0;
  width: 230px;
}
.sidebar.sidebar-expanded .sidebar-brand { width: 100%; gap: 11px; padding: 0 16px; border-radius: 0; }

.sidebar-logo {
  width: 38px; height: 38px;
  background: rgba(255,255,255,0.13);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
}

.sidebar-brand-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.sidebar-brand-sub {
  font-size: 0.64rem;
  color: rgba(255,255,255,0.38);
  display: block;
  margin-top: 2px;
}

.sidebar-section { padding: 18px 11px 6px; }

.sidebar-section-label {
  font-size: 0.63rem;
  font-weight: 700;
  color: rgba(255,255,255,0.28);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.sidebar:not(.sidebar-expanded) .sidebar-section-label { display: none; }

.sidebar-nav {
  list-style: none;
  padding: 6px 10px;
  flex: 1;
}

.sidebar-nav-item {
  margin-bottom: 2px;
  position: relative;
}

.sidebar-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: rgba(255,255,255,0.52);
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  position: relative;
}

.sidebar-nav-link svg { flex-shrink: 0; }

.sidebar-nav-link:hover {
  color: rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.08);
}

.sidebar-nav-link.active {
  color: #ffffff;
  background: rgba(255,255,255,0.12);
  font-weight: 600;
}
.sidebar-nav-link.active svg { opacity: 1 !important; }

/* Hide link text when collapsed */
.sidebar:not(.sidebar-expanded) .sidebar-link-text { display: none; }
.sidebar:not(.sidebar-expanded) .sidebar-nav-link > span { display: none; }

/* Center icons when collapsed */
.sidebar:not(.sidebar-expanded) .sidebar-nav-link {
  justify-content: center;
  padding: 10px 8px;
}

/* ── Sidebar Tooltip (positioned fixed via JS) ── */
.sidebar-tooltip {
  position: fixed;
  background: var(--navy-900, #0a0a0a);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 99999;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.1);
  transform: translateX(-4px);
}
.sidebar-tooltip.visible {
  opacity: 1;
  transform: translateX(0);
}
.sidebar-tooltip::before {
  content: '';
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-right-color: rgba(255,255,255,0.1);
}
.sidebar-tooltip::after {
  content: '';
  position: absolute;
  right: calc(100% - 1px);
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-right-color: var(--navy-900, #0a0a0a);
}

.sidebar-footer {
  padding: 14px 11px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-footer-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.72rem;
  color: rgba(255,255,255,0.35);
  white-space: nowrap;
}
.sidebar:not(.sidebar-expanded) .sidebar-footer-badge > span:not([style]) { display: none; }
.sidebar:not(.sidebar-expanded) .sidebar-footer-badge { justify-content: center; }
.sidebar:not(.sidebar-expanded) .sidebar-footer { padding: 14px 6px; }

/* ── Sidebar Toggle Button ── */
.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 40px; height: 40px;
  margin: 8px auto;
  padding: 0;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-md);
  cursor: pointer;
  color: rgba(255,255,255,0.4);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 500;
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}
.sidebar-toggle:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
  border-color: rgba(255,255,255,0.15);
}
.sidebar-toggle svg { flex-shrink: 0; transition: transform 0.25s ease; }
.sidebar-expanded .sidebar-toggle { width: calc(100% - 20px); margin: 8px 10px; }
.sidebar-expanded .sidebar-toggle svg { transform: rotate(180deg); }
.sidebar-toggle-text { margin-left: 2px; }
.sidebar:not(.sidebar-expanded) .sidebar-toggle-text { display: none; }

/* ── Content Area ── */
.content-area {
  flex: 1;
  margin-left: 60px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar-expanded ~ .content-area { margin-left: 224px; }

/* Adjust existing header to work inside content-area */
.content-area .header {
  position: sticky;
  top: 0;
  width: 100%;
}

/* ═══════════════════════════════════════════════════════════
   DASHBOARD STYLES
═══════════════════════════════════════════════════════════ */

/* Period filter bar */
.period-filter-bar {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}

.period-filter-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

.period-presets {
  display: flex;
  gap: 4px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.period-btn {
  padding: 6px 14px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.79rem;
  font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

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

.period-btn.active {
  background: #ffffff;
  color: var(--navy-900);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

.period-custom {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.period-custom input[type="date"] {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 6px 11px;
  font-family: inherit;
  font-size: 0.82rem;
  color: var(--text-primary);
  outline: none;
  background: #ffffff;
  transition: var(--transition);
  cursor: pointer;
}

.period-custom input[type="date"]:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(26,26,26,0.1);
}

.period-sep { font-size: 0.8rem; color: var(--text-muted); }

/* Dashboard summary cards */
.dash-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: var(--sp-7);
  margin-bottom: var(--sp-9);
}

.dash-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-8);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  animation: fadeUp 0.4s ease both;
  display: flex;
  flex-direction: column;
  gap: var(--sp-7);
}

.dash-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.dash-card-coupon { border-left: 4px solid var(--indigo); }
.dash-card-coupon .dash-card-value { color: var(--indigo); }

.dash-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.dash-card-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.dash-card-label {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  font-weight: var(--fw-medium);
  margin-bottom: var(--sp-2);
}

.dash-card-value {
  font-size: var(--fs-xl);
  font-weight: var(--fw-extrabold);
  color: var(--text-primary);
  letter-spacing: -0.04em;
  line-height: 1;
}

.dash-card-value.money { font-size: var(--fs-xl); letter-spacing: -0.03em; }

.dash-card-sub {
  font-size: 0.73rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.rate-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: #f0f0f0;
  color: #333333;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 700;
  border: 1px solid #bbbbbb;
  white-space: nowrap;
}

/* Chart container */
.dash-chart-box {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 24px;
  animation: fadeUp 0.5s ease 0.1s both;
}

.dash-chart-header {
  padding: 16px 22px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dash-chart-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.dash-chart-sub {
  font-size: 0.73rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.dash-chart-body {
  padding: 20px 22px;
  position: relative;
}

/* Breakdown table */
.dash-table-container {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  animation: fadeUp 0.5s ease 0.15s both;
}

.dash-table-header {
  background: var(--navy-900);
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dash-table-title { font-size: var(--fs-md); font-weight: var(--fw-bold); color: #ffffff; letter-spacing: -0.01em; }
.dash-table-sub { font-size: var(--fs-xs); color: rgba(255,255,255,0.45); margin-top: var(--sp-1); }

.dash-table {
  width: 100%;
  border-collapse: collapse;
}

.dash-table thead tr {
  background: #f9fafb;
  border-bottom: 1px solid var(--border);
}

.dash-table th {
  padding: var(--sp-5) var(--sp-7);
  text-align: left;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  white-space: nowrap;
}

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

.dash-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
  animation: fadeIn 0.25s ease both;
}

.dash-table tbody tr:last-child { border-bottom: none; }
.dash-table tbody tr:hover { background: #f9fafb; }

.dash-table td {
  padding: var(--sp-6) var(--sp-7);
  font-size: var(--fs-base);
  color: var(--text-primary);
  vertical-align: middle;
}

/* Rank */
.rank-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  color: var(--text-muted);
  flex-shrink: 0;
}

.rank-num.gold   { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.rank-num.silver { background: #f3f4f6; color: #6b7280; border-color: #d1d5db; }
.rank-num.bronze { background: #fef9c3; color: #713f12; border-color: #fde68a; }

/* Coupon cell in dash table */
.dcoupon-name {
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  margin-bottom: var(--sp-1);
}

.dcoupon-code {
  display: inline-flex;
  background: var(--bg-base);
  border: 1px solid var(--border-strong);
  border-radius: var(--sp-2);
  padding: var(--sp-1) var(--sp-4);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  font-family: 'SFMono-Regular', 'Consolas', monospace;
  color: var(--navy-900);
  letter-spacing: 0.04em;
}

/* Progress bar */
.progress-wrap {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  min-width: 120px;
}

.progress-bar {
  flex: 1;
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--navy-900), #555555);
  transition: width 0.8s cubic-bezier(0.4,0,0.2,1);
}

.progress-pct {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-weight: var(--fw-medium);
  min-width: 34px;
  text-align: right;
}

/* Money values */
.money-val { font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; }
.commission-val { font-weight: var(--fw-bold); color: var(--navy-900); font-variant-numeric: tabular-nums; }
.dval-tag { display: inline-block; padding: var(--sp-1) var(--sp-5); background: var(--indigo-50); color: var(--indigo-700); border-radius: 999px; font-size: var(--fs-sm); font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; }

/* Truncation notice */
.truncated-notice {
  padding: var(--sp-5) var(--sp-8);
  background: #fffbeb;
  border-top: 1px solid #fde68a;
  font-size: var(--fs-base);
  color: #92400e;
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}

/* Dash loading/empty */
.dash-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-7);
  padding: var(--sp-12) var(--sp-9);
  color: var(--text-muted);
  font-size: var(--fs-base);
}

.dash-empty {
  text-align: center;
  padding: var(--sp-12) var(--sp-9);
  color: var(--text-secondary);
}

.dash-empty-icon { font-size: var(--fs-3xl); margin-bottom: var(--sp-7); opacity: 0.4; }
.dash-empty h3 { font-size: var(--fs-lg); font-weight: var(--fw-semibold); color: var(--text-primary); margin-bottom: var(--sp-4); }
.dash-empty p { font-size: var(--fs-base); color: var(--text-muted); }

/* Sidebar responsive */
@media (max-width: 900px) {
  .sidebar { width: 50px; min-width: 50px; }
  .sidebar.sidebar-expanded { width: 200px; min-width: 200px; }
  .sidebar:not(.sidebar-expanded) .sidebar-brand { padding: 0 4px; justify-content: center; width: 210px; }
  .sidebar:not(.sidebar-expanded) .sidebar-logo { width: 32px; height: 32px; }
  .sidebar:not(.sidebar-expanded) .sidebar-nav-link { padding: 8px; justify-content: center; }
  .sidebar.sidebar-expanded .sidebar-brand { padding: 0 12px; }
  .content-area { margin-left: 50px; }
  .sidebar-expanded ~ .content-area { margin-left: 200px; }
  html.sidebar-preload-expanded .sidebar { width: 200px; min-width: 200px; }
  html.sidebar-preload-expanded .sidebar ~ .content-area { margin-left: 200px; }
}

@media (max-width: 640px) {
  .sidebar { display: none; }
  .content-area { margin-left: 0; }
}

/* ─── Integration Multi-Select ─── */
.integ-select-wrap {
  position: relative;
  width: 100%;
  font-family: 'Inter', sans-serif;
}
.integ-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-5) var(--sp-7);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #ffffff;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  user-select: none;
  min-height: 42px;
}
.integ-select-trigger:hover {
  border-color: var(--border-focus);
}
.integ-select-trigger.open {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(26,26,26,0.1);
}
.integ-select-trigger.open .integ-select-caret {
  transform: rotate(180deg);
}
.integ-select-label {
  font-size: var(--fs-base);
  color: var(--text-secondary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.integ-select-label.has-selection {
  color: var(--text-primary);
  font-weight: var(--fw-medium);
}
.integ-select-caret {
  font-size: 0.58rem;
  color: var(--text-muted);
  transition: transform 0.18s;
  flex-shrink: 0;
}
.integ-select-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 8px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 100;
  display: none;
  overflow: hidden;
  animation: intSelFade 0.15s ease-out;
}
.integ-select-dropdown.open { display: block; }
@keyframes intSelFade {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.integ-select-option {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  padding: var(--sp-5) var(--sp-7);
  cursor: pointer;
  transition: background 0.1s;
  border-bottom: 1px solid var(--border);
}
.integ-select-option:last-child { border-bottom: none; }
.integ-select-option:hover { background: var(--bg-hover); }
.integ-select-option.selected {
  background: var(--indigo-light);
}
.integ-select-logo {
  width: 20px;
  height: 20px;
  object-fit: contain;
  border-radius: 3px;
  flex-shrink: 0;
}
.integ-select-fallback {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  color: #ffffff;
  flex-shrink: 0;
}
.integ-select-option span:nth-child(2) {
  flex: 1;
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  color: var(--text-primary);
}
.integ-select-check {
  width: 18px;
  height: 18px;
  border-radius: var(--sp-2);
  border: 2px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.55rem;
  font-weight: var(--fw-bold);
  color: transparent;
  flex-shrink: 0;
  transition: all 0.15s;
}
.integ-select-option.selected .integ-select-check {
  background: var(--indigo);
  border-color: var(--indigo);
  color: #ffffff;
}
.integ-select-option.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ─── Date Fields ─── */
.date-field-group {
  min-width: 0;
}
.date-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.date-input-row input[type="date"] {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm, 8px);
  padding: 9px 12px;
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #ffffff;
  appearance: none;
  -webkit-appearance: none;
}
.date-input-row input[type="date"]:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(26,26,26,0.1);
}
.date-input-row input[type="date"]:invalid {
  color: var(--text-placeholder);
}
.date-input-row .btn-sm {
  padding: 7px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.date-input-row .btn-sm.active {
  background: var(--indigo-light);
  border-color: var(--indigo);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.date-field-group.full-width .date-input-row {
  max-width: 100%;
}
.date-field-group.full-width .date-input-row input[type="date"] {
  max-width: 260px;
}

/* ═══════════════════════════════════════════════════════════
   BAGY CUPONS — Admin Impersonate Bar
═══════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════
   BAGY CUPONS — BackOffice User Selector (no header)
═══════════════════════════════════════════════════════════ */

.admin-selector-wrap {
  position: relative;
  display: none;
  align-items: center;
  margin-left: 8px;
  font-family: 'Inter', sans-serif;
}
.admin-selector-wrap.visible { display: inline-flex; }

.admin-selector-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, #0a0a0a, #2a2a2a);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, box-shadow 0.15s;
  height: 30px;
  font-family: inherit;
  white-space: nowrap;
}
.admin-selector-btn:hover {
  box-shadow: 0 2px 8px rgba(10,10,10,0.25);
}
.admin-selector-btn:active { opacity: 0.85; }
.admin-selector-btn .user-avatar-initials {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  color: #ffffff;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  flex-shrink: 0;
}
.admin-selector-btn .user-selector-name {
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #ffffff;
}
.admin-selector-btn .user-selector-role {
  font-size: 0.55rem;
  color: rgba(255,255,255,0.45);
  border: 1px solid rgba(255,255,255,0.15);
  padding: 0 5px;
  border-radius: 100px;
  background: rgba(255,255,255,0.06);
  text-transform: uppercase;
  line-height: 1.5;
}
.admin-selector-btn .user-selector-caret {
  font-size: 0.5rem;
  color: rgba(255,255,255,0.45);
  margin-left: 1px;
}
.admin-selector-btn .admin-badge-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #f59e0b;
  flex-shrink: 0;
}
.admin-selector-wrap .user-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 230px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 40px rgba(0,0,0,0.15);
  z-index: 10000;
  display: none;
  padding: 6px 0;
  animation: fadeUp 0.18s ease-out;
}
.admin-selector-wrap .user-dropdown-menu.open { display: block; }
.admin-selector-wrap .user-dropdown-item {
  display: flex;
  flex-direction: column;
  padding: 7px 14px;
  cursor: pointer;
  transition: background 0.12s;
  text-align: left;
  border: none;
  background: none;
  width: 100%;
  font-family: inherit;
}
.admin-selector-wrap .user-dropdown-item:hover { background: var(--bg-hover); }
.admin-selector-wrap .user-dropdown-item.active { background: var(--navy-50); }
.admin-selector-wrap .user-dropdown-item.active .user-dropdown-item-name { color: var(--indigo); }
.admin-selector-wrap .user-dropdown-item-name { font-size: 0.8rem; font-weight: 600; color: var(--text-primary); }
.admin-selector-wrap .user-dropdown-item-role { font-size: 0.65rem; color: var(--text-muted); margin-top: 1px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }
.admin-selector-wrap .user-dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }
.admin-selector-wrap .user-dropdown-header { padding: 6px 14px 4px; font-size: 0.65rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }

/* ── Painél (Operador) ── */
.painel-coupon-info {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.painel-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}
.painel-info-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.painel-info-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.painel-info-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}
.painel-filter-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.painel-filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.painel-filter-group label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.painel-filter-group input[type="date"] {
  padding: 7px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.82rem;
  background: var(--input-bg);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s;
}
.painel-filter-group input[type="date"]:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(26,26,26,0.12);
}

.painel-top-row {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
  align-items: stretch;
}
.painel-top-row .painel-coupon-info {
  flex: 1;
  margin-bottom: 0;
}
.painel-cards-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 280px;
}
.painel-cards-col .dash-card {
  margin: 0;
}
.painel-cards-col .dash-card-value {
  font-size: 1.15rem;
}

