/* FIPI / LIPI Smart Money Dashboard — KseAlert website (mobile parity) */

body.kse-fipi-lipi-page {
  background: #f4f7fb;
}

.kse-fipi-lipi-page .site-main {
  padding-bottom: 48px;
}

.fld-root {
  min-height: 320px;
}

.fld-chart-tooltip {
  position: fixed;
  z-index: 10050;
  pointer-events: none;
  background: #0f172a;
  color: #f8fafc;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.5;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
  max-width: 240px;
}

.fl-trend-chart-host,
.fl-sector-chart-host {
  display: block;
  width: 100%;
  background: #fafbfc;
  border-radius: 8px;
}

.fl-tab {
  cursor: pointer;
  font-family: inherit;
}

@media (min-width: 768px) {
  .fl-summary-grid {
    grid-template-columns: repeat(2, 1fr);
    max-width: 520px;
  }

  .fl-chip-row {
    max-width: 720px;
  }
}

/* FIPI / LIPI Smart Money & Sector Rotation */
.fl-page-wrap {
  padding: 12px;
  padding-bottom: 24px;
}

.fl-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.fl-tab {
  flex: 1;
  text-align: center;
  padding: 10px 8px;
  border-radius: 8px;
  border: 1px solid #dbeafe;
  background: #f8fbff;
  color: #1e40af;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}

.fl-tab.is-active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.fl-date-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 12px;
  margin-bottom: 10px;
  padding: 12px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
  width: fit-content;
  max-width: 100%;
}

.fl-date-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 0 0 168px;
  width: 168px;
  min-width: 0;
}

.fl-date-field label {
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  margin: 0;
}

/* Bootstrap sets date inputs to 206px × 21px — reset for this dashboard */
.kse-fipi-lipi-page .fl-date-field input[type="date"] {
  display: block;
  width: 100% !important;
  max-width: 100%;
  min-width: 0;
  height: 40px;
  min-height: 40px;
  margin: 0;
  padding: 0 12px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: #0f172a;
  line-height: normal;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  box-sizing: border-box;
  box-shadow: none;
  vertical-align: middle;
}

.kse-fipi-lipi-page .fl-date-field input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.7;
}

.kse-fipi-lipi-page .fl-date-field input[type="date"]:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.fl-date-apply {
  flex: 0 0 auto;
  padding: 0 18px;
  border-radius: 10px;
  border: none;
  background: #2563eb;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  height: 40px;
  min-height: 40px;
  margin: 0;
}

.fl-range-hint {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 12px;
}

/* Smart Money header */
.fl-smart-header {
  margin-bottom: 14px;
}

.fl-smart-title {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.25;
}

.fl-smart-sub {
  margin: 0 0 4px;
  font-size: 12px;
  color: #64748b;
}

.fl-data-meta {
  margin: 0;
  font-size: 11px;
  color: #94a3b8;
}

/* Tug-of-war card */
.fl-tug-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.fl-tug-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #334155;
  margin-bottom: 12px;
}

.fl-tug-bar-track {
  display: flex;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  gap: 2px;
  margin-bottom: 12px;
  background: #f1f5f9;
}

.fl-tug-bar-seg {
  min-width: 4%;
  transition: background 0.25s ease;
}

.fl-tug-bar-seg:first-child {
  border-radius: 999px 0 0 999px;
}

.fl-tug-bar-seg:last-child {
  border-radius: 0 999px 999px 0;
}

/* Inflow (buy) bar shades */
.fl-tug-bar--buy-strong {
  background: linear-gradient(90deg, #047857, #059669);
}

.fl-tug-bar--buy-weak {
  background: linear-gradient(90deg, #6ee7b7, #34d399);
}

/* Outflow (sell) bar shades */
.fl-tug-bar--sell-strong {
  background: linear-gradient(90deg, #991b1b, #dc2626);
}

.fl-tug-bar--sell-weak {
  background: linear-gradient(90deg, #fca5a5, #f87171);
}

.fl-tug-bar--neutral {
  background: #cbd5e1;
}

/* Legacy aliases (home widgets) */
.fl-tug-bar-inst {
  background: linear-gradient(90deg, #059669, #10b981);
  border-radius: 999px 0 0 999px;
  min-width: 4%;
}

.fl-tug-bar-ret {
  background: linear-gradient(90deg, #dc2626, #ef4444);
  border-radius: 0 999px 999px 0;
  min-width: 4%;
}

.fl-tug-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.fl-tug-stat {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 12px;
  border-left-width: 3px;
  border-left-style: solid;
}

.fl-tug-stat--buy-strong { border-left-color: #059669; }
.fl-tug-stat--buy-weak { border-left-color: #6ee7b7; }
.fl-tug-stat--sell-strong { border-left-color: #dc2626; }
.fl-tug-stat--sell-weak { border-left-color: #fca5a5; }
.fl-tug-stat--neutral { border-left-color: #cbd5e1; }

.fl-tug-stat-inst,
.fl-tug-stat-ret {
  /* Side label hooks only — border color comes from fl-tug-stat--* classes */
}

.fl-tug-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 4px;
}

.fl-tug-value {
  display: block;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

/* Stat chips */
.fl-chip-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.fl-chip {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px;
}

.fl-chip-k {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 4px;
}

.fl-chip-v {
  font-size: 12px;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.3;
}

.fl-chip-in { border-left: 3px solid #22c55e; }
.fl-chip-out { border-left: 3px solid #ef4444; }

.fl-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.fl-summary-compact {
  margin-bottom: 12px;
}

.fl-summary-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.fl-summary-card .label {
  font-size: 11px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.fl-summary-card .value {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
}

.fl-pos { color: #15803d; }
.fl-neg { color: #b91c1c; }

/* Chart legend — above canvas, high contrast */
.fl-chart-legend {
  display: flex;
  gap: 16px;
  margin-bottom: 10px;
  padding: 8px 10px;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.fl-leg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
}

.fl-leg-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.fl-leg-inst .fl-leg-dot {
  background: #059669;
  box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.2);
}

.fl-leg-ret .fl-leg-dot {
  background: #dc2626;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.2);
}

.fl-section-head {
  margin-bottom: 10px;
}

.fl-section-title {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 4px;
}

.fl-section-desc {
  margin: 0;
  font-size: 11px;
  color: #64748b;
  line-height: 1.4;
}

.fl-chart-block {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 14px;
}

.fl-trend-block .fl-trend-chart-host {
  display: block;
  width: 100%;
  min-height: 200px;
  border-radius: 8px;
  overflow: hidden;
}

/* Sector heatmap list */
.fl-sector-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fl-sector-item {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.fl-sector-item.is-selected {
  border-color: #93c5fd;
  box-shadow: 0 0 0 1px #bfdbfe;
}

.fl-sector-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.fl-sector-main {
  flex: 1;
  min-width: 0;
}

.fl-sector-name {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fl-flow-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.fl-pill-in {
  background: #dcfce7;
  color: #15803d;
}

.fl-pill-out {
  background: #fee2e2;
  color: #b91c1c;
}

.fl-sector-side {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.fl-spark {
  flex-shrink: 0;
  display: block;
}

.fl-sector-chevron {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s ease, background 0.2s ease, border-color 0.2s ease;
}

.fl-sector-chevron::after {
  content: "";
  display: block;
  width: 7px;
  height: 7px;
  border-right: 2px solid #64748b;
  border-bottom: 2px solid #64748b;
  transform: rotate(45deg);
  margin-top: -3px;
  transition: border-color 0.2s ease;
}

.fl-sector-item.is-open .fl-sector-chevron {
  transform: rotate(180deg);
  background: #eff6ff;
  border-color: #bfdbfe;
}

.fl-sector-item.is-open .fl-sector-chevron::after {
  border-color: #2563eb;
}

.fl-sector-item.is-selected .fl-sector-chevron {
  background: #eff6ff;
  border-color: #93c5fd;
}

.fl-sector-expand {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease;
  background: #f8fafc;
  border-top: 1px solid transparent;
}

.fl-sector-item.is-open .fl-sector-expand {
  max-height: 620px;
  border-top-color: #e2e8f0;
  padding: 10px 12px 12px;
}

.fl-sector-chart-block {
  margin-bottom: 12px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
}

.fl-sector-chart-label {
  padding: 8px 10px 4px;
  font-size: 11px;
  font-weight: 700;
  color: #475569;
}

.fl-sector-chart-host {
  min-height: 165px;
  width: 100%;
}

.fl-inv-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.fl-inv-cell {
  border-radius: 8px;
  padding: 8px;
  border: 1px solid rgba(15, 23, 42, 0.06);
}

.fl-inv-label {
  font-size: 10px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 4px;
}

.fl-inv-value {
  font-size: 12px;
  font-weight: 700;
}

.fl-sector-range-meta {
  margin-top: 10px;
  font-size: 11px;
  color: #64748b;
}

.fl-flow-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.fl-flow-badge.fl-inflow { background: #dcfce7; color: #15803d; }
.fl-flow-badge.fl-outflow { background: #fee2e2; color: #b91c1c; }

.fl-empty,
.fl-loading {
  padding: 24px 12px;
  text-align: center;
  color: #64748b;
  font-size: 14px;
}

/* Home dashboard */
.fl-home-summary { min-height: 48px; }

.fl-home-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.fl-home-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px;
}

.fl-home-card-fipi { border-top: 3px solid #2563eb; }
.fl-home-card-lipi { border-top: 3px solid #7c3aed; }

.fl-home-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
}

.fl-home-card-title {
  font-size: 13px;
  font-weight: 800;
  color: #0f172a;
}

.fl-home-card-date {
  font-size: 11px;
  color: #64748b;
  margin-bottom: 6px;
}

.fl-home-card-value {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

.fl-home-card-sub {
  font-size: 10px;
  color: #64748b;
  line-height: 1.3;
}

.fl-home-empty {
  padding: 12px;
  text-align: center;
  color: #64748b;
  font-size: 13px;
  grid-column: 1 / -1;
}

/* LIPI local category breakdown (under tug-of-war) */
.fl-lipi-breakdown {
  margin-bottom: 12px;
}

.fl-lipi-breakdown-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin-bottom: 8px;
}

.fl-lipi-chip-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.fl-lipi-chip-scroll::-webkit-scrollbar {
  display: none;
}

.fl-cat-chip {
  flex: 0 0 auto;
  min-width: 118px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #fff;
}

.fl-cat-chip-buy {
  border-top: 3px solid #059669;
}

.fl-cat-chip-sell {
  border-top: 3px solid #dc2626;
}

.fl-cat-chip-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: #64748b;
  margin-bottom: 4px;
  line-height: 1.2;
}

.fl-cat-chip-buy .fl-cat-chip-value {
  color: #059669;
}

.fl-cat-chip-sell .fl-cat-chip-value {
  color: #dc2626;
}

.fl-cat-chip-value {
  display: block;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
}

/* Logged-in workspace embed */
.kse-fipi-lipi-page.is-workspace {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.kse-fipi-lipi-page.is-workspace .kse-fipi-ws-head h1 {
  margin: 0 0 6px;
  font-size: 1.45rem;
  font-weight: 800;
  color: #0a2540;
}

.kse-fipi-lipi-page.is-workspace .kse-fipi-ws-section {
  padding-top: 0;
}

.kse-fipi-lipi-page.is-workspace .kse-fipi-ws-card {
  padding: 14px 16px 16px;
  margin: 0;
}

.kse-fipi-lipi-page.is-workspace .kse-fipi-ws-card .kse-section-inner.site-container {
  width: 100%;
  max-width: none;
  padding: 0;
}

.kse-fipi-lipi-page.is-workspace .fl-page-wrap {
  padding: 0;
}

.kse-fipi-lipi-page.is-workspace .kse-screener-note {
  margin-top: 12px;
  margin-bottom: 0;
}

@media (max-width: 640px) {
  .kse-fipi-lipi-page .fl-date-filter {
    width: 100%;
  }

  .kse-fipi-lipi-page .fl-date-field {
    flex: 1 1 100%;
    width: 100%;
  }

  .kse-fipi-lipi-page .fl-date-apply {
    width: 100%;
  }
}
