/* Scrivania del coach: i riquadri «Recupero» (dkr-) e «Stress e passi» (dks-) di js/desk-rest.js.
   Solo i colori di styles.css (vanno nel tema chiaro e scuro): verde, giallo e rosso sono --ok, --partial e --missed;
   una notte senza qualità scritta è grigia come il riposo. Il riquadro (cornice, titolo, Media/Giorni) è del guscio.
   Niente scritte una sopra l'altra: la scritta dell'obiettivo sta nella striscia --gut a destra delle colonne (la
   larghezza arriva da js/desk-rest.js), le colonne delle settimane hanno le misure in em della riga (anche
   l'intestazione, che rimpicciolisce solo le sue scritte) e quello che non ci sta finisce con «…» dove c'è il fumetto. */

.dkr, .dks {
  display: flex; flex-direction: column; gap: 6px;
  height: 100%; min-height: 0;
  font-size: 12.5px; line-height: 1.3; font-variant-numeric: tabular-nums;
}
.dkr-none { margin: auto; padding: 10px 0; text-align: center; }

/* colore di ogni segno: la classe is-… mette --dkt, il segno lo usa */
.dkr .is-ok, .dks .is-ok { --dkt: var(--ok); }
.dkr .is-mid, .dks .is-mid { --dkt: var(--partial); }
.dkr .is-bad, .dks .is-bad { --dkt: var(--missed); }
.dkr .is-none, .dks .is-none { --dkt: color-mix(in srgb, var(--rest) 75%, var(--surface)); }
.dkr .is-muted, .dks .is-muted { --dkt: var(--muted); }

/* anello di riserva, se il guscio non ha R.Desk.ring */
.dkr-fb { flex: none; color: var(--dkt, var(--accent)); }
.dkr-fb-bg { stroke: color-mix(in srgb, var(--ink) 10%, transparent); }
.dkr-fb-fg { stroke: currentColor; }
.dkr-fb text { fill: var(--ink); font: 700 13px var(--f-display); }

/* ---------- Recupero: Media ---------- */
.dkr-avg { gap: 8px; }
/* largo e basso: anello e numeri a sinistra, settimane a destra */
.dkr-avg.is-side {
  display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: minmax(0, 1fr);
  column-gap: 16px; align-items: start;
}
.dkr-head { display: flex; flex: none; flex-direction: column; gap: 4px; min-width: 0; }
.dkr-top { display: flex; align-items: center; gap: 12px; min-width: 0; }
.dkr-ring { display: block; flex: none; line-height: 0; cursor: default; }
.dkr-ss {
  display: grid; grid-template-columns: auto auto; align-items: baseline; gap: 1px 8px;
  margin: 0; font-size: 11.5px; color: var(--muted); white-space: nowrap;
}
.dkr-ss dt, .dkr-ss dd { margin: 0; }
.dkr-ss b { font: 700 16px/1.1 var(--f-display); color: var(--ink); }
.dkr-dl { margin: 0; overflow: hidden; font-size: 11.5px; color: var(--muted); white-space: nowrap; text-overflow: ellipsis; }
.dkr-dl b { font-weight: 700; }

/* una riga per settimana: «sett 19/10», barra, ore medie, qualità (l'obiettivo è in alto, una volta sola).
   6,4em: «sett 19/10» ci sta anche in grassetto; 4em: «10 h 05» */
.dkr-wk {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; scrollbar-width: thin;
  margin: 0; padding: 4px 0 0; border-top: 1px solid var(--line); list-style: none;
}
.dkr-avg.is-side .dkr-wk { height: 100%; padding-top: 0; border-top: 0; }
.dkr-w {
  display: grid; grid-template-columns: 6.4em minmax(16px, 1fr) 4em; align-items: center; column-gap: 6px;
  min-height: 20px; padding: 0 4px; border-radius: 4px; font-size: 12px;
}
.dkr-wk.has-q .dkr-w { grid-template-columns: 6.4em minmax(16px, 1fr) 4em 3.6em; }
.dkr-w[data-dk-tip] { cursor: default; }
.dkr-w[data-dk-tip]:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.dkr-w > * { min-width: 0; }
.dkr-wl { overflow: hidden; color: var(--muted); white-space: nowrap; text-overflow: ellipsis; }
.dkr-w.is-now .dkr-wl { color: var(--ink); font-weight: 700; }
.dkr-w.is-out { opacity: .55; }
.dkr-wb { height: 6px; overflow: hidden; border-radius: 99px; background: color-mix(in srgb, var(--ink) 9%, transparent); }
.dkr-wb i { display: block; height: 100%; border-radius: inherit; background: var(--dkt); }
.dkr-w b { overflow: hidden; font-weight: 700; text-align: right; white-space: nowrap; text-overflow: ellipsis; }
.dkr-w em { display: flex; align-items: center; justify-content: flex-end; gap: 4px; font-size: 11.5px; font-style: normal; font-weight: 600; white-space: nowrap; }
.dkr-w em i { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--dkt); }
.dkr-w.is-nil .dk-nil { grid-column: 2 / -1; overflow: hidden; font-size: 11.5px; white-space: nowrap; text-overflow: ellipsis; }
/* intestazione: stessa misura della riga (le colonne in em restano allineate), scritte più piccole */
.dkr-wh { min-height: 14px; color: var(--muted); }
.dkr-wh > span { overflow: hidden; font-size: 10.5px; white-space: nowrap; text-overflow: ellipsis; }
.dkr-wh > span:nth-child(n+3) { text-align: right; }

/* ---------- Recupero: Giorni ---------- */
.dkr-days { gap: 4px; }
/* in alto 8 px per il pallino «nuova» sulla colonna più alta; a destra la striscia --gut per l'obiettivo */
.dkr-plot { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 72px; padding-top: 8px; }
.dkr-area {
  position: relative; display: flex; flex: 1 1 auto; gap: var(--g, 2px); min-height: 46px;
  padding-right: var(--gut, 0px); border-bottom: 1px solid var(--line);
}
.dkr-plot > .dkr-ax { padding-right: var(--gut, 0px); }
.dkr-c {
  display: flex; flex: 1 1 0; align-items: flex-end; justify-content: center; min-width: 0;
  margin: 0; padding: 0; border: 0; border-radius: 3px 3px 0 0; background: none; color: inherit; font: inherit;
}
button.dkr-c { cursor: pointer; }
.dkr-c:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.dkr-c.is-today { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.dkr-c > i { position: relative; display: block; width: min(100%, 26px); border-radius: 3px 3px 0 0; background: var(--dkt); }
.dkr-c.is-nil > i { width: min(100%, 6px); height: 3px; border-radius: 99px; background: color-mix(in srgb, var(--muted) 45%, transparent); }
/* notte arrivata dopo l'ultima visita del coach */
.dkr-c.is-new > i::before {
  content: ""; position: absolute; top: -7px; left: 50%;
  width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: var(--accent);
}
.dkr-goal, .dks-goal {
  position: absolute; left: 0; right: 0; z-index: 1; height: 0;
  border-top: 1.5px dashed color-mix(in srgb, var(--ink) 45%, transparent); pointer-events: none;
}
/* la scritta dell'obiettivo: nella striscia a destra, centrata sulla linea (che passa sotto il suo fondo pieno);
   così non copre mai la cima delle colonne */
.dkr-goal b, .dks-goal b {
  position: absolute; right: 0; top: 0; max-width: var(--gut, 40px); padding: 0 2px; border-radius: 3px;
  transform: translateY(-50%); overflow: hidden; background: var(--surface);
  font-size: 10px; font-weight: 600; line-height: 13px; color: var(--muted); white-space: nowrap; text-overflow: ellipsis; text-align: right;
}
/* sotto le colonne: giorni (o lunedì, o mesi) */
.dkr-ax { display: flex; flex: none; gap: var(--g, 2px); height: 14px; margin-top: 2px; font-size: 10px; line-height: 14px; color: var(--muted); }
.dkr-ax > span { flex: 1 1 0; min-width: 0; text-align: center; white-space: nowrap; }
.dkr-ax > .is-tick { text-align: left; }
.dkr-ax > .is-today { color: var(--accent); font-weight: 700; }
.dkr-ax > .is-fut { opacity: .6; }
/* la legenda: va a capo se non ci sta in una riga (niente voci tagliate) */
.dkr-key {
  display: flex; flex: none; flex-wrap: wrap; gap: 0 10px;
  margin: 0; font-size: 10.5px; line-height: 15px; color: var(--muted);
}
.dkr-key span { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.dkr-key i { width: 8px; height: 8px; border-radius: 2px; background: var(--dkt); }
.dkr-key i.dkr-kg { width: 14px; height: 0; border-top: 1.5px dashed color-mix(in srgb, var(--ink) 45%, transparent); border-radius: 0; background: none; }

/* ---------- Stress e passi: Media ---------- */
.dks-avg { flex-direction: row; align-items: center; gap: 14px; }
/* anellino e, accanto, nome e riga sotto: si stringono con «…» se lo spazio non basta (il fumetto ha tutto) */
.dks-m {
  display: flex; flex: 0 1 auto; align-items: center; gap: 8px; min-width: 0;
  margin: 0; padding: 2px 6px 2px 0; border: 0; border-radius: 8px; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.dks-m:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.dks-mt { display: flex; flex: 0 1 auto; flex-direction: column; min-width: 0; overflow: hidden; line-height: 1.25; }
.dks-n { overflow: hidden; font-size: 13px; white-space: nowrap; text-overflow: ellipsis; }
.dks-n b { font-weight: 700; }
.dks-n b + b { font-size: 11.5px; }
.dks-mt small { overflow: hidden; font-size: 11px; color: var(--muted); white-space: nowrap; text-overflow: ellipsis; }
/* stretto: anellino e nome sotto */
.dks-avg.is-tiny { justify-content: space-around; gap: 6px; }
.dks-avg.is-tiny .dks-m { flex-direction: column; gap: 2px; padding: 0; }
.dks-avg.is-tiny .dks-n { font-size: 11px; }
.dks-avg.is-tiny .dks-n b { font-weight: 600; color: var(--muted); }
/* medie di ogni settimana, se c'è posto: prendono quello che resta dopo i due anellini (base 0: non li stringono) */
.dks-wk {
  flex: 1 1 0; align-self: stretch; min-width: 0; overflow-y: auto; scrollbar-width: thin;
  margin: 0; padding: 0 0 0 12px; border-left: 1px solid var(--line); list-style: none;
}
/* la settimana prende lo spazio che resta (con «…» e il fumetto della riga se non ci sta); 3,2em: «● 5,4»; 3,6em: «12,6k» */
.dks-w {
  display: grid; grid-template-columns: minmax(0, 1fr) 3.2em 3.6em; align-items: center; column-gap: 8px;
  min-height: 18px; padding: 0 4px; border-radius: 4px; font-size: 11.5px;
}
.dks-w[data-dk-tip] { cursor: default; }
.dks-w[data-dk-tip]:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.dks-w > span:first-child { min-width: 0; overflow: hidden; color: var(--muted); white-space: nowrap; text-overflow: ellipsis; }
.dks-w.is-now > span:first-child { color: var(--ink); font-weight: 700; }
.dks-w > span + span { display: flex; align-items: center; justify-content: flex-end; gap: 4px; min-width: 0; font-weight: 600; white-space: nowrap; }
.dks-w i { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--dkt); }
.dks-w em { font-style: normal; font-weight: 400; color: var(--muted); }
.dks-w.is-out { opacity: .55; }
/* intestazione: stessa misura della riga (colonne in em allineate), scritte più piccole */
.dks-wh { min-height: 14px; color: var(--muted); }
.dks-wh > span { font-size: 10.5px; }
.dks-wh > span + span { font-weight: 500; }

/* ---------- Stress e passi: Giorni ---------- */
.dks-days { gap: 3px; }
.dks-r { display: flex; align-items: stretch; gap: 6px; min-height: 0; }
.dks-r.is-st { flex: none; height: calc(var(--dot, 10px) + 4px); }
.dks-r.is-sp { flex: 1 1 auto; min-height: 18px; }
.dks-r.is-ax { flex: none; }
.dks-k { flex: none; align-self: center; width: 40px; overflow: hidden; font-size: 10.5px; color: var(--muted); white-space: nowrap; }
/* tutte e tre le righe lasciano a destra la striscia --gut: le colonne restano allineate e «10k» ci sta dentro */
.dks-tr { position: relative; display: flex; flex: 1 1 auto; gap: var(--g, 2px); min-width: 0; padding-right: var(--gut, 0px); }
.dks-r.is-sp > .dks-tr { border-bottom: 1px solid var(--line); }
.dks-tr.dkr-ax { margin-top: 0; }
.dks-c {
  display: flex; flex: 1 1 0; align-items: center; justify-content: center; min-width: 0;
  margin: 0; padding: 0; border: 0; border-radius: 3px; background: none; color: inherit; font: inherit;
}
button.dks-c { cursor: pointer; }
.dks-c:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.dks-c.is-today { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.dks-r.is-sp .dks-c { align-items: flex-end; border-radius: 3px 3px 0 0; }
.dks-d {
  display: grid; place-items: center; width: var(--dot, 10px); height: var(--dot, 10px);
  border-radius: 50%; background: var(--dkt); font-style: normal;
}
/* pallino grande: il numero dentro, su un fondo chiaro del suo colore (si legge in tutti e due i temi) */
.dks-d.has-n {
  border: 1.5px solid var(--dkt); background: color-mix(in srgb, var(--dkt) 22%, var(--surface));
  color: var(--ink); font-size: 10px; font-weight: 700; line-height: 1;
}
.dks-d.is-nil { width: 6px; height: 6px; border: 1.5px solid color-mix(in srgb, var(--muted) 55%, transparent); background: none; }
.dks-b { display: block; width: min(100%, 22px); border-radius: 3px 3px 0 0; background: var(--dkt); }
.dks-b.is-nil { width: min(100%, 6px); height: 3px; border-radius: 99px; background: color-mix(in srgb, var(--muted) 45%, transparent); }
.dks-nil { align-self: center; font-size: 11.5px; }

/* «Stress» e «Passi» da soli (un anellino ciascuno, 21/10): le settimane in due colonne, la riga dello stress al centro */
.dks-wk.is-one .dks-w { grid-template-columns: minmax(0, 1fr) 3.6em; }
.dks-days:not(:has(> .is-sp)) { justify-content: center; }

/* ---------- in grande (js/desk.js openDetail): la media in alto, giorno per giorno sotto fino in fondo ---------- */
.dkr-big { display: flex; flex-direction: column; gap: 14px; height: 100%; min-height: 0; }
.dkr-bs { display: flex; flex: none; flex-direction: column; gap: 8px; min-height: 0; }
.dkr-bs.is-days { flex: 1 1 auto; padding-top: 12px; border-top: 1px solid var(--line); }
.dkr-bs > .dkr, .dkr-bs > .dks { flex: 1 1 auto; height: auto; }
.dkr-bh { margin: 0; font: 600 11px/1.2 var(--f-display); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
