/* ==========================================================================
   FluxSales — "Esmeralda / Calm Fintech Ledger" design system
   Auto-loaded by Dash from ./assets. Every visual token lives here or in
   utils/theme.py so the three pages read as one typeset product.
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Inter+Tight:wght@600;700&display=swap');

:root {
  --page-bg: #f7faf9;
  --surface: #ffffff;
  --surface-alt: #f4f7f6;
  --border: #e5e7eb;
  --border-soft: #f1f3f5;
  --ink: #111827;
  --secondary: #6b7280;
  --muted: #9ca3af;
  --brand: #10b981;
  --brand-deep: #047857;
  --brand-soft: #ecfdf5;
  --indigo: #4f46e5;
  --indigo-soft: #eef2ff;
  --negative: #ef4444;
  --row-hover: #f6faf8;
  --sidebar-w: 240px;
  --radius: 16px;
  --radius-sm: 8px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Inter Tight", "Inter", -apple-system, sans-serif;
}

/* ----- reset ------------------------------------------------------------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--page-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11" 1;
  line-height: 1.5;
}
h1, h2, h3, h4, h5, p { margin: 0; }
a { text-decoration: none; color: inherit; }
.tnum { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1, "lnum" 1; }

/* ==========================================================================
   App shell — full width (embedded; host platform owns navigation)
   ========================================================================== */
.fx-main { min-height: 100vh; background: var(--page-bg); padding: 32px 40px; }
.fx-page { max-width: 1280px; margin: 0 auto; }

/* page header */
.fx-page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 26px; flex-wrap: wrap; }
.fx-page-title { font-family: var(--font-display); font-size: 24px; font-weight: 700; color: var(--ink); letter-spacing: -0.01em; }
.fx-page-subtitle { font-size: 13px; color: var(--muted); margin-top: 3px; }

/* ==========================================================================
   Segmented control (date filters)
   ========================================================================== */
.fx-seg {
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: 10px; padding: 3px; position: relative;
}
.fx-seg__btn {
  appearance: none; font-family: var(--font);
  font-size: 14px; font-weight: 500; color: var(--secondary);
  padding: 7px 14px; border: none; border-radius: var(--radius-sm);
  background: transparent; cursor: pointer; transition: all .15s ease;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.fx-seg__btn:hover { color: var(--ink); background: rgba(255,255,255,0.6); }
.fx-seg__btn.active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(16,24,40,0.06); }
.fx-seg__btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.fx-seg__btn .fx-icon { width: 15px; height: 15px; }

/* ==========================================================================
   Filters row + location dropdown
   ========================================================================== */
.fx-filters { display: inline-flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.fx-loc { display: inline-flex; align-items: center; gap: 8px; }
.fx-loc__label {
  font-size: 12px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap;
}
.fx-loc__select { min-width: 230px; font-size: 14px; }

/* dcc.Dropdown (react-select) tuned to the segmented-control look */
.fx-loc__select .Select-control {
  background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: 10px; min-height: 38px; box-shadow: none; cursor: pointer;
}
.fx-loc__select .Select-control:hover { border-color: #d1d5db; }
.fx-loc__select.is-focused:not(.is-open) > .Select-control {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(16,185,129,0.12);
}
.fx-loc__select .Select-placeholder,
.fx-loc__select .Select-value-label { line-height: 36px; color: var(--ink); }
.fx-loc__select .Select-placeholder { color: var(--muted); }
.fx-loc__select .Select-value { padding-left: 12px; padding-right: 34px; }
.fx-loc__select .Select-input { height: 36px; padding-left: 12px; }
.fx-loc__select .Select-menu-outer {
  border: 1px solid var(--border); border-radius: 10px; margin-top: 4px;
  box-shadow: 0 8px 24px rgba(16,24,40,0.10); overflow: hidden; z-index: 30;
}
.fx-loc__select .Select-option { font-size: 14px; color: var(--ink); padding: 9px 12px; }
.fx-loc__select .Select-option.is-focused { background: var(--brand-soft); }
.fx-loc__select .Select-option.is-selected { background: var(--surface-alt); font-weight: 600; }
.fx-loc__select .Select-arrow-zone { padding-right: 10px; }
.fx-loc__select .Select-clear-zone { color: var(--muted); }

/* ==========================================================================
   KPI cards
   ========================================================================== */
.fx-kpi-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.fx-kpi {
  position: relative; display: flex; gap: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 22px;
  box-shadow: 0 1px 2px rgba(16,24,40,0.04);
  transition: border-color .16s ease, transform .16s ease, box-shadow .16s ease;
}
.fx-kpi:hover { border-color: #d1d5db; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(16,24,40,0.06); }
.fx-kpi__icon { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.fx-kpi__icon--money { background: var(--brand-soft); }
.fx-kpi__icon--count { background: var(--indigo-soft); }
.fx-kpi__body { min-width: 0; }
.fx-kpi__label-row { display: flex; align-items: center; gap: 5px; }
.fx-kpi__label { font-size: 13px; font-weight: 500; color: var(--secondary); }
.fx-kpi__hint { display: inline-flex; align-items: center; justify-content: center; width: 14px; height: 14px; border-radius: 50%; background: var(--surface-alt); cursor: help; flex: 0 0 auto; }
.fx-kpi__hint::after { content: "i"; font-size: 9px; font-weight: 700; font-family: var(--font); color: var(--muted); line-height: 1; }
.fx-kpi__value {
  font-family: var(--font-display); font-size: 29px; font-weight: 700; color: var(--ink);
  letter-spacing: -0.01em; margin-top: 6px; line-height: 1.15;
  font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1, "lnum" 1;
}
.fx-kpi__value .kpi-prefix { font-size: 18px; font-weight: 600; color: var(--muted); margin-right: 2px; }
.fx-kpi--sm .fx-kpi__value { font-size: 21px; }
.fx-kpi--hero { }
.fx-kpi--hero::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand); }
.fx-kpi--hero .fx-kpi__value { color: var(--brand-deep); }

/* ==========================================================================
   Cards, section headers, charts
   ========================================================================== */
.fx-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; margin-bottom: 20px; box-shadow: 0 1px 2px rgba(16,24,40,0.04); }
.fx-card--table { padding: 0; overflow: hidden; }
.fx-card--table .fx-section { padding: 22px 22px 14px; margin-bottom: 0; }

.fx-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.fx-grid-2 > .fx-card { margin-bottom: 0; }

.fx-section { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.fx-section__text { min-width: 0; }
.fx-eyebrow { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--brand-deep); margin-bottom: 4px; }
.fx-section__title { font-size: 16px; font-weight: 600; color: var(--ink); }
.fx-section__subtitle { font-size: 13px; color: var(--muted); margin-top: 2px; }
.fx-section__legend { display: flex; align-items: center; gap: 14px; flex: 0 0 auto; padding-top: 2px; }
.fx-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--secondary); white-space: nowrap; }
.fx-chip__dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.fx-graph { width: 100%; }

/* empty state */
.fx-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 48px 20px; text-align: center; }
.fx-empty__icon { width: 44px; height: 44px; border-radius: 12px; background: var(--surface-alt); display: flex; align-items: center; justify-content: center; }
.fx-empty__msg { font-size: 14px; color: var(--muted); }

/* ==========================================================================
   DataTable overrides (react DataTable + native filter/sort)
   ========================================================================== */
.fx-table-wrap .dash-spreadsheet-container { border: none !important; }
.fx-table-wrap .dash-spreadsheet-inner table { border-collapse: collapse; width: 100%; }
.fx-table-wrap .dash-cell, .fx-table-wrap .dash-header { font-family: var(--font) !important; }
.fx-table-wrap .dash-cell.column-1, .fx-table-wrap td.dash-cell:first-of-type { font-weight: 500; }
.fx-table-wrap .column-header-name { font-family: var(--font) !important; }
.fx-table-wrap .dash-spreadsheet tr:hover td.dash-cell { background-color: var(--row-hover, #f6faf8) !important; }
/* native filter inputs */
.fx-table-wrap input.dash-filter--case, .fx-table-wrap .dash-filter input {
  border: 1px solid var(--border) !important; border-radius: 8px !important;
  padding: 5px 8px !important; font-family: var(--font) !important; font-size: 13px !important;
  color: var(--ink) !important; background: var(--surface) !important;
}
.fx-table-wrap .dash-filter input:focus { border-color: var(--brand) !important; box-shadow: 0 0 0 3px var(--brand-soft) !important; outline: none !important; }
/* pagination */
.fx-table-wrap .previous-next-container .page-number, .fx-table-wrap .dash-table-container .previous-next-container { color: var(--secondary) !important; }
.fx-table-wrap button.previous-page, .fx-table-wrap button.next-page, .fx-table-wrap button.first-page, .fx-table-wrap button.last-page { color: var(--secondary) !important; border-radius: 6px !important; }

/* ==========================================================================
   Rango date-range popover + DatePickerRange
   ========================================================================== */
.fx-popover {
  display: none; position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: 0 12px 32px rgba(16,24,40,0.12);
  padding: 16px; min-width: 300px; z-index: 1000;
}
.fx-popover.open { display: block; animation: fx-pop .15s ease; }
@keyframes fx-pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.fx-popover__footer { display: flex; justify-content: flex-end; margin-top: 8px; }

.fx-btn-primary {
  appearance: none; border: none; cursor: pointer;
  background: var(--brand); color: #fff; font-family: var(--font);
  font-size: 14px; font-weight: 600; padding: 8px 16px; border-radius: 8px;
  transition: background .15s ease;
}
.fx-btn-primary:hover { background: #059669; }

/* react-dates restyle */
.DateInput_input { font-family: var(--font) !important; font-size: 14px !important; color: var(--ink) !important; border-bottom: 2px solid transparent !important; }
.DateInput_input__focused { border-bottom: 2px solid var(--brand) !important; }
.DateRangePickerInput { border: 1px solid var(--border) !important; border-radius: 8px !important; overflow: hidden; }
.CalendarDay__selected, .CalendarDay__selected:active, .CalendarDay__selected:hover { background: var(--brand) !important; border-color: var(--brand) !important; color: #fff !important; }
.CalendarDay__selected_span { background: var(--brand-soft) !important; border-color: var(--brand-soft) !important; color: var(--brand-deep) !important; }
.CalendarDay__hovered_span, .CalendarDay__hovered_span:hover { background: var(--brand-soft) !important; border-color: var(--brand-soft) !important; color: var(--brand-deep) !important; }
.CalendarDay__today { border: 1px solid var(--brand) !important; }
.DayPickerKeyboardShortcuts_show__bottomRight { display: none !important; }

/* ==========================================================================
   Scrollbars
   ========================================================================== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #dfe3e1; border-radius: 8px; border: 2px solid var(--page-bg); }
::-webkit-scrollbar-thumb:hover { background: #cdd3d0; }
::-webkit-scrollbar-track { background: transparent; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1024px) {
  .fx-main { padding: 24px 20px; }
  .fx-grid-2 { grid-template-columns: 1fr; }
  .fx-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .fx-main { padding: 20px 14px; }
  .fx-kpi-grid { grid-template-columns: 1fr; }
  .fx-page-header { align-items: flex-start; }
}
