/*******************************************************
 * chart.css
 * -----------------------------------------------------
 * Visual summary and rule impact styling.
 *
 * Responsibilities:
 * - Quick Visual Summary cards
 * - Rule Impact cards
 * - Adjustment Flow card
 * - Chart legends, callouts, B&B bars
 * - External Chart.js tooltip
 *******************************************************/


/*******************************************************
 * CHART VARIABLES
 *******************************************************/

:root {
  --color-card-border: #dfe8e2;
  --color-callout: #eef8f1;
  --color-callout-border: #cce6d4;

  --green: #138a36;
  --dark-green: #006b35;
  --light-green: #8bc995;
  --blue: #2f78bd;
  --gold: #f5b80b;
  --orange: #ea8a00;
  --grey: #8f8f8f;
  --red: #c0392b;
  --pale-red: #f4a6a0;
  --cgt-gold: #d4af37;
}


/*******************************************************
 * CARD HEADERS
 *******************************************************/

.quick-visual-card > h2,
.rule-visual-card > h2,
.adjustment-flow-card > h2 {
  margin: -30px -30px 14px -30px;
  padding: 14px 22px;
  background: var(--color-bg-light);
  border-bottom: 3px solid var(--color-accent);
  border-radius: 8px 8px 0 0;
  color: var(--color-primary);
  font-size: 1.25rem;
  font-weight: 700;
}

.rule-card-subtitle {
  margin: -6px 0 10px;
  color: #333;
  font-size: 12px;
}


/*******************************************************
 * GRID LAYOUTS
 *******************************************************/

.quick-visual-grid,
.rule-visual-grid {
  display: grid;
  gap: 10px;
}

.quick-visual-grid,
.rule-visual-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.28fr) minmax(0, 1fr);
}


/*******************************************************
 * TILE CONTAINERS
 *******************************************************/

.visual-tile {
  min-width: 0;
  padding: 14px 16px;
  overflow: visible;
  background: #fff;
  border: 1px solid var(--color-card-border);
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.quick-tile,
.rule-visual-card .visual-tile {
  display: flex;
  flex-direction: column;
}

.quick-tile {
  min-height: 235px;
}

.rule-visual-card .visual-tile {
  min-height: 275px;
}

.rule-visual-card .visual-tile > :not(.tile-callout):not(.tile-note) {
  flex-shrink: 0;
}

.rule-visual-card .tile-callout,
.rule-visual-card .tile-note {
  margin-top: auto;
}


/*******************************************************
 * TILE HEADER
 *******************************************************/

.tile-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.tile-header h3 {
  margin: 0;
  color: var(--color-primary);
  font-size: 14px;
  font-weight: 700;
}

.tile-header p {
  margin: 3px 0 0;
  color: #333;
  font-size: 11px;
  line-height: 1.25;
}


/*******************************************************
 * CHART BOXES
 *******************************************************/

.chart-box {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}

.quick-donut-layout {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 6px;
  margin-bottom: 16px;
}

.quick-donut-box {
  width: 158px;
  height: 158px;
  overflow: visible;
}

.waterfall-chart-box {
  height: 165px;
}


/*******************************************************
 * LEGENDS
 *******************************************************/

.legend-list,
.money-legend {
  display: flex;
  flex-direction: column;
}

.legend-list {
  gap: 13px;
}

.money-legend {
  gap: 8px;
  margin-bottom: 12px;
}

.legend-row {
  display: grid;
  grid-template-columns: 13px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  font-size: 11px;
  line-height: 1.25;
}

.money-row {
  display: grid;
  grid-template-columns: 13px auto 1fr;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  line-height: 1.25;
}

.legend-row strong {
  display: block;
  margin-bottom: 3px;
}

.money-row span:last-child {
  text-align: left;
}

.legend-swatch {
  width: 13px;
  height: 13px;
  margin-top: 2px;
  border-radius: 3px;
}

.swatch-green {
  background: var(--green);
}

.swatch-red {
  background: var(--red);
}

.swatch-blue {
  background: var(--blue);
}

.swatch-gold {
  background: var(--gold);
}

.swatch-grey {
  background: var(--grey);
}

.swatch-dark-green {
  background: var(--dark-green);
}

.swatch-light-green {
  background: var(--light-green);
}

.swatch-orange {
  background: var(--orange);
}

.swatch-pale-red {
  background: var(--pale-red);
}


/*******************************************************
 * CALLOUTS
 *******************************************************/

.tile-callout {
  width: 92%;
  margin: 10px auto 0;
  padding: 10px 12px;
  background: var(--color-callout);
  border: 1px solid var(--color-callout-border);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
}

.callout-subtext {
  margin-top: 3px;
  color: #2e4a38;
  font-size: 11px;
  font-weight: 400;
}

.tile-callout.cgt-highlight {
  background: rgba(212, 175, 55, 0.08);
  border-color: rgba(212, 175, 55, 0.4);
}

.tile-callout.loss-carryforward-highlight {
  background: rgba(192, 57, 43, 0.07);
  border-color: rgba(192, 57, 43, 0.28);
  color: #7f1d1d;
}

.warning-callout {
  background: #fff9e6;
  border-color: #f2dea0;
  color: #8a6500;
}

.tile-note {
  margin-top: 10px;
  padding: 8px 10px;
  background: #f3faf5;
  border: 1px solid #d9eadf;
  border-radius: 6px;
  font-size: 11px;
}


/*******************************************************
 * RULE IMPACT DETAILS
 *******************************************************/

.recon-equation {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.bnb-impact {
  margin-bottom: 10px;
  font-size: 14px;
  text-align: center;
}

.big-number {
  margin: 12px 0 0;
  font-size: 22px;
  font-weight: 700;
  text-align: center;
}

.big-number-label {
  margin-bottom: 14px;
  font-size: 12px;
  text-align: center;
}


/*******************************************************
 * B&B LOSS MOVEMENT
 *******************************************************/

.bar-label {
  margin: 6px 0 4px;
  color: #555;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}

.stacked-money-bar {
  display: flex;
  height: 50px;
  margin-bottom: 14px;
  overflow: hidden;
  background: #f3f3f3;
  border-radius: 6px;
}

.bar-segment {
  display: grid;
  place-items: center;
  min-width: 40px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.bar-released {
  background: var(--green);
}

.bar-deferred {
  background: var(--orange);
}

.bnb-tooltip-bar .bar-segment {
  position: relative;
  transition: filter 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.bnb-tooltip-bar .bar-segment:hover {
  z-index: 2;
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.65);
}


/*******************************************************
 * ADJUSTMENT FLOW
 *******************************************************/

.adjustment-flow-card .visual-tile {
  padding: 12px 16px;
}

.adjustment-flow-card .tile-header {
  margin-bottom: 4px;
}

.adjustment-flow-card .tile-callout {
  margin-top: 6px;
}

.standalone-flow-tile {
  width: auto;
}


/*******************************************************
 * EXTERNAL CHART TOOLTIP
 *******************************************************/

.cg1-chart-tooltip {
  position: absolute;
  z-index: 99999;
  max-width: 220px;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid #d9e4dd;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  color: #333;
  font-size: 11px;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -100%);
  transition: opacity 0.08s ease;
}

.cg1-tooltip-title {
  margin-bottom: 4px;
  color: var(--color-primary);
  font-weight: 700;
}

.cg1-tooltip-body {
  color: #333;
}

/*******************************************************
 * RESULT CARD HEADERS
 *******************************************************/

#summary .card > h2 {
  margin: -30px -30px 20px -30px;
  padding: 15px 20px;
  background: var(--color-bg-light);
  color: var(--color-primary);
  border-bottom: 3px solid var(--color-accent);
  font-size: 1.3rem;
  font-weight: bold;
  border-radius: 8px 8px 0 0;
}

/*******************************************************
 * RESPONSIVE
 *******************************************************/

@media (max-width: 980px) {
  .quick-visual-grid,
  .rule-visual-grid {
    grid-template-columns: 1fr;
  }

  .quick-donut-layout,
  .breakdown-layout {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .legend-list {
    width: 100%;
  }
}
/*******************************************************
 * TRADING ACTIVITY OVERVIEW
 *******************************************************/

.trading-activity-card .visual-tile {
  min-height: 285px;
}

.activity-bar-chart-box {
  height: 142px;
  width: 100%;
}

.chart-empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 132px;
  padding: 12px;
  background: #f8fbf9;
  border: 1px dashed #c8d9d0;
  border-radius: 6px;
  color: #52635a;
  font-size: 12px;
  line-height: 1.35;
  text-align: center;
  box-sizing: border-box;
}

.fx-placeholder-state {
  background: #fffbea;
  border-color: #f2dea0;
  color: #7a6300;
}

.bnb-lifecycle-mini-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.28fr) minmax(0, 1fr);
  gap: 6px;
  margin: 8px 0 4px;
}

.bnb-lifecycle-mini-grid div {
  min-width: 0;
  padding: 6px 5px;
  background: #f8fbf9;
  border: 1px solid #d9eadf;
  border-radius: 6px;
  text-align: center;
}

.bnb-lifecycle-mini-grid strong,
.bnb-lifecycle-mini-grid span {
  display: block;
}

.bnb-lifecycle-mini-grid strong {
  color: var(--color-primary);
  font-size: 12px;
  line-height: 1.2;
}

.bnb-lifecycle-mini-grid span {
  margin-top: 3px;
  color: #52635a;
  font-size: 9px;
  line-height: 1.15;
}

@media (max-width: 900px) {
  .trading-activity-grid {
    grid-template-columns: 1fr;
  }

  .trading-activity-card .visual-tile {
    min-height: auto;
  }

  .activity-bar-chart-box {
    height: 170px;
  }
}

/*******************************************************
 * TRADING ACTIVITY OVERVIEW — UPDATED LAYOUT
 *******************************************************/
.trading-activity-card .trading-activity-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.28fr) minmax(0, 1fr);
  align-items: stretch;
}

.trading-activity-card .fx-wide-tile {
  grid-column: span 2;
}

.trading-activity-card .monthly-disposals-wide-tile {
  grid-column: 1 / -1;
}

.trading-activity-card .activity-donut-layout {
  grid-template-columns: auto minmax(95px, 1fr);
  justify-content: center;
  gap: 12px;
}

.trading-activity-card .activity-asset-legend {
  max-width: 145px;
  gap: 8px;
}

.trading-activity-card .activity-asset-legend .legend-row {
  font-size: 10.5px;
}

.trading-activity-card .activity-bar-chart-box {
  height: 150px;
}

.trading-activity-card .brokerage-stacked-chart-box {
  height: 165px;
  max-width: 310px;
  margin-left: auto;
  margin-right: auto;
}

.trading-activity-card .bnb-lifecycle-chart-box {
  height: 132px;
}

.trading-activity-card .fx-wide-chart-box {
  height: 180px;
}

.trading-activity-card .monthly-disposals-chart-box {
  height: 210px;
}

.bnb-lifecycle-mini-grid.bnb-no-brought-forward {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 900px) {
  .trading-activity-card .trading-activity-grid {
    grid-template-columns: 1fr;
  }

  .trading-activity-card .fx-wide-tile,
  .trading-activity-card .monthly-disposals-wide-tile {
    grid-column: auto;
  }
}


.fx-comparison-tile .fx-wide-chart-box {
  width: 100%;
}
