/* ══ TASCHE (tasche.js): impianto di cisterne nello stile «Linee d'acqua» ══ */
:root { --tk-water: #a9c4f0; --tk-free: #8e9ac0; --tk-ease: cubic-bezier(.16, 1, .3, 1); }
:root[data-theme="light"] { --tk-water: #2d5aa8; --tk-free: #6e7894; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) { --tk-water: #2d5aa8; --tk-free: #6e7894; } }

/* Tasche | Obiettivi: due pagine della stessa voce del menu, con l'aspetto delle schede (.tabs in styles.css) */

/* impianto e pannello di lato */
.tk-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(340px, 1fr); gap: 48px; align-items: start; }
.tk-col { display: flex; flex-direction: column; gap: 28px; min-width: 0; }
.tk-hero { display: flex; flex-direction: column; gap: 6px; }
.tk-hero-lab { margin: 0; font-weight: 700; font-size: 19px; color: var(--ink-2); }
.tk-hero-num { margin: 0; font-family: var(--font-num); font-weight: 700; font-stretch: 88%; font-variant-numeric: tabular-nums lining-nums; font-size: 60px; line-height: 1; letter-spacing: -.02em; color: var(--ink); }
.tk-cur { font-size: .5em; font-weight: 600; color: var(--ink-2); }
.tk-neg { margin: 0; color: var(--warn-ink); font-weight: 700; max-width: 62ch; }
.tk-neg[hidden] { display: none; }

.tk-plant { position: relative; padding-bottom: 96px; }
.tk-pipes { position: absolute; inset: 0; overflow: visible; pointer-events: none; }
.tk-pipes .tk-lab { font: 700 15px var(--font); fill: var(--ink-2); }
.tk-pipes .tk-flow { fill: none; stroke: var(--ink); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 6 14; animation: tkFlow 1s linear both; }
@keyframes tkFlow { from { stroke-dashoffset: 80; opacity: 1; } 85% { opacity: 1; } to { stroke-dashoffset: 0; opacity: 0; } }
.tk-tanks { list-style: none; margin: 0; padding: 0; display: flex; align-items: flex-end; gap: 24px; position: relative; }
.tk-tanks > li { flex: 1 1 0; min-width: 0; display: flex; }
.tk-tanks > li[data-id="_free"] { flex-grow: 1.55; }
@media (min-width: 820px) { .tk-tanks > li:only-child { max-width: 50%; } } /* solo i liberi (nessuna tasca): non a tutta larghezza */
.tk-tank { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 14px; min-width: 0; padding: 0; border: 0; background: none; color: var(--ink); font: inherit; text-align: left; cursor: pointer; border-radius: 14px; }
.tk-tank:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 6px; }
.tk-cap { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 0 2px; }
.tk-amt { font: 700 22px/1.1 var(--font-num); font-stretch: 88%; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tk-name { font-weight: 800; font-size: 17px; line-height: 1.25; overflow-wrap: anywhere; hyphens: auto; }
.tk-sub { font-size: 15px; line-height: 1.3; color: var(--ink-2); }
.tk-pays { display: block; margin-top: 2px; }
.tk-vessel { position: relative; display: block; border: 3px solid var(--control); border-top-width: 0; border-radius: 4px 4px 14px 14px; background: var(--surface); overflow: hidden; transition: height .7s var(--tk-ease), border-color .18s; }
.tk-vessel::before { content: ""; position: absolute; left: -3px; right: -3px; top: 0; height: 3px; background: var(--control); border-radius: 2px; }
.tk-water { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: var(--tk-water); box-shadow: inset 0 3px 0 rgba(255, 255, 255, .32); transition: height .85s var(--tk-ease); }
.tk-tank.free .tk-water { background: var(--tk-free); }
.tk-mark { position: absolute; left: 0; right: 0; height: 0; border-top: 2.5px dashed var(--ink); z-index: 1; }
.tk-mark[hidden] { display: none; }
.tk-tank:hover .tk-vessel { border-color: var(--ink); }
.tk-tank:hover .tk-vessel::before { background: var(--ink); }
.tk-tank[aria-pressed="true"] .tk-vessel { border-color: var(--ink); box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--ink); }
.tk-tank[aria-pressed="true"] .tk-vessel::before { background: var(--ink); }
.tk-tank[aria-pressed="true"] .tk-name { text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 5px; }

/* prossimi movimenti */
.tk-next-box { display: flex; flex-direction: column; gap: 12px; padding-top: 24px; border-top: 1px solid var(--hair); }
.tk-h3 { margin: 0; font-weight: 800; font-size: 18px; line-height: 1.25; color: var(--ink); padding: 0; }
.tk-next, .tk-hist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.tk-row, .tk-hist li:not(.tk-empty) { display: grid; grid-template-columns: 6.6em 30px minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 56px; padding: 8px 14px; border-radius: 10px; background: var(--ln-strip, var(--surface-2)); }
.tk-hist li:not(.tk-empty) { grid-template-columns: 4.4em minmax(0, 1fr) auto; } /* tre colonne: deve battere la regola a quattro qui sopra (stessa specificità, viene dopo) */
.tk-when { font: 700 16px/1.2 var(--font-num); font-stretch: 90%; color: var(--ink); }
.tk-dot { width: 26px; height: 26px; border-radius: 8px; background: var(--tk-water); }
.tk-who { display: flex; flex-direction: column; min-width: 0; }
.tk-wname { font-weight: 700; font-size: 16px; line-height: 1.25; }
.tk-wnote { font-size: 15px; color: var(--ink-2); line-height: 1.3; overflow-wrap: anywhere; }
.tk-wamt { font: 700 18px/1.2 var(--font-num); font-stretch: 88%; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.tk-wamt.in { color: var(--good-ink); }
.tk-empty { color: var(--ink-2); list-style: none; padding: 8px 0; background: none; display: block; min-height: 0; }
.tk-empty p { margin: 0 0 10px; max-width: 60ch; }
.tk-empty-acts { display: flex; flex-wrap: wrap; gap: 8px; }

/* pannello */
.tk-side { position: sticky; top: calc(var(--topbar-h, 64px) + 16px); min-width: 0; } /* sotto la barra in alto, non dietro */
.tk-detail { display: flex; flex-direction: column; gap: 22px; min-width: 0; padding: 24px; }
.tk-detail:focus { outline: none; }
.tk-detail:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 3px; }
.tk-detail.tk-swap { animation: tkSwap .26s var(--tk-ease) both; }
@keyframes tkSwap { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.tk-dhead { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.tk-dh { margin: 0; font-weight: 800; font-size: 24px; line-height: 1.2; overflow-wrap: anywhere; }
.tk-dnum { margin: -10px 0 0; font-family: var(--font-num); font-weight: 700; font-stretch: 88%; font-variant-numeric: tabular-nums; font-size: 48px; line-height: 1; }
.tk-where { margin: -10px 0 0; display: flex; gap: 8px; align-items: flex-start; color: var(--ink-2); }
.tk-where .ico { width: 20px; height: 20px; flex: none; margin-top: 2px; }
.tk-goal { display: flex; flex-direction: column; gap: 8px; }
.tk-goal p { margin: 0; color: var(--ink-2); }
.tk-goal b { font: 700 19px/1 var(--font-num); font-stretch: 88%; color: var(--ink); }
.tk-bar { display: block; height: 16px; border-radius: 8px; border: 2px dashed var(--control); padding: 1px; box-sizing: border-box; }
.tk-bar > span { display: block; height: 100%; border-radius: 6px; background: var(--tk-water); transition: width .85s var(--tk-ease); }
.tk-opt { border: 0; margin: 0; padding: 20px 0 0; min-width: 0; display: flex; flex-direction: column; gap: 12px; border-top: 1px solid var(--hair); }
fieldset.tk-opt > legend { padding: 20px 0 0; margin-bottom: 12px; float: left; width: 100%; }
fieldset.tk-opt { padding-top: 0; }
fieldset.tk-opt > *:not(legend) { clear: both; }
.tk-opt .seg { align-self: flex-start; flex-wrap: wrap; }
.tk-opt .seg.tk-rules { border-radius: 18px; }
.tk-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tk-grid3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 16px; align-items: end; }
.tk-detail .field, .tk-new .field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tk-detail .field > span, .tk-new .field > span { font-weight: 700; font-size: 15px; }
.tk-detail .inp, .tk-detail .sel, .tk-new .inp, .tk-new .sel { width: 100%; box-sizing: border-box; min-height: 44px; font-size: 16px; }
.tk-small .inp { max-width: 8em; }
.tk-err { margin: 0; color: var(--warn-ink); font-weight: 700; }
.tk-err[hidden] { display: none; }
.tk-lines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.tk-lines:empty { display: none; }
.tk-lines li { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 48px; padding: 6px 14px; border-radius: 10px; background: var(--ln-strip, var(--surface-2)); font-weight: 700; }
.tk-lv { font-family: var(--font-num); font-stretch: 90%; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tk-lv small { font-family: var(--font); font-weight: 400; color: var(--ink-2); font-size: 14px; }
.tk-acts { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; padding-top: 20px; border-top: 1px solid var(--hair); }
.tk-rename { flex: 1 1 220px; }
.tk-end { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
/* azione che toglie: colore di avviso come «Elimina» degli obiettivi (l'id batte .btn:not(...) di styles.css) */
#tk-detail .btn.tk-close { color: var(--crit-ink); border-color: var(--crit-ink); background: transparent; }
#tk-detail .btn.tk-close:hover { background: color-mix(in srgb, var(--crit-ink) 10%, transparent); }
.tk-close-msg { color: var(--ink-2); font-size: 15px; }
.tk-close-msg:empty { display: none; }
.tk-detail .tk-all { align-self: flex-start; display: inline-flex; align-items: center; }
.tk-detail .link-btn { background: none; border: 0; padding: 0 4px; min-height: 44px; color: var(--ink); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* nuova tasca */
.tk-new { display: flex; flex-direction: column; gap: 20px; margin-bottom: 32px; padding: 24px; }
.tk-new[hidden] { display: none; }
.tk-new form { display: flex; flex-direction: column; gap: 20px; }
.tk-types { border: 0; margin: 0; padding: 0; min-width: 0; }
.tk-types legend { padding: 0; margin-bottom: 12px; }
.tk-type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 12px; }
.tk-type { position: relative; display: flex; }
.tk-type input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.tk-type input:disabled { cursor: not-allowed; }
.tk-type > span { flex: 1; display: flex; flex-direction: column; gap: 4px; min-height: 84px; padding: 14px; border: 2px solid var(--control); border-radius: 12px; }
.tk-type b { font-size: 17px; }
.tk-type small { font-size: 15px; color: var(--ink-2); line-height: 1.35; }
.tk-type:hover > span { border-color: var(--ink); }
.tk-type input:checked + span { border-color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); background: var(--surface-2); }
.tk-type input:focus-visible + span { outline: 3px solid var(--focus-ring); outline-offset: 3px; }
.tk-type input:disabled + span { border-style: dashed; opacity: .7; }
.tk-new-rule { margin: 0; color: var(--ink-2); padding-bottom: 10px; }
.tk-new-acts { display: flex; flex-wrap: wrap; gap: 12px; }

/* pannello dal basso sul telefono */
.tk-sheet { width: 100%; max-width: 100%; margin: auto 0 0; max-height: 88vh; border: 0; border-radius: 18px 18px 0 0; background: var(--surface); color: var(--ink); padding: 0; }
.tk-sheet::backdrop { background: rgba(3, 10, 31, .6); }
.tk-sheet[open] { animation: tkSheet .3s var(--tk-ease) both; }
@keyframes tkSheet { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.tk-sheet .tk-detail { border: 0; border-radius: 0; box-shadow: none; max-height: 88vh; overflow: auto; padding: 20px 16px 28px; background: transparent; }

@media (max-width: 1179px) { .tk-layout { grid-template-columns: minmax(0, 1fr) minmax(320px, .9fr); gap: 28px; } .tk-tanks { gap: 14px; } .tk-dnum { font-size: 42px; } }
@media (max-width: 899px) { .tk-layout { grid-template-columns: 1fr; } .tk-side { display: none; } }
@media (max-width: 819px) {
  .tk-plant { padding-bottom: 0; }
  .tk-pipes { display: none; }
  .tk-tanks { flex-wrap: wrap; gap: 24px 14px; }
  .tk-tanks > li { flex: 1 1 calc(33% - 14px); }
  .tk-tanks > li[data-id="_free"] { flex: 1 1 100%; }
  .tk-hero-num { font-size: 52px; }
  .tk-amt { font-size: 20px; }
  .tk-name { font-size: 16px; }
  .tk-row { grid-template-columns: 5.4em 26px minmax(0, 1fr); }
  .tk-row .tk-wamt { grid-column: 3; text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
  .tk-vessel, .tk-water, .tk-bar > span { transition: none; }
  .tk-detail.tk-swap, .tk-sheet[open], .tk-pipes .tk-flow { animation: none; }
}
.tk-detail h2.tk-dh, .tk-new h2.tk-dh { font: 800 24px/1.2 var(--font); letter-spacing: -.01em; text-transform: none; color: var(--ink); margin: 0; }
.tk-detail .tk-h3, .tk-new .tk-h3, .tk-next-box .tk-h3 { font: 800 18px/1.25 var(--font); letter-spacing: 0; text-transform: none; color: var(--ink); }
