/* Ohjauspaneelin omat tyylit tokenien ja components.css:n päällä.
 *
 * Mitat ja värit tulevat design-handoffista. Muutamassa kohdassa handoff
 * määrittelee arvon, joka ei ole DS:n oletustokeni (esim. tiilen hover-reuna
 * #c4bdb2 = --text-ghost eikä --line-hover) — nämä on merkitty kommentein. */

/* ------------------------------------------------------------------ Runko */

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg-app);
  font-family: var(--font-ui);
  color: var(--text-1);
  -webkit-font-smoothing: antialiased;
}

/* Sisältö paljastetaan vasta kun istunto on tarkistettu (ks. ohjauspaneeli.js). */
.tarkistetaan body { visibility: hidden; }

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }

::placeholder { color: var(--text-ghost); }

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ----------------------------------------------------------------- Header */

.vp-header--sticky {
  position: sticky;
  top: 0;
  z-index: 5;
}

/* Sovelluksen nimi on paneelisivun <h1>. Ulkoasu tulee components.css:stä. */
.vp-header__app { margin: 0; }

.header__meta {
  font-size: 13.5px;
  color: var(--text-faint);
}

/* "Kirjaudu ulos" — nappi, joka näyttää linkiltä (POST /api/logout). */
.header__ulos {
  border: none;
  background: none;
  padding: 0;
  font-family: var(--font-ui);
  font-size: 13.5px;
  color: var(--text-3);
  cursor: pointer;
}
.header__ulos:hover { color: var(--link-hover); text-decoration: underline; }

/* -------------------------------------------------------- Paneelin runko */

.paneeli {
  flex: 1;
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding: 40px var(--page-pad-x) 72px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 48px;
}

.paneeli__osio,
.paneeli__graafit {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.paneeli__graafit { gap: 48px; }

.paneeli-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px var(--page-pad-x);
  border-top: 1px solid var(--line-1);
  background: var(--surface-1);
  font: var(--text-meta);
  color: var(--text-faint);
}

/* ------------------------------------------------------ Osio A: sovellukset */

.sovellukset {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}

.sovellus {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 22px 12px 18px;
  background: var(--surface-1);
  border: 1px solid var(--line-1);
  border-radius: var(--radius-xl);
  text-decoration: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.sovellus:hover {
  /* Handoffin arvot; --text-ghost on sama väri kuin designin #c4bdb2. */
  border-color: var(--text-ghost);
  box-shadow: 0 2px 12px rgba(28, 26, 23, .06);
  text-decoration: none;
}

.sovellus__laatta {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-xl);
  background: var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sovellus__ikoni {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  object-fit: contain;
}

.sovellus__merkki {
  font-family: var(--font-content);
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
}

.sovellus__tekstit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
}

.sovellus__nimi {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-1);
}

.sovellus__kuvaus {
  font: var(--text-meta);
  color: var(--text-faint);
}

/* ------------------------------------------------------- Osio B: avainluvut */

.luvut {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(196px, 1fr));
  gap: 14px;
}

.luku {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px 22px 16px;
  background: var(--surface-1);
  border: 1px solid var(--line-1);
  border-radius: var(--radius-xl);
}

.luku__kicker {
  font: var(--text-kicker);
  text-transform: uppercase;
  letter-spacing: var(--kicker-tracking);
  color: var(--text-faint);
}

.luku__arvot {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.luku__arvo {
  font-family: var(--font-content);
  font-size: 34px;
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.01em;
}

.luku__muutos {
  font-size: 12.5px;
  color: var(--text-muted);
}

.luku__muutos--nousu { color: var(--status-done-fg); }

/* --------------------------------------------------- Osio C: tilatiedot */

.terveys {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: start;
}

.terveys__kortti {
  display: flex;
  flex-direction: column;
  padding: 8px 22px;
  background: var(--surface-1);
  border: 1px solid var(--line-1);
  border-radius: var(--radius-xl);
}

.terveys__otsikkorivi {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0 10px;
  border-bottom: 1px solid var(--line-2);
}

.terveys__otsikko {
  margin: 0;
  font-family: var(--font-content);
  font-size: 16px;
  font-weight: 600;
}

.terveys__yhteenveto {
  font: var(--text-meta);
  color: var(--text-faint);
}

.terveys__rivi {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line-2);
}

.terveys__piste {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--status-done-fg);
}

.terveys__piste--tarkista { background: var(--warn-dot); }
.terveys__piste--virhe { background: var(--danger); }

.terveys__tekstit {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.terveys__nimi {
  font-size: 13.5px;
  font-weight: 500;
}

.terveys__meta {
  font: var(--text-meta);
  color: var(--text-faint);
}

/* Tilateksti ennen kuin rivit on haettu. */
.terveys__tila {
  margin: 0;
  padding: 22px 0;
  font: var(--text-ui);
  color: var(--text-faint);
}

/* ------------------------------------------------------ Osio D: vuosigraafit */

.graafi {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 24px 26px 18px;
  background: var(--surface-1);
  border: 1px solid var(--line-1);
  border-radius: var(--radius-xl);
}

.graafi__legenda {
  display: flex;
  align-items: center;
  gap: 24px;
  padding-bottom: 8px;
  flex-wrap: wrap;
}

.graafi__legenda-kohta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.graafi__legenda-viiva {
  width: 18px;
  height: 0;
  border-top: 2.5px solid var(--accent);
}

.graafi__legenda-viiva--edellinen {
  border-top: 2px dashed var(--text-ghost);
}

/* Kolmas vertailuvuosi: pistekatkoviiva ja vaaleampi sävy — vanhempi kuin
   edellinen vuosi, mutta samaa neutraalia perhettä. */
.graafi__legenda-viiva--toissa {
  border-top: 2px dotted var(--line-hover);
}

.graafi__legenda-teksti {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
}

.graafi__legenda-teksti--edellinen {
  font-weight: 400;
  color: var(--text-muted);
}

.graafi__kuva {
  width: 100%;
  height: auto;
  display: block;
}

/* Tilateksti ennen kuin sarjat on haettu — pitää kortin korkeuden vakaana. */
.graafi__tila {
  margin: 0;
  padding: 78px 0;
  text-align: center;
  font: var(--text-ui);
  color: var(--text-faint);
}

.graafi__akseli { stroke: var(--line-1); stroke-width: 1; }
.graafi__apuviiva { stroke: var(--line-2); stroke-width: 1; }

.graafi__viiva {
  fill: none;
  stroke-linejoin: round;
}

.graafi__viiva--edellinen {
  stroke: var(--text-ghost);
  stroke-width: 2;
  stroke-dasharray: 6 5;
}

.graafi__viiva--toissa {
  stroke: var(--line-hover);
  stroke-width: 2;
  stroke-dasharray: 2 4;
}

.graafi__viiva--nyky {
  stroke: var(--accent);
  stroke-width: 2.5;
}

.graafi__piste { fill: var(--accent); }

.graafi__kk {
  font-family: var(--font-ui);
  font-size: 11.5px;
  fill: var(--text-muted);
}

.graafi__ytick {
  font-family: var(--font-ui);
  font-size: 11px;
  fill: var(--text-faint);
}

/* ---------------------------------------------------------- Kirjautuminen */

.kirjautuminen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.kirjautuminen__kortti {
  box-sizing: border-box;
  width: 360px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 40px 44px;
  background: var(--surface-1);
  border: 1px solid var(--line-1);
  border-radius: var(--radius-2xl);
  box-shadow: 0 12px 40px rgba(28, 26, 23, .10);
}

.kirjautuminen__ylaosa {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
}

.kirjautuminen__otsikot {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kirjautuminen__otsikko {
  margin: 0;
  font-family: var(--font-content);
  font-size: 22px;
  font-weight: 600;
}

.kirjautuminen__selite {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-3);
}

.kirjautuminen__kohde {
  margin: 0;
  padding: 10px 14px;
  background: var(--accent-tint);
  border-radius: var(--radius-md);
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--accent-deep);
}

.kirjautuminen__nappi { justify-content: center; }

.kirjautuminen__note {
  font: var(--text-meta);
  color: var(--text-faint);
  text-align: center;
}

/* ------------------------------------------------------------ Responsiivisuus */

@media (max-width: 720px) {
  .terveys { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .vp-header { padding: 14px 20px; }
  .vp-header__links { gap: 16px; }
  /* Päiväys on kertaluontoista taustatietoa — kapealla tila menee
     sovelluksen nimelle ja uloskirjautumiselle. */
  .header__paivays { display: none; }
  .paneeli { padding: 28px 20px 56px; gap: 40px; }
  .paneeli__graafit { gap: 40px; }
  .paneeli-footer { padding: 16px 20px; }
  .kirjautuminen__kortti { padding: 32px 28px; }
}

@media (max-width: 420px) {
  .paneeli-footer { flex-direction: column; gap: 6px; }
}
