/* ═══════════════════════════════════════════════════════════════
   Finance Module — Studio Meus Cílios
   finance.css  (module-only styles, no global overrides)
   ═══════════════════════════════════════════════════════════════ */

/* Local aliases for module — mapped from project's :root vars */
#tab-financeiro {
  --bordeaux-dark:   var(--rose-deep, #6B1E3A);
  --bordeaux-mid:    var(--rose-mid, #9B3D5F);
  --rose-gold:       var(--gold, #C9956A);
  --rose-gold-light: var(--gold-light, #E8C9A8);
  --beige:           var(--creme-dark, #F0E8E0);
  --warm-gray:       var(--gray, #8B6E6A);
  --text:            var(--brown, #3D1F0D);
  --border:          var(--creme-dark, #F0E8E0);
  --card:            var(--white, #FFFFFF);
  --bg:              var(--creme, #FDF8F4);
  --radius:          14px;
  --shadow:          0 1px 3px rgba(74,18,40,.06), 0 6px 20px rgba(74,18,40,.08);
}

/* ── Finance Wrap ───────────────────────────────────────────────── */
.finance-wrap {
  padding: 28px 0 56px;
}

/* ── Section card ───────────────────────────────────────────────── */
.fin-section {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--beige);
  padding: 24px 28px;
  margin-bottom: 20px;
}

.fin-section-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 19px;
  font-weight: 600;
  font-style: italic;
  color: var(--bordeaux-mid);
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--beige);
  display: flex;
  align-items: center;
  gap: 8px;
}

.fin-section-title svg { color: var(--rose-gold); flex-shrink: 0; }

/* ── Controls ───────────────────────────────────────────────────── */
.fin-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
  margin-bottom: 20px;
}

.fin-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 160px;
}

.fin-field label,
.fin-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--warm-gray);
}

.fin-select,
.fin-input {
  background: var(--beige);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-family: 'Jost', sans-serif;
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.fin-select:focus,
.fin-input:focus {
  border-color: var(--rose-gold);
  box-shadow: 0 0 0 3px rgba(201,149,107,.18);
}

/* ── Upload Zone ────────────────────────────────────────────────── */
.fin-upload-zone {
  border: 2px dashed var(--rose-gold-light);
  border-radius: 12px;
  background: var(--beige);
  padding: 32px 24px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  position: relative;
}

.fin-upload-zone:hover,
.fin-upload-zone.dragover {
  border-color: var(--rose-gold);
  background: #F0E2D5;
}

.fin-upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.fin-upload-icon { color: var(--rose-gold); margin-bottom: 10px; }
.fin-upload-label { font-size: 14px; color: var(--bordeaux-mid); font-weight: 500; margin-bottom: 4px; }
.fin-upload-sub   { font-size: 12px; color: var(--warm-gray); }

.fin-upload-or {
  text-align: center;
  font-size: 12px;
  color: var(--warm-gray);
  margin: 12px 0;
  position: relative;
}
.fin-upload-or::before,
.fin-upload-or::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 44%;
  height: 1px;
  background: var(--border);
}
.fin-upload-or::before { left: 0; }
.fin-upload-or::after  { right: 0; }

.fin-paste-area {
  width: 100%;
  min-height: 80px;
  padding: 12px;
  background: var(--beige);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: 'Jost', monospace;
  font-size: 12px;
  color: var(--text);
  resize: vertical;
  outline: none;
  transition: border-color .15s;
}
.fin-paste-area:focus {
  border-color: var(--rose-gold);
  box-shadow: 0 0 0 3px rgba(201,149,107,.18);
}

.fin-file-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #F0FFF5;
  border: 1px solid #AAF0C0;
  border-radius: 8px;
  margin-top: 10px;
  font-size: 12px;
  color: #1A6B3A;
}
.fin-file-info svg { color: #2E9E6B; flex-shrink: 0; }

/* Column mapping */
.fin-col-map {
  background: var(--beige);
  border-radius: 10px;
  padding: 16px 18px;
  margin-top: 14px;
  display: none;
}
.fin-col-map.visible { display: block; }
.fin-col-map-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--warm-gray);
  margin-bottom: 10px;
}
.fin-col-map-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}
.fin-col-map-grid .fin-field label { font-size: 11px; }
.fin-col-map-grid select {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 12px;
  color: var(--text);
  outline: none;
  width: 100%;
}

/* ── Alerts ─────────────────────────────────────────────────────── */
.fin-alerts-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}
.fin-alerts-bar:empty { display: none; }

.fin-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
}
.fin-alert svg { flex-shrink: 0; margin-top: 1px; }
.fin-alert--warning { background: #FFF8E7; color: #8A6200; border: 1px solid #F5D470; }
.fin-alert--danger  { background: #FFF0F0; color: #8B1A1A; border: 1px solid #F5AAAA; }
.fin-alert--success { background: #F0FFF5; color: #1A6B3A; border: 1px solid #AAF0C0; }

/* ── KPI Cards ──────────────────────────────────────────────────── */
.fin-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
@media (max-width: 900px) { .fin-kpis { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 500px) { .fin-kpis { grid-template-columns: 1fr; } }

.fin-card {
  background: var(--white);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(74,18,40,.05), 0 3px 10px rgba(74,18,40,.07);
  position: relative;
  overflow: hidden;
  border: 1px solid var(--beige);
}
.fin-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--card-accent, var(--rose-gold));
  border-radius: 12px 12px 0 0;
}
.fin-card--revenue { --card-accent: #2E9E6B; }
.fin-card--expense { --card-accent: #C9956B; }
.fin-card--result  { --card-accent: var(--bordeaux-mid); }
.fin-card--margin  { --card-accent: #6B6EC9; }

.fin-card-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--warm-gray);
  margin-bottom: 6px;
}
.fin-card-value {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--bordeaux-dark);
  line-height: 1.1;
}
.fin-card-value.negative { color: #8B1A1A; }
.fin-card-value.positive { color: #1A6B3A; }
.fin-card-sub { font-size: 11px; color: var(--warm-gray); margin-top: 4px; }

/* ── Charts ─────────────────────────────────────────────────────── */
.fin-charts-row {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
@media (max-width: 780px) { .fin-charts-row { grid-template-columns: 1fr; } }

.fin-chart-wrap {
  background: var(--white);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(74,18,40,.05), 0 3px 10px rgba(74,18,40,.07);
  border: 1px solid var(--beige);
}
.fin-chart-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--warm-gray);
  margin-bottom: 14px;
}

/* ── Sub-tabs ────────────────────────────────────────────────────── */
.fin-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
}
.fin-tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  padding: 10px 18px;
  font-family: 'Jost', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--warm-gray);
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
  letter-spacing: .03em;
}
.fin-tab-btn:hover { color: var(--bordeaux-mid); }
.fin-tab-btn.active {
  color: var(--bordeaux-mid);
  border-bottom-color: var(--rose-gold);
  font-weight: 600;
}
.fin-tab-panel { display: none; }
.fin-tab-panel.active { display: block; }

/* ── Transactions Table ─────────────────────────────────────────── */
.fin-table-wrap {
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.fin-table-wrap::-webkit-scrollbar { height: 6px; }
.fin-table-wrap::-webkit-scrollbar-track { background: var(--beige); }
.fin-table-wrap::-webkit-scrollbar-thumb { background: var(--rose-gold-light); border-radius: 3px; }
.fin-table-wrap::-webkit-scrollbar-thumb:hover { background: var(--rose-gold); }

.fin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 900px;
}
.fin-table thead th {
  background: var(--beige);
  color: var(--bordeaux-dark);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.fin-table tbody tr {
  border-bottom: 1px solid rgba(245,232,221,.7);
  transition: background .1s;
}
.fin-table tbody tr:hover { background: rgba(245,232,221,.4); }
.fin-table tbody tr:last-child { border-bottom: none; }
.fin-table td { padding: 7px 12px; vertical-align: middle; color: var(--text); }

/* Editable cells */
.fin-editable {
  outline: none;
  border-radius: 5px;
  padding: 4px 7px;
  display: inline-block;
  min-width: 60px;
  cursor: text;
  transition: background .12s, box-shadow .12s;
}
.fin-editable:hover  { background: rgba(201,149,107,.1); }
.fin-editable:focus  { background: var(--white); box-shadow: 0 0 0 2px var(--rose-gold); outline: none; }

/* Inline select/checkbox */
.fin-inline-select {
  background: transparent;
  border: none;
  border-radius: 5px;
  padding: 4px 6px;
  font-family: 'Jost', sans-serif;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  outline: none;
  transition: background .12s, box-shadow .12s;
  max-width: 160px;
  width: 100%;
}
.fin-inline-select:hover { background: rgba(201,149,107,.1); }
.fin-inline-select:focus { background: var(--white); box-shadow: 0 0 0 2px var(--rose-gold); }

.fin-inline-check {
  width: 16px; height: 16px;
  accent-color: var(--bordeaux-mid);
  cursor: pointer;
  display: block;
  margin: 0 auto;
}

/* Row highlights */
.row-uncategorized { background: #FFFDE7 !important; }
.row-uncategorized:hover { background: #FFF9C4 !important; }
.row-error  { background: #FFF0F0 !important; }
.row-error:hover { background: #FFE0E0 !important; }
.row-edited { box-shadow: inset 3px 0 0 var(--rose-gold); }

/* Value formatting */
.fin-val-positive { color: #1A6B3A; font-weight: 600; }
.fin-val-negative { color: #8B1A1A; font-weight: 600; }

/* ── DRE Table ──────────────────────────────────────────────────── */
.dre-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.dre-table th, .dre-table td { padding: 9px 14px; text-align: left; }

.dre-group-header td {
  background: var(--bordeaux-dark);
  color: var(--white);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: 8px 14px;
}
.dre-item-row:hover { background: rgba(245,232,221,.5); }
.dre-item-row td:first-child { padding-left: 28px; color: var(--warm-gray); }
.dre-subtotal { background: var(--beige); font-weight: 600; border-top: 1px solid var(--border); }
.dre-subtotal td:first-child { color: var(--bordeaux-dark); }

.dre-result td {
  background: var(--bordeaux-dark);
  color: var(--white);
  font-weight: 700;
  font-size: 14px;
}
.dre-result.positive td { background: #1A6B3A; color: #fff; }
.dre-result.negative td { background: #8B1A1A; color: #fff; }
.dre-margin-row { background: var(--beige); font-style: italic; color: var(--warm-gray); font-size: 12px; }

.dre-value-col { text-align: right; min-width: 120px; font-variant-numeric: tabular-nums; }

/* ── Recorrentes ────────────────────────────────────────────────── */
.fin-recorrentes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.fin-rec-group {
  background: var(--beige);
  border-radius: 10px;
  padding: 14px 16px;
}
.fin-rec-group-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--bordeaux-mid);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.fin-rec-group-total { font-size: 13px; color: var(--bordeaux-dark); font-style: normal; font-weight: 700; }
.fin-rec-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid rgba(245,232,221,.7);
  font-size: 12px;
  gap: 8px;
}
.fin-rec-item:last-child { border-bottom: none; }
.fin-rec-item-desc { color: var(--text); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fin-rec-item-val { font-weight: 600; white-space: nowrap; }

/* ── Compare ────────────────────────────────────────────────────── */
.fin-compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 700px) { .fin-compare-grid { grid-template-columns: 1fr; } }
.fin-compare-col-label {
  font-size: 13px; font-weight: 600; color: var(--bordeaux-mid);
  padding: 10px 14px; background: var(--beige);
  border-radius: 8px; margin-bottom: 12px; text-align: center;
}

/* ── Buttons ────────────────────────────────────────────────────── */
.fin-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: 9px;
  font-family: 'Jost', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .18s;
  letter-spacing: .02em;
  white-space: nowrap;
}
.fin-btn--primary   { background: var(--bordeaux-mid); color: var(--white); }
.fin-btn--primary:hover { background: var(--bordeaux-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(74,18,40,.25); }
.fin-btn--secondary { background: var(--beige); color: var(--bordeaux-dark); border: 1px solid var(--border); }
.fin-btn--secondary:hover { background: #EDD8C8; transform: translateY(-1px); }
.fin-btn--ghost { background: transparent; color: var(--warm-gray); border: 1px solid var(--border); padding: 7px 14px; font-size: 12px; }
.fin-btn--ghost:hover { background: var(--beige); color: var(--bordeaux-dark); }
.fin-btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }

.fin-export-row { display: flex; gap: 12px; flex-wrap: wrap; padding-top: 4px; }

/* ── Empty state ────────────────────────────────────────────────── */
.fin-empty { text-align: center; padding: 48px 24px; color: var(--warm-gray); font-size: 14px; }
.fin-empty svg { color: var(--rose-gold-light); margin-bottom: 12px; }
.fin-empty strong { display: block; font-size: 16px; font-weight: 600; color: var(--bordeaux-mid); margin-bottom: 6px; }

/* ── Misc ───────────────────────────────────────────────────────── */
.fin-divider { height: 1px; background: var(--border); margin: 18px 0; }

.fin-count-badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bordeaux-mid); color: var(--white);
  border-radius: 20px; padding: 1px 9px;
  font-size: 11px; font-weight: 600; margin-left: 8px; vertical-align: middle;
}

.fin-pagination {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 8px; margin-top: 14px; font-size: 12px; color: var(--warm-gray);
}

.fin-toast {
  position: fixed;
  bottom: 28px; right: 28px;
  background: var(--bordeaux-dark);
  color: var(--white);
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 13px; font-weight: 500;
  box-shadow: 0 4px 20px rgba(74,18,40,.3);
  z-index: 9999;
  opacity: 0;
  transform: translateY(10px);
  transition: all .25s;
  pointer-events: none;
}
.fin-toast.show { opacity: 1; transform: translateY(0); }

.fin-search-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.fin-search-input {
  flex: 1;
  min-width: 200px;
  background: var(--beige);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-family: 'Jost', sans-serif;
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
.fin-search-input:focus { border-color: var(--rose-gold); box-shadow: 0 0 0 3px rgba(201,149,107,.18); }

/* ── Grouped transactions ───────────────────────────────────────── */
.fin-grup-table td { vertical-align: middle; }
.fin-grup-desc { font-weight: 500; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fin-grup-count { text-align: center; color: var(--warm-gray, #8B6E6A); font-size: 12px; }
.fin-grup-total { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.fin-grup-cat select { width: 100%; }
.fin-grup-uncategorized { background: #FFFDE7 !important; }
.fin-grup-uncategorized:hover { background: #FFF9C4 !important; }
.fin-grup-row--selected { background: #FDF0F3 !important; }
.fin-grup-row--selected:hover { background: #FAE4E9 !important; }

/* ── Sortable headers ───────────────────────────────────────────── */
.fin-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.fin-sortable:hover { background: var(--creme-dark, #E8DDD5); }
.fin-sort-icon { font-size: 11px; color: var(--gold, #C9956A); margin-left: 2px; }

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .fin-section { padding: 18px 16px; }
  .fin-export-row { flex-direction: column; }
  .fin-btn { width: 100%; justify-content: center; }
  .fin-controls { flex-direction: column; }
  .fin-field { min-width: unset; width: 100%; }
  .fin-select, .fin-input { width: 100%; }
}
