/* ═══════════════════════════════════════════
   dashboard.css — Hintafiksu.fi · v6
   Mobiilioptimoitu
═══════════════════════════════════════════ */

/* ─── ALERT BUTTON ───────────────────────────────────────── */
.alert-btn {
  display: flex; align-items: center; gap: 6px;
  background: rgba(0,232,122,0.08); border: 1px solid rgba(0,232,122,0.25);
  color: var(--accent); padding: 6px 14px; border-radius: 8px;
  font-size: 0.85rem; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background 0.2s;
}
.alert-btn:hover { background: rgba(0,232,122,0.15); }
@media (max-width: 700px) { .alert-btn-text { display: none; } }

/* ─── HERO ────────────────────────────────────────────────── */
.hero-dashboard {
  padding: clamp(1.5rem,4vw,3rem) clamp(1rem,4vw,3rem) 0;
  max-width: 1400px; margin: 0 auto;
}
.hero-top { max-width: 680px; }
.hero-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.78rem; color: var(--text-muted);
  margin-bottom: 0.75rem;
}
.hero-live-dot {
  width: 7px; height: 7px; background: var(--green);
  border-radius: 50%; animation: pulse 1.5s infinite; flex-shrink: 0;
  display: inline-block;
}
.hero-h1 {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4.5vw, 3.2rem);
  font-weight: 700; letter-spacing: -0.025em;
  line-height: 1.1; margin-bottom: 0.75rem;
}
.hero-h1 em { font-style: normal; color: var(--accent); }
.hero-sub {
  font-size: clamp(0.875rem, 2vw, 1rem);
  color: var(--text-muted); line-height: 1.6;
}

/* ─── DASHBOARD SECTION WRAPPER ──────────────────────────── */
.dashboard-section {
  padding: 1rem clamp(0.75rem,4vw,3rem) 0;
  max-width: 1400px; margin: 0 auto;
}

/* ─── DASHBOARD GRID ─────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px; background: var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  border: 1px solid var(--border);
}
@media (max-width: 1100px) { .dashboard-grid { grid-template-columns: repeat(3,1fr); } }
@media (max-width: 680px)  { .dashboard-grid { grid-template-columns: repeat(2,1fr); } }

/* ─── DASH CARD ──────────────────────────────────────────── */
.dash-card {
  background: var(--card);
  padding: clamp(0.875rem,2vw,1.2rem) clamp(0.875rem,2vw,1.2rem) 0.75rem;
  display: flex; flex-direction: column; gap: 0.1rem;
  text-decoration: none; color: inherit;
  position: relative; transition: background 0.15s; overflow: hidden;
  min-width: 0; /* prevent overflow in grid */
}
.dash-card::before {
  content: ''; position: absolute; inset: 0 0 auto 0;
  height: 2px; background: var(--border); transition: background 0.3s;
}
.dash-card:hover { background: var(--card-hover); }
.dash-card.state-down::before { background: var(--green); }
.dash-card.state-up::before   { background: var(--red); }
.dash-card.state-flat::before { background: var(--amber); }
/* dash-card--xl: ensimmäinen kortti isommalla fontilla, ei span-2 */
.dash-card--xl .dash-card__value { font-size: clamp(1.75rem, 3.5vw, 2.75rem); }
.dash-card--xl .dash-card__label { letter-spacing: 0.09em; }

/* Card header */
.dash-card__header {
  display: flex; align-items: center; gap: 6px; margin-bottom: 0.3rem;
}
.dash-card__icon { font-size: 0.9rem; line-height: 1; flex-shrink: 0; }
.dash-card__meta { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.dash-card__label {
  font-size: 0.65rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dash-card__src { font-size: 0.58rem; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.src-live { color: var(--green); font-size: 0.5rem; margin-left: 2px; }

/* Trend badge */
.dash-trend {
  font-size: 0.68rem; font-weight: 700;
  padding: 2px 6px; border-radius: 4px; white-space: nowrap; flex-shrink: 0;
}
.t-down { background: rgba(34,197,94,0.12); color: var(--green); }
.t-up   { background: rgba(239,68,68,0.10); color: var(--red); }
.t-flat { background: rgba(245,158,11,0.10); color: var(--amber); }

/* Value */
.dash-card__value {
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 3.5vw, 1.9rem);
  font-weight: 700; letter-spacing: -0.03em;
  line-height: 1; color: var(--text);
  font-variant-numeric: tabular-nums;
}
@media (max-width: 380px) { .dash-card__value { font-size: 1.25rem; } }

.dash-card__unit { font-size: 0.62rem; color: var(--text-dim); margin-bottom: 0.2rem; }

/* Changes row */
.dash-card__changes { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.1rem; }
.dash-change        { font-size: 0.62rem; color: var(--text-dim); }
.dash-change strong { font-weight: 600; }
.c-down strong { color: var(--green); }
.c-up   strong { color: var(--red); }
.c-flat strong { color: var(--amber); }

/* Sparkline */
.dash-spark     { height: 30px; margin-top: 0.35rem; }
.dash-spark svg { width: 100%; height: 100%; }

/* ─── STATUS BAR ─────────────────────────────────────────── */
.status-bar {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.5rem 1rem;
  background: var(--bg3); border: 1px solid var(--border);
  border-top: none; border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  font-size: 0.7rem; flex-wrap: wrap; gap: 0.5rem;
}
.status-bar__item        { display: flex; align-items: center; gap: 4px; }
.status-bar__item--good  { color: var(--green); }
.status-bar__item--bad   { color: var(--red); }
.status-bar__sep         { width: 1px; height: 12px; background: var(--border); flex-shrink: 0; }
.status-bar__updated     { color: var(--text-dim); font-size: 0.65rem; margin-left: auto; }
@media (max-width: 500px) {
  .status-bar__sep { display: none; }
  .status-bar__updated { margin-left: 0; width: 100%; }
}

/* ─── SÄHKÖ LAYOUT ───────────────────────────────────────── */
.sahko-layout {
  display: grid;
  grid-template-columns: 1fr 210px;
  gap: 1.25rem;
  align-items: start;
}
@media (max-width: 760px) { .sahko-layout { grid-template-columns: 1fr; } }

.sahko-main { min-width: 0; }
.sahko-side { display: flex; flex-direction: column; gap: 0; }

/* Mobile: side widgets as horizontal row */
@media (max-width: 760px) {
  .sahko-side {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }
  .sahko-side .side-widget--link {
    grid-column: span 2;
  }
}

/* ─── SIDE WIDGETS ───────────────────────────────────────── */
.side-widget {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.75rem 0.875rem;
  margin-bottom: 0.5rem;
}
@media (max-width: 760px) { .side-widget { margin-bottom: 0; } }

.side-widget:last-child { margin-bottom: 0; }
.side-widget--dim { background: var(--bg3); }
.side-widget--link {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.78rem; color: var(--accent); text-decoration: none;
  cursor: pointer; transition: background 0.2s;
}
.side-widget--link:hover { background: rgba(0,232,122,0.06); }
.side-widget__title {
  font-size: 0.58rem; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-dim); margin-bottom: 0.2rem;
}
.side-widget__value {
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 2.5vw, 1.45rem);
  font-weight: 700; letter-spacing: -0.02em; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.side-widget__sub { font-size: 0.62rem; color: var(--text-dim); margin-top: 1px; }

/* ─── TUNTIRUUDUKKO ──────────────────────────────────────── */
.time-grid {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  gap: 2px;
}
@media (max-width: 860px) { .time-grid { grid-template-columns: repeat(12, 1fr); } }
@media (max-width: 480px) { .time-grid { grid-template-columns: repeat(8, 1fr); } }

.time-cell {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 5px; padding: 4px 1px 3px;
  cursor: default; transition: transform 0.12s; position: relative;
}
.time-cell:hover { transform: translateY(-2px); z-index: 1; }
.time-cell.tc-cheap  { background: rgba(34,197,94,0.07); border-color: rgba(34,197,94,0.4); }
.time-cell.tc-normal { background: rgba(245,158,11,0.05); border-color: rgba(245,158,11,0.3); }
.time-cell.tc-exp    { background: rgba(239,68,68,0.07); border-color: rgba(239,68,68,0.4); }
.time-cell.tc-now    { outline: 2px solid var(--accent); outline-offset: 1px; z-index: 2; }
.tc-bar   { width: 100%; border-radius: 2px 2px 0 0; min-height: 2px; }
.tc-cheap  .tc-bar { background: var(--green); }
.tc-normal .tc-bar { background: var(--amber); }
.tc-exp    .tc-bar { background: var(--red); }
.tc-hour  { font-size: 0.48rem; color: var(--text-dim); line-height: 1; }
.tc-price { font-size: 0.6rem; font-weight: 700; color: var(--text); line-height: 1; }
.tc-cheap  .tc-price { color: var(--green); }
.tc-exp    .tc-price { color: var(--red); }

/* On mobile show every other hour label */
@media (max-width: 860px) {
  .time-cell { padding: 5px 2px 4px; border-radius: 6px; }
  .tc-hour   { font-size: 0.58rem; }
  .tc-price  { font-size: 0.7rem; }
}
@media (max-width: 480px) {
  .time-cell { padding: 6px 2px 5px; }
  .tc-hour   { font-size: 0.6rem; }
  .tc-price  { font-size: 0.72rem; font-weight: 700; }
  .tc-bar    { min-height: 4px; }
}

.time-legend {
  display: flex; align-items: center; gap: 0.35rem;
  font-size: 0.68rem; color: var(--text-dim);
  margin-top: 0.5rem; flex-wrap: wrap;
}
.legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ─── ASUNTOLAINA KORTIT ─────────────────────────────────── */
.loan-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.625rem;
}
@media (max-width: 800px) { .loan-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 480px) { .loan-grid { grid-template-columns: repeat(2, 1fr); } }

.loan-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.875rem 0.75rem;
  text-align: center; transition: border-color 0.2s, transform 0.15s;
  display: flex; flex-direction: column; gap: 0.3rem;
}
.loan-card--highlight {
  border-color: rgba(0,232,122,0.3);
  background: rgba(0,232,122,0.03);
}
.loan-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.loan-amount      { font-size: 0.72rem; color: var(--text-muted); font-weight: 500; }
.loan-rate        { font-size: 0.6rem; color: var(--text-dim); }
.loan-monthly     {
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 2.5vw, 1.25rem);
  font-weight: 700; letter-spacing: -0.02em; color: var(--text); line-height: 1;
  font-variant-numeric: tabular-nums;
}
.loan-card--highlight .loan-monthly { color: var(--accent); }
.loan-monthly-unit { font-size: 0.6rem; color: var(--text-dim); }

/* ─── VIRAL CARD ─────────────────────────────────────────── */
.viral-card {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: clamp(1.25rem,4vw,2rem);
  position: relative; overflow: hidden;
}
@media (max-width: 680px) { .viral-card { grid-template-columns: 1fr; gap: 1.25rem; } }
.viral-eyebrow  { font-size: 0.68rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); margin-bottom: 0.5rem; }
.viral-title    { font-family: var(--font-display); font-size: clamp(1.15rem,2.8vw,1.6rem); font-weight: 600; letter-spacing: -0.02em; line-height: 1.18; margin-bottom: 0.5rem; }
.viral-sub      { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 1rem; }
.viral-inputs   { display: flex; flex-direction: column; gap: 0.4rem; }
.vi-row         { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; background: var(--bg3); border-radius: 7px; padding: 0.5rem 0.75rem; }
.vi-label       { font-size: 0.78rem; color: var(--text-muted); flex-shrink: 0; }
.vi-input       { background: var(--card); border: 1px solid var(--border-light); color: var(--text); font-family: var(--font-display); font-size: 0.875rem; font-weight: 600; text-align: right; padding: 4px 7px; border-radius: 6px; width: 75px; }
.vi-input:focus { outline: none; border-color: var(--accent); }
.viral-card__right  { background: var(--bg3); border-radius: var(--radius); padding: 1.25rem; display: flex; flex-direction: column; }
.viral-result-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-dim); margin-bottom: 0.2rem; }
.viral-result       { font-family: var(--font-display); font-size: clamp(1.75rem,5vw,2.6rem); font-weight: 700; letter-spacing: -0.02em; line-height: 1; color: var(--red); }
.viral-result.negative { color: var(--green); }
.viral-result-annual   { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 0.75rem; }
.viral-breakdown       { display: flex; flex-direction: column; flex: 1; margin-bottom: 0.75rem; }
.vb-line { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--text-muted); padding: 0.25rem 0; border-bottom: 1px solid var(--border); }
.vb-line:last-child { border: none; }
.vb-up   { color: var(--red); }
.vb-down { color: var(--green); }
.viral-actions { display: flex; flex-direction: column; gap: 0.4rem; }

/* ─── BADGE ──────────────────────────────────────────────── */
.badge      { display: inline-flex; align-items: center; padding: 2px 7px; border-radius: 4px; font-size: 0.7rem; font-weight: 600; white-space: nowrap; }
.badge-down { background: rgba(34,197,94,0.12); color: var(--green); }
.badge-up   { background: rgba(239,68,68,0.10); color: var(--red); }

/* ─── PAREMPI / HUONOMPI ─────────────────────────────────── */
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
@media (max-width: 600px) { .compare-grid { grid-template-columns: 1fr; } }
.cmp-card { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.cmp-card--good { border-color: rgba(34,197,94,0.25); }
.cmp-card--bad  { border-color: rgba(239,68,68,0.2); }
.cmp-header { padding: 0.6rem 0.875rem; font-size: 0.75rem; font-weight: 600; }
.cmp-card--good .cmp-header { background: rgba(34,197,94,0.06); color: var(--green); }
.cmp-card--bad  .cmp-header { background: rgba(239,68,68,0.05); color: var(--red); }
.cmp-rows { background: var(--card); }
.cmp-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.45rem 0.875rem; font-size: 0.75rem;
  border-bottom: 1px solid var(--border); gap: 0.5rem; flex-wrap: wrap;
}
.cmp-row:last-child { border: none; }
.cmp-row span:first-child { color: var(--text-muted); }
.cmp-row span:last-child  { text-align: right; white-space: nowrap; }

/* ─── ALERT CTA ──────────────────────────────────────────── */
.alert-cta-card {
  display: flex; align-items: center; justify-content: space-between; gap: 1.5rem;
  background: linear-gradient(135deg, rgba(0,232,122,0.05) 0%, transparent 100%);
  border: 1px solid rgba(0,232,122,0.2); border-radius: var(--radius-lg);
  padding: clamp(1.25rem,4vw,1.75rem) clamp(1.25rem,4vw,2rem); flex-wrap: wrap;
}
.alert-cta-left  { display: flex; align-items: flex-start; gap: 1rem; flex: 1; min-width: 0; }
.alert-cta-icon  { font-size: 1.5rem; flex-shrink: 0; line-height: 1; }
.alert-cta-title { font-family: var(--font-display); font-size: clamp(0.95rem,2vw,1.05rem); font-weight: 700; margin-bottom: 0.2rem; }
.alert-cta-sub   { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.alert-examples  { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.alert-ex { font-size: 0.65rem; padding: 2px 8px; background: rgba(0,232,122,0.08); border: 1px solid rgba(0,232,122,0.2); border-radius: 100px; color: var(--accent); }
.btn-lg   { padding: 11px 22px; font-size: 0.9rem; }

/* ─── EXPLAINER GRID ─────────────────────────────────────── */
.explainer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px,1fr)); gap: 0.75rem; }
@media (max-width: 480px) { .explainer-grid { grid-template-columns: repeat(2,1fr); } }
.explainer-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem;
  display: flex; flex-direction: column; gap: 0.35rem;
  transition: border-color 0.2s, transform 0.2s; text-decoration: none; color: inherit;
}
.explainer-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.expl-icon  { font-size: 1.3rem; }
.expl-title { font-family: var(--font-display); font-size: 0.85rem; font-weight: 700; line-height: 1.3; }
.expl-desc  { font-size: 0.75rem; color: var(--text-muted); flex: 1; }
.expl-time  { font-size: 0.63rem; color: var(--text-dim); }

/* ─── NEWSLETTER ─────────────────────────────────────────── */
.newsletter-card {
  display: flex; align-items: center; justify-content: space-between; gap: 1.5rem;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(1.25rem,4vw,1.75rem) clamp(1.25rem,4vw,2rem); flex-wrap: wrap;
}
.newsletter-left     { flex: 1; min-width: 0; }
.newsletter-title    { font-family: var(--font-display); font-size: clamp(0.95rem,2vw,1.1rem); font-weight: 700; margin-bottom: 0.35rem; }
.newsletter-sub      { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.newsletter-stats    { display: flex; gap: 0.75rem; font-size: 0.72rem; color: var(--text-muted); flex-wrap: wrap; }
.newsletter-form     { display: flex; gap: 0.5rem; flex-wrap: wrap; min-width: 240px; }
.nl-input {
  flex: 1; background: var(--bg3); border: 1px solid var(--border-light);
  color: var(--text); padding: 8px 12px; border-radius: 8px;
  font-size: 0.875rem; min-width: 140px;
}
.nl-input:focus { outline: none; border-color: var(--accent); }
.nl-input::placeholder { color: var(--text-dim); }
@media (max-width: 480px) {
  .newsletter-form { min-width: 100%; width: 100%; }
  .nl-input { min-width: 0; }
}

/* ─── MODAL ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal-box {
  background: var(--bg2); border: 1px solid var(--border-light);
  border-radius: var(--radius-lg); padding: clamp(1.25rem,4vw,2rem);
  max-width: 400px; width: 100%; position: relative;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}
.modal-close {
  position: absolute; top: 0.875rem; right: 0.875rem;
  background: none; border: none; color: var(--text-dim);
  font-size: 1.1rem; cursor: pointer; padding: 4px 8px; border-radius: 6px;
}
.modal-close:hover { color: var(--text); background: var(--bg3); }
.modal-title { font-family: var(--font-display); font-size: 1.15rem; font-weight: 700; margin-bottom: 0.35rem; }
.modal-sub   { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 1.25rem; }
.mf-input {
  background: var(--bg3); border: 1px solid var(--border-light);
  color: var(--text); padding: 8px 12px; border-radius: 8px;
  font-size: 0.875rem; width: 100%;
}
.mf-input:focus { outline: none; border-color: var(--accent); }

/* ─── LIVE FLASH ─────────────────────────────────────────── */
.live-updated { animation: liveFlash 0.8s ease; }
@keyframes liveFlash { 0%,100%{color:inherit;} 30%{color:var(--accent);} }
