/* ── Dashboard styles ────────────────────────────── */

/* Controls bar */
.dash-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .75rem;
}
.month-nav { display: flex; align-items: center; gap: .5rem; }
.month-input { width: 165px; font-size: .875rem; }
.month-btn {
  padding: .4rem .7rem;
  font-size: .95rem;
  line-height: 1;
  min-width: 36px;
  justify-content: center;
}

/* ── Headline cards ───────────────────────────────── */
.headline-cards {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: .875rem;
}

/* ── Skeleton loaders ────────────────────────────── */
@keyframes sk-shimmer {
  from { background-position: -600px 0; }
  to   { background-position: 600px 0; }
}
.sk-budget-row {
  height: 2.2rem;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--bg3) 25%, var(--bg4) 50%, var(--bg3) 75%);
  background-size: 600px 100%;
  animation: sk-shimmer 1.4s ease-in-out infinite;
  margin-bottom: .65rem;
}
.sk-budget-row:last-child { margin-bottom: 0; }
.sk-chart {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--bg3) 25%, var(--bg4) 50%, var(--bg3) 75%);
  background-size: 600px 100%;
  animation: sk-shimmer 1.4s ease-in-out infinite;
  z-index: 1;
}
.sk-donut {
  border-radius: 50%;
  inset: 10%;
}
.sk-trend { border-radius: var(--radius-sm); }
.chart-wrap { position: relative; }
.trend-wrap { position: relative; }
canvas.chart-ready { position: relative; z-index: 2; }

@keyframes hcard-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes shimmer {
  from { background-position: -400px 0; }
  to   { background-position: 400px 0; }
}
.hcard.loading .hcard-value,
.hcard.loading .hcard-sub {
  color: transparent;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--bg4) 25%, var(--bg3) 50%, var(--bg4) 75%);
  background-size: 400px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  user-select: none;
}
.hcard.loading .hcard-value { min-width: 120px; min-height: 1.75rem; display: inline-block; }
.hcard.loading .hcard-sub   { min-width: 70px;  min-height: .85rem;  display: inline-block; }
@media (prefers-reduced-motion: reduce) {
  .hcard { animation: none !important; }
}

.hcard {
  border-radius: var(--radius);
  padding: 1.35rem 1.4rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  border: 1px solid var(--border);
  background: var(--bg2);
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
  animation: hcard-in .5s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.hcard:nth-child(1) { animation-delay: 0s; }
.hcard:nth-child(2) { animation-delay: .06s; }
.hcard:nth-child(3) { animation-delay: .12s; }
.hcard:nth-child(4) { animation-delay: .18s; }
.hcard:nth-child(5) { animation-delay: .24s; }

.hcard:hover { border-color: var(--border-hover); transform: translateY(-2px); }

/* Per-card top color stripe + subtle tint */
.hcard:nth-child(1) {
  box-shadow: inset 0 2px 0 rgba(16, 185, 129, 0.65);
  background-image: linear-gradient(135deg, rgba(16, 185, 129, 0.04) 0%, transparent 60%);
}
.hcard:nth-child(2) {
  box-shadow: inset 0 2px 0 rgba(244, 63, 94, 0.65);
  background-image: linear-gradient(135deg, rgba(244, 63, 94, 0.04) 0%, transparent 60%);
}
.hcard:nth-child(3) {
  box-shadow: inset 0 2px 0 rgba(96, 165, 250, 0.65);
  background-image: linear-gradient(135deg, rgba(96, 165, 250, 0.04) 0%, transparent 60%);
}
.hcard:nth-child(4) {
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.12);
}

.hcard-label {
  font-size: .68rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .09em;
  font-weight: 600;
}

.hcard-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.04em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

/* The savings rate card gets extra prominence */
#hc-savings-card .hcard-value {
  font-size: 2.1rem;
  letter-spacing: -0.05em;
}

.hcard-invest { color: var(--blue); }
.hcard-sub { font-size: .70rem; color: var(--text-dim); margin-top: .1rem; }

/* Savings rate card states */
.hcard.savings-green {
  border-color: rgba(16, 185, 129, 0.3);
  box-shadow: inset 0 2px 0 rgba(16, 185, 129, 0.7), 0 0 24px rgba(16, 185, 129, 0.08);
  background-image: linear-gradient(135deg, rgba(16, 185, 129, 0.06) 0%, transparent 60%);
}
.hcard.savings-green .hcard-value { color: var(--green); }

.hcard.savings-amber {
  border-color: rgba(245, 158, 11, 0.3);
  box-shadow: inset 0 2px 0 rgba(245, 158, 11, 0.7);
  background-image: linear-gradient(135deg, rgba(245, 158, 11, 0.04) 0%, transparent 60%);
}
.hcard.savings-amber .hcard-value { color: var(--amber); }

.hcard.savings-red {
  border-color: rgba(244, 63, 94, 0.3);
  box-shadow: inset 0 2px 0 rgba(244, 63, 94, 0.7);
  background-image: linear-gradient(135deg, rgba(244, 63, 94, 0.04) 0%, transparent 60%);
}
.hcard.savings-red .hcard-value { color: var(--red); }

/* ── Budget bars ─────────────────────────────────── */
.budget-row {
  display: grid;
  grid-template-columns: 165px 1fr 120px 70px;
  align-items: center;
  gap: .85rem;
  padding: .65rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  transition: background var(--transition);
}
.budget-row:last-child { border-bottom: none; }
.budget-row:hover { background: rgba(255,255,255,0.015); margin: 0 -.5rem; padding-left: .5rem; padding-right: .5rem; border-radius: 8px; border-bottom-color: transparent; }

.budget-name { font-size: .855rem; font-weight: 500; color: var(--text); }
.budget-name.muted { color: var(--text-dim); }

/* Bar track */
.bar-track {
  height: 10px;
  background: rgba(255,255,255,0.05);
  border-radius: 99px;
  overflow: visible;
  position: relative;
}

.bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width .5s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

/* Normal fill — theme accent */
.bar-fill:not(.over):not(.muted-fill):not(.invest-fill) {
  background: var(--bar-fill-color);
  box-shadow: 0 0 10px var(--bar-fill-glow);
}

/* Over budget — red glow */
.bar-fill.over {
  background: linear-gradient(135deg, #f43f5e, #e11d48);
  box-shadow: 0 0 8px var(--red-glow);
}

/* Pre-deducted / muted */
.bar-fill.muted-fill {
  background: rgba(107,115,148,0.3);
  box-shadow: none;
}

/* Investment fill — blue glow */
.bar-fill.invest-fill {
  background: linear-gradient(135deg, #38bdf8, #0ea5e9);
  box-shadow: 0 0 8px var(--blue-glow);
}

.budget-amounts {
  font-size: .78rem;
  color: var(--text-dim);
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.budget-amounts.over { color: var(--red); }
.budget-amounts span { color: var(--text-dim); font-weight: 400; }

.budget-pct {
  font-size: .78rem;
  text-align: right;
  font-weight: 700;
  white-space: nowrap;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.budget-pct.over { color: var(--red); }

/* ── Charts row ──────────────────────────────────── */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .875rem;
}
.chart-card { display: flex; flex-direction: column; }
.chart-wrap {
  position: relative;
  height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: .5rem;
}
.chart-wrap canvas { max-height: 240px; }

/* ── Split legend ────────────────────────────────── */
.split-legend {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem 1.25rem;
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: .25rem;
}
.split-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: .35rem;
  vertical-align: middle;
}

/* ── Trend chart ─────────────────────────────────── */
.trend-wrap {
  height: 260px;
  position: relative;
  margin-top: .5rem;
}
.trend-wrap canvas { max-height: 260px; }

/* ── Empty state ─────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 180px;
  color: var(--text-dim);
  font-size: .875rem;
  gap: .5rem;
}

/* ── Rollover banner ─────────────────────────────── */
.rollover-banner {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  background: rgba(244, 63, 94, 0.07);
  border: 1px solid rgba(244, 63, 94, 0.25);
  border-radius: var(--radius);
  padding: .85rem 1.1rem;
  font-size: .855rem;
  color: var(--text-muted);
  position: relative;
}
.rollover-banner .rb-icon {
  color: var(--red);
  font-size: 1rem;
  flex-shrink: 0;
  margin-top: .05rem;
}
.rollover-banner .rb-body strong { color: var(--text); display: block; margin-bottom: .2rem; font-size: .875rem; }
.rollover-banner .rb-body ul {
  margin: .3rem 0 0 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: .2rem .75rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.rollover-banner .rb-body li { color: var(--red); font-size: .82rem; font-weight: 600; }
.rollover-banner .rb-body li span { color: var(--text-muted); font-weight: 400; }
.rb-dismiss {
  position: absolute;
  top: .6rem;
  right: .75rem;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}
.rb-dismiss:hover { color: var(--text-muted); }
.hidden { display: none !important; }

/* ── Suggestions panel ───────────────────────────── */
.suggestions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: .75rem;
  margin-top: .25rem;
}
.suggestion-item {
  background: var(--bg3);
  border: 1px solid rgba(244, 63, 94, 0.18);
  border-radius: var(--radius-sm);
  padding: .9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .3rem;
}
.si-name { font-size: .8rem; font-weight: 600; color: var(--text); }
.si-over { font-size: 1.05rem; font-weight: 800; color: var(--red); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.si-meta { font-size: .75rem; color: var(--text-dim); }
.si-bar {
  height: 4px;
  background: rgba(244,63,94,0.15);
  border-radius: 99px;
  margin-top: .35rem;
  overflow: hidden;
}
.si-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #f43f5e, #e11d48);
  border-radius: 99px;
}

/* ── Statement Import section ───────────────────── */
.import-zone {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}
.import-zone select.filter-input {
  flex: 1;
  min-width: 200px;
}
.import-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .6rem 0 0;
  border-top: 1px solid var(--border);
  margin-top: .85rem;
}
.import-btns {
  display: flex;
  gap: .5rem;
  flex-shrink: 0;
}
.import-count {
  font-size: .85rem;
  color: var(--text-muted);
  flex: 1;
}
.import-row-skipped td {
  opacity: 0.35;
  text-decoration: line-through;
  pointer-events: none;
}
.import-row-skipped td:last-child {
  pointer-events: auto;
  text-decoration: none;
  opacity: 1;
}
.import-row-skipped .import-row-toggle {
  color: var(--green);
  border-color: rgba(16, 185, 129, 0.3);
}
.import-desc-input {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: .85rem;
  padding: .2rem .4rem;
  width: 100%;
  min-width: 160px;
  transition: border-color var(--transition), background var(--transition);
}
.import-desc-input:hover { border-color: var(--border-hover); background: var(--bg3); }
.import-desc-input:focus { outline: none; border-color: var(--border-glow); background: var(--bg3); }

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 1000px) {
  .headline-cards { grid-template-columns: repeat(3, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
  .budget-row { grid-template-columns: 140px 1fr 100px; }
  .budget-pct { display: none; }
}
@media (max-width: 640px) {
  .headline-cards { grid-template-columns: 1fr 1fr; }
  .hcard-value { font-size: 1.3rem; }
  #hc-savings-card .hcard-value { font-size: 1.55rem; }
  .budget-row { grid-template-columns: 110px 1fr 80px; font-size: .8rem; }
  .dash-controls { flex-direction: column; align-items: flex-start; gap: .5rem; }
}
