/* ============ Ricoveri: tabellone del reparto e scheda del ricovero ============ */

/* ---------- tabellone ---------- */
.ho-toolbar .seg { flex: none; }
.ho-kpis .kpi.ho-kpi-late { border-color: color-mix(in srgb, var(--red) 55%, var(--line)); animation: ho-glow 2.4s ease-in-out infinite; }
@keyframes ho-glow { 0%, 100% { box-shadow: var(--shadow-sm); } 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--red) 18%, transparent), var(--shadow-sm); } }

.ho-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 16px; }
.ho-card {
  position: relative; display: flex; flex-direction: column; gap: 10px; background: var(--card); border-radius: var(--radius); padding: 16px 16px 14px;
  border: 2px solid var(--line); box-shadow: var(--shadow-sm); cursor: pointer; transition: transform .18s, box-shadow .18s, border-color .18s; overflow: hidden;
}
.ho-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--c, var(--sky)); opacity: .85; }
.ho-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.ho-card:focus-visible { outline: none; box-shadow: var(--ring), var(--shadow); }
.ho-card.soon { border-color: color-mix(in srgb, var(--sun) 70%, var(--line)); }
.ho-card.late { border-color: color-mix(in srgb, var(--red) 70%, var(--line)); background: color-mix(in srgb, var(--red-soft) 38%, var(--card)); }
.ho-card.late::before { background: var(--red); }
.ho-box {
  position: absolute; top: 12px; right: 12px; background: var(--ink); color: var(--card); font: 600 12.5px var(--font-display); letter-spacing: .02em;
  padding: 4px 10px; border-radius: 99px; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ho-top { display: flex; gap: 12px; align-items: center; padding-right: 80px; }
.ho-top .pet-av.lg { --s: 64px; font-size: 34px; }
.ho-name { font: 600 20px/1.15 var(--font-display); }
.ho-meta { gap: 6px; }
.ho-meta .chip { font-size: 12px; }
.ho-alerts, .ho-mini-alerts { gap: 6px; }
.ho-alert { font-size: 12px; font-weight: 800; }
.ho-reason { color: var(--ink-2); line-height: 1.35; }
.ho-next { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 14px; background: var(--bg-2); }
.ho-next > .emoji { font-size: 22px; }
.ho-next.soon { background: var(--sun-soft); }
.ho-next.ok { background: var(--mint-soft); }
.ho-next.late { background: var(--red-soft); color: var(--ink); }
.ho-late-badge { flex: none; background: var(--red); color: #fff; font: 600 12.5px var(--font-display); padding: 5px 10px; border-radius: 99px; animation: ho-pulse 1.8s ease-in-out infinite; }
@keyframes ho-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.ho-count-down b { color: var(--ink); }
.ho-vitals { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 26px; }
.ho-vital { display: inline-flex; align-items: center; gap: 4px; background: var(--bg-2); border-radius: 99px; padding: 3px 9px; font-size: 12.5px; font-weight: 800; color: var(--ink-2); }
.ho-vital .emoji { font-size: 13px; }
.ho-vital.warn { background: var(--red-soft); color: var(--red-dark); }
.ho-vitals-ago { margin-left: auto; }
.ho-actions { display: flex; gap: 8px; margin-top: auto; }
.ho-actions .btn { flex: 1; }
.ho-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--red); color: #fff; font-size: 12px; margin-left: 4px; }
.ho-empty .big-emoji { animation-duration: 4s; }

.ho-recent summary { display: flex; align-items: center; gap: 10px; cursor: pointer; list-style: none; font: 600 16px var(--font-display); }
.ho-recent summary::-webkit-details-marker { display: none; }
.ho-recent summary::after { content: '▾'; margin-left: auto; color: var(--muted); transition: transform .2s; }
.ho-recent[open] summary::after { transform: rotate(180deg); }
.ho-recent summary .emoji { font-size: 22px; }
.ho-recent-list { display: flex; flex-direction: column; margin-top: 12px; }
.ho-recent-row { display: flex; gap: 12px; align-items: center; padding: 10px 6px; border-top: 1px dashed var(--line); color: var(--ink); text-decoration: none !important; border-radius: 12px; }
.ho-recent-row:hover { background: var(--bg-2); }
.ho-recent-reason { display: block; color: var(--ink-2); }
.ho-recent-when { text-align: right; }

/* ---------- dosi da dare (tabellone, finestra "Somministra", scheda) ---------- */
.ho-due-head { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.ho-due-list { display: flex; flex-direction: column; gap: 8px; }
.ho-due-item { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 16px; border: 2px solid var(--line); background: var(--card); }
.ho-due-item.overdue { border-color: color-mix(in srgb, var(--red) 60%, var(--line)); background: color-mix(in srgb, var(--red-soft) 55%, var(--card)); }
.ho-due-item.due-soon { border-color: color-mix(in srgb, var(--sun) 70%, var(--line)); background: color-mix(in srgb, var(--sun-soft) 55%, var(--card)); }
.ho-due-item.prn { border-style: dashed; }
.ho-due-time { flex: none; width: 88px; display: flex; flex-direction: column; line-height: 1.15; }
.ho-due-time b { font: 600 20px var(--font-display); }
.ho-due-time small { font-size: 11.5px; color: var(--ink-2); font-weight: 700; }
.ho-due-item.overdue .ho-due-time small { color: var(--red-dark); }
.ho-due-what { line-height: 1.4; }
.ho-dose { font-weight: 800; color: var(--ink-2); }
.ho-due-btns { display: flex; gap: 6px; flex: none; }
.ho-give { min-width: 96px; }
.ho-recent-doses { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* ---------- controllo dei parametri ---------- */
.ho-check-form { display: flex; flex-direction: column; gap: 14px; }
.ho-vit-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.ho-vit { display: flex; flex-direction: column; gap: 5px; background: var(--bg-2); border-radius: 16px; padding: 10px 12px; }
.ho-vit-l { font-size: 12.5px; font-weight: 800; color: var(--ink-2); }
.ho-vit-in { display: flex; align-items: center; gap: 6px; }
.ho-vit-in .input { font: 600 20px var(--font-display); padding: 8px 10px; text-align: center; min-width: 0; }
.ho-vit-in em { font-style: normal; font-size: 12px; color: var(--muted); font-weight: 800; flex: none; }
.ho-vit-hint { font-size: 11.5px; color: var(--muted); min-height: 15px; }
.ho-vit-hint.warn { color: #9A6A00; font-weight: 800; }
.ho-vit-hint.err { color: var(--red-dark); font-weight: 800; }
.ho-pain { align-self: flex-start; }
.ho-pain button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow-sm); }
.ho-pain button .emoji { font-size: 18px; }
.ho-enum-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.ho-enum { gap: 6px; }
.ho-enum .pick-chip { padding: 6px 11px; font-size: 13px; }

/* ---------- finestre: nuovo ricovero, terapia ---------- */
.ho-chips-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.ho-chips-row .toggle-chip { padding: 6px 11px; font-size: 13px; }
.ho-alert-pick .pick-chip { padding: 6px 12px; font-size: 13px; }
.ho-route-pick .pick-chip { padding: 7px 12px; font-size: 13.5px; }
.ho-every { gap: 10px; align-items: center; }
.ho-every .ho-chips-row { margin-top: 0; }
.ho-num { max-width: 110px; }
.ho-times .toggle-chip { font-variant-numeric: tabular-nums; min-width: 64px; }
.ho-tx-preview { align-items: center; }
.ho-tx-preview b { white-space: nowrap; }

/* ---------- scheda: testata ---------- */
.ho-hero { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(200px, 250px); gap: 22px; align-items: start; position: relative; overflow: hidden; }
.ho-hero::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 8px; background: var(--c, var(--sky)); }
.ho-hero.closed { background: color-mix(in srgb, var(--mint-soft) 40%, var(--card)); }
.ho-hero-art { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; padding-left: 6px; }
.ho-hero-art .pet-av.xl { --s: 108px; font-size: 60px; }
.ho-hero-art .ho-box { position: static; max-width: 140px; font-size: 13px; }
.ho-hero-main { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.ho-hero-title { gap: 10px; }
.ho-hero-title h1 { margin: 0; font-size: clamp(24px, 3.4vw, 34px); }
.ho-hero-title h1 a { color: inherit; text-decoration: none; }
.ho-hero-title h1 a:hover { color: var(--brand); }
.ho-hero-reason { font-size: 15px; line-height: 1.4; }
.ho-hero-owner { display: flex; flex-direction: column; gap: 8px; background: var(--bg-2); border-radius: 18px; padding: 14px; }
.ho-hero-owner .row { gap: 6px; }

.ho-sum { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 0 0 18px; }
.ho-sum-item { display: flex; gap: 12px; align-items: center; background: var(--card); border: 2px solid var(--line); border-radius: 18px; padding: 12px 14px; min-width: 0; }
.ho-sum-item > .emoji { font-size: 26px; flex: none; }
.ho-sum-item small { display: block; font-size: 12px; font-weight: 800; color: var(--ink-2); }
.ho-sum-item b { display: block; font: 600 22px/1.15 var(--font-display); }
.ho-sum-item .tiny { display: block; }
.ho-sum-item.late { border-color: color-mix(in srgb, var(--red) 65%, var(--line)); background: color-mix(in srgb, var(--red-soft) 60%, var(--card)); }
.ho-sum-item.late b { color: var(--red-dark); }
.ho-sum-item.soon { border-color: color-mix(in srgb, var(--sun) 70%, var(--line)); background: color-mix(in srgb, var(--sun-soft) 60%, var(--card)); }
.ho-sum-item.stale { border-style: dashed; }
.ho-progress { display: block; height: 7px; border-radius: 99px; background: var(--line); margin-top: 6px; overflow: hidden; }
.ho-progress > span { display: block; height: 100%; border-radius: 99px; background: var(--mint); transition: width .4s ease; }
.tabs .count.late { background: var(--red); color: #fff; }

/* ---------- scheda: terapie ---------- */
.ho-now .card-title .tiny { font-family: var(--font); }
.ho-tx-list { display: flex; flex-direction: column; gap: 10px; }
.ho-tx { border: 2px solid var(--line); border-radius: 18px; padding: 12px 14px; background: var(--card); }
.ho-tx.off { background: var(--bg-2); border-style: dashed; }
.ho-tx.off .ho-tx-name b { color: var(--ink-2); }
.ho-tx-head { display: flex; gap: 12px; align-items: flex-start; }
.ho-tx-ic { flex: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 14px; background: var(--grape-soft); font-size: 20px; }
.ho-tx.prn .ho-tx-ic { background: var(--pink-soft); }
.ho-tx-main { display: flex; flex-direction: column; gap: 3px; }
.ho-tx-name { line-height: 1.6; }
.ho-tx-name b { font-size: 15.5px; }
.ho-tx-name .chip { font-size: 11.5px; vertical-align: 1px; }
.ho-tx-notes { color: var(--ink-2); }
.ho-tx-count { flex: none; text-align: center; line-height: 1.05; padding: 4px 8px; border-radius: 12px; background: var(--mint-soft); min-width: 52px; }
.ho-tx-count b { display: block; font: 600 19px var(--font-display); color: var(--mint-dark); }
.ho-tx-count small { font-size: 11px; font-weight: 800; color: var(--mint-dark); }
.ho-tx-btns { display: flex; gap: 4px; flex: none; }
.ho-tx-btns .icon-btn { width: 34px; height: 34px; font-size: 15px; }

.ho-slots { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; padding-left: 52px; }
.ho-slot-day { display: flex; gap: 10px; align-items: flex-start; }
.ho-slot-dl { flex: none; width: 58px; font-size: 11.5px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; padding-top: 7px; }
.ho-slot-row { display: flex; flex-wrap: wrap; gap: 6px; }
.ho-slot {
  display: inline-flex; align-items: center; gap: 5px; border: 2px solid var(--line-2); background: var(--card); color: var(--ink-2);
  border-radius: 12px; padding: 4px 9px; font: 600 13.5px var(--font-display); font-variant-numeric: tabular-nums; cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
button.ho-slot:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
button.ho-slot:focus-visible { outline: none; box-shadow: var(--ring); }
.ho-slot-i { font-size: 12px; }
.ho-slot.done { background: var(--mint-soft); border-color: color-mix(in srgb, var(--mint) 55%, var(--line)); color: var(--mint-dark); }
.ho-slot.skipped { background: var(--sun-soft); border-color: color-mix(in srgb, var(--sun) 60%, var(--line)); color: #8A5E00; }
.ho-slot.overdue { background: var(--red); border-color: var(--red); color: #fff; animation: ho-pulse 1.8s ease-in-out infinite; }
.ho-slot.due-soon { background: var(--sun); border-color: var(--sun-dark); color: #2A2140; }
.ho-slot.upcoming { border-style: dashed; }
.ho-slot.missed { background: var(--bg-2); color: var(--muted); text-decoration: line-through; border-style: dashed; }
.ho-slot.mini { padding: 1px 6px; font-size: 11px; border-radius: 8px; cursor: default; animation: none; }
.ho-slot-undo { border: 0; background: none; padding: 0 0 0 2px; cursor: pointer; font-size: 12px; }
.ho-slots-empty { margin: 8px 0 0 52px; }
[data-theme="dark"] .ho-slot.skipped { color: var(--sun); }
.ho-stopped summary { cursor: pointer; font: 600 14.5px var(--font-display); color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.ho-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }

/* ---------- scheda: controlli ---------- */
.ho-check-card .card-title { margin-bottom: 10px; }
.ho-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 14px; }
.ho-chart { padding: 16px 16px 12px; }
.ho-chart .card-title { font-size: 15.5px; margin-bottom: 6px; }
.ho-chart-last { font: 600 18px var(--font-display); color: var(--ink); }
.ho-checks-table td { vertical-align: top; }
.ho-checks-table .ho-vitals { min-height: 0; }

/* ---------- scheda: diario ---------- */
.ho-diary-form .reason-chips { flex-direction: row; flex-wrap: wrap; }
.ho-diary-form .reason-chip, .ho-dis-form .reason-chip { padding: 6px 10px; font-size: 12.5px; }
.ho-diary { display: flex; flex-direction: column; position: relative; }
.ho-diary-item { display: flex; gap: 14px; padding: 12px 0; position: relative; }
.ho-diary-item + .ho-diary-item { border-top: 1px dashed var(--line); }
.ho-diary-dot { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-2); font-size: 17px; }
.ho-diary-dot.sent { background: var(--mint-soft); }
.ho-diary-text { margin: 4px 0 8px; white-space: pre-line; line-height: 1.45; }

/* ---------- scheda: registro ---------- */
.ho-log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.ho-log li { display: flex; gap: 12px; align-items: baseline; padding: 8px 4px; border-top: 1px dashed var(--line); font-size: 13.5px; }
.ho-log li:first-child { border-top: 0; }

/* ---------- scheda: dimissione e lettera ---------- */
.ho-dis-form .reason-chips { flex-direction: row; flex-wrap: wrap; }
.ho-dis-grid { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 16px; align-items: start; }
.ho-kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0; font-size: 14px; }
.ho-kv dt { color: var(--muted); font-weight: 800; font-size: 12.5px; padding-top: 2px; }
.ho-kv dd { margin: 0; }
.ho-letter-wrap { padding: 10px; background: var(--bg-2); }

.ho-letter { background: #fff; color: #2A2140; border-radius: 16px; padding: 26px 28px 22px; font-size: 13.5px; line-height: 1.5; position: relative; overflow: hidden; }
.ho-letter::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 8px; background: linear-gradient(90deg, var(--mint), var(--sky), var(--grape), var(--pink)); }
.ho-letter .muted, .ho-letter .tiny { color: #6B6485; }
.ho-letter-head { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.ho-letter-brand { font: 600 18px var(--font-display); margin-bottom: 2px; }
.ho-letter-doc { text-align: right; display: flex; flex-direction: column; }
.ho-letter-doc b { font: 700 19px var(--font-display); color: #178A55; }
.ho-letter-kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; background: #FFF7EE; border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; }
.ho-letter-kv small { display: block; color: #8C84A3; font-weight: 800; font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; }
.ho-letter-kv b { display: block; }
.ho-letter-kv span { display: block; font-size: 12.5px; color: #544A6E; }
.ho-letter section { margin: 0 0 12px; }
.ho-letter h3 { font: 600 14px var(--font-display); margin: 0 0 3px; color: #2A2140; }
.ho-letter p { margin: 0; }
.ho-letter ul { margin: 0; padding-left: 18px; }
.ho-letter .pre { white-space: pre-line; }
.ho-letter-hl { background: #DBF5E8; border-radius: 12px; padding: 10px 14px; }
.ho-letter-foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-top: 20px; padding-top: 12px; border-top: 2px solid #F1E4D3; }
.ho-letter-sig { min-width: 210px; text-align: center; display: flex; flex-direction: column; gap: 4px; }
.ho-letter-sig span { display: block; min-height: 38px; border-bottom: 1.5px solid #2A2140; font-weight: 800; padding-top: 18px; }
.ho-letter-sig small { color: #8C84A3; font-size: 11px; }
.ho-sheet-table { width: 100%; border-collapse: collapse; margin: 6px 0 10px; }
.ho-sheet-table th { text-align: left; font-size: 10.5px; text-transform: uppercase; color: #8C84A3; border-bottom: 2px solid #F1E4D3; padding: 6px 5px; }
.ho-sheet-table td { padding: 8px 5px; border-bottom: 1px solid #F1E4D3; vertical-align: top; }
.ho-sheet-cell { display: inline-block; margin: 0 10px 4px 0; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ho-sheet-cell small { font-size: 10px; color: #6B6485; }

/* ---------- scheda paziente: "è ricoverato" ---------- */
.pt-hosp { align-items: center; color: var(--ink); text-decoration: none !important; border: 2px solid color-mix(in srgb, var(--sky) 45%, transparent); transition: transform .15s, box-shadow .15s; }
.pt-hosp:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.pt-hosp-late { color: var(--red-dark); }

/* ---------- schermi piccoli ---------- */
@media (max-width: 1100px) {
  .ho-hero { grid-template-columns: auto minmax(0, 1fr); }
  .ho-hero-owner { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .ho-dis-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .ho-sum { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ho-vit-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .ho-board { grid-template-columns: minmax(0, 1fr); }
  .ho-hero { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .ho-hero-art { flex-direction: row; justify-content: flex-start; padding-left: 4px; }
  .ho-hero-art .pet-av.xl { --s: 76px; font-size: 42px; }
  .ho-sum { gap: 8px; }
  .ho-sum-item { padding: 10px; gap: 8px; }
  .ho-sum-item > .emoji { font-size: 20px; }
  .ho-sum-item b { font-size: 18px; }
  .ho-enum-grid { grid-template-columns: minmax(0, 1fr); }
  .ho-due-item { flex-wrap: wrap; }
  .ho-due-time { width: auto; flex-direction: row; gap: 8px; align-items: baseline; }
  .ho-due-btns { width: 100%; }
  .ho-due-btns .btn { flex: 1; }
  .ho-slots { padding-left: 0; }
  .ho-slots-empty { margin-left: 0; }
  .ho-slot-dl { width: 48px; }
  .ho-tx-head { flex-wrap: wrap; }
  .ho-tx-btns { width: 100%; justify-content: flex-end; }
  .ho-letter { padding: 20px 16px; }
  .ho-letter-kv { grid-template-columns: minmax(0, 1fr); }
  .ho-letter-foot { flex-direction: column; align-items: stretch; }
}
@media (prefers-reduced-motion: reduce) {
  .ho-slot.overdue, .ho-late-badge, .ho-kpis .kpi.ho-kpi-late { animation: none; }
}

/* ---------- stampa (lettera di dimissione, foglio terapia) ---------- */
.ho-print { display: none; }
@media print {
  .ho-print { display: block; }
  .ho-print .ho-letter { padding: 0; border-radius: 0; font-size: 12pt; }
  .ho-print .ho-letter::before { display: none; }
  .ho-print .ho-letter-kv, .ho-print .ho-letter-hl { background: none; border: 1px solid #ccc; }
  .ho-print .ho-sheet-table td { height: 34px; }
}
