/* ============================================================
   Tool Styles — Savings Calculator v2.1
   File: /assets/css/modules/calculators/financialcalculators/savings-calculator.v2.1.css
   Purpose:
   - Tool-only layout + savings projection visuals + chart + work formatting
   - No changes to ub-toolkit.v2.1.css required
   - Mobile-first, 44x44 touch targets, clamp typography
   ============================================================ */

/* Tool-scoped tokens */
:root{
  --sav-radius: 16px;
  --sav-gap: 14px;
  --sav-soft: rgba(0,0,0,.06);
  --sav-track: rgba(249,58,19,.10);
  --sav-fill-a: #ff7426;
  --sav-fill-b: #f93a13;
}

/* Main two-panel hero */
.ub-hero{
  display:grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: var(--sav-gap);
}

@media (max-width: 980px){
  .ub-hero{
    grid-template-columns: 1fr;
  }
}

/* Visual / projection panel */
.ub-visual-panel{
  background: var(--ub-surface-2);
  border: 1px solid var(--ub-border);
  border-radius: var(--sav-radius);
  padding: 12px;
}

.ub-visual-top{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:10px;
  flex-wrap:wrap;
  margin-bottom:8px;
}

.ub-visual-title{
  font-size: clamp(13px, 1.2vw, 14px);
  font-weight: 950;
  letter-spacing: .01em;
}

.ub-visual-sub{
  font-size: 12px;
  color: var(--ub-muted);
  margin-top: 2px;
}

/* KPI tiles */
.ub-kpis{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  justify-content:flex-end;
}

.ub-kpi{
  min-width: 120px;
  padding: 8px 10px;
  border-radius: 14px;
  border: 1px solid var(--ub-border);
  background: var(--ub-card-bg);
}

.ub-kpi .k{
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ub-muted);
}

.ub-kpi .v{
  font-family: var(--ub-mono);
  font-weight: 950;
  font-size: 14px;
  margin-top: 2px;
}

/* Balance highlight card */
.ub-balance-card{
  margin-top: 10px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--ub-border);
  background:
    linear-gradient(180deg, rgba(249,58,19,.06), rgba(249,58,19,.02)),
    var(--ub-card-bg);
}

.ub-balance-header{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:10px;
  flex-wrap:wrap;
}

.ub-balance-label{
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ub-muted);
}

.ub-balance-note{
  margin-top: 4px;
  font-size: 12px;
  color: var(--ub-muted);
}

.ub-balance-value{
  font-family: var(--ub-mono);
  font-weight: 950;
  font-size: clamp(24px, 2.7vw, 34px);
  line-height: 1.05;
  text-align:right;
  overflow-wrap:anywhere;
}

/* Growth bar */
.ub-progress-wrap{
  margin-top: 14px;
}

.ub-progress-track{
  width: 100%;
  min-height: 14px;
  border-radius: 999px;
  border: 1px solid var(--ub-border);
  background: var(--sav-track);
  overflow:hidden;
}

.ub-progress-fill{
  height: 14px;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(92deg, var(--sav-fill-a), var(--sav-fill-b));
  transition: width 180ms ease;
}

@media (prefers-reduced-motion: reduce){
  .ub-progress-fill{
    transition: none;
  }
}

/* Mini stats */
.ub-mini-grid{
  display:grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap:10px;
  margin-top: 14px;
}

.ub-mini-stat{
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--ub-border);
  background: var(--ub-surface-2);
}

.ub-mini-k{
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ub-muted);
}

.ub-mini-v{
  margin-top: 4px;
  font-family: var(--ub-mono);
  font-weight: 950;
  font-size: 14px;
  overflow-wrap:anywhere;
}

@media (max-width: 560px){
  .ub-mini-grid{
    grid-template-columns: 1fr;
  }
}

/* Chart shell */
.ub-chart-shell{
  position:relative;
  width:100%;
  min-height: 320px;
  border-radius: 14px;
  border: 1px solid var(--ub-border);
  background: var(--ub-card-bg);
  overflow:hidden;
}

.ub-chart-shell canvas{
  display:block;
  width:100%;
  height:auto;
}

.ub-chart-placeholder{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:16px;
  text-align:center;
  font-size: 13px;
  font-weight: 900;
  color: var(--ub-muted);
  background:
    linear-gradient(180deg, rgba(0,0,0,.015), rgba(0,0,0,.025));
  pointer-events:none;
}

html.ub-theme-dark .ub-chart-placeholder{
  background:
    linear-gradient(180deg, rgba(255,255,255,.015), rgba(255,255,255,.03));
}

/* Presets row */
.ub-preset-row{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin-top: 10px;
}

.ub-preset-row .ub-chip{
  min-height: 44px;
  padding: 10px 12px;
}

/* Hint + inline errors */
.hint{
  margin-top: 6px;
  font-size: 12px;
  color: var(--ub-muted);
}

.ub-inline-error{
  margin-top: 6px;
  font-size: 12px;
  color: var(--ub-danger);
  font-weight: 800;
  min-height: 16px;
}

/* Slider helpers */
.ub-slider-row{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
}

.ub-range{
  width: min(420px, 100%);
  height: 44px;
  accent-color: var(--ub-btn-grad-b);
}

/* Work area */
.ub-work{
  font-family: var(--ub-mono);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap:anywhere;
}

/* Details focus polish */
.ub-collapsible summary{
  cursor:pointer;
  font-weight: 950;
  min-height: 44px;
  display:flex;
  align-items:center;
}

.ub-collapsible summary:focus{
  outline:none;
  box-shadow: 0 0 0 4px var(--ub-focus);
  border-radius: 12px;
}

/* Schedule table cell wrapping safety */
#scheduleTable td,
#scheduleTable th{
  vertical-align: middle;
}

#scheduleTable td{
  overflow-wrap:anywhere;
  word-break:break-word;
}

/* Rail helper */
.ub-btn--block{
  width: 100%;
}

/* Small-screen tuning */
@media (max-width: 640px){
  .ub-kpi{
    min-width: 104px;
  }

  .ub-balance-value{
    text-align:left;
  }

  .ub-balance-header{
    align-items:stretch;
  }
}

@media (max-width: 520px){
  .ub-kpis{
    justify-content:flex-start;
  }

  .ub-kpi{
    flex: 1 1 calc(50% - 8px);
    min-width: 0;
  }

  .ub-chart-shell{
    min-height: 260px;
  }
}

/* Print cleanup */
@media print{
  .ub-rail,
  .ub-rail-togglebar,
  .ub-rail-backdrop,
  #btnCopy,
  #btnShare,
  #resetBtn,
  .ub-preset-row,
  #ubThemeToggle{
    display:none !important;
  }

  .ub-hero{
    grid-template-columns: 1fr;
  }

  .ub-card,
  .ub-visual-panel,
  .ub-balance-card,
  .ub-chart-shell{
    box-shadow:none !important;
    break-inside: avoid;
  }
}